diff options
866 files changed, 14069 insertions, 15294 deletions
diff --git a/Kodi.xcodeproj/project.pbxproj b/Kodi.xcodeproj/project.pbxproj index 6dd3cf260e..5662c19065 100644 --- a/Kodi.xcodeproj/project.pbxproj +++ b/Kodi.xcodeproj/project.pbxproj @@ -1234,6 +1234,15 @@ DF40BC31178B4C07009DB567 /* ScriptInvocationManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF40BC27178B4C07009DB567 /* ScriptInvocationManager.cpp */; }; DF448457140048A60069344B /* AirTunesServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF448455140048A60069344B /* AirTunesServer.cpp */; }; DF44845E140048C80069344B /* PipesManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF44845B140048C80069344B /* PipesManager.cpp */; }; + DF4BF0151A4EF30F0053AC56 /* cc_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = DF4BF0111A4EF30F0053AC56 /* cc_decoder.c */; }; + DF4BF0161A4EF30F0053AC56 /* cc_decoder708.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF4BF0131A4EF30F0053AC56 /* cc_decoder708.cpp */; }; + DF4BF0171A4EF31E0053AC56 /* cc_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = DF4BF0111A4EF30F0053AC56 /* cc_decoder.c */; }; + DF4BF0181A4EF31E0053AC56 /* cc_decoder708.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF4BF0131A4EF30F0053AC56 /* cc_decoder708.cpp */; }; + DF4BF0191A4EF31F0053AC56 /* cc_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = DF4BF0111A4EF30F0053AC56 /* cc_decoder.c */; }; + DF4BF01A1A4EF31F0053AC56 /* cc_decoder708.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF4BF0131A4EF30F0053AC56 /* cc_decoder708.cpp */; }; + DF4BF01D1A4EF3410053AC56 /* DVDDemuxCC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF4BF01B1A4EF3410053AC56 /* DVDDemuxCC.cpp */; }; + DF4BF01E1A4EF3410053AC56 /* DVDDemuxCC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF4BF01B1A4EF3410053AC56 /* DVDDemuxCC.cpp */; }; + DF4BF01F1A4EF3410053AC56 /* DVDDemuxCC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF4BF01B1A4EF3410053AC56 /* DVDDemuxCC.cpp */; }; DF52566D1732C1890094A464 /* DVDDemuxCDDA.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF52566B1732C1890094A464 /* DVDDemuxCDDA.cpp */; }; DF5276E1151BAEDA00B5B63B /* Base64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF52769A151BAEDA00B5B63B /* Base64.cpp */; }; DF5276E2151BAEDA00B5B63B /* HttpResponse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF52769C151BAEDA00B5B63B /* HttpResponse.cpp */; }; @@ -1246,6 +1255,12 @@ DF64FE3E16C07AAA00D028FB /* GUIViewState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF64FE3716C07AAA00D028FB /* GUIViewState.cpp */; }; DF64FE4016C07AAA00D028FB /* ViewDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF64FE3A16C07AAA00D028FB /* ViewDatabase.cpp */; }; DF673AA51443819600A5A509 /* AddonManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18B49FF41152BFA5001AF8A6 /* AddonManager.cpp */; }; + DF6A0D811A4584E80075BBFC /* OverrideDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF6A0D7D1A4584E80075BBFC /* OverrideDirectory.cpp */; }; + DF6A0D821A4584E80075BBFC /* OverrideDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF6A0D7D1A4584E80075BBFC /* OverrideDirectory.cpp */; }; + DF6A0D831A4584E80075BBFC /* OverrideDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF6A0D7D1A4584E80075BBFC /* OverrideDirectory.cpp */; }; + DF6A0D841A4584E80075BBFC /* OverrideFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF6A0D7F1A4584E80075BBFC /* OverrideFile.cpp */; }; + DF6A0D851A4584E80075BBFC /* OverrideFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF6A0D7F1A4584E80075BBFC /* OverrideFile.cpp */; }; + DF6A0D861A4584E80075BBFC /* OverrideFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF6A0D7F1A4584E80075BBFC /* OverrideFile.cpp */; }; DF6D1DFE18312525009DB64F /* OverlayRendererGUI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 55D3604C1826CAB900DA66D2 /* OverlayRendererGUI.cpp */; }; DF6D1DFF18312525009DB64F /* OverlayRendererGUI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 55D3604C1826CAB900DA66D2 /* OverlayRendererGUI.cpp */; }; DF830D0C15BB260C00602BE6 /* GUIDialogKeyboardGeneric.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF830D0A15BB260C00602BE6 /* GUIDialogKeyboardGeneric.cpp */; }; @@ -1486,7 +1501,6 @@ DFF0F15817528350002DA3A4 /* DVDAudioCodecFFmpeg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E15070D25F9F900618676 /* DVDAudioCodecFFmpeg.cpp */; }; DFF0F15B17528350002DA3A4 /* DVDAudioCodecPassthrough.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFB6610615374E80006B8FF1 /* DVDAudioCodecPassthrough.cpp */; }; DFF0F15E17528350002DA3A4 /* DVDOverlayCodec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFDA3152160E34230047A626 /* DVDOverlayCodec.cpp */; }; - DFF0F15F17528350002DA3A4 /* DVDOverlayCodecCC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E152B0D25F9F900618676 /* DVDOverlayCodecCC.cpp */; }; DFF0F16017528350002DA3A4 /* DVDOverlayCodecFFmpeg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E152D0D25F9F900618676 /* DVDOverlayCodecFFmpeg.cpp */; }; DFF0F16117528350002DA3A4 /* DVDOverlayCodecSSA.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8883CE9E0DD817D1004E8B72 /* DVDOverlayCodecSSA.cpp */; }; DFF0F16217528350002DA3A4 /* DVDOverlayCodecText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E152F0D25F9F900618676 /* DVDOverlayCodecText.cpp */; }; @@ -2257,7 +2271,6 @@ DFF0F48417528350002DA3A4 /* DVDFactoryCodec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E15240D25F9F900618676 /* DVDFactoryCodec.cpp */; }; DFF0F48717528350002DA3A4 /* DVDVideoCodecVideoToolBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E499158F174E6ABD00741B6D /* DVDVideoCodecVideoToolBox.cpp */; }; DFF0F48817528350002DA3A4 /* fstrcmp.c in Sources */ = {isa = PBXBuildFile; fileRef = 7CBEBB8212912BA300431822 /* fstrcmp.c */; }; - DFF0F48917528350002DA3A4 /* cc_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = E38E15350D25F9F900618676 /* cc_decoder.c */; }; DFF0F48A17528350002DA3A4 /* yuv2rgb.neon.S in Sources */ = {isa = PBXBuildFile; fileRef = E4991595174E70BF00741B6D /* yuv2rgb.neon.S */; }; DFF0F49D1752838E002DA3A4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = DFF0F4901752838E002DA3A4 /* InfoPlist.strings */; }; DFF1FE23199D2FFF0008211F /* KodiAppliance.mm in Sources */ = {isa = PBXBuildFile; fileRef = DFC8B7CE199C2B3A00424777 /* KodiAppliance.mm */; }; @@ -2318,10 +2331,8 @@ E38E1F7B0D25F9FD00618676 /* DVDAudioCodecFFmpeg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E15070D25F9F900618676 /* DVDAudioCodecFFmpeg.cpp */; }; E38E1F840D25F9FD00618676 /* DVDCodecUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E15220D25F9F900618676 /* DVDCodecUtils.cpp */; }; E38E1F850D25F9FD00618676 /* DVDFactoryCodec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E15240D25F9F900618676 /* DVDFactoryCodec.cpp */; }; - E38E1F870D25F9FD00618676 /* DVDOverlayCodecCC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E152B0D25F9F900618676 /* DVDOverlayCodecCC.cpp */; }; E38E1F880D25F9FD00618676 /* DVDOverlayCodecFFmpeg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E152D0D25F9F900618676 /* DVDOverlayCodecFFmpeg.cpp */; }; E38E1F890D25F9FD00618676 /* DVDOverlayCodecText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E152F0D25F9F900618676 /* DVDOverlayCodecText.cpp */; }; - E38E1F8A0D25F9FD00618676 /* cc_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = E38E15350D25F9F900618676 /* cc_decoder.c */; }; E38E1F8D0D25F9FD00618676 /* DVDVideoCodecFFmpeg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E153D0D25F9F900618676 /* DVDVideoCodecFFmpeg.cpp */; }; E38E1F8E0D25F9FD00618676 /* DVDVideoCodecLibMpeg2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E153F0D25F9F900618676 /* DVDVideoCodecLibMpeg2.cpp */; }; E38E1F8F0D25F9FD00618676 /* DVDVideoPPFFmpeg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E15410D25F9F900618676 /* DVDVideoPPFFmpeg.cpp */; }; @@ -2744,7 +2755,6 @@ E49911C0174E5D2500741B6D /* DVDAudioCodecFFmpeg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E15070D25F9F900618676 /* DVDAudioCodecFFmpeg.cpp */; }; E49911C3174E5D2500741B6D /* DVDAudioCodecPassthrough.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFB6610615374E80006B8FF1 /* DVDAudioCodecPassthrough.cpp */; }; E49911C6174E5D2500741B6D /* DVDOverlayCodec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFDA3152160E34230047A626 /* DVDOverlayCodec.cpp */; }; - E49911C7174E5D2500741B6D /* DVDOverlayCodecCC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E152B0D25F9F900618676 /* DVDOverlayCodecCC.cpp */; }; E49911C8174E5D2500741B6D /* DVDOverlayCodecFFmpeg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E152D0D25F9F900618676 /* DVDOverlayCodecFFmpeg.cpp */; }; E49911C9174E5D2500741B6D /* DVDOverlayCodecSSA.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8883CE9E0DD817D1004E8B72 /* DVDOverlayCodecSSA.cpp */; }; E49911CA174E5D2500741B6D /* DVDOverlayCodecText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E152F0D25F9F900618676 /* DVDOverlayCodecText.cpp */; }; @@ -3520,7 +3530,6 @@ E499158C174E68EE00741B6D /* DVDFactoryCodec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E15240D25F9F900618676 /* DVDFactoryCodec.cpp */; }; E4991591174E6ABE00741B6D /* DVDVideoCodecVideoToolBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E499158F174E6ABD00741B6D /* DVDVideoCodecVideoToolBox.cpp */; }; E4991592174E6B5C00741B6D /* fstrcmp.c in Sources */ = {isa = PBXBuildFile; fileRef = 7CBEBB8212912BA300431822 /* fstrcmp.c */; }; - E4991593174E707400741B6D /* cc_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = E38E15350D25F9F900618676 /* cc_decoder.c */; }; E4991596174E70BF00741B6D /* yuv2rgb.neon.S in Sources */ = {isa = PBXBuildFile; fileRef = E4991595174E70BF00741B6D /* yuv2rgb.neon.S */; }; E49ACD8C100745C400A86ECD /* ZeroconfDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E49ACD8B100745C400A86ECD /* ZeroconfDirectory.cpp */; }; E49ACD9F10074A4000A86ECD /* ZeroconfBrowserOSX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E49ACD9D10074A4000A86ECD /* ZeroconfBrowserOSX.cpp */; }; @@ -4913,6 +4922,12 @@ DF448456140048A60069344B /* AirTunesServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AirTunesServer.h; sourceTree = "<group>"; }; DF44845B140048C80069344B /* PipesManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PipesManager.cpp; sourceTree = "<group>"; }; DF44845C140048C80069344B /* PipesManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PipesManager.h; sourceTree = "<group>"; }; + DF4BF0111A4EF30F0053AC56 /* cc_decoder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cc_decoder.c; sourceTree = "<group>"; }; + DF4BF0121A4EF30F0053AC56 /* cc_decoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cc_decoder.h; sourceTree = "<group>"; }; + DF4BF0131A4EF30F0053AC56 /* cc_decoder708.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cc_decoder708.cpp; sourceTree = "<group>"; }; + DF4BF0141A4EF30F0053AC56 /* cc_decoder708.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cc_decoder708.h; sourceTree = "<group>"; }; + DF4BF01B1A4EF3410053AC56 /* DVDDemuxCC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DVDDemuxCC.cpp; sourceTree = "<group>"; }; + DF4BF01C1A4EF3410053AC56 /* DVDDemuxCC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DVDDemuxCC.h; sourceTree = "<group>"; }; DF52566B1732C1890094A464 /* DVDDemuxCDDA.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DVDDemuxCDDA.cpp; sourceTree = "<group>"; }; DF52566C1732C1890094A464 /* DVDDemuxCDDA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DVDDemuxCDDA.h; sourceTree = "<group>"; }; DF52769A151BAEDA00B5B63B /* Base64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Base64.cpp; sourceTree = "<group>"; }; @@ -4937,6 +4952,10 @@ DF64FE3A16C07AAA00D028FB /* ViewDatabase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewDatabase.cpp; sourceTree = "<group>"; }; DF64FE3B16C07AAA00D028FB /* ViewDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewDatabase.h; sourceTree = "<group>"; }; DF64FE3C16C07AAA00D028FB /* ViewState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewState.h; sourceTree = "<group>"; }; + DF6A0D7D1A4584E80075BBFC /* OverrideDirectory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OverrideDirectory.cpp; sourceTree = "<group>"; }; + DF6A0D7E1A4584E80075BBFC /* OverrideDirectory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverrideDirectory.h; sourceTree = "<group>"; }; + DF6A0D7F1A4584E80075BBFC /* OverrideFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OverrideFile.cpp; sourceTree = "<group>"; }; + DF6A0D801A4584E80075BBFC /* OverrideFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverrideFile.h; sourceTree = "<group>"; }; DF830D0A15BB260C00602BE6 /* GUIDialogKeyboardGeneric.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUIDialogKeyboardGeneric.cpp; sourceTree = "<group>"; }; DF830D0B15BB260C00602BE6 /* GUIDialogKeyboardGeneric.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIDialogKeyboardGeneric.h; sourceTree = "<group>"; }; DF830D0E15BB262700602BE6 /* GUIKeyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIKeyboard.h; sourceTree = "<group>"; }; @@ -5237,8 +5256,6 @@ E38E15250D25F9F900618676 /* DVDFactoryCodec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DVDFactoryCodec.h; sourceTree = "<group>"; }; E38E15290D25F9F900618676 /* DVDOverlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DVDOverlay.h; sourceTree = "<group>"; }; E38E152A0D25F9F900618676 /* DVDOverlayCodec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DVDOverlayCodec.h; sourceTree = "<group>"; }; - E38E152B0D25F9F900618676 /* DVDOverlayCodecCC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DVDOverlayCodecCC.cpp; sourceTree = "<group>"; }; - E38E152C0D25F9F900618676 /* DVDOverlayCodecCC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DVDOverlayCodecCC.h; sourceTree = "<group>"; }; E38E152D0D25F9F900618676 /* DVDOverlayCodecFFmpeg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DVDOverlayCodecFFmpeg.cpp; sourceTree = "<group>"; }; E38E152E0D25F9F900618676 /* DVDOverlayCodecFFmpeg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DVDOverlayCodecFFmpeg.h; sourceTree = "<group>"; }; E38E152F0D25F9F900618676 /* DVDOverlayCodecText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DVDOverlayCodecText.cpp; sourceTree = "<group>"; }; @@ -5246,8 +5263,6 @@ E38E15310D25F9F900618676 /* DVDOverlayImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DVDOverlayImage.h; sourceTree = "<group>"; }; E38E15320D25F9F900618676 /* DVDOverlaySpu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DVDOverlaySpu.h; sourceTree = "<group>"; }; E38E15330D25F9F900618676 /* DVDOverlayText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DVDOverlayText.h; sourceTree = "<group>"; }; - E38E15350D25F9F900618676 /* cc_decoder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cc_decoder.c; sourceTree = "<group>"; }; - E38E15360D25F9F900618676 /* cc_decoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cc_decoder.h; sourceTree = "<group>"; }; E38E153B0D25F9F900618676 /* DllLibMpeg2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DllLibMpeg2.h; sourceTree = "<group>"; }; E38E153C0D25F9F900618676 /* DVDVideoCodec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DVDVideoCodec.h; sourceTree = "<group>"; }; E38E153D0D25F9F900618676 /* DVDVideoCodecFFmpeg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DVDVideoCodecFFmpeg.cpp; sourceTree = "<group>"; }; @@ -8278,6 +8293,17 @@ path = generic; sourceTree = "<group>"; }; + DF4BF0101A4EF30F0053AC56 /* contrib */ = { + isa = PBXGroup; + children = ( + DF4BF0111A4EF30F0053AC56 /* cc_decoder.c */, + DF4BF0121A4EF30F0053AC56 /* cc_decoder.h */, + DF4BF0131A4EF30F0053AC56 /* cc_decoder708.cpp */, + DF4BF0141A4EF30F0053AC56 /* cc_decoder708.h */, + ); + path = contrib; + sourceTree = "<group>"; + }; DF527729151BAF4C00B5B63B /* websocket */ = { isa = PBXGroup; children = ( @@ -8862,12 +8888,10 @@ E38E15280D25F9F900618676 /* Overlay */ = { isa = PBXGroup; children = ( - E38E15340D25F9F900618676 /* libspucc */, + DF4BF0101A4EF30F0053AC56 /* contrib */, E38E15290D25F9F900618676 /* DVDOverlay.h */, DFDA3152160E34230047A626 /* DVDOverlayCodec.cpp */, E38E152A0D25F9F900618676 /* DVDOverlayCodec.h */, - E38E152B0D25F9F900618676 /* DVDOverlayCodecCC.cpp */, - E38E152C0D25F9F900618676 /* DVDOverlayCodecCC.h */, E38E152D0D25F9F900618676 /* DVDOverlayCodecFFmpeg.cpp */, E38E152E0D25F9F900618676 /* DVDOverlayCodecFFmpeg.h */, 8883CE9E0DD817D1004E8B72 /* DVDOverlayCodecSSA.cpp */, @@ -8884,15 +8908,6 @@ path = Overlay; sourceTree = "<group>"; }; - E38E15340D25F9F900618676 /* libspucc */ = { - isa = PBXGroup; - children = ( - E38E15350D25F9F900618676 /* cc_decoder.c */, - E38E15360D25F9F900618676 /* cc_decoder.h */, - ); - path = libspucc; - sourceTree = "<group>"; - }; E38E153A0D25F9F900618676 /* Video */ = { isa = PBXGroup; children = ( @@ -8932,6 +8947,8 @@ E38E154A0D25F9F900618676 /* DVDDemux.h */, AE89ACA41621DAB800E17DBC /* DVDDemuxBXA.cpp */, AE89ACA51621DAB800E17DBC /* DVDDemuxBXA.h */, + DF4BF01B1A4EF3410053AC56 /* DVDDemuxCC.cpp */, + DF4BF01C1A4EF3410053AC56 /* DVDDemuxCC.h */, DF52566B1732C1890094A464 /* DVDDemuxCDDA.cpp */, DF52566C1732C1890094A464 /* DVDDemuxCDDA.h */, E38E25C20D263DE200618676 /* DVDDemuxFFmpeg.cpp */, @@ -9234,6 +9251,10 @@ E38E173D0D25F9FA00618676 /* NSFFileDirectory.h */, E38E173E0D25F9FA00618676 /* OGGFileDirectory.cpp */, E38E173F0D25F9FA00618676 /* OGGFileDirectory.h */, + DF6A0D7D1A4584E80075BBFC /* OverrideDirectory.cpp */, + DF6A0D7E1A4584E80075BBFC /* OverrideDirectory.h */, + DF6A0D7F1A4584E80075BBFC /* OverrideFile.cpp */, + DF6A0D801A4584E80075BBFC /* OverrideFile.h */, DF93D67F1444A8B0007C6459 /* PipeFile.cpp */, DF93D6801444A8B0007C6459 /* PipeFile.h */, DF44845B140048C80069344B /* PipesManager.cpp */, @@ -10684,6 +10705,7 @@ E38E1F4E0D25F9FD00618676 /* dll_tracker.cpp in Sources */, E38E1F500D25F9FD00618676 /* dll_tracker_file.cpp in Sources */, E38E1F510D25F9FD00618676 /* dll_tracker_library.cpp in Sources */, + DF4BF0151A4EF30F0053AC56 /* cc_decoder.c in Sources */, E38E1F540D25F9FD00618676 /* dll_util.cpp in Sources */, E38E1F560D25F9FD00618676 /* DllLoader.cpp in Sources */, E38E1F570D25F9FD00618676 /* DllLoaderContainer.cpp in Sources */, @@ -10702,10 +10724,8 @@ E38E1F7B0D25F9FD00618676 /* DVDAudioCodecFFmpeg.cpp in Sources */, E38E1F840D25F9FD00618676 /* DVDCodecUtils.cpp in Sources */, E38E1F850D25F9FD00618676 /* DVDFactoryCodec.cpp in Sources */, - E38E1F870D25F9FD00618676 /* DVDOverlayCodecCC.cpp in Sources */, E38E1F880D25F9FD00618676 /* DVDOverlayCodecFFmpeg.cpp in Sources */, E38E1F890D25F9FD00618676 /* DVDOverlayCodecText.cpp in Sources */, - E38E1F8A0D25F9FD00618676 /* cc_decoder.c in Sources */, E38E1F8D0D25F9FD00618676 /* DVDVideoCodecFFmpeg.cpp in Sources */, E38E1F8E0D25F9FD00618676 /* DVDVideoCodecLibMpeg2.cpp in Sources */, E38E1F8F0D25F9FD00618676 /* DVDVideoPPFFmpeg.cpp in Sources */, @@ -10715,6 +10735,7 @@ E38E1F970D25F9FD00618676 /* DVDDemuxSPU.cpp in Sources */, E38E1F980D25F9FD00618676 /* DVDFactoryInputStream.cpp in Sources */, E38E1F990D25F9FD00618676 /* DVDInputStream.cpp in Sources */, + DF6A0D841A4584E80075BBFC /* OverrideFile.cpp in Sources */, E38E1F9A0D25F9FD00618676 /* DVDInputStreamFFmpeg.cpp in Sources */, E38E1F9B0D25F9FD00618676 /* DVDInputStreamFile.cpp in Sources */, E38E1F9C0D25F9FD00618676 /* DVDInputStreamHttp.cpp in Sources */, @@ -10810,6 +10831,7 @@ E38E20640D25F9FD00618676 /* DirectoryNodeMusicVideosOverview.cpp in Sources */, E38E20650D25F9FD00618676 /* DirectoryNodeOverview.cpp in Sources */, E38E20660D25F9FD00618676 /* DirectoryNodeRecentlyAddedEpisodes.cpp in Sources */, + DF4BF01D1A4EF3410053AC56 /* DVDDemuxCC.cpp in Sources */, E38E20670D25F9FD00618676 /* DirectoryNodeRecentlyAddedMovies.cpp in Sources */, E38E20680D25F9FD00618676 /* DirectoryNodeRecentlyAddedMusicVideos.cpp in Sources */, E38E20690D25F9FD00618676 /* DirectoryNodeRoot.cpp in Sources */, @@ -11366,6 +11388,7 @@ DF93D6AC1444A8B1007C6459 /* SlingboxFile.cpp in Sources */, DF93D6AD1444A8B1007C6459 /* SMBFile.cpp in Sources */, DF93D6AE1444A8B1007C6459 /* SpecialProtocolFile.cpp in Sources */, + DF6A0D811A4584E80075BBFC /* OverrideDirectory.cpp in Sources */, DF93D6AF1444A8B1007C6459 /* TuxBoxDirectory.cpp in Sources */, DF93D6B01444A8B1007C6459 /* TuxBoxFile.cpp in Sources */, DF93D6B11444A8B1007C6459 /* UDFFile.cpp in Sources */, @@ -11669,6 +11692,7 @@ 7CCDA7A0192756250074CF51 /* NptConsole.cpp in Sources */, 7CCDA7A3192756250074CF51 /* NptCrypto.cpp in Sources */, 7CCDA7A6192756250074CF51 /* NptDataBuffer.cpp in Sources */, + DF4BF0161A4EF30F0053AC56 /* cc_decoder708.cpp in Sources */, 7CCDA7AF192756250074CF51 /* NptDebug.cpp in Sources */, 7CCDA7B8192756250074CF51 /* NptDigest.cpp in Sources */, 7CCDA7BB192756250074CF51 /* NptDynamicLibraries.cpp in Sources */, @@ -11971,7 +11995,6 @@ DFF0F15817528350002DA3A4 /* DVDAudioCodecFFmpeg.cpp in Sources */, DFF0F15B17528350002DA3A4 /* DVDAudioCodecPassthrough.cpp in Sources */, DFF0F15E17528350002DA3A4 /* DVDOverlayCodec.cpp in Sources */, - DFF0F15F17528350002DA3A4 /* DVDOverlayCodecCC.cpp in Sources */, DFF0F16017528350002DA3A4 /* DVDOverlayCodecFFmpeg.cpp in Sources */, DFF0F16117528350002DA3A4 /* DVDOverlayCodecSSA.cpp in Sources */, DFF0F16217528350002DA3A4 /* DVDOverlayCodecText.cpp in Sources */, @@ -12080,6 +12103,7 @@ DFF0F1CF17528350002DA3A4 /* GUIDialogExtendedProgressBar.cpp in Sources */, DFF0F1D017528350002DA3A4 /* GUIDialogFavourites.cpp in Sources */, DFF0F1D117528350002DA3A4 /* GUIDialogFileBrowser.cpp in Sources */, + DF6A0D861A4584E80075BBFC /* OverrideFile.cpp in Sources */, DFF0F1D217528350002DA3A4 /* GUIDialogGamepad.cpp in Sources */, DFF0F1D317528350002DA3A4 /* GUIDialogKaiToast.cpp in Sources */, DFF0F1D417528350002DA3A4 /* GUIDialogKeyboardGeneric.cpp in Sources */, @@ -12287,6 +12311,7 @@ DFF0F2A017528350002DA3A4 /* GUIRadioButtonControl.cpp in Sources */, DFF0F2A117528350002DA3A4 /* GUIRenderingControl.cpp in Sources */, DFF0F2A217528350002DA3A4 /* GUIResizeControl.cpp in Sources */, + DF4BF01A1A4EF31F0053AC56 /* cc_decoder708.cpp in Sources */, DFF0F2A317528350002DA3A4 /* GUIRSSControl.cpp in Sources */, DFF0F2A417528350002DA3A4 /* GUIScrollBarControl.cpp in Sources */, DFF0F2A517528350002DA3A4 /* GUISelectButtonControl.cpp in Sources */, @@ -12479,6 +12504,7 @@ DFF0F35F17528350002DA3A4 /* PlayListB4S.cpp in Sources */, DFF0F36017528350002DA3A4 /* PlayListFactory.cpp in Sources */, DFF0F36117528350002DA3A4 /* PlayListM3U.cpp in Sources */, + DF4BF0191A4EF31F0053AC56 /* cc_decoder.c in Sources */, DFF0F36217528350002DA3A4 /* PlayListPLS.cpp in Sources */, DFF0F36317528350002DA3A4 /* PlayListURL.cpp in Sources */, DFF0F36417528350002DA3A4 /* PlayListWPL.cpp in Sources */, @@ -12753,7 +12779,6 @@ DFF0F48417528350002DA3A4 /* DVDFactoryCodec.cpp in Sources */, DFF0F48717528350002DA3A4 /* DVDVideoCodecVideoToolBox.cpp in Sources */, DFF0F48817528350002DA3A4 /* fstrcmp.c in Sources */, - DFF0F48917528350002DA3A4 /* cc_decoder.c in Sources */, DFF0F48A17528350002DA3A4 /* yuv2rgb.neon.S in Sources */, DF3C3C0E1752A7EE000989C3 /* IOSEAGLView.mm in Sources */, DF3C3C0F1752A7EE000989C3 /* IOSExternalTouchController.mm in Sources */, @@ -12852,6 +12877,7 @@ 7CCDA21F192753E30074CF51 /* PltFileMediaServer.cpp in Sources */, 7CCDA228192753E30074CF51 /* PltMediaBrowser.cpp in Sources */, 7CCDA231192753E30074CF51 /* PltMediaCache.cpp in Sources */, + DF4BF01F1A4EF3410053AC56 /* DVDDemuxCC.cpp in Sources */, 7CCDA23A192753E30074CF51 /* PltMediaItem.cpp in Sources */, 7CCDA243192753E30074CF51 /* PltMediaServer.cpp in Sources */, 7CCDA24C192753E30074CF51 /* PltSyncMediaBrowser.cpp in Sources */, @@ -12872,6 +12898,7 @@ 7CCDA7DB192756250074CF51 /* NptJson.cpp in Sources */, 7CCDA7DE192756250074CF51 /* NptList.cpp in Sources */, 7CCDA7E7192756250074CF51 /* NptLogging.cpp in Sources */, + DF6A0D831A4584E80075BBFC /* OverrideDirectory.cpp in Sources */, 7CCDA7EA192756250074CF51 /* NptMessaging.cpp in Sources */, 7CCDA7F3192756250074CF51 /* NptNetwork.cpp in Sources */, 7CCDA7FC192756250074CF51 /* NptQueue.cpp in Sources */, @@ -13070,6 +13097,7 @@ files = ( E49910B7174D0E2A00741B6D /* IOSKeyboard.mm in Sources */, E49910B8174D0E2A00741B6D /* IOSKeyboardView.mm in Sources */, + DF4BF0181A4EF31E0053AC56 /* cc_decoder708.cpp in Sources */, E49910BA174D0E2A00741B6D /* XBMCApplication.m in Sources */, E49910BB174D0E2A00741B6D /* XBMCController.mm in Sources */, E49910DC174E4A6400741B6D /* IOSEAGLView.mm in Sources */, @@ -13162,6 +13190,7 @@ E49911B7174E5D0A00741B6D /* dll.cpp in Sources */, E49911B8174E5D0A00741B6D /* dll_tracker.cpp in Sources */, E49911B9174E5D0A00741B6D /* dll_tracker_file.cpp in Sources */, + DF4BF0171A4EF31E0053AC56 /* cc_decoder.c in Sources */, E49911BA174E5D0A00741B6D /* dll_tracker_library.cpp in Sources */, E49911BB174E5D0A00741B6D /* dll_util.cpp in Sources */, E49911BC174E5D0A00741B6D /* DllLoader.cpp in Sources */, @@ -13171,7 +13200,6 @@ E49911C0174E5D2500741B6D /* DVDAudioCodecFFmpeg.cpp in Sources */, E49911C3174E5D2500741B6D /* DVDAudioCodecPassthrough.cpp in Sources */, E49911C6174E5D2500741B6D /* DVDOverlayCodec.cpp in Sources */, - E49911C7174E5D2500741B6D /* DVDOverlayCodecCC.cpp in Sources */, E49911C8174E5D2500741B6D /* DVDOverlayCodecFFmpeg.cpp in Sources */, E49911C9174E5D2500741B6D /* DVDOverlayCodecSSA.cpp in Sources */, E49911CA174E5D2500741B6D /* DVDOverlayCodecText.cpp in Sources */, @@ -13401,6 +13429,7 @@ E49912B3174E5D9900741B6D /* SMBDirectory.cpp in Sources */, E49912B4174E5D9900741B6D /* SMBFile.cpp in Sources */, E49912B5174E5D9900741B6D /* SourcesDirectory.cpp in Sources */, + DF6A0D821A4584E80075BBFC /* OverrideDirectory.cpp in Sources */, E49912B6174E5D9900741B6D /* SpecialProtocol.cpp in Sources */, E49912B7174E5D9900741B6D /* SpecialProtocolDirectory.cpp in Sources */, E49912B8174E5D9900741B6D /* SpecialProtocolFile.cpp in Sources */, @@ -13562,6 +13591,7 @@ E499136E174E5EF700741B6D /* PosixMountProvider.cpp in Sources */, E499136F174E5EF700741B6D /* XFileUtils.cpp in Sources */, E4991370174E5EF700741B6D /* XHandle.cpp in Sources */, + DF6A0D851A4584E80075BBFC /* OverrideFile.cpp in Sources */, E4991371174E5EF700741B6D /* XMemUtils.cpp in Sources */, E4991372174E5EF700741B6D /* XTimeUtils.cpp in Sources */, E4991373174E5F0E00741B6D /* GUIDialogMusicInfo.cpp in Sources */, @@ -13755,6 +13785,7 @@ E499143C174E604700741B6D /* Thread.cpp in Sources */, E499143D174E604700741B6D /* Timer.cpp in Sources */, E499143E174E605900741B6D /* AlarmClock.cpp in Sources */, + DF4BF01E1A4EF3410053AC56 /* DVDDemuxCC.cpp in Sources */, E499143F174E605900741B6D /* AliasShortcutUtils.cpp in Sources */, E4991440174E605900741B6D /* Archive.cpp in Sources */, E4991441174E605900741B6D /* AsyncFileCopy.cpp in Sources */, @@ -13948,7 +13979,6 @@ E499158C174E68EE00741B6D /* DVDFactoryCodec.cpp in Sources */, E4991591174E6ABE00741B6D /* DVDVideoCodecVideoToolBox.cpp in Sources */, E4991592174E6B5C00741B6D /* fstrcmp.c in Sources */, - E4991593174E707400741B6D /* cc_decoder.c in Sources */, E4991596174E70BF00741B6D /* yuv2rgb.neon.S in Sources */, 0E3036ED1760F68A00D93596 /* FavouritesDirectory.cpp in Sources */, DFBB4319178B5E6F006CC20A /* CompileInfo.cpp in Sources */, diff --git a/Makefile.in b/Makefile.in index f88c88b558..4151266a44 100644 --- a/Makefile.in +++ b/Makefile.in @@ -9,9 +9,6 @@ AUTOGENERATED_MAKEFILES=@OUTPUT_FILES@ EC_DIRS= \ tools/EventClients -XBMCTEX_DIRS= \ - tools/TexturePacker - DVDPCODECS_DIRS= \ lib \ lib/libdvd @@ -34,7 +31,6 @@ DIRECTORY_ARCHIVES=$(DVDPLAYER_ARCHIVES) \ lib/libRTV/librtv.a \ lib/libXDAAP/libxdaap.a \ lib/libhts/libhts.a \ - lib/libsquish/libsquish.a \ xbmc/addons/addons.a \ xbmc/cdrip/cdrip.a \ xbmc/cores/AudioEngine/audioengine.a \ @@ -352,7 +348,7 @@ config.status: configure # skin textures ifeq (@USE_TEXTUREPACKER@,1) -skins: tools/TexturePacker/TexturePacker force +skins: @TEXTUREPACKER@ $(MAKE) -C $(CONFLUENCE_MEDIA) ifeq (@USE_TOUCH_SKIN@,1) $(MAKE) -C $(TOUCH_SKIN_MEDIA) @@ -460,7 +456,6 @@ externals: codecs libs visualizations screensavers libaddon pvraddons xcode_depends: \ codecs libs visualizations screensavers eventclients skins libaddon \ - lib/libsquish/libsquish.a \ lib/libRTV/librtv.a \ lib/libXDAAP/libxdaap.a \ lib/SlingboxLib/SlingboxLib.a @@ -508,7 +503,7 @@ OBJSXBMC:=$(filter-out $(DYNOBJSXBMC), $(OBJSXBMC)) BIN_DIRS = $(dir $(DIRECTORY_ARCHIVES)) $(dir $(NWAOBJSXBMC)) $(dir $(MAINOBJS)) -DIRS= $(BIN_DIRS) $(EC_DIRS) $(XBMCTEX_DIRS) $(DVDPCODECS_DIRS) $(PAPCODECS_DIRS) \ +DIRS= $(BIN_DIRS) $(EC_DIRS) $(DVDPCODECS_DIRS) $(PAPCODECS_DIRS) \ $(LIB_DIRS) $(SS_DIRS) $(VIS_DIRS) $(LIBADDON_DIRS) $(SKIN_DIRS) xbmc/main $(NWAOBJSXBMC) $(DIRECTORY_ARCHIVES) $(MAINOBJS): force @@ -540,9 +535,6 @@ else $(SILENT_LD) $(CC) $(CFLAGS) $(LDFLAGS) -o @APP_NAME_LC@-xrandr xbmc-xrandr.c -lXrandr -lX11 -lm endif -tools/TexturePacker/TexturePacker: xbmc/guilib/XBTF.h - $(MAKE) -C tools/TexturePacker/ - install-bin: @APP_NAME_LC@.bin # developement convenience target sudo install -d $(DESTDIR)$(libdir) @@ -692,8 +684,6 @@ clean-@APP_NAME_LC@.bin: for d in $(BIN_DIRS); do if test -f $$d/Makefile; then $(MAKE) -C $$d clean; fi; done clean-eventclients: for d in $(EC_DIRS); do if test -f $$d/Makefile; then $(MAKE) -C $$d clean; fi; done -clean-xbmctex: - for d in $(XBMCTEX_DIRS); do if test -f $$d/Makefile; then $(MAKE) -C $$d clean; fi; done clean-dvdpcodecs: for d in $(DVDPCODECS_DIRS); do if test -f $$d/Makefile; then $(MAKE) -C $$d clean; fi; done clean-papcodecs: @@ -713,7 +703,7 @@ endif clean-codecs: clean-dvdpcodecs clean-papcodecs -clean-externals: clean-codecs clean-eventclients clean-xbmctex clean-libs \ +clean-externals: clean-codecs clean-eventclients clean-libs \ clean-screensavers clean-visualisations clean-libaddons clean-pvraddons ifeq (1,@GTEST_CONFIGURED@) diff --git a/addons/library.xbmc.gui/libXBMC_gui.h b/addons/library.xbmc.gui/libXBMC_gui.h index 59075b8faa..3b50e9cacb 100644 --- a/addons/library.xbmc.gui/libXBMC_gui.h +++ b/addons/library.xbmc.gui/libXBMC_gui.h @@ -36,7 +36,7 @@ typedef void* GUIHANDLE; #endif /* current ADDONGUI API version */ -#define XBMC_GUI_API_VERSION "5.3.0" +#define XBMC_GUI_API_VERSION "5.6.0" /* min. ADDONGUI API version */ #define XBMC_GUI_MIN_API_VERSION "5.3.0" diff --git a/addons/service.xbmc.versioncheck/addon.xml b/addons/service.xbmc.versioncheck/addon.xml index 545722bc69..8f63c24e06 100644 --- a/addons/service.xbmc.versioncheck/addon.xml +++ b/addons/service.xbmc.versioncheck/addon.xml @@ -1,10 +1,9 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <addon id="service.xbmc.versioncheck" name="Version Check" - version="0.2.7" + version="0.3.2" provider-name="XBMC Foundation"> <requires> - <import addon="xbmc.addon" version="12.0.0"/> <import addon="xbmc.python" version="2.1.0"/> </requires> <extension point="xbmc.service" library="service.py" start="login"/> diff --git a/addons/service.xbmc.versioncheck/changelog.txt b/addons/service.xbmc.versioncheck/changelog.txt index 0a038bbea3..b5f5c3a56a 100644 --- a/addons/service.xbmc.versioncheck/changelog.txt +++ b/addons/service.xbmc.versioncheck/changelog.txt @@ -1,3 +1,12 @@ +v0.3.2 +- Don't notify on newer unreleased builds + +v0.3.1 +- Don't notify on newer unreleased builds + +v0.3.0 +- Update with 14.0 Helix + v0.2.7 - Fix popup on Kodi 15.0 builds diff --git a/addons/service.xbmc.versioncheck/lib/versions.py b/addons/service.xbmc.versioncheck/lib/versions.py index 5b0f66c207..5ee95d505f 100644 --- a/addons/service.xbmc.versioncheck/lib/versions.py +++ b/addons/service.xbmc.versioncheck/lib/versions.py @@ -66,11 +66,13 @@ def compare_version(version_installed, versionlist): # check if you are using a RC build lower than current available RC # then check if you are using a beta/alpha lower than current available RC # 14.0rc3 is newer than: 14.0rc1, 14.0b9, 14.0a15 - if version_installed.get('tagversion','') < versionlist_rc[0]['tagversion']: - version_available = versionlist_rc[0] - oldversion = True - log('Version available %s' %versionlist_rc[0]) - log('You are running an older RC version') + if version_installed['major'] <= int(versionlist_rc[0]['major']): + if version_installed['minor'] <= int(versionlist_rc[0]['minor']): + if version_installed.get('tagversion','') < versionlist_rc[0]['tagversion']: + version_available = versionlist_rc[0] + oldversion = True + log('Version available %s' %versionlist_rc[0]) + log('You are running an older RC version') # now check if installed !=rc elif not oldversion and version_installed['tag'] in ['beta','alpha','prealpha']: if version_installed['major'] <= int(versionlist_rc[0]['major']): @@ -85,11 +87,13 @@ def compare_version(version_installed, versionlist): # check if you are using a RC build lower than current available RC # then check if you are using a beta/alpha lower than current available RC # 14.0b3 is newer than: 14.0b1, 14.0a15 - if version_installed.get('tagversion','') < versionlist_beta[0]['tagversion']: - version_available = versionlist_beta[0] - oldversion = True - log('Version available %s' %versionlist_beta[0]) - log('You are running an older beta version') + if version_installed['major'] <= int(versionlist_beta[0]['major']): + if version_installed['minor'] <= int(versionlist_beta[0]['minor']): + if version_installed.get('tagversion','') < versionlist_beta[0]['tagversion']: + version_available = versionlist_beta[0] + oldversion = True + log('Version available %s' %versionlist_beta[0]) + log('You are running an older beta version') # now check if installed !=beta elif not oldversion and version_installed['tag'] in ['alpha','prealpha']: if version_installed['major'] <= int(versionlist_beta[0]['major']): @@ -105,11 +109,12 @@ def compare_version(version_installed, versionlist): # then check if you are using a beta/alpha lower than current available RC # 14.0a3 is newer than: 14.0a1 or pre-alpha if version_installed['major'] <= int(versionlist_alpha[0]['major']): - if version_installed.get('tagversion','') < versionlist_alpha[0]['tagversion']: - version_available = versionlist_alpha[0] - oldversion = True - log('Version available %s' %versionlist_alpha[0]) - log('You are running an older alpha version') + if version_installed['minor'] <= int(versionlist_alpha[0]['minor']): + if version_installed.get('tagversion','') < versionlist_alpha[0]['tagversion']: + version_available = versionlist_alpha[0] + oldversion = True + log('Version available %s' %versionlist_alpha[0]) + log('You are running an older alpha version') # now check if installed !=alpha elif not oldversion and version_installed['tag'] in ['prealpha']: if version_installed['major'] <= int(versionlist_alpha[0]['major']): diff --git a/addons/service.xbmc.versioncheck/resources/versions.txt b/addons/service.xbmc.versioncheck/resources/versions.txt index aea69cc9c7..73e2f1ca90 100644 --- a/addons/service.xbmc.versioncheck/resources/versions.txt +++ b/addons/service.xbmc.versioncheck/resources/versions.txt @@ -3,6 +3,15 @@ "releases": { "stable": [ { + "major": "14", + "minor": "0", + "tag": "stable", + "tagversion":"", + "revision": "20141223-ad747d9", + "extrainfo": "final", + "addon_support": "yes" + }, + { "major": "13", "minor": "2", "tag": "stable", diff --git a/addons/service.xbmc.versioncheck/service.py b/addons/service.xbmc.versioncheck/service.py index 69e7a68b5d..97a4f3238c 100644 --- a/addons/service.xbmc.versioncheck/service.py +++ b/addons/service.xbmc.versioncheck/service.py @@ -39,6 +39,9 @@ class Main: if xbmc.getCondVisibility('System.Platform.Linux') and __addon__.getSetting("upgrade_apt") == 'true': packages = ['xbmc'] _versionchecklinux(packages) + # temporary don't notify Windows untill crashing has been solved + elif xbmc.getCondVisibility('System.Platform.Windows'): + pass else: oldversion, version_installed, version_available, version_stable = _versioncheck() if oldversion: diff --git a/addons/skin.confluence/720p/DialogAddonInfo.xml b/addons/skin.confluence/720p/DialogAddonInfo.xml index a5234447e0..bcb4b8f4cc 100644 --- a/addons/skin.confluence/720p/DialogAddonInfo.xml +++ b/addons/skin.confluence/720p/DialogAddonInfo.xml @@ -287,7 +287,7 @@ <width>600</width> <height>260</height> <font>font13</font> - <align>justify</align> + <align>left</align> <textcolor>white</textcolor> <label>$INFO[ListItem.Property(Addon.Description)]</label> <pagecontrol>61</pagecontrol> diff --git a/addons/skin.confluence/720p/DialogPVRGroupManager.xml b/addons/skin.confluence/720p/DialogPVRGroupManager.xml index 46b1c33e44..818a2f2256 100644 --- a/addons/skin.confluence/720p/DialogPVRGroupManager.xml +++ b/addons/skin.confluence/720p/DialogPVRGroupManager.xml @@ -429,6 +429,12 @@ <include>ButtonInfoDialogsCommonValues</include> <label>31504</label> </control> + <control type="radiobutton" id="25"> + <description>Hide Group</description> + <width>200</width> + <include>ButtonInfoDialogsCommonValues</include> + <label>19289</label> + </control> <control type="button" id="28"> <description>Delete Group</description> <width>200</width> diff --git a/addons/skin.confluence/720p/DialogPVRTimerSettings.xml b/addons/skin.confluence/720p/DialogPVRTimerSettings.xml index ff9d181f68..3898ca6826 100644 --- a/addons/skin.confluence/720p/DialogPVRTimerSettings.xml +++ b/addons/skin.confluence/720p/DialogPVRTimerSettings.xml @@ -24,14 +24,14 @@ <height>40</height> <texture>dialogheader.png</texture> </control> - <control type="label" id="2"> + <control type="label"> <description>header label</description> <left>40</left> <top>20</top> <width>650</width> <height>30</height> <font>font13_title</font> - <label>-</label> + <label>$LOCALIZE[19065]</label> <align>center</align> <aligny>center</aligny> <textcolor>selected</textcolor> diff --git a/addons/skin.confluence/720p/DialogVideoInfo.xml b/addons/skin.confluence/720p/DialogVideoInfo.xml index 0c84e8ef67..b5260f2a1f 100644 --- a/addons/skin.confluence/720p/DialogVideoInfo.xml +++ b/addons/skin.confluence/720p/DialogVideoInfo.xml @@ -851,7 +851,7 @@ <left>210</left> <top>525</top> <width>1030</width> - <height>120</height> + <height>122</height> <font>font13</font> <align>justify</align> <textcolor>white</textcolor> diff --git a/addons/skin.confluence/720p/IncludesBackgroundBuilding.xml b/addons/skin.confluence/720p/IncludesBackgroundBuilding.xml index 01d4ee9414..67d9db4f61 100644 --- a/addons/skin.confluence/720p/IncludesBackgroundBuilding.xml +++ b/addons/skin.confluence/720p/IncludesBackgroundBuilding.xml @@ -50,7 +50,7 @@ <top>0</top> <width>1280</width> <height>720</height> - <visible>Player.HasAudio + !Skin.HasSetting(ShowBackgroundVis) + !Window.IsVisible(TVChannels) + !Window.IsVisible(RadioChannels)</visible> + <visible>Player.HasAudio + !Skin.HasSetting(ShowBackgroundVis)</visible> <visible>!SubString(Window(videolibrary).Property(TvTunesIsAlive),True)</visible> </control> <control type="videowindow"> diff --git a/addons/skin.confluence/720p/IncludesCodecFlagging.xml b/addons/skin.confluence/720p/IncludesCodecFlagging.xml index c3412987fa..ff1921ffcf 100644 --- a/addons/skin.confluence/720p/IncludesCodecFlagging.xml +++ b/addons/skin.confluence/720p/IncludesCodecFlagging.xml @@ -1,23 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <includes> - <variable name="typehackflagging"> - <value condition="[substring(ListItem.FilenameAndPath,bluray) | substring(ListItem.FilenameAndPath,bdrip) | substring(ListItem.FilenameAndPath,bd25) | substring(ListItem.FilenameAndPath,bd50)]">bluray</value> - <value condition="substring(ListItem.FilenameAndPath,hddvd)">hddvd</value> - <value condition="substring(ListItem.FilenameAndPath,dvd)">dvd</value> - <value condition="[substring(ListItem.FilenameAndPath,pdtv) | substring(ListItem.FilenameAndPath,hdtv) | substring(ListItem.FilenameAndPath,dsr)]">TV</value> - <value condition="substring(ListItem.FilenameAndPath,vhs)">vhs</value> - </variable> - <variable name="rating"> - <value condition="substring(listitem.mpaa,Rated G)">mpaa_general</value> - <value condition="substring(listitem.mpaa,Rated PG) + !substring(listitem.mpaa,Rated PG-13)">mpaa_pg</value> - <value condition="substring(listitem.mpaa,Rated PG-13)">mpaa_pg13</value> - <value condition="substring(Listitem.mpaa,Rated R)">mpaa_restricted</value> - <value condition="substring(Listitem.mpaa,Rated NC)">mpaa_nc17</value> - </variable> - <variable name="videocodec"> - <value condition="[substring(ListItem.VideoCodec,div,left) | stringcompare(ListItem.VideoCodec,dx50)]">divx</value> - <value>$INFO[ListItem.VideoCodec]</value> - </variable> <include name="VideoCodecFlaggingConditions"> <control type="image"> <description>Video rez Image</description> diff --git a/addons/skin.confluence/720p/IncludesPVR.xml b/addons/skin.confluence/720p/IncludesPVR.xml index 8f0245d8fe..aa84ee35f8 100644 --- a/addons/skin.confluence/720p/IncludesPVR.xml +++ b/addons/skin.confluence/720p/IncludesPVR.xml @@ -79,7 +79,6 @@ <left>0</left> <top>60</top> <width>250</width> - <height>600</height> <onleft>9000</onleft> <onright>50</onright> <onup>9000</onup> @@ -163,15 +162,6 @@ <include>ButtonCommonValues</include> <label>-</label> </control> - <control type="radiobutton" id="5"> - <description>Group recording items by folder structure</description> - <left>0</left> - <right>40</right> - <textwidth>235</textwidth> - <include>ButtonCommonValues</include> - <label>19270</label> - <visible>Window.IsActive(TVRecordings) | Window.IsActive(RadioRecordings)</visible> - </control> <control type="button" id="2"> <description>View As button</description> <left>0</left> @@ -195,6 +185,46 @@ <altlabel>31050</altlabel> <usealttexture>Container.SortDirection(Ascending)</usealttexture> </control> + <control type="radiobutton" id="31"> + <description>Filter</description> + <left>0</left> + <right>40</right> + <textwidth>235</textwidth> + <include>ButtonCommonValues</include> + <label>587</label> + <selected>Container.Filtered</selected> + <onclick>right</onclick> + <visible>Window.IsActive(TVChannels) | Window.IsActive(RadioChannels)</visible> + </control> + <!-- Misc Options (ID is completely arbitrary) --> + <control type="label" id="205"> + <width>250</width> + <height>35</height> + <font>font12</font> + <label>31026</label> + <textcolor>blue</textcolor> + <align>center</align> + <aligny>center</aligny> + </control> + <control type="radiobutton" id="5"> + <description>Group recording items by folder structure</description> + <left>0</left> + <right>40</right> + <textwidth>235</textwidth> + <include>ButtonCommonValues</include> + <label>19270</label> + <visible>Window.IsActive(TVRecordings) | Window.IsActive(RadioRecordings)</visible> + </control> + <control type="radiobutton" id="6"> + <description>Show hidden channels</description> + <left>0</left> + <right>40</right> + <textwidth>235</textwidth> + <include>ButtonCommonValues</include> + <label>19051</label> + <visible>Window.IsActive(TVChannels) | Window.IsActive(RadioChannels)</visible> + </control> + <!-- Playback controls --> <include>CommonNowPlaying_Controls</include> </control> </control> diff --git a/addons/skin.confluence/720p/MyPVRSearch.xml b/addons/skin.confluence/720p/MyPVRSearch.xml index b3d6370df9..06862eb03d 100644 --- a/addons/skin.confluence/720p/MyPVRSearch.xml +++ b/addons/skin.confluence/720p/MyPVRSearch.xml @@ -195,9 +195,9 @@ <info>ListItem.Label</info> </control> <control type="label"> - <left>700</left> + <left>750</left> <top>0</top> - <width>270</width> + <width>230</width> <height>40</height> <font>font12</font> <aligny>center</aligny> @@ -332,9 +332,9 @@ <info>ListItem.Label</info> </control> <control type="label"> - <left>700</left> + <left>750</left> <top>0</top> - <width>270</width> + <width>230</width> <height>40</height> <font>font12</font> <aligny>center</aligny> diff --git a/addons/skin.confluence/720p/VideoOSD.xml b/addons/skin.confluence/720p/VideoOSD.xml index e7b71742ae..55e2f3fd90 100644 --- a/addons/skin.confluence/720p/VideoOSD.xml +++ b/addons/skin.confluence/720p/VideoOSD.xml @@ -43,46 +43,35 @@ <visible>![Window.IsVisible(SliderDialog) | Window.IsVisible(OSDVideoSettings) | Window.IsVisible(OSDAudioSettings) | Window.IsVisible(VideoBookmarks) | VideoPlayer.Content(LiveTV)]</visible> </control> <!-- !LiveTV --> - <control type="group" id="100"> + <control type="grouplist" id="100"> <left>325</left> <top>60r</top> - <defaultcontrol always="true">202</defaultcontrol> + <orientation>horizontal</orientation> + <itemgap>0</itemgap> <animation effect="fade" time="200">VisibleChange</animation> <visible>![Window.IsVisible(SliderDialog) | Window.IsVisible(OSDVideoSettings) | Window.IsVisible(OSDAudioSettings) | Window.IsVisible(VideoBookmarks)]</visible> <visible>!VideoPlayer.Content(LiveTV)</visible> + <onup>1000</onup> + <onleft>254</onleft> <control type="button" id="200"> - <left>0</left> - <top>0</top> <width>55</width> <height>55</height> <label>210</label> <font>-</font> <texturefocus>OSDPrevTrackFO.png</texturefocus> <texturenofocus>OSDPrevTrackNF.png</texturenofocus> - <onleft>254</onleft> - <onright>201</onright> - <onup>1000</onup> - <ondown>1000</ondown> <onclick>PlayerControl(Previous)</onclick> </control> <control type="button" id="201"> - <left>55</left> - <top>0</top> <width>55</width> <height>55</height> <label>31354</label> <font>-</font> <texturefocus>OSDRewindFO.png</texturefocus> <texturenofocus>OSDRewindNF.png</texturenofocus> - <onleft>200</onleft> - <onright>202</onright> - <onup>1000</onup> - <ondown>1000</ondown> <onclick>PlayerControl(Rewind)</onclick> </control> <control type="togglebutton" id="202"> - <left>110</left> - <top>0</top> <width>55</width> <height>55</height> <label>31351</label> @@ -93,117 +82,150 @@ <usealttexture>Player.Paused | Player.Forwarding | Player.Rewinding</usealttexture> <alttexturefocus>OSDPlayFO.png</alttexturefocus> <alttexturenofocus>OSDPlayNF.png</alttexturenofocus> - <onleft>201</onleft> - <onright>203</onright> - <onup>1000</onup> - <ondown>1000</ondown> <onclick>PlayerControl(Play)</onclick> </control> <control type="button" id="203"> - <left>165</left> - <top>0</top> <width>55</width> <height>55</height> <label>31352</label> <font>-</font> <texturefocus>OSDStopFO.png</texturefocus> <texturenofocus>OSDStopNF.png</texturenofocus> - <onleft>202</onleft> - <onright>204</onright> - <onup>1000</onup> - <ondown>1000</ondown> <onclick>PlayerControl(Stop)</onclick> </control> <control type="button" id="204"> - <left>220</left> - <top>0</top> <width>55</width> <height>55</height> <label>31353</label> <font>-</font> <texturefocus>OSDForwardFO.png</texturefocus> <texturenofocus>OSDForwardNF.png</texturenofocus> - <onleft>203</onleft> - <onright>205</onright> - <onup>1000</onup> - <ondown>1000</ondown> <onclick>PlayerControl(Forward)</onclick> </control> <control type="button" id="205"> - <left>275</left> - <top>0</top> <width>55</width> <height>55</height> <label>209</label> <font>-</font> <texturefocus>OSDNextTrackFO.png</texturefocus> <texturenofocus>OSDNextTrackNF.png</texturenofocus> - <onleft>204</onleft> - <onright>255</onright> + <onclick>PlayerControl(Next)</onclick> + </control> + <control type="image" id="2200"> + <width>270</width> + <texture>-</texture> + </control> + <control type="button" id="255"> + <enable>VideoPlayer.IsStereoscopic</enable> + <animation effect="fade" start="100" end="0" time="100" condition="!VideoPlayer.IsStereoscopic">Conditional</animation> + <width>55</width> + <height>55</height> + <label>36501</label> + <font>-</font> + <texturefocus>OSDStereoscopicFO.png</texturefocus> + <texturenofocus>OSDStereoscopicNF.png</texturenofocus> + <onup>501</onup> + <ondown>1000</ondown> + </control> + <control type="button" id="250"> + <width>55</width> + <height>55</height> + <label>31356</label> + <font>-</font> + <texturefocus>OSDSubtitlesFO.png</texturefocus> + <texturenofocus>OSDSubtitlesNF.png</texturenofocus> + <onup>404</onup> + <ondown>1000</ondown> + </control> + <control type="button" id="251"> + <width>55</width> + <height>55</height> + <label>13395</label> + <font>-</font> + <texturefocus>OSDVideoFO.png</texturefocus> + <texturenofocus>OSDVideoNF.png</texturenofocus> <onup>1000</onup> <ondown>1000</ondown> - <onclick>PlayerControl(Next)</onclick> + <onclick>ActivateWindow(OSDVideoSettings)</onclick> + </control> + <control type="button" id="252"> + <width>55</width> + <height>55</height> + <label>13396</label> + <font>-</font> + <texturefocus>OSDAudioFO.png</texturefocus> + <texturenofocus>OSDAudioNF.png</texturenofocus> + <onup>1000</onup> + <ondown>1000</ondown> + <onclick>ActivateWindow(OSDAudioSettings)</onclick> + </control> + <control type="button" id="253"> + <width>55</width> + <height>55</height> + <label>298</label> + <font>-</font> + <texturefocus>OSDBookmarksFO.png</texturefocus> + <texturenofocus>OSDBookmarksNF.png</texturenofocus> + <onup>1000</onup> + <ondown>1000</ondown> + <onclick>ActivateWindow(VideoBookmarks)</onclick> + </control> + <control type="button" id="254"> + <width>55</width> + <height>55</height> + <label>31355</label> + <font>-</font> + <texturefocus>OSDDvdFO.png</texturefocus> + <texturenofocus>OSDDvdNF.png</texturenofocus> + <onup>1000</onup> + <ondown>1000</ondown> + <onclick>PlayerControl(ShowVideoMenu)</onclick> + <enable>VideoPlayer.HasMenu</enable> + <animation effect="fade" start="100" end="50" time="100" condition="!VideoPlayer.HasMenu">Conditional</animation> </control> </control> - <!-- LiveTV --> - <control type="group" id="100"> + <control type="grouplist" id="100"> <left>325</left> <top>60r</top> <defaultcontrol always="true">301</defaultcontrol> <animation effect="fade" time="200">VisibleChange</animation> <visible>![Window.IsVisible(SliderDialog) | Window.IsVisible(OSDVideoSettings) | Window.IsVisible(OSDAudioSettings) | Window.IsVisible(VideoBookmarks) | Window.IsVisible(PVROSDChannels) | Window.IsVisible(PVROSDGuide)]</visible> <visible>VideoPlayer.Content(LiveTV)</visible> + <onup>1000</onup> + <onleft>353</onleft> + <orientation>horizontal</orientation> + <itemgap>0</itemgap> <control type="button" id="300"> - <left>0</left> - <top>0</top> <width>55</width> <height>55</height> <label>210</label> <font>-</font> <texturefocus>OSDChannelUPFO.png</texturefocus> <texturenofocus>OSDChannelUPNF.png</texturenofocus> - <onleft>353</onleft> - <onright>301</onright> - <onup>1000</onup> - <ondown>1000</ondown> <onclick>PlayerControl(Previous)</onclick> </control> <control type="button" id="301"> - <left>55</left> - <top>0</top> <width>55</width> <height>55</height> <label>209</label> <font>-</font> <texturefocus>OSDChannelDownFO.png</texturefocus> <texturenofocus>OSDChannelDownNF.png</texturenofocus> - <onleft>300</onleft> - <onright>302</onright> - <onup>1000</onup> - <ondown>1000</ondown> <onclick>PlayerControl(Next)</onclick> </control> <control type="button" id="302"> - <left>110</left> - <top>0</top> <width>55</width> <height>55</height> <label>31354</label> <font>-</font> <texturefocus>OSDRewindFO.png</texturefocus> <texturenofocus>OSDRewindNF.png</texturenofocus> - <onleft>301</onleft> - <onright>303</onright> - <onup>1000</onup> - <ondown>1000</ondown> <onclick>PlayerControl(Rewind)</onclick> <enable>Player.SeekEnabled</enable> <animation effect="fade" start="100" end="50" time="100" condition="!Player.SeekEnabled">Conditional</animation> </control> <control type="togglebutton" id="303"> - <left>165</left> - <top>0</top> <width>55</width> <height>55</height> <label>31351</label> @@ -214,250 +236,93 @@ <usealttexture>Player.Paused | Player.Forwarding | Player.Rewinding</usealttexture> <alttexturefocus>OSDPlayFO.png</alttexturefocus> <alttexturenofocus>OSDPlayNF.png</alttexturenofocus> - <onleft>302</onleft> - <onright>304</onright> - <onup>1000</onup> - <ondown>1000</ondown> <onclick>PlayerControl(Play)</onclick> <enable>Player.PauseEnabled</enable> <animation effect="fade" start="100" end="50" time="100" condition="!Player.PauseEnabled">Conditional</animation> </control> <control type="button" id="304"> - <left>220</left> - <top>0</top> <width>55</width> <height>55</height> <label>31352</label> <font>-</font> <texturefocus>OSDStopFO.png</texturefocus> <texturenofocus>OSDStopNF.png</texturenofocus> - <onleft>303</onleft> - <onright>305</onright> - <onup>1000</onup> - <ondown>1000</ondown> <onclick>PlayerControl(Stop)</onclick> </control> <control type="button" id="305"> - <left>275</left> - <top>0</top> <width>55</width> <height>55</height> <label>31353</label> <font>-</font> <texturefocus>OSDForwardFO.png</texturefocus> <texturenofocus>OSDForwardNF.png</texturenofocus> - <onleft>304</onleft> - <onright>306</onright> - <onup>1000</onup> - <ondown>1000</ondown> <onclick>PlayerControl(Forward)</onclick> <enable>Player.SeekEnabled</enable> <animation effect="fade" start="100" end="50" time="100" condition="!Player.SeekEnabled">Conditional</animation> </control> <control type="button" id="306"> - <left>330</left> - <top>0</top> <width>55</width> <height>55</height> <label>19019</label> <font>-</font> <texturefocus>OSDChannelListFO.png</texturefocus> <texturenofocus>OSDChannelListNF.png</texturenofocus> - <onleft>305</onleft> - <onright>307</onright> - <onup>1000</onup> - <ondown>1000</ondown> <onclick>ActivateWindow(PVROSDChannels)</onclick> <onclick>Dialog.Close(VideoOSD)</onclick> </control> <control type="button" id="307"> - <left>385</left> - <top>0</top> <width>55</width> <height>55</height> <label>$LOCALIZE[19029]$INFO[VideoPlayer.ChannelName, - ]</label> <font>-</font> <texturefocus>OSDepgFO.png</texturefocus> <texturenofocus>OSDepgNF.png</texturenofocus> - <onleft>306</onleft> - <onright>354</onright> - <onup>1000</onup> - <ondown>1000</ondown> <onclick>ActivateWindow(PVROSDGuide)</onclick> <onclick>Dialog.Close(VideoOSD)</onclick> </control> - </control> - - <!-- !LiveTV --> - <control type="group"> - <left>355r</left> - <top>60r</top> - <animation effect="fade" time="200">VisibleChange</animation> - <visible>![Window.IsVisible(SliderDialog) | Window.IsVisible(OSDVideoSettings) | Window.IsVisible(OSDAudioSettings) | Window.IsVisible(VideoBookmarks)]</visible> - <visible>!VideoPlayer.Content(LiveTV)</visible> - <control type="button" id="255"> - <visible>VideoPlayer.IsStereoscopic</visible> - <left>0</left> - <top>0</top> - <width>55</width> - <height>55</height> - <label>36501</label> - <font>-</font> - <texturefocus>OSDStereoscopicFO.png</texturefocus> - <texturenofocus>OSDStereoscopicNF.png</texturenofocus> - <onleft>205</onleft> - <onright>250</onright> - <onup>501</onup> - <ondown>1000</ondown> - </control> - <control type="button" id="250"> - <left>55</left> - <top>0</top> - <width>55</width> - <height>55</height> - <label>31356</label> - <font>-</font> - <texturefocus>OSDSubtitlesFO.png</texturefocus> - <texturenofocus>OSDSubtitlesNF.png</texturenofocus> - <onleft>255</onleft> - <onright>251</onright> - <onup>404</onup> - <ondown>1000</ondown> - </control> - <control type="button" id="251"> - <left>110</left> - <top>0</top> - <width>55</width> - <height>55</height> - <label>13395</label> - <font>-</font> - <texturefocus>OSDVideoFO.png</texturefocus> - <texturenofocus>OSDVideoNF.png</texturenofocus> - <onleft>250</onleft> - <onright>252</onright> - <onup>1000</onup> - <ondown>1000</ondown> - <onclick>ActivateWindow(OSDVideoSettings)</onclick> - </control> - <control type="button" id="252"> - <left>165</left> - <top>0</top> - <width>55</width> - <height>55</height> - <label>13396</label> - <font>-</font> - <texturefocus>OSDAudioFO.png</texturefocus> - <texturenofocus>OSDAudioNF.png</texturenofocus> - <onleft>251</onleft> - <onright>253</onright> - <onup>1000</onup> - <ondown>1000</ondown> - <onclick>ActivateWindow(OSDAudioSettings)</onclick> - </control> - <control type="button" id="253"> - <left>220</left> - <top>0</top> - <width>55</width> - <height>55</height> - <label>298</label> - <font>-</font> - <texturefocus>OSDBookmarksFO.png</texturefocus> - <texturenofocus>OSDBookmarksNF.png</texturenofocus> - <onleft>252</onleft> - <onright>254</onright> - <onup>1000</onup> - <ondown>1000</ondown> - <onclick>ActivateWindow(VideoBookmarks)</onclick> + <control type="image" id="2300"> + <width>215</width> + <texture>-</texture> </control> - <control type="button" id="254"> - <left>275</left> - <top>0</top> - <width>55</width> - <height>55</height> - <label>31355</label> - <font>-</font> - <texturefocus>OSDDvdFO.png</texturefocus> - <texturenofocus>OSDDvdNF.png</texturenofocus> - <onleft>253</onleft> - <onright>200</onright> - <onup>1000</onup> - <ondown>1000</ondown> - <onclick>PlayerControl(ShowVideoMenu)</onclick> - <enable>VideoPlayer.HasMenu</enable> - <animation effect="fade" start="100" end="50" time="100" condition="!VideoPlayer.HasMenu">Conditional</animation> - </control> - </control> - - <!-- LiveTV --> - <control type="group"> - <left>300r</left> - <top>60r</top> - <animation effect="fade" time="200">VisibleChange</animation> - <visible>![Window.IsVisible(SliderDialog) | Window.IsVisible(OSDVideoSettings) | Window.IsVisible(OSDAudioSettings) | Window.IsVisible(VideoBookmarks) | Window.IsVisible(PVROSDChannels) | Window.IsVisible(PVROSDGuide)]</visible> - <visible>VideoPlayer.Content(LiveTV)</visible> <control type="button" id="354"> - <visible>VideoPlayer.IsStereoscopic</visible> - <left>0</left> - <top>0</top> + <enable>VideoPlayer.IsStereoscopic</enable> + <animation effect="fade" start="100" end="0" time="100" condition="!VideoPlayer.IsStereoscopic">Conditional</animation> <width>55</width> <height>55</height> <label>36501</label> <font>-</font> <texturefocus>OSDStereoscopicFO.png</texturefocus> <texturenofocus>OSDStereoscopicNF.png</texturenofocus> - <onleft>307</onleft> - <onright>350</onright> <onup>551</onup> - <ondown>1000</ondown> </control> <control type="button" id="350"> - <left>55</left> - <top>0</top> <width>55</width> <height>55</height> <label>31356</label> <font>-</font> <texturefocus>OSDTeleTextFO.png</texturefocus> <texturenofocus>OSDTeleTextNF.png</texturenofocus> - <onleft>354</onleft> - <onright>351</onright> - <onup>1000</onup> - <ondown>1000</ondown> <onclick>ActivateWindow(Teletext)</onclick> </control> <control type="button" id="351"> - <left>110</left> - <top>0</top> <width>55</width> <height>55</height> <label>13395</label> <font>-</font> <texturefocus>OSDVideoFO.png</texturefocus> <texturenofocus>OSDVideoNF.png</texturenofocus> - <onleft>350</onleft> - <onright>352</onright> - <onup>1000</onup> - <ondown>1000</ondown> <onclick>ActivateWindow(OSDVideoSettings)</onclick> </control> <control type="button" id="352"> - <left>165</left> - <top>0</top> <width>55</width> <height>55</height> <label>13396</label> <font>-</font> <texturefocus>OSDAudioFO.png</texturefocus> <texturenofocus>OSDAudioNF.png</texturenofocus> - <onleft>351</onleft> - <onright>353</onright> - <onup>1000</onup> - <ondown>1000</ondown> <onclick>ActivateWindow(OSDAudioSettings)</onclick> </control> <control type="togglebutton" id="353"> - <left>220</left> - <top>0</top> <width>55</width> <height>55</height> <label>264</label> @@ -468,10 +333,6 @@ <usealttexture>Player.Recording</usealttexture> <alttexturefocus>OSDRecordOnFO.png</alttexturefocus> <alttexturenofocus>OSDRecordOnNF.png</alttexturenofocus> - <onleft>352</onleft> - <onright>300</onright> - <onup>1000</onup> - <ondown>1000</ondown> <onclick>PlayerControl(Record)</onclick> <enable>Player.CanRecord</enable> <animation effect="fade" start="100" end="50" time="100" condition="!Player.CanRecord">Conditional</animation> @@ -518,7 +379,7 @@ <height>40</height> <texture border="20,18,20,0">SubMenuBack-Header.png</texture> </control> - <control type="label" id=""> + <control type="label"> <left>30</left> <top>20</top> <width>196</width> @@ -616,8 +477,8 @@ <width>256</width> <height>220</height> <itemgap>0</itemgap> - <onleft>500</onleft> - <onright>500</onright> + <onleft>100</onleft> + <onright>100</onright> <onup>255</onup> <ondown>255</ondown> <orientation>vertical</orientation> @@ -635,7 +496,7 @@ <height>40</height> <texture border="20,18,20,0">SubMenuBack-Header.png</texture> </control> - <control type="label" id=""> + <control type="label"> <left>0</left> <top>20</top> <width>256</width> @@ -734,7 +595,7 @@ <height>40</height> <texture border="20,18,20,0">SubMenuBack-Header.png</texture> </control> - <control type="label" id=""> + <control type="label"> <left>0</left> <top>20</top> <width>256</width> diff --git a/addons/skin.confluence/720p/VideoOSDSettings.xml b/addons/skin.confluence/720p/VideoOSDSettings.xml index 1ccef8ef9e..39be871780 100644 --- a/addons/skin.confluence/720p/VideoOSDSettings.xml +++ b/addons/skin.confluence/720p/VideoOSDSettings.xml @@ -76,7 +76,7 @@ <left>40</left> <top>65</top> <width>720</width> - <height>490</height> + <height>505</height> <itemgap>5</itemgap> <pagecontrol>60</pagecontrol> <onleft>60</onleft> diff --git a/addons/skin.confluence/720p/ViewsAddonBrowser.xml b/addons/skin.confluence/720p/ViewsAddonBrowser.xml index 7d0c50de2a..119bb5c5bc 100644 --- a/addons/skin.confluence/720p/ViewsAddonBrowser.xml +++ b/addons/skin.confluence/720p/ViewsAddonBrowser.xml @@ -213,7 +213,7 @@ <width>490</width> <height>215</height> <font>font13</font> - <align>justify</align> + <align>left</align> <textcolor>white</textcolor> <label>$INFO[ListItem.Property(Addon.Description)]</label> <autoscroll time="2000" delay="3000" repeat="5000">Skin.HasSetting(AutoScroll)</autoscroll> @@ -445,7 +445,7 @@ <width>290</width> <height>445</height> <font>font13</font> - <align>justify</align> + <align>left</align> <textcolor>white</textcolor> <label>$INFO[ListItem.Property(Addon.Description)]</label> <autoscroll time="2000" delay="3000" repeat="5000">Skin.HasSetting(AutoScroll)</autoscroll> diff --git a/addons/skin.confluence/720p/ViewsVideoLibrary.xml b/addons/skin.confluence/720p/ViewsVideoLibrary.xml index 5e3c2e7c5d..d9867b5c89 100644 --- a/addons/skin.confluence/720p/ViewsVideoLibrary.xml +++ b/addons/skin.confluence/720p/ViewsVideoLibrary.xml @@ -811,36 +811,17 @@ <top>8</top> <width>40</width> <height>26</height> - <texture>$INFO[ListItem.VideoResolution,flagging/lists/,.png]</texture> + <texture>$VAR[ResolutionOverlayVar]</texture> <aspectratio>keep</aspectratio> - <visible>Window.IsVisible(Videos) + [Container.Content(Movies) | Container.Content(Episodes) | Container.Content(MusicVideos)]</visible> - <visible>!ListItem.IsStereoscopic</visible> - </control> - <control type="image"> - <left>515</left> - <top>8</top> - <width>40</width> - <height>26</height> - <texture>flagging/lists/3D.png</texture> - <visible>Window.IsVisible(Videos) + [Container.Content(Movies) | Container.Content(Episodes) | Container.Content(MusicVideos)]</visible> - <visible>ListItem.IsStereoscopic</visible> + <visible>Container.Content(Movies) | Container.Content(Episodes) | Container.Content(MusicVideos)</visible> </control> <control type="image"> <left>555</left> <top>14</top> <width>20</width> <height>16</height> - <texture>$INFO[ListItem.Overlay]</texture> - <aspectratio>keep</aspectratio> - <visible>!ListItem.IsResumable</visible> - </control> - <control type="image"> - <left>555</left> - <top>14</top> - <width>16</width> - <height>16</height> - <texture>OverlayWatching.png</texture> - <visible>ListItem.IsResumable</visible> + <texture>$VAR[OverlayVar]</texture> + <aspectratio align="left">keep</aspectratio> </control> </itemlayout> <focusedlayout height="40" width="580"> @@ -901,36 +882,17 @@ <top>8</top> <width>40</width> <height>26</height> - <texture>$INFO[ListItem.VideoResolution,flagging/lists/,.png]</texture> + <texture>$VAR[ResolutionOverlayVar]</texture> <aspectratio>keep</aspectratio> - <visible>Window.IsVisible(Videos) + [Container.Content(Movies) | Container.Content(Episodes) | Container.Content(MusicVideos)]</visible> - <visible>!ListItem.IsStereoscopic</visible> - </control> - <control type="image"> - <left>515</left> - <top>8</top> - <width>40</width> - <height>26</height> - <texture>flagging/lists/3D.png</texture> - <visible>Window.IsVisible(Videos) + [Container.Content(Movies) | Container.Content(Episodes) | Container.Content(MusicVideos)]</visible> - <visible>ListItem.IsStereoscopic</visible> + <visible>Container.Content(Movies) | Container.Content(Episodes) | Container.Content(MusicVideos)</visible> </control> <control type="image"> <left>555</left> <top>14</top> <width>20</width> <height>16</height> - <texture>$INFO[ListItem.Overlay]</texture> - <aspectratio>keep</aspectratio> - <visible>!ListItem.IsResumable</visible> - </control> - <control type="image"> - <left>555</left> - <top>14</top> - <width>16</width> - <height>16</height> - <texture>OverlayWatching.png</texture> - <visible>ListItem.IsResumable</visible> + <texture>$VAR[OverlayVar]</texture> + <aspectratio align="left">keep</aspectratio> </control> </focusedlayout> </control> @@ -1265,36 +1227,17 @@ <top>8</top> <width>40</width> <height>26</height> - <texture>$INFO[ListItem.VideoResolution,flagging/lists/,.png]</texture> + <texture>$VAR[ResolutionOverlayVar]</texture> <aspectratio>keep</aspectratio> - <visible>Window.IsVisible(Videos) + [Container.Content(Movies) | Container.Content(Episodes) | Container.Content(MusicVideos)]</visible> - <visible>!ListItem.IsStereoscopic</visible> - </control> - <control type="image"> - <left>515</left> - <top>8</top> - <width>40</width> - <height>26</height> - <texture>flagging/lists/3D.png</texture> - <visible>Window.IsVisible(Videos) + [Container.Content(Movies) | Container.Content(Episodes) | Container.Content(MusicVideos)]</visible> - <visible>ListItem.IsStereoscopic</visible> + <visible>Container.Content(Movies) | Container.Content(Episodes) | Container.Content(MusicVideos)</visible> </control> <control type="image"> <left>555</left> <top>14</top> <width>20</width> <height>16</height> - <texture>$INFO[ListItem.Overlay]</texture> - <aspectratio>keep</aspectratio> - <visible>!ListItem.IsResumable</visible> - </control> - <control type="image"> - <left>555</left> - <top>14</top> - <width>16</width> - <height>16</height> - <texture>OverlayWatching.png</texture> - <visible>ListItem.IsResumable</visible> + <texture>$VAR[OverlayVar]</texture> + <aspectratio align="left">keep</aspectratio> </control> </itemlayout> <focusedlayout height="40" width="580"> @@ -1355,36 +1298,17 @@ <top>8</top> <width>40</width> <height>26</height> - <texture>$INFO[ListItem.VideoResolution,flagging/lists/,.png]</texture> + <texture>$VAR[ResolutionOverlayVar]</texture> <aspectratio>keep</aspectratio> - <visible>Window.IsVisible(Videos) + [Container.Content(Movies) | Container.Content(Episodes) | Container.Content(MusicVideos)]</visible> - <visible>!ListItem.IsStereoscopic</visible> - </control> - <control type="image"> - <left>515</left> - <top>8</top> - <width>40</width> - <height>26</height> - <texture>flagging/lists/3D.png</texture> - <visible>Window.IsVisible(Videos) + [Container.Content(Movies) | Container.Content(Episodes) | Container.Content(MusicVideos)]</visible> - <visible>ListItem.IsStereoscopic</visible> + <visible>Container.Content(Movies) | Container.Content(Episodes) | Container.Content(MusicVideos)</visible> </control> <control type="image"> <left>555</left> <top>14</top> <width>20</width> <height>16</height> - <texture>$INFO[ListItem.Overlay]</texture> - <aspectratio>keep</aspectratio> - <visible>!ListItem.IsResumable</visible> - </control> - <control type="image"> - <left>555</left> - <top>14</top> - <width>16</width> - <height>16</height> - <texture>OverlayWatching.png</texture> - <visible>ListItem.IsResumable</visible> + <texture>$VAR[OverlayVar]</texture> + <aspectratio align="left">keep</aspectratio> </control> </focusedlayout> </control> diff --git a/addons/skin.confluence/720p/includes.xml b/addons/skin.confluence/720p/includes.xml index 6aa3350785..4ec624b6c9 100644 --- a/addons/skin.confluence/720p/includes.xml +++ b/addons/skin.confluence/720p/includes.xml @@ -17,7 +17,14 @@ <constant name="FanartCrossfadeTime">500</constant> <constant name="IconCrossfadeTime">400</constant> - + <variable name="ResolutionOverlayVar"> + <value condition="!ListItem.IsStereoscopic">$INFO[ListItem.VideoResolution,flagging/lists/,.png]</value> + <value>flagging/lists/3D.png</value> + </variable> + <variable name="OverlayVar"> + <value condition="!ListItem.IsResumable">$INFO[ListItem.Overlay]</value> + <value>OverlayWatching.png</value> + </variable> <variable name="BannerThumb"> <value condition="!IsEmpty(ListItem.Art(banner))">$INFO[ListItem.Art(banner)]</value> <value>$INFO[ListItem.Icon]</value> @@ -34,6 +41,24 @@ <value condition="![Window.IsVisible(FullscreenVideo) | Window.IsVisible(Visualisation)]">DialogBack.png</value> <value>DialogBack2.png</value> </variable> + <variable name="typehackflagging"> + <value condition="[substring(ListItem.FilenameAndPath,bluray) | substring(ListItem.FilenameAndPath,bdrip) | substring(ListItem.FilenameAndPath,bd25) | substring(ListItem.FilenameAndPath,bd50)]">bluray</value> + <value condition="substring(ListItem.FilenameAndPath,hddvd)">hddvd</value> + <value condition="substring(ListItem.FilenameAndPath,dvd)">dvd</value> + <value condition="[substring(ListItem.FilenameAndPath,pdtv) | substring(ListItem.FilenameAndPath,hdtv) | substring(ListItem.FilenameAndPath,dsr)]">TV</value> + <value condition="substring(ListItem.FilenameAndPath,vhs)">vhs</value> + </variable> + <variable name="rating"> + <value condition="substring(listitem.mpaa,Rated G)">mpaa_general</value> + <value condition="substring(listitem.mpaa,Rated PG) + !substring(listitem.mpaa,Rated PG-13)">mpaa_pg</value> + <value condition="substring(listitem.mpaa,Rated PG-13)">mpaa_pg13</value> + <value condition="substring(Listitem.mpaa,Rated R)">mpaa_restricted</value> + <value condition="substring(Listitem.mpaa,Rated NC)">mpaa_nc17</value> + </variable> + <variable name="videocodec"> + <value condition="[substring(ListItem.VideoCodec,div,left) | stringcompare(ListItem.VideoCodec,dx50)]">divx</value> + <value>$INFO[ListItem.VideoCodec]</value> + </variable> <include name="BehindDialogFadeOut"> <control type="image"> @@ -1035,7 +1060,7 @@ <align>center</align> <aligny>center</aligny> <label>$INFO[ListItem.Label]</label> - <visible>Control.HasFocus(9002)</visible> + <visible>ControlGroup(9002).HasFocus</visible> </control> <control type="label"> <left>1</left> @@ -1047,7 +1072,7 @@ <align>center</align> <aligny>center</aligny> <label>$INFO[ListItem.Label]</label> - <visible>!Control.HasFocus(9002)</visible> + <visible>!ControlGroup(9002).HasFocus</visible> </control> </focusedlayout> </include> diff --git a/addons/skin.confluence/addon.xml b/addons/skin.confluence/addon.xml index c3e49e8c00..1b19cffd10 100644 --- a/addons/skin.confluence/addon.xml +++ b/addons/skin.confluence/addon.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <addon id="skin.confluence" - version="2.5.8" + version="2.6.0" name="Confluence" provider-name="Jezz_X, Team Kodi"> <requires> @@ -9,7 +9,6 @@ </requires> <extension point="xbmc.gui.skin" - defaultthemename="textures.xbt" debugging="false" effectslowdown="0.75"> <res width="1280" height="720" aspect="16:9" default="true" folder="720p" /> diff --git a/addons/skin.confluence/changelog.txt b/addons/skin.confluence/changelog.txt index fcd3e7f3a9..6dbb4c6f41 100644 --- a/addons/skin.confluence/changelog.txt +++ b/addons/skin.confluence/changelog.txt @@ -1,3 +1,7 @@ +[B]2.6.0[/B] + +- Moved some context menu functionality for PVR channels to the sideblade + [B]2.5.8[/B] - Updated language files from Transifex diff --git a/addons/skin.confluence/media/Makefile.in b/addons/skin.confluence/media/Makefile.in index bfb18c5453..181c2e8824 100644 --- a/addons/skin.confluence/media/Makefile.in +++ b/addons/skin.confluence/media/Makefile.in @@ -1,5 +1,4 @@ TARGET=Textures.xbt -XBMCTEX=@abs_top_srcdir@/tools/TexturePacker/TexturePacker IMAGES := $(shell find . -name "*jpg") IMAGES += $(shell find . -name "*png") @@ -9,15 +8,13 @@ all: $(TARGET) .PHONY: force -$(TARGET): $(XBMCTEX) $(IMAGES) +$(TARGET): $(IMAGES) ifeq (@ARCH@,arm) - $(XBMCTEX) -use_none -input . -output $(TARGET) + @TEXTUREPACKER@ -use_none -input . -output $(TARGET) else - $(XBMCTEX) -input . -output $(TARGET) + @TEXTUREPACKER@ -input . -output $(TARGET) endif -$(XBMCTEX): force - $(MAKE) -C @abs_top_srcdir@/tools/TexturePacker clean: rm -f $(TARGET) diff --git a/addons/skin.re-touched b/addons/skin.re-touched -Subproject ab497bf5eb6d9dbf8cea27bdb4f7ed8a447faec +Subproject cf9f8e2f3f222becdf6fca00e76197b5d97df34 diff --git a/addons/xbmc.addon/metadata.xsd b/addons/xbmc.addon/metadata.xsd index c4a929bece..18c5559987 100644 --- a/addons/xbmc.addon/metadata.xsd +++ b/addons/xbmc.addon/metadata.xsd @@ -41,7 +41,6 @@ <xs:enumeration value="osx64"/> <xs:enumeration value="osx32"/> <xs:enumeration value="ios"/> - <xs:enumeration value="wingl"/> <xs:enumeration value="windx"/> <xs:enumeration value="android"/> </xs:restriction> diff --git a/addons/xbmc.addon/repository.xsd b/addons/xbmc.addon/repository.xsd index eef49bfb93..70a35f783c 100644 --- a/addons/xbmc.addon/repository.xsd +++ b/addons/xbmc.addon/repository.xsd @@ -3,19 +3,43 @@ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="extension"> <xs:complexType> + <xs:complexContent> + <xs:extension base="repositorydirectory"> + <xs:sequence> + <xs:element name="dir" type="repositorydirectory" minOccurs="1" maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="point" type="xs:string" use="required"/> + <xs:attribute name="id" type="simpleIdentifier"/> + <xs:attribute name="name" type="xs:string"/> + </xs:extension> + </xs:complexContent> + </xs:complexType> + </xs:element> + <xs:complexType name="repositorydirectory"> + <xs:sequence> <xs:element name="info"> <xs:complexType> - <xs:attribute name="compressed" type="xs:boolean"/> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="compressed" type="xs:boolean"/> + </xs:extension> + </xs:simpleContent> </xs:complexType> </xs:element> <xs:element name="checksum" type="xs:string"/> <xs:element name="datadir"> <xs:complexType> - <xs:attribute name="zip" type="xs:boolean"/> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="zip" type="xs:boolean"/> + </xs:extension> + </xs:simpleContent> </xs:complexType> </xs:element> - </xs:complexType> - </xs:element> + <xs:element name="hashes" type="xs:boolean"/> + </xs:sequence> + <xs:attribute name="minversion" type="xs:string"/> + </xs:complexType> <xs:simpleType name="simpleIdentifier"> <xs:restriction base="xs:string"> <xs:pattern value="[^.]+"/> diff --git a/addons/xbmc.gui/addon.xml b/addons/xbmc.gui/addon.xml index 5fb4490a8c..5614e79e2d 100644 --- a/addons/xbmc.gui/addon.xml +++ b/addons/xbmc.gui/addon.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<addon id="xbmc.gui" version="5.4.0" provider-name="Team-Kodi"> +<addon id="xbmc.gui" version="5.6.0" provider-name="Team-Kodi"> <backwards-compatibility abi="5.3.0"/> <requires> <import addon="xbmc.core" version="0.1.0"/> diff --git a/addons/xbmc.gui/skin.xsd b/addons/xbmc.gui/skin.xsd index c669367a16..edf1e337a1 100644 --- a/addons/xbmc.gui/skin.xsd +++ b/addons/xbmc.gui/skin.xsd @@ -3,12 +3,22 @@ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="extension"> <xs:complexType> + <xs:sequence> + <xs:element name="res" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:attribute name="width" type="xs:unsignedInt" use="required"/> + <xs:attribute name="height" type="xs:unsignedInt" use="required"/> + <xs:attribute name="default" type="xs:boolean"/> + <xs:attribute name="folder" type="xs:string"/> + <xs:attribute name="aspect" type="xs:string"/> + </xs:complexType> + </xs:element> + </xs:sequence> <xs:attribute name="point" type="xs:string" use="required"/> <xs:attribute name="id" type="simpleIdentifier"/> <xs:attribute name="name" type="xs:string"/> - <xs:attribute name="defaultresolution" type="xs:string" use="required"/> - <xs:attribute name="defaultresolutionwide" type="xs:string" use="required"/> - <xs:attribute name="defaultthemename" type="xs:string" use="required"/> + <xs:attribute name="defaultresolution" type="xs:string"/> + <xs:attribute name="defaultwideresolution" type="xs:string"/> <xs:attribute name="effectslowdown" type="xs:float"/> <xs:attribute name="debugging" type="xs:boolean"/> </xs:complexType> diff --git a/addons/xbmc.metadata/scraper.xsd b/addons/xbmc.metadata/scraper.xsd index d993052f46..ccdeadf096 100644 --- a/addons/xbmc.metadata/scraper.xsd +++ b/addons/xbmc.metadata/scraper.xsd @@ -9,6 +9,7 @@ <xs:attribute name="library" type="xs:string"/> <xs:attribute name="language" type="xs:string"/> <xs:attribute name="requiressetting" type="xs:boolean"/> + <xs:attribute name="cachepersistence" type="xs:string"/> </xs:complexType> </xs:element> <xs:simpleType name="simpleIdentifier"> diff --git a/addons/xbmc.python/pluginsource.xsd b/addons/xbmc.python/pluginsource.xsd index 48891a4481..b2261b47fd 100644 --- a/addons/xbmc.python/pluginsource.xsd +++ b/addons/xbmc.python/pluginsource.xsd @@ -3,18 +3,15 @@ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="extension"> <xs:complexType> - <xs:element name="provides" type="providesList"/> + <xs:sequence> + <xs:element name="provides" type="providesList"/> + </xs:sequence> <xs:attribute name="point" type="xs:string" use="required"/> <xs:attribute name="id" type="simpleIdentifier"/> <xs:attribute name="name" type="xs:string"/> <xs:attribute name="library" type="xs:string" use="required"/> </xs:complexType> </xs:element> - <xs:element name="content"> - <xs:complexType> - <xs:attribute name="type" type="xs:string" use="required"/> - </xs:complexType> - </xs:element> <xs:simpleType name="simpleIdentifier"> <xs:restriction base="xs:string"> <xs:pattern value="[^.]+"/> diff --git a/addons/xbmc.python/service.xsd b/addons/xbmc.python/service.xsd new file mode 100644 index 0000000000..e29950f34f --- /dev/null +++ b/addons/xbmc.python/service.xsd @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "http://www.w3.org/2001/XMLSchema.dtd"> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <xs:element name="extension"> + <xs:complexType> + <xs:attribute name="point" type="xs:string" use="required"/> + <xs:attribute name="id" type="simpleIdentifier"/> + <xs:attribute name="name" type="xs:string"/> + <xs:attribute name="library" type="xs:string" use="required"/> + <xs:attribute name="start" type="xs:string"/> + </xs:complexType> + </xs:element> + <xs:simpleType name="simpleIdentifier"> + <xs:restriction base="xs:string"> + <xs:pattern value="[^.]+"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/configure.in b/configure.in index 6cfe954dcd..dbca6ae95f 100644 --- a/configure.in +++ b/configure.in @@ -125,16 +125,26 @@ APP_VERSION_TAG_LC=$(echo $APP_VERSION_TAG | ${AWK} '{print tolower($0)}') APP_VERSION_CODE=${APP_VERSION_CODE-$(${AWK} '/VERSION_CODE/ {print $2}' version.txt)} APP_ADDON_API=${APP_ADDON_API-$(${AWK} '/ADDON_API/ {print $2}' version.txt)} if test "$APP_NAME" != "" && test "$APP_VERSION_MAJOR" != "" && test "$APP_VERSION_MINOR" != "" \ -&& test "$APP_VERSION_TAG" != "" && test "$APP_VERSION_CODE" != "" && test "$APP_ADDON_API" != ""; then - final_message="$final_message\n ${APP_NAME} Version:\t${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}-${APP_VERSION_TAG}" +&& test "$APP_VERSION_CODE" != "" && test "$APP_ADDON_API" != ""; then + APP_VERSION=${APP_VERSION_MAJOR}.${APP_VERSION_MINOR} + if test "$APP_VERSION_TAG" != ""; then + APP_VERSION=${APP_VERSION}-${APP_VERSION_TAG} + fi + AC_SUBST(APP_NAME) AC_SUBST(APP_NAME_LC) + AC_SUBST(APP_VERSION) AC_SUBST(APP_VERSION_MAJOR) AC_SUBST(APP_VERSION_MINOR) AC_SUBST(APP_VERSION_TAG) AC_SUBST(APP_VERSION_TAG_LC) AC_SUBST(APP_VERSION_CODE) AC_SUBST(APP_ADDON_API) + + dashes="------------------------" + final_message="\n ${APP_NAME} Configuration:" + final_message="\n$dashes$final_message\n$dashes" + final_message="$final_message\n ${APP_NAME} Version:\t${APP_VERSION}" else AC_MSG_ERROR(could not detect application Version, make sure version.txt is complete) fi @@ -207,6 +217,7 @@ libplist_not_found="== Could not find libplist. AirPlay support disabled. ==" libplist_disabled="== AirPlay support disabled. ==" alsa_not_found="== Could not find ALSA. ALSA support disabled. ==" dbus_not_found="== Could not find DBUS. DBUS support disabled. ==" +sdl_joystick_not_found="== Could not find SDL2. Joystick support disabled. ==" libcap_disabled="== Capabilities detection support disabled. ==" libcap_not_found="== Could not find libcap. Capabilities detection support disabled. ==" gtest_enabled="== Google Test Framework will be configured. ==" @@ -220,10 +231,6 @@ libusb_disabled_udev_found="== libusb disabled. ==" libcec_enabled="== libcec enabled. ==" libcec_disabled="== libcec disabled. CEC adapter support will not be available. ==" -dashes="------------------------" -final_message="\n ${APP_NAME} Configuration:" -final_message="\n$dashes$final_message\n$dashes" - AC_ARG_WITH([ffmpeg], [AS_HELP_STRING([--with-ffmpeg], [ffmpeg options: auto (search pkg-config or auto build), force (always build ffmpeg), shared (link dynamically), path_to_ffmpeg [default=force]])], @@ -266,12 +273,6 @@ AC_ARG_ENABLE([gles], [use_gles=$enableval], [use_gles=no]) -AC_ARG_ENABLE([sdl], - [AS_HELP_STRING([--enable-sdl], - [enable SDL (default is auto)])], - [use_sdl=$enableval], - [use_sdl=auto]) - AC_ARG_ENABLE([vdpau], [AS_HELP_STRING([--enable-vdpau], [enable VDPAU decoding (default is auto)])], @@ -310,9 +311,9 @@ AC_ARG_ENABLE([profiling], AC_ARG_ENABLE([joystick], [AS_HELP_STRING([--enable-joystick], - [enable SDL joystick support (default is yes)])], + [enable SDL joystick support (default is auto)])], [use_joystick=$enableval], - [use_joystick=yes]) + [use_joystick=auto]) AC_ARG_ENABLE([xrandr], [AS_HELP_STRING([--enable-xrandr], @@ -502,7 +503,7 @@ AC_ARG_ENABLE([libbluray], AC_ARG_ENABLE([texturepacker], [AS_HELP_STRING([--enable-texturepacker], - [enable texturepacker support (default is yes)])], + [enable texturepacker support (default is auto)])], [use_texturepacker=$enableval], [use_texturepacker=auto]) @@ -598,7 +599,6 @@ case $host in use_joystick=no use_gles=yes use_optical_drive=no - use_sdl=no use_x11=no build_shared_lib=yes ;; @@ -673,7 +673,6 @@ case $host in use_neon=yes use_gles=yes use_gl=no - use_sdl=no use_wayland=no USE_STATIC_FFMPEG=1 ;; @@ -686,7 +685,6 @@ case $host in use_neon=yes use_gles=yes use_optical_drive=no - use_sdl=no use_x11=no use_wayland=no build_shared_lib=yes @@ -984,7 +982,6 @@ if test "$use_wayland" = "yes" && test "$host_vendor" != "apple"; then fi # Disable SDL and X11 builds - use_sdl=no use_joystick=no use_x11=no @@ -1215,18 +1212,22 @@ if test "x$use_dbus" != "xno"; then else AC_MSG_NOTICE($dbus_disabled) fi - if test "x$use_sdl" != "xno"; then - PKG_CHECK_MODULES([SDL2], [sdl2], + #case "$host_vendor" != "apple"; determine availability of SDL or SDL2 + # joystick + if test "$use_joystick" != "no"; then + PKG_CHECK_MODULES([SDL2], [sdl2], [AC_DEFINE([SDL_VERSION],[2],["SDL major version"]) - INCLUDES="$INCLUDES $SDL2_CFLAGS"; LIBS="$LIBS $SDL2_LIBS";], - [PKG_CHECK_MODULES([SDL], [sdl], - [AC_DEFINE([SDL_VERSION],[1],["SDL major version"]) - INCLUDES="$INCLUDES $SDL_CFLAGS"; LIBS="$LIBS $SDL_LIBS"; use_joystick=no], - [AC_MSG_ERROR($missing_library)]) - ] - ) - AC_CHECK_LIB([SDL_image], [main],, AC_MSG_ERROR($missing_library)) - AC_DEFINE([HAVE_SDL],[1],["Define to 1 if using sdl"]) + AC_DEFINE([HAVE_SDL],[1],["Define to 1 if using sdl"]) + INCLUDES="$INCLUDES $SDL2_CFLAGS"; LIBS="$LIBS $SDL2_LIBS"; use_joystick="yes"], + [if test "$use_joystick" = "yes"; then + AC_MSG_ERROR($sdl_joystick_not_found) + elif test "$use_joystick" != "no"; then + AC_MSG_NOTICE($sdl_joystick_not_found) + use_joystick="no" + fi + ]) + else + AC_MSG_RESULT($sdl_joystick_not_found) fi fi @@ -1278,6 +1279,7 @@ if test "x$use_pulse" != "xno"; then if test "x$use_pulse" = "xyes"; then AC_MSG_ERROR($pulse_not_found) else + use_pulse="no" AC_MSG_RESULT($pulse_disabled) fi fi @@ -2165,9 +2167,35 @@ else final_message="$final_message\n Bluray:\tNo" fi +# we don't compile with default upstream squish, so we use our own one +# even on non unified deps platforms +if test "$cross_compiling" != "yes"; then + make -C ${abs_top_srcdir}/tools/depends/native/libsquish-native + export PKG_CONFIG_PATH="${abs_top_srcdir}/tools/depends/native/libsquish-native/squish-install/lib/pkgconfig:$PKG_CONFIG_PATH" +fi +PKG_CHECK_MODULES([SQUISH], [squish], + [INCLUDES="$INCLUDES $SQUISH_CFLAGS" LIBS="$LIBS $SQUISH_LIBS"], + AC_MSG_ERROR("squish not found")) + if test "x$use_texturepacker" != "xno"; then - final_message="$final_message\n TexturePacker:Yes" - USE_TEXTUREPACKER=1 + AC_PATH_PROG([TEXTUREPACKER], [TexturePacker], ["none"], + [$PATH$PATH_SEPARATOR${abs_top_srcdir}/tools/depends/native/TexturePacker/bin]) + if test "$TEXTUREPACKER" = "none"; then + make -C ${abs_top_srcdir}/tools/depends/native/TexturePacker + TEXTUREPACKER="${abs_top_srcdir}/tools/depends/native/TexturePacker/bin/TexturePacker" + fi + if test -x "$TEXTUREPACKER"; then + final_message="$final_message\n TexturePacker:Yes" + USE_TEXTUREPACKER=1 + else + if test "x$use_texturepacker" = "xyes"; then + AC_MSG_ERROR("Texturepacker not found") + else + AC_MSG_NOTICE("Texturepacker not found") + USE_TEXTUREPACKER=0 + final_message="$final_message\n TexturePacker:No" + fi + fi else final_message="$final_message\n TexturePacker:No" USE_TEXTUREPACKER=0 @@ -2458,7 +2486,6 @@ OUTPUT_FILES="Makefile \ lib/libXDAAP/Makefile \ lib/cmyth/Makefile \ lib/libhdhomerun/Makefile \ - lib/libsquish/Makefile \ lib/cximage-6.0/Makefile \ lib/libUPnP/Makefile \ xbmc/DllPaths_generated.h \ @@ -2484,7 +2511,6 @@ OUTPUT_FILES="Makefile \ tools/Linux/${APP_NAME_LC}-xsession.desktop \ tools/Linux/FEH.py \ tools/Linux/FEH-ARM.py \ - tools/TexturePacker/Makefile \ tools/EventClients/Makefile \ tools/EventClients/Clients/OSXRemote/Makefile \ xbmc/peripherals/bus/Makefile \ @@ -2591,6 +2617,7 @@ AC_SUBST(HAVE_LIBPULSE) AC_SUBST(USE_XRANDR) AC_SUBST(USE_ALSA) AC_SUBST(USE_TEXTUREPACKER) +AC_SUBST(TEXTUREPACKER) AC_SUBST(USE_AIRTUNES) AC_SUBST(USE_LIBUDEV) AC_SUBST(USE_LIBUSB) diff --git a/docs/README.linux b/docs/README.linux index 0bdfa265f1..cfe1db9f47 100644 --- a/docs/README.linux +++ b/docs/README.linux @@ -47,18 +47,17 @@ Build-Depends: autoconf, automake, autopoint, autotools-dev, cmake, curl, libavfilter-dev, libavformat-dev, libavutil-dev, libbluetooth-dev, libbluray-dev, libboost-dev, libboost-thread-dev, libbz2-dev, libcap-dev, libcdio-dev, libcec-dev, libcurl4-gnutls-dev | libcurl4-openssl-dev | libcurl-dev, libcwiid-dev, libdbus-1-dev, - libenca-dev, libfontconfig-dev, libfreetype6-dev, libfribidi-dev, - libgl1-mesa-dev | libgl-dev, libglew-dev, libglu1-mesa-dev | libglu-dev, libhal-dev, - libhal-storage-dev, libiso9660-dev, libjasper-dev, libjpeg-dev, libltdl-dev, liblzo2-dev, - libmad0-dev, libmicrohttpd-dev, libmodplug-dev, libmpcdec-dev, libmpeg2-4-dev, libmysqlclient-dev, - libnfs-dev, libogg-dev, libpcre3-dev, libplist-dev, libpng12-dev | libpng-dev, libpostproc-dev, - libpulse-dev, librtmp-dev, libsdl-dev, libsdl-image1.2-dev, libsdl-mixer1.2-dev, libsdl2-dev, - libshairplay-dev, libsmbclient-dev, libsqlite3-dev, libssh-dev, libssl-dev, - libswscale-dev, libtag1-dev (>= 1.8), libtiff-dev, libtinyxml-dev, libtool, + libenca-dev, libfontconfig-dev, libfreetype6-dev, libfribidi-dev, libgif-dev (>= 4.1.6), + libgl1-mesa-dev | libgl-dev, libglew-dev, libglu1-mesa-dev | libglu-dev, libiso9660-dev, + libjasper-dev, libjpeg-dev, libltdl-dev, liblzo2-dev, libmad0-dev, libmicrohttpd-dev, + libmodplug-dev, libmpcdec-dev, libmpeg2-4-dev, libmysqlclient-dev, libnfs-dev, libogg-dev, + libpcre3-dev, libplist-dev, libpng12-dev | libpng-dev, libpostproc-dev, libpulse-dev, + librtmp-dev, libsdl2-dev, libshairplay-dev, libsmbclient-dev, libsqlite3-dev, libssh-dev, + libssl-dev, libswscale-dev, libtag1-dev (>= 1.8), libtiff-dev, libtinyxml-dev, libtool, libudev-dev, libusb-dev, libva-dev, libvdpau-dev, libvorbis-dev, libxinerama-dev, - libxml2-dev, libxmu-dev, libxrandr-dev, libxslt1-dev, libxt-dev, libyajl-dev, - lsb-release, nasm [!amd64], python-dev, python-imaging, python-support, swig, - unzip, yasm, zip, zlib1g-dev + libxml2-dev, libxmu-dev, libxrandr-dev, libxslt1-dev, libxt-dev, libyajl-dev, lsb-release, + nasm [!amd64], python-dev, python-imaging, python-support, swig, unzip, yasm, zip, zlib1g-dev + Note: For developers and anyone else who compiles frequently it is recommended to use ccache. $ sudo apt-get install ccache diff --git a/docs/README.ubuntu b/docs/README.ubuntu index 7ae7b21c04..a19dae44eb 100644 --- a/docs/README.ubuntu +++ b/docs/README.ubuntu @@ -74,7 +74,7 @@ Tip: For those with multiple computers at home is to try out distcc For Ubuntu (all versions >= 7.04): - $ sudo apt-get install automake bison build-essential cmake curl cvs default-jre fp-compiler gawk gdc gettext git-core gperf libasound2-dev libass-dev libboost-dev libboost-thread-dev libbz2-dev libcap-dev libcdio-dev libcurl3 libcurl4-gnutls-dev libdbus-1-dev libenca-dev libfontconfig-dev libfreetype6-dev libfribidi-dev libglew-dev libiso9660-dev libjasper-dev libjpeg-dev liblzo2-dev libmad0-dev libmicrohttpd-dev libmodplug-dev libmpeg2-4-dev libmpeg3-dev libmysqlclient-dev libnfs-dev libogg-dev libpcre3-dev libplist-dev libpng-dev libpulse-dev libsdl-dev libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl2-dev libsmbclient-dev libsqlite3-dev libssh-dev libssl-dev libtiff-dev libtinyxml-dev libtool libudev-dev libusb-dev libvdpau-dev libvorbisenc2 libxml2-dev libxmu-dev libxrandr-dev libxrender-dev libxslt1-dev libxt-dev libyajl-dev mesa-utils nasm pmount python-dev python-imaging python-sqlite swig unzip yasm zip zlib1g-dev + $ sudo apt-get install automake bison build-essential cmake curl cvs default-jre fp-compiler gawk gdc gettext git-core gperf libasound2-dev libass-dev libboost-dev libboost-thread-dev libbz2-dev libcap-dev libcdio-dev libcurl3 libcurl4-gnutls-dev libdbus-1-dev libenca-dev libfontconfig-dev libfreetype6-dev libfribidi-dev libgif-dev libglew-dev libiso9660-dev libjasper-dev libjpeg-dev liblzo2-dev libmad0-dev libmicrohttpd-dev libmodplug-dev libmpeg2-4-dev libmpeg3-dev libmysqlclient-dev libnfs-dev libogg-dev libpcre3-dev libplist-dev libpng-dev libpulse-dev libsdl2-dev libsmbclient-dev libsqlite3-dev libssh-dev libssl-dev libtiff-dev libtinyxml-dev libtool libudev-dev libusb-dev libvdpau-dev libvorbisenc2 libxml2-dev libxmu-dev libxrandr-dev libxrender-dev libxslt1-dev libxt-dev libyajl-dev mesa-utils nasm pmount python-dev python-imaging python-sqlite swig unzip yasm zip zlib1g-dev For >= 10.10: $ sudo apt-get install autopoint libltdl-dev diff --git a/language/English/strings.po b/language/English/strings.po index 27b690a16d..bfc78440e7 100755 --- a/language/English/strings.po +++ b/language/English/strings.po @@ -2722,9 +2722,7 @@ msgctxt "#643" msgid "Avoid clipping on ReplayGained files" msgstr "" -msgctxt "#644" -msgid "Crop black bars" -msgstr "" +#empty string with id 644 msgctxt "#645" msgid "Need to unpack a big file. Continue?" @@ -6339,27 +6337,7 @@ msgctxt "#13459" msgid "Use OMXPlayer for decoding of video files." msgstr "" -#empty strings from id 13460 to 13499 - -#: system/settings/settings.xml -msgctxt "#13500" -msgid "A/V sync method" -msgstr "" - -#: system/settings/settings.xml -msgctxt "#13501" -msgid "Audio clock" -msgstr "" - -#: system/settings/settings.xml -msgctxt "#13502" -msgid "Video clock (Drop/Dupe audio)" -msgstr "" - -#: system/settings/settings.xml -msgctxt "#13503" -msgid "Video clock (Resample audio)" -msgstr "" +#empty strings from id 13460 to 13503 #: system/settings/settings.xml msgctxt "#13504" @@ -7804,7 +7782,7 @@ msgid "Programme info" msgstr "" msgctxt "#19048" -msgid "Group management" +msgid "Group manager" msgstr "" msgctxt "#19049" @@ -7872,7 +7850,9 @@ msgctxt "#19064" msgid "Go to end" msgstr "" -#empty string with id 19065 +msgctxt "#19065" +msgid "Timer settings" +msgstr "" #. Name of a shortcut to a custom folder for channel icons #: xbmc/pvr/windows/GUIWindowPVRChannels.cpp @@ -8839,7 +8819,13 @@ msgctxt "#19288" msgid "Foreground" msgstr "" -#empty strings from id 19289 to 19498 +#. Label for button to hide a group in the group manager +#: addons/skin/confluence +msgctxt "#19289" +msgid "Hide group" +msgstr "" + +#empty strings from id 19290 to 19498 #: xbmc/epg/Epg.cpp msgctxt "#19499" @@ -9307,7 +9293,19 @@ msgctxt "#19684" msgid "Adult" msgstr "" -#empty strings from id 19685 to 19999 +#. Title for shutdown confirmation dialog +#: xbmc/ApplicationMessenger.cpp +msgctxt "#19685" +msgid "Confirm shutdown" +msgstr "" + +#. Text for shutdown confirmation dialog +#: xbmc/ApplicationMessenger.cpp +msgctxt "#19686" +msgid "The PVR backend is busy. Shutdown anyway?" +msgstr "" + +#empty strings from id 19687 to 19999 #: system/settings/settings.xml msgctxt "#20000" @@ -12703,7 +12701,17 @@ msgctxt "#24129" msgid "The configuration of XBMC has been moved to the new location for Kodi. Please refer to http://kodi.wiki/view/Migration - this message will not be shown again!" msgstr "" -#empty strings from id 24130 to 24998 +#: system/settings/settings.xml +msgctxt "#24130" +msgid "Enable parsing for closed captions" +msgstr "" + +#: system/settings/settings.xml +msgctxt "#24131" +msgid "Enable to parse for CC in video stream. Puts slightly more load on the CPU" +msgstr "" + +#empty strings from id 24132 to 24998 msgctxt "#24999" msgid "Hide incompatible" @@ -14109,11 +14117,7 @@ msgctxt "#36166" msgid "Synchronise the video to the refresh rate of the monitor." msgstr "" -#. Description of setting "Videos -> Playback -> A/V sync method" with label #13500 -#: system/settings/settings.xml -msgctxt "#36167" -msgid "Audio has to stay in sync, this can either be done by resampling, skipping/duplicating packets, or adjusting the clock if it gets out of sync too far." -msgstr "" +#empty string with id 36167 #. Description of setting "Videos -> Playback -> Maximum speedup/slowdown amount (%)" with label #13504 #: system/settings/settings.xml @@ -14368,7 +14372,10 @@ msgctxt "#36212" msgid "Display programming information when changing channels, such as the current TV show." msgstr "" -#empty string with id 36213 +#: system/settings/settings.xml +msgctxt "#36213" +msgid "Open the group manager, which allows modification of groups and their respective channels" +msgstr "" #: system/settings/settings.xml msgctxt "#36214" @@ -16124,7 +16131,55 @@ msgctxt "#37031" msgid "Specifies how Blu-rays should be opened/played back. Disc menus are not fully supported yet and may cause problems." msgstr "" -#empty strings from id 37032 to 38009 +#. Title of category #37032 Settings -> Video -> Accessibility +#: system/settings/settings.xml +msgctxt "#37032" +msgid "Accessibility" +msgstr "" + +#. Description of category #37032 Settings -> Video -> Accessibility +#: system/settings/settings.xml +msgctxt "#37033" +msgid "Video playback related accessibility settings, e.g., "Prefer subtitles for the hearing impaired"" +msgstr "" + +#. Setting #37034 Settings -> Video -> Accessibility +#: system/settings/settings.xml +msgctxt "#37034" +msgid "Prefer audio stream for the visually impaired" +msgstr "" + +#. Description of setting #37034 Settings -> Video -> Accessibility +#: system/settings/settings.xml +msgctxt "#37035" +msgid "Prefer the audio stream for the visually impaired to other audio streams of the same language" +msgstr "" + +#. Setting #37036 Settings -> Video -> Accessibility +#: system/settings/settings.xml +msgctxt "#37036" +msgid "Prefer audio stream for the hearing impaired" +msgstr "" + +#. Description of setting #37036 Settings -> Video -> Accessibility +#: system/settings/settings.xml +msgctxt "#37037" +msgid "Prefer the audio stream for the hearing impaired to other audio streams of the same language" +msgstr "" + +#. Setting #37038 Settings -> Video -> Accessibility +#: system/settings/settings.xml +msgctxt "#37038" +msgid "Prefer subtitles for the hearing impaired" +msgstr "" + +#. Description of setting #37038 Settings -> Video -> Accessibility +#: system/settings/settings.xml +msgctxt "#37039" +msgid "Prefer the subtitle stream for the hearing impaired to other subtitle streams of the same language" +msgstr "" + +#empty strings from id 37040 to 38009 #: system/settings/rbp.xml msgctxt "#38010" diff --git a/lib/UnrarXLib/file.cpp b/lib/UnrarXLib/file.cpp index 4b37d126d1..d70ad84884 100644 --- a/lib/UnrarXLib/file.cpp +++ b/lib/UnrarXLib/file.cpp @@ -175,7 +175,7 @@ bool File::Create(const char *Name,const wchar *NameW) WideToUtf(NameW, _name, sizeof(_name)); else strcpy(_name, Name); - CStdString strPath = URIUtils::GetDirectory(_name); + std::string strPath = URIUtils::GetDirectory(_name); CUtil::CreateDirectoryEx(strPath); m_File.OpenForWrite(_name,true); NewFile=true; diff --git a/lib/UnrarXLib/ulinks.cpp b/lib/UnrarXLib/ulinks.cpp index 247171f152..cf317a14dd 100644 --- a/lib/UnrarXLib/ulinks.cpp +++ b/lib/UnrarXLib/ulinks.cpp @@ -14,7 +14,7 @@ int ExtractLink(ComprDataIO &DataIO,Archive &Arc,char *DestName,uint &LinkCRC,bo FileName[DataSize]=0; if (Create) { - CStdString strPath = URIUtils::GetDirectory(DestName); + std::string strPath = URIUtils::GetDirectory(DestName); CUtil::CreateDirectoryEx(strPath); if (symlink(FileName,DestName)==-1) { diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.cpp b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.cpp index 2bb6a04139..7b853c8c9a 100644 --- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.cpp +++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.cpp @@ -170,6 +170,8 @@ PLT_Didl::ConvertFilterToMask(const NPT_String& filter) mask |= PLT_FILTER_MASK_XBMC_VOTES; } else if (NPT_String::CompareN(s+i, PLT_FILTER_FIELD_XBMC_ARTWORK, len, true) == 0) { mask |= PLT_FILTER_MASK_XBMC_ARTWORK; + } else if (NPT_String::CompareN(s+i, PLT_FILTER_FIELD_XBMC_UNIQUE_IDENTIFIER, len, true) == 0) { + mask |= PLT_FILTER_MASK_XBMC_UNIQUE_IDENTIFIER; } if (next_comma < 0) { diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.h b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.h index 9e87599955..fe1de45cde 100644 --- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.h +++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.h @@ -99,6 +99,7 @@ #define PLT_FILTER_MASK_XBMC_RATING NPT_UINT64_C(0x0000200000000000) #define PLT_FILTER_MASK_XBMC_VOTES NPT_UINT64_C(0x0000400000000000) #define PLT_FILTER_MASK_XBMC_ARTWORK NPT_UINT64_C(0x0000800000000000) +#define PLT_FILTER_MASK_XBMC_UNIQUE_IDENTIFIER NPT_UINT64_C(0x0001000000000000) #define PLT_FILTER_FIELD_TITLE "dc:title" #define PLT_FILTER_FIELD_CREATOR "dc:creator" @@ -148,6 +149,7 @@ #define PLT_FILTER_FIELD_XBMC_RATING "xbmc:rating" #define PLT_FILTER_FIELD_XBMC_VOTES "xbmc:votes" #define PLT_FILTER_FIELD_XBMC_ARTWORK "xbmc:artwork" +#define PLT_FILTER_FIELD_XBMC_UNIQUE_IDENTIFIER "xbmc:uniqueidentifier" extern const char* didl_header; extern const char* didl_footer; diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.cpp b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.cpp index 5c2ec8494a..4db2d45ebd 100644 --- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.cpp +++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.cpp @@ -260,6 +260,7 @@ PLT_MediaObject::Reset() m_XbmcInfo.rating = 0.0f; m_XbmcInfo.votes = ""; m_XbmcInfo.artwork.Clear(); + m_XbmcInfo.unique_identifier = ""; m_Didl = ""; @@ -559,6 +560,13 @@ PLT_MediaObject::ToDidl(NPT_UInt64 mask, NPT_String& didl) m_XbmcInfo.artwork.ToDidl(didl, "artwork"); } + // xbmc unique identifier + if (mask & PLT_FILTER_MASK_XBMC_UNIQUE_IDENTIFIER && !m_XbmcInfo.unique_identifier.IsEmpty()) { + didl += "<xbmc:uniqueidentifier>"; + PLT_Didl::AppendXmlEscape(didl, m_XbmcInfo.unique_identifier); + didl += "</xbmc:uniqueidentifier>"; + } + // class is required didl += "<upnp:class"; if (!m_ObjectClass.friendly_name.IsEmpty()) { @@ -781,6 +789,8 @@ PLT_MediaObject::FromDidl(NPT_XmlElementNode* entry) PLT_XmlHelper::GetChildren(entry, children, "artwork", didl_namespace_xbmc); m_XbmcInfo.artwork.FromDidl(children); + PLT_XmlHelper::GetChildText(entry, "uniqueidentifier", m_XbmcInfo.unique_identifier, didl_namespace_xbmc, 256); + // re serialize the entry didl as a we might need to pass it to a renderer // we may have modified the tree to "fix" issues, so as not to break a renderer // (don't write xml prefix as this didl could be part of a larger document) diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.h b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.h index 56291a7062..deb4961436 100644 --- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.h +++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.h @@ -169,6 +169,7 @@ typedef struct { NPT_Float rating; NPT_String votes; PLT_Artworks artwork; + NPT_String unique_identifier; } PLT_XbmcInfo; /*---------------------------------------------------------------------- diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.h b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.h index 21f1d28b68..8fb23dd16e 100644 --- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.h +++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.h @@ -70,7 +70,7 @@ typedef struct PLT_CapabilitiesData { typedef NPT_Reference<PLT_CapabilitiesData> PLT_CapabilitiesDataReference; // explicitely specify res otherwise WMP won't return a URL! -#define PLT_DEFAULT_FILTER "dc:date,dc:description,upnp:longDescription,upnp:genre,res,res@duration,res@size,upnp:albumArtURI,upnp:rating,upnp:lastPlaybackPosition,upnp:lastPlaybackTime,upnp:playbackCount,upnp:originalTrackNumber,upnp:episodeNumber,upnp:programTitle,upnp:seriesTitle,upnp:album,upnp:artist,upnp:author,upnp:director,dc:publisher,searchable,childCount,dc:title,dc:creator,upnp:actor,res@resolution,upnp:episodeCount,upnp:episodeSeason,xbmc:dateadded,xbmc:rating,xbmc:votes,xbmc:artwork" +#define PLT_DEFAULT_FILTER "dc:date,dc:description,upnp:longDescription,upnp:genre,res,res@duration,res@size,upnp:albumArtURI,upnp:rating,upnp:lastPlaybackPosition,upnp:lastPlaybackTime,upnp:playbackCount,upnp:originalTrackNumber,upnp:episodeNumber,upnp:programTitle,upnp:seriesTitle,upnp:album,upnp:artist,upnp:author,upnp:director,dc:publisher,searchable,childCount,dc:title,dc:creator,upnp:actor,res@resolution,upnp:episodeCount,upnp:episodeSeason,xbmc:dateadded,xbmc:rating,xbmc:votes,xbmc:artwork,xbmc:uniqueidentifier" /*---------------------------------------------------------------------- | PLT_MediaContainerListener diff --git a/lib/libUPnP/patches/0034-platinum-add-xbmc-uniqueidentifier-for-IMDB-TVDB-ide.patch b/lib/libUPnP/patches/0034-platinum-add-xbmc-uniqueidentifier-for-IMDB-TVDB-ide.patch new file mode 100644 index 0000000000..87d1400128 --- /dev/null +++ b/lib/libUPnP/patches/0034-platinum-add-xbmc-uniqueidentifier-for-IMDB-TVDB-ide.patch @@ -0,0 +1,109 @@ +From 03a57931ab47724558d3ed8762a2c978cf056501 Mon Sep 17 00:00:00 2001 +From: montellese <montellese@xbmc.org> +Date: Sat, 29 Nov 2014 19:58:33 +0100 +Subject: [PATCH] platinum: add xbmc:uniqueidentifier for IMDB/TVDB identifiers + +--- + lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.cpp | 2 ++ + lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.h | 2 ++ + .../Platinum/Source/Devices/MediaServer/PltMediaItem.cpp | 10 ++++++++++ + lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.h | 1 + + .../Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.h | 2 +- + 5 files changed, 16 insertions(+), 1 deletion(-) + +diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.cpp b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.cpp +index 2bb6a04..7b853c8 100644 +--- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.cpp ++++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.cpp +@@ -170,6 +170,8 @@ PLT_Didl::ConvertFilterToMask(const NPT_String& filter) + mask |= PLT_FILTER_MASK_XBMC_VOTES; + } else if (NPT_String::CompareN(s+i, PLT_FILTER_FIELD_XBMC_ARTWORK, len, true) == 0) { + mask |= PLT_FILTER_MASK_XBMC_ARTWORK; ++ } else if (NPT_String::CompareN(s+i, PLT_FILTER_FIELD_XBMC_UNIQUE_IDENTIFIER, len, true) == 0) { ++ mask |= PLT_FILTER_MASK_XBMC_UNIQUE_IDENTIFIER; + } + + if (next_comma < 0) { +diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.h b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.h +index 0f7c892..a5015db 100644 +--- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.h ++++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.h +@@ -99,6 +99,7 @@ + #define PLT_FILTER_MASK_XBMC_RATING NPT_UINT64_C(0x0000200000000000) + #define PLT_FILTER_MASK_XBMC_VOTES NPT_UINT64_C(0x0000300000000000) + #define PLT_FILTER_MASK_XBMC_ARTWORK NPT_UINT64_C(0x0000400000000000) ++#define PLT_FILTER_MASK_XBMC_UNIQUE_IDENTIFIER NPT_UINT64_C(0x0001000000000000) + + #define PLT_FILTER_FIELD_TITLE "dc:title" + #define PLT_FILTER_FIELD_CREATOR "dc:creator" +@@ -148,6 +149,7 @@ + #define PLT_FILTER_FIELD_XBMC_RATING "xbmc:rating" + #define PLT_FILTER_FIELD_XBMC_VOTES "xbmc:votes" + #define PLT_FILTER_FIELD_XBMC_ARTWORK "xbmc:artwork" ++#define PLT_FILTER_FIELD_XBMC_UNIQUE_IDENTIFIER "xbmc:uniqueidentifier" + + extern const char* didl_header; + extern const char* didl_footer; +diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.cpp b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.cpp +index 0c6830f..f8ddd85 100644 +--- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.cpp ++++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.cpp +@@ -268,6 +268,7 @@ PLT_MediaObject::Reset() + m_XbmcInfo.rating = 0.0f; + m_XbmcInfo.votes = ""; + m_XbmcInfo.artwork.Clear(); ++ m_XbmcInfo.unique_identifier = ""; + + m_Didl = ""; + +@@ -567,6 +568,13 @@ PLT_MediaObject::ToDidl(NPT_UInt64 mask, NPT_String& didl) + m_XbmcInfo.artwork.ToDidl(didl, "artwork"); + } + ++ // xbmc unique identifier ++ if (mask & PLT_FILTER_MASK_XBMC_UNIQUE_IDENTIFIER && !m_XbmcInfo.unique_identifier.IsEmpty()) { ++ didl += "<xbmc:uniqueidentifier>"; ++ PLT_Didl::AppendXmlEscape(didl, m_XbmcInfo.unique_identifier); ++ didl += "</xbmc:uniqueidentifier>"; ++ } ++ + // class is required + didl += "<upnp:class"; + if (!m_ObjectClass.friendly_name.IsEmpty()) { +@@ -789,6 +797,8 @@ PLT_MediaObject::FromDidl(NPT_XmlElementNode* entry) + PLT_XmlHelper::GetChildren(entry, children, "artwork", didl_namespace_xbmc); + m_XbmcInfo.artwork.FromDidl(children); + ++ PLT_XmlHelper::GetChildText(entry, "uniqueidentifier", m_XbmcInfo.unique_identifier, didl_namespace_xbmc, 256); ++ + // re serialize the entry didl as a we might need to pass it to a renderer + // we may have modified the tree to "fix" issues, so as not to break a renderer + // (don't write xml prefix as this didl could be part of a larger document) +diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.h b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.h +index 18a094f..dd7f8ae 100644 +--- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.h ++++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.h +@@ -170,6 +170,7 @@ typedef struct { + NPT_Float rating; + NPT_String votes; + PLT_Artworks artwork; ++ NPT_String unique_identifier; + } PLT_XbmcInfo; + + /*---------------------------------------------------------------------- +diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.h b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.h +index 21f1d28..8fb23dd 100644 +--- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.h ++++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.h +@@ -70,7 +70,7 @@ typedef struct PLT_CapabilitiesData { + typedef NPT_Reference<PLT_CapabilitiesData> PLT_CapabilitiesDataReference; + + // explicitely specify res otherwise WMP won't return a URL! +-#define PLT_DEFAULT_FILTER "dc:date,dc:description,upnp:longDescription,upnp:genre,res,res@duration,res@size,upnp:albumArtURI,upnp:rating,upnp:lastPlaybackPosition,upnp:lastPlaybackTime,upnp:playbackCount,upnp:originalTrackNumber,upnp:episodeNumber,upnp:programTitle,upnp:seriesTitle,upnp:album,upnp:artist,upnp:author,upnp:director,dc:publisher,searchable,childCount,dc:title,dc:creator,upnp:actor,res@resolution,upnp:episodeCount,upnp:episodeSeason,xbmc:dateadded,xbmc:rating,xbmc:votes,xbmc:artwork" ++#define PLT_DEFAULT_FILTER "dc:date,dc:description,upnp:longDescription,upnp:genre,res,res@duration,res@size,upnp:albumArtURI,upnp:rating,upnp:lastPlaybackPosition,upnp:lastPlaybackTime,upnp:playbackCount,upnp:originalTrackNumber,upnp:episodeNumber,upnp:programTitle,upnp:seriesTitle,upnp:album,upnp:artist,upnp:author,upnp:director,dc:publisher,searchable,childCount,dc:title,dc:creator,upnp:actor,res@resolution,upnp:episodeCount,upnp:episodeSeason,xbmc:dateadded,xbmc:rating,xbmc:votes,xbmc:artwork,xbmc:uniqueidentifier" + + /*---------------------------------------------------------------------- + | PLT_MediaContainerListener +-- +1.9.4.msysgit.2 + diff --git a/lib/libsquish/Makefile.in b/lib/libsquish/Makefile.in deleted file mode 100644 index ef57bb884d..0000000000 --- a/lib/libsquish/Makefile.in +++ /dev/null @@ -1,35 +0,0 @@ -ARCH=@ARCH@ - -SRCS= \ - alpha.cpp \ - clusterfit.cpp \ - colourblock.cpp \ - colourfit.cpp \ - colourset.cpp \ - maths.cpp \ - rangefit.cpp \ - singlecolourfit.cpp \ - squish.cpp - -CXXFLAGS += -I. -CXXFLAGS_FOR_BUILD += -I. -LIB = libsquish.a -NATIVE_LIB = libsquish-native.so -CLEAN_FILES += $(NATIVE_LIB) - -ifeq ($(findstring Darwin,$(shell uname -s)),Darwin) - CXXFLAGS_FOR_BUILD += @DARWIN_NATIVE_ARCH@ -endif - -all: $(LIB) - -# TexturePacker links to libsquish and needs to run on build system, so make a native flavor. -$(NATIVE_LIB): $(SRCS) -ifeq ($(findstring Darwin,$(shell uname -s)),Darwin) - $(CXX_FOR_BUILD) $(CXXFLAGS_FOR_BUILD) $(SRCS) -dynamiclib -install_name `pwd`/$(NATIVE_LIB) -o $@ -else - $(CXX_FOR_BUILD) $(CXXFLAGS_FOR_BUILD) $(SRCS) -shared -fPIC -Wl,-soname,`pwd`/$(NATIVE_LIB) -o $@ -endif - -include ../../Makefile.include --include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS))) diff --git a/project/BuildDependencies/scripts/0_package.list b/project/BuildDependencies/scripts/0_package.list index 13d5c23089..259cafe52b 100644 --- a/project/BuildDependencies/scripts/0_package.list +++ b/project/BuildDependencies/scripts/0_package.list @@ -27,3 +27,6 @@ python-2.7.8-win32.7z sqlite-3.8.6-win32-vc120.7z taglib-1.9.1-win32-vc120.7z tinyxml-2.6.2_3-win32-vc120.7z +libpng-1.5.13-win32.7z +giflib-5.0.5p-win32.7z +texturepacker-1.0.0-win32.7z diff --git a/project/BuildDependencies/scripts/libsdl_d.bat b/project/BuildDependencies/scripts/libsdl_d.bat index 601a58e5d9..4f7f0cead5 100644 --- a/project/BuildDependencies/scripts/libsdl_d.bat +++ b/project/BuildDependencies/scripts/libsdl_d.bat @@ -10,9 +10,7 @@ cd %TMP_PATH% xcopy SDL-1.2.14\include\* "%CUR_PATH%\include\SDL\" /E /Q /I /Y copy SDL-1.2.14\lib\SDL.lib "%CUR_PATH%\lib\SDL.lib" /Y -copy SDL-1.2.14\lib\SDL.dll "%APP_PATH%\tools\TexturePacker\SDL.dll" copy SDL_image-1.2.10\include\SDL_image.h "%CUR_PATH%\include\SDL\" -copy SDL_image-1.2.10\lib\*.dll "%APP_PATH%\tools\TexturePacker\" copy SDL_image-1.2.10\lib\SDL_image.lib "%CUR_PATH%\lib\SDL_image.lib" /Y diff --git a/project/BuildDependencies/scripts/zlib_d.bat b/project/BuildDependencies/scripts/zlib_d.bat index a472ff593e..f9fb00f458 100644 --- a/project/BuildDependencies/scripts/zlib_d.bat +++ b/project/BuildDependencies/scripts/zlib_d.bat @@ -8,7 +8,7 @@ CALL dlextract.bat zlib %FILES% cd %TMP_PATH% xcopy include\* "%CUR_PATH%\include\" /E /Q /I /Y -copy lib\zlib.lib "%CUR_PATH%\lib\" /Y +copy lib\zlib*.lib "%CUR_PATH%\lib\" /Y copy bin\zlib1.dll "%APP_PATH%\system\" /Y cd %LOC_PATH% diff --git a/project/BuildDependencies/scripts/zlib_d.txt b/project/BuildDependencies/scripts/zlib_d.txt index 9f466ab249..a48685ff54 100644 --- a/project/BuildDependencies/scripts/zlib_d.txt +++ b/project/BuildDependencies/scripts/zlib_d.txt @@ -1,3 +1,3 @@ ; filename mirror of the file source of the file zlib-vc100-1.2.5-bin.tar.bz2 http://mirrors.xbmc.org/build-deps/win32/ http://winkde.org/pub/kde/ports/win32/releases/stable/4.5.4/zlib-vc100-1.2.5-bin.tar.bz2 -zlib-vc100-1.2.5-lib.tar.bz2 http://mirrors.xbmc.org/build-deps/win32/ http://winkde.org/pub/kde/ports/win32/releases/stable/4.5.4/zlib-vc100-1.2.5-lib.tar.bz2
\ No newline at end of file +zlib-vc100-1.2.5-lib-1.tar.bz2 http://mirrors.xbmc.org/build-deps/win32/ http://winkde.org/pub/kde/ports/win32/releases/stable/4.5.4/zlib-vc100-1.2.5-lib.tar.bz2
\ No newline at end of file diff --git a/project/VS2010Express/XBMC for Windows.sln b/project/VS2010Express/XBMC for Windows.sln index ef8a99893d..4d0a740f57 100644 --- a/project/VS2010Express/XBMC for Windows.sln +++ b/project/VS2010Express/XBMC for Windows.sln @@ -49,7 +49,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libRTV", "..\..\lib\libRTV\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "visWaveform", "..\..\xbmc\visualizations\WaveForm\Waveform.vcxproj", "{D450FE9A-CE56-4496-B4AB-379094E642F2}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "squish", "..\..\lib\libsquish\vs7\squish\squish_2010.vcxproj", "{6A8518C3-D81A-4428-BD7F-C37933088AC1}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "squish", "..\..\tools\depends\native\libsquish-native\src\vs7\squish\squish_2010.vcxproj", "{6A8518C3-D81A-4428-BD7F-C37933088AC1}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libStSoundLibrary_dll", "..\..\lib\stsound\StSoundLibrary\StSoundLibrary.vcxproj", "{D9885434-4B9D-41FB-B5FC-5E89D41AEFF0}" EndProject diff --git a/project/VS2010Express/XBMC.vcxproj b/project/VS2010Express/XBMC.vcxproj index b461edad26..3d8f6d76bf 100644 --- a/project/VS2010Express/XBMC.vcxproj +++ b/project/VS2010Express/XBMC.vcxproj @@ -75,7 +75,7 @@ </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ClCompile> - <AdditionalIncludeDirectories>..\..\;..\..\xbmc\;..\..\xbmc\cores\dvdplayer;..\..\xbmc\win32;..\..\lib;..\..\lib\win32\ffmpeg;..\..\lib\libUPnP;..\..\lib\libUPnP\Platinum\Source\Devices\MediaRenderer;..\..\lib\libUPnP\Platinum\Source\Devices\MediaConnect;..\..\lib\libUPnP\Platinum\Source\Devices\MediaServer;..\..\lib\libUPnP\Platinum\Source\Platinum;..\..\lib\libUPnP\Platinum\Source\Core;..\..\lib\libUPnP\Platinum\Source\Extras;..\..\lib\libUPnP\Neptune\Source\Core;..\..\lib\libUPnP\Neptune\Source\System\Win32;..\..\lib\win32\pcre;..\..\lib\win32;..\..\xbmc\cores\AudioEngine\;..\..\addons\library.xbmc.gui;..\..\addons\library.xbmc.addon;..\..\addons\library.xbmc.pvr;..\..\addons\library.xbmc.codec;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\..\;..\..\xbmc\;..\..\xbmc\cores\dvdplayer;..\..\xbmc\win32;..\..\lib;..\..\lib\win32\ffmpeg;..\..\lib\libUPnP;..\..\lib\libUPnP\Platinum\Source\Devices\MediaRenderer;..\..\lib\libUPnP\Platinum\Source\Devices\MediaConnect;..\..\lib\libUPnP\Platinum\Source\Devices\MediaServer;..\..\lib\libUPnP\Platinum\Source\Platinum;..\..\lib\libUPnP\Platinum\Source\Core;..\..\lib\libUPnP\Platinum\Source\Extras;..\..\lib\libUPnP\Neptune\Source\Core;..\..\lib\libUPnP\Neptune\Source\System\Win32;..\..\lib\win32\pcre;..\..\lib\win32;..\..\xbmc\cores\AudioEngine\;..\..\addons\library.xbmc.gui;..\..\addons\library.xbmc.addon;..\..\addons\library.xbmc.pvr;..\..\addons\library.xbmc.codec;..\..\tools\depends\native\libsquish-native\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>NOMINMAX;_USE_32BIT_TIME_T;HAS_DX;D3D_DEBUG_INFO;__STDC_CONSTANT_MACROS;_SECURE_SCL=0;TAGLIB_STATIC;NPT_CONFIG_ENABLE_LOGGING;PLT_HTTP_DEFAULT_USER_AGENT="UPnP/1.0 DLNADOC/1.50 Kodi";PLT_HTTP_DEFAULT_SERVER="UPnP/1.0 DLNADOC/1.50 Kodi";%(PreprocessorDefinitions)</PreprocessorDefinitions> <ExceptionHandling>Async</ExceptionHandling> <PrecompiledHeader>Use</PrecompiledHeader> @@ -107,7 +107,7 @@ </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Testsuite|Win32'"> <ClCompile> - <AdditionalIncludeDirectories>..\..\;..\..\xbmc\;..\..\xbmc\cores\dvdplayer;..\..\xbmc\win32;..\..\lib;..\..\lib\win32\ffmpeg;..\..\lib\libUPnP;..\..\lib\libUPnP\Platinum\Source\Devices\MediaRenderer;..\..\lib\libUPnP\Platinum\Source\Devices\MediaConnect;..\..\lib\libUPnP\Platinum\Source\Devices\MediaServer;..\..\lib\libUPnP\Platinum\Source\Platinum;..\..\lib\libUPnP\Platinum\Source\Core;..\..\lib\libUPnP\Platinum\Source\Extras;..\..\lib\libUPnP\Neptune\Source\Core;..\..\lib\libUPnP\Neptune\Source\System\Win32;..\..\lib\win32\pcre;..\..\lib\win32;..\..\xbmc\cores\AudioEngine\;..\..\addons\library.xbmc.gui;..\..\addons\library.xbmc.addon;..\..\addons\library.xbmc.pvr;..\..\addons\library.xbmc.codec;..\..\lib\gtest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\..\;..\..\xbmc\;..\..\xbmc\cores\dvdplayer;..\..\xbmc\win32;..\..\lib;..\..\lib\win32\ffmpeg;..\..\lib\libUPnP;..\..\lib\libUPnP\Platinum\Source\Devices\MediaRenderer;..\..\lib\libUPnP\Platinum\Source\Devices\MediaConnect;..\..\lib\libUPnP\Platinum\Source\Devices\MediaServer;..\..\lib\libUPnP\Platinum\Source\Platinum;..\..\lib\libUPnP\Platinum\Source\Core;..\..\lib\libUPnP\Platinum\Source\Extras;..\..\lib\libUPnP\Neptune\Source\Core;..\..\lib\libUPnP\Neptune\Source\System\Win32;..\..\lib\win32\pcre;..\..\lib\win32;..\..\xbmc\cores\AudioEngine\;..\..\addons\library.xbmc.gui;..\..\addons\library.xbmc.addon;..\..\addons\library.xbmc.pvr;..\..\addons\library.xbmc.codec;..\..\lib\gtest\include;..\..\tools\depends\native\libsquish-native\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>_CONSOLE;NOMINMAX;_USE_32BIT_TIME_T;HAS_DX;D3D_DEBUG_INFO;__STDC_CONSTANT_MACROS;_SECURE_SCL=0;TAGLIB_STATIC;NPT_CONFIG_ENABLE_LOGGING;PLT_HTTP_DEFAULT_USER_AGENT="UPnP/1.0 DLNADOC/1.50 Kodi";PLT_HTTP_DEFAULT_SERVER="UPnP/1.0 DLNADOC/1.50 Kodi";%(PreprocessorDefinitions)</PreprocessorDefinitions> <ExceptionHandling>Async</ExceptionHandling> <PrecompiledHeader>Use</PrecompiledHeader> @@ -141,7 +141,7 @@ </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ClCompile> - <AdditionalIncludeDirectories>..\..\;..\..\xbmc\;..\..\xbmc\cores\dvdplayer;..\..\xbmc\win32;..\..\lib;..\..\lib\win32\ffmpeg;..\..\lib\libUPnP;..\..\lib\libUPnP\Platinum\Source\Devices\MediaRenderer;..\..\lib\libUPnP\Platinum\Source\Devices\MediaConnect;..\..\lib\libUPnP\Platinum\Source\Devices\MediaServer;..\..\lib\libUPnP\Platinum\Source\Platinum;..\..\lib\libUPnP\Platinum\Source\Core;..\..\lib\libUPnP\Platinum\Source\Extras;..\..\lib\libUPnP\Neptune\Source\Core;..\..\lib\libUPnP\Neptune\Source\System\Win32;..\..\lib\win32\pcre;..\..\lib\win32;..\..\xbmc\cores\AudioEngine\;..\..\addons\library.xbmc.gui;..\..\addons\library.xbmc.addon;..\..\addons\library.xbmc.pvr;..\..\addons\library.xbmc.codec;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\..\;..\..\xbmc\;..\..\xbmc\cores\dvdplayer;..\..\xbmc\win32;..\..\lib;..\..\lib\win32\ffmpeg;..\..\lib\libUPnP;..\..\lib\libUPnP\Platinum\Source\Devices\MediaRenderer;..\..\lib\libUPnP\Platinum\Source\Devices\MediaConnect;..\..\lib\libUPnP\Platinum\Source\Devices\MediaServer;..\..\lib\libUPnP\Platinum\Source\Platinum;..\..\lib\libUPnP\Platinum\Source\Core;..\..\lib\libUPnP\Platinum\Source\Extras;..\..\lib\libUPnP\Neptune\Source\Core;..\..\lib\libUPnP\Neptune\Source\System\Win32;..\..\lib\win32\pcre;..\..\lib\win32;..\..\xbmc\cores\AudioEngine\;..\..\addons\library.xbmc.gui;..\..\addons\library.xbmc.addon;..\..\addons\library.xbmc.pvr;..\..\addons\library.xbmc.codec;..\..\tools\depends\native\libsquish-native\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>NOMINMAX;_USE_32BIT_TIME_T;HAS_DX;__STDC_CONSTANT_MACROS;TAGLIB_STATIC;NPT_CONFIG_ENABLE_LOGGING;PLT_HTTP_DEFAULT_USER_AGENT="UPnP/1.0 DLNADOC/1.50 Kodi";PLT_HTTP_DEFAULT_SERVER="UPnP/1.0 DLNADOC/1.50 Kodi";%(PreprocessorDefinitions)</PreprocessorDefinitions> <ExceptionHandling>Async</ExceptionHandling> <PrecompiledHeader>Use</PrecompiledHeader> @@ -217,8 +217,15 @@ <ClCompile Include="..\..\xbmc\cores\AudioEngine\Utils\AEUtil.cpp" /> <ClCompile Include="..\..\xbmc\cores\DataCacheCore.cpp" /> <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Audio\DVDAudioCodecPassthrough.cpp" /> + <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\contrib\cc_decoder.c"> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug Testsuite|Win32'">CompileAsCpp</CompileAs> + </ClCompile> + <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\contrib\cc_decoder708.cpp" /> <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Video\DVDVideoCodec.cpp" /> <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDDemuxers\DVDDemuxBXA.cpp" /> + <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDDemuxers\DVDDemuxCC.cpp" /> <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDDemuxers\DVDDemuxCDDA.cpp" /> <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDDemuxers\DVDDemuxPVRClient.cpp" /> <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDInputStreams\DVDInputStreamBluray.cpp" /> @@ -330,6 +337,8 @@ <ClCompile Include="..\..\xbmc\filesystem\NptXbmcFile.cpp" /> <ClCompile Include="..\..\xbmc\filesystem\NSFFileDirectory.cpp" /> <ClCompile Include="..\..\xbmc\filesystem\OGGFileDirectory.cpp" /> + <ClCompile Include="..\..\xbmc\filesystem\OverrideDirectory.cpp" /> + <ClCompile Include="..\..\xbmc\filesystem\OverrideFile.cpp" /> <ClCompile Include="..\..\xbmc\filesystem\PipeFile.cpp" /> <ClCompile Include="..\..\xbmc\filesystem\PVRDirectory.cpp" /> <ClCompile Include="..\..\xbmc\filesystem\PVRFile.cpp" /> @@ -834,7 +843,10 @@ <ClInclude Include="..\..\xbmc\cores\AudioEngine\Utils\AEStreamInfo.h" /> <ClInclude Include="..\..\xbmc\cores\AudioEngine\Utils\AEUtil.h" /> <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Audio\DVDAudioCodecPassthrough.h" /> + <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\contrib\cc_decoder.h" /> + <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\contrib\cc_decoder708.h" /> <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDDemuxers\DVDDemuxBXA.h" /> + <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDDemuxers\DVDDemuxCC.h" /> <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDDemuxers\DVDDemuxCDDA.h" /> <ClInclude Include="..\..\xbmc\cores\FFmpeg.h" /> <ClInclude Include="..\..\xbmc\cores\VideoRenderers\OverlayRendererGUI.h" /> @@ -848,6 +860,8 @@ <ClInclude Include="..\..\xbmc\filesystem\DAVFile.h" /> <ClInclude Include="..\..\xbmc\filesystem\ImageFile.h" /> <ClInclude Include="..\..\xbmc\filesystem\MusicDatabaseDirectory\DirectoryNodeGrouped.h" /> + <ClInclude Include="..\..\xbmc\filesystem\OverrideDirectory.h" /> + <ClInclude Include="..\..\xbmc\filesystem\OverrideFile.h" /> <ClInclude Include="..\..\xbmc\filesystem\VideoDatabaseDirectory\DirectoryNodeGrouped.h" /> <ClInclude Include="..\..\xbmc\filesystem\win32\Win32Directory.h" /> <ClInclude Include="..\..\xbmc\filesystem\win32\Win32SMBDirectory.h" /> @@ -1292,10 +1306,6 @@ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> </ClCompile> - <ClCompile Include="..\..\xbmc\utils\test\TestStdString.cpp"> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> - </ClCompile> <ClCompile Include="..\..\xbmc\utils\test\TestStopwatch.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> @@ -1472,16 +1482,10 @@ <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Video\DVDVideoPPFFmpeg.cpp" /> <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Video\DXVA.cpp" /> <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayCodec.cpp" /> - <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayCodecCC.cpp" /> <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayCodecFFmpeg.cpp" /> <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayCodecSSA.cpp" /> <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayCodecText.cpp" /> <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayCodecTX3G.cpp" /> - <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\libspucc\cc_decoder.c"> - <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> - <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug Testsuite|Win32'">CompileAsCpp</CompileAs> - <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs> - </ClCompile> <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDDemuxers\DVDDemux.cpp" /> <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDDemuxers\DVDDemuxFFmpeg.cpp" /> <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDDemuxers\DVDDemuxHTSP.cpp" /> @@ -2074,7 +2078,6 @@ <ClInclude Include="..\..\xbmc\utils\SeekHandler.h" /> <ClInclude Include="..\..\xbmc\utils\SortUtils.h" /> <ClInclude Include="..\..\xbmc\utils\Splash.h" /> - <ClInclude Include="..\..\xbmc\utils\StdString.h" /> <ClInclude Include="..\..\xbmc\utils\Stopwatch.h" /> <ClInclude Include="..\..\xbmc\utils\StreamDetails.h" /> <ClInclude Include="..\..\xbmc\utils\StreamUtils.h" /> @@ -2168,7 +2171,6 @@ <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Video\DXVA.h" /> <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlay.h" /> <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayCodec.h" /> - <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayCodecCC.h" /> <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayCodecFFmpeg.h" /> <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayCodecSSA.h" /> <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayCodecText.h" /> @@ -2177,7 +2179,6 @@ <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlaySpu.h" /> <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlaySSA.h" /> <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayText.h" /> - <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\libspucc\cc_decoder.h" /> <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDDemuxers\DVDDemux.h" /> <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDDemuxers\DVDDemuxFFmpeg.h" /> <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDDemuxers\DVDDemuxHTSP.h" /> @@ -2362,7 +2363,7 @@ <LinkLibraryDependencies>true</LinkLibraryDependencies> <UseLibraryDependencyInputs>false</UseLibraryDependencyInputs> </ProjectReference> - <ProjectReference Include="..\..\lib\libsquish\vs7\squish\squish_2010.vcxproj"> + <ProjectReference Include="..\..\tools\depends\native\libsquish-native\src\vs7\squish\squish_2010.vcxproj"> <Project>{6a8518c3-d81a-4428-bd7f-c37933088ac1}</Project> <Private>true</Private> <ReferenceOutputAssembly>false</ReferenceOutputAssembly> @@ -2510,7 +2511,6 @@ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug Testsuite|Win32'">%(RelativeDir)..\ServiceDescription.h</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(RelativeDir)..\ServiceDescription.h</Outputs> </CustomBuild> - <None Include="..\..\xbmc\interfaces\swig\ControlListAddItemMethods.i" /> <CustomBuild Include="..\..\xbmc\win32\git_revision.t"> <FileType>Document</FileType> <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CALL update_git_rev.bat</Command> diff --git a/project/VS2010Express/XBMC.vcxproj.filters b/project/VS2010Express/XBMC.vcxproj.filters index 52eb9c95f3..a462ca8b99 100644 --- a/project/VS2010Express/XBMC.vcxproj.filters +++ b/project/VS2010Express/XBMC.vcxproj.filters @@ -22,9 +22,6 @@ <Filter Include="cores\dvdplayer\DVDCodecs\Overlay"> <UniqueIdentifier>{cc80e830-cd3b-4790-9d73-b727b997efdc}</UniqueIdentifier> </Filter> - <Filter Include="cores\dvdplayer\DVDCodecs\Overlay\libspucc"> - <UniqueIdentifier>{43526341-7b96-462d-9f71-685e426251ec}</UniqueIdentifier> - </Filter> <Filter Include="cores\dvdplayer\DVDDemuxers"> <UniqueIdentifier>{59ff29b6-c2b5-4ed8-a80c-e5dd130802a7}</UniqueIdentifier> </Filter> @@ -322,6 +319,9 @@ <Filter Include="video\videosync"> <UniqueIdentifier>{9775d5c0-c640-4606-a625-e6cdcf9f959e}</UniqueIdentifier> </Filter> + <Filter Include="cores\dvdplayer\DVDCodecs\Overlay\contrib"> + <UniqueIdentifier>{43526341-7b96-462d-9f71-685e426251ec}</UniqueIdentifier> + </Filter> </ItemGroup> <ItemGroup> <ClCompile Include="..\..\xbmc\win32\pch.cpp"> @@ -420,9 +420,6 @@ <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayCodec.cpp"> <Filter>cores\dvdplayer\DVDCodecs\Overlay</Filter> </ClCompile> - <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayCodecCC.cpp"> - <Filter>cores\dvdplayer\DVDCodecs\Overlay</Filter> - </ClCompile> <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayCodecFFmpeg.cpp"> <Filter>cores\dvdplayer\DVDCodecs\Overlay</Filter> </ClCompile> @@ -435,9 +432,6 @@ <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayCodecTX3G.cpp"> <Filter>cores\dvdplayer\DVDCodecs\Overlay</Filter> </ClCompile> - <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\libspucc\cc_decoder.c"> - <Filter>cores\dvdplayer\DVDCodecs\Overlay\libspucc</Filter> - </ClCompile> <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDDemuxers\DVDDemux.cpp"> <Filter>cores\dvdplayer\DVDDemuxers</Filter> </ClCompile> @@ -2569,9 +2563,6 @@ <ClCompile Include="..\..\xbmc\utils\test\TestSortUtils.cpp"> <Filter>utils\test</Filter> </ClCompile> - <ClCompile Include="..\..\xbmc\utils\test\TestStdString.cpp"> - <Filter>utils\test</Filter> - </ClCompile> <ClCompile Include="..\..\xbmc\utils\test\TestStopwatch.cpp"> <Filter>utils\test</Filter> </ClCompile> @@ -3080,6 +3071,21 @@ <ClCompile Include="..\..\xbmc\cores\DataCacheCore.cpp"> <Filter>cores</Filter> </ClCompile> + <ClCompile Include="..\..\xbmc\filesystem\OverrideDirectory.cpp"> + <Filter>filesystem</Filter> + </ClCompile> + <ClCompile Include="..\..\xbmc\filesystem\OverrideFile.cpp"> + <Filter>filesystem</Filter> + </ClCompile> + <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\contrib\cc_decoder.c"> + <Filter>cores\dvdplayer\DVDCodecs\Overlay\contrib</Filter> + </ClCompile> + <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\contrib\cc_decoder708.cpp"> + <Filter>cores\dvdplayer\DVDCodecs\Overlay\contrib</Filter> + </ClCompile> + <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDDemuxers\DVDDemuxCC.cpp"> + <Filter>cores\dvdplayer\DVDDemuxers</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\..\xbmc\win32\pch.h"> @@ -3196,9 +3202,6 @@ <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayCodec.h"> <Filter>cores\dvdplayer\DVDCodecs\Overlay</Filter> </ClInclude> - <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayCodecCC.h"> - <Filter>cores\dvdplayer\DVDCodecs\Overlay</Filter> - </ClInclude> <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayCodecFFmpeg.h"> <Filter>cores\dvdplayer\DVDCodecs\Overlay</Filter> </ClInclude> @@ -3223,9 +3226,6 @@ <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\DVDOverlayText.h"> <Filter>cores\dvdplayer\DVDCodecs\Overlay</Filter> </ClInclude> - <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\libspucc\cc_decoder.h"> - <Filter>cores\dvdplayer\DVDCodecs\Overlay\libspucc</Filter> - </ClInclude> <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDDemuxers\DVDDemux.h"> <Filter>cores\dvdplayer\DVDDemuxers</Filter> </ClInclude> @@ -4440,9 +4440,6 @@ <ClInclude Include="..\..\xbmc\utils\Splash.h"> <Filter>utils</Filter> </ClInclude> - <ClInclude Include="..\..\xbmc\utils\StdString.h"> - <Filter>utils</Filter> - </ClInclude> <ClInclude Include="..\..\xbmc\utils\Stopwatch.h"> <Filter>utils</Filter> </ClInclude> @@ -5997,6 +5994,21 @@ <ClInclude Include="..\..\xbmc\cores\DataCacheCore.h"> <Filter>cores</Filter> </ClInclude> + <ClInclude Include="..\..\xbmc\filesystem\OverrideDirectory.h"> + <Filter>filesystem</Filter> + </ClInclude> + <ClInclude Include="..\..\xbmc\filesystem\OverrideFile.h"> + <Filter>filesystem</Filter> + </ClInclude> + <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\contrib\cc_decoder.h"> + <Filter>cores\dvdplayer\DVDCodecs\Overlay\contrib</Filter> + </ClInclude> + <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Overlay\contrib\cc_decoder708.h"> + <Filter>cores\dvdplayer\DVDCodecs\Overlay\contrib</Filter> + </ClInclude> + <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDDemuxers\DVDDemuxCC.h"> + <Filter>cores\dvdplayer\DVDDemuxers</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ResourceCompile Include="..\..\xbmc\win32\XBMC_PC.rc"> @@ -6039,9 +6051,4 @@ <Filter>win32</Filter> </CustomBuild> </ItemGroup> - <ItemGroup> - <None Include="..\..\xbmc\interfaces\swig\ControlListAddItemMethods.i"> - <Filter>interfaces\swig</Filter> - </None> - </ItemGroup> </Project>
\ No newline at end of file diff --git a/project/Win32BuildSetup/buildpvraddons.bat b/project/Win32BuildSetup/buildpvraddons.bat index 9372aee771..b4cf4142ba 100644 --- a/project/Win32BuildSetup/buildpvraddons.bat +++ b/project/Win32BuildSetup/buildpvraddons.bat @@ -9,7 +9,7 @@ SET DEPS_DIR=..\BuildDependencies SET TMP_DIR=%DEPS_DIR%\tmp SET LIBNAME=xbmc-pvr-addons -SET VERSION=9f63d1bc39ffcb28f8aea580ea0669211e4d16e5 +SET VERSION=28f0e74864791cb9bb123559acb3d82e995b2b80 SET SOURCE=%LIBNAME% SET GIT_URL=git://github.com/opdenkamp/%LIBNAME%.git SET SOURCE_DIR=%TMP_DIR%\%SOURCE% diff --git a/project/cmake/addons/CMakeLists.txt b/project/cmake/addons/CMakeLists.txt index e41ab0f951..8cbd70291d 100644 --- a/project/cmake/addons/CMakeLists.txt +++ b/project/cmake/addons/CMakeLists.txt @@ -24,20 +24,25 @@ else() endif() get_filename_component(APP_ROOT "${APP_ROOT}" ABSOLUTE) -if(NOT WIN32) - if(NOT DEPENDS_PATH) - set(DEPENDS_PATH "${PROJECT_SOURCE_DIR}/output/depends") - else() - file(TO_CMAKE_PATH "${DEPENDS_PATH}" DEPENDS_PATH) - endif() +if(NOT BUILD_DIR) + set(BUILD_DIR "${CMAKE_BINARY_DIR}/build") +else() + file(TO_CMAKE_PATH "${BUILD_DIR}" BUILD_DIR) +endif() +get_filename_component(BUILD_DIR "${BUILD_DIR}" ABSOLUTE) - # make sure CMAKE_PREFIX_PATH is set - if(NOT CMAKE_PREFIX_PATH) - set(CMAKE_PREFIX_PATH "${DEPENDS_PATH}") - else() - file(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH) - list(APPEND CMAKE_PREFIX_PATH "${DEPENDS_PATH}") - endif() +if(NOT DEPENDS_PATH) + set(DEPENDS_PATH "${BUILD_DIR}/depends") +else() + file(TO_CMAKE_PATH "${DEPENDS_PATH}" DEPENDS_PATH) +endif() + +# make sure CMAKE_PREFIX_PATH is set +if(NOT CMAKE_PREFIX_PATH) + set(CMAKE_PREFIX_PATH "${DEPENDS_PATH}") +else() + file(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH) + list(APPEND CMAKE_PREFIX_PATH "${DEPENDS_PATH}") endif() if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX) @@ -47,6 +52,7 @@ list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}) set(BUILD_ARGS -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + -DPACKAGE_CONFIG_PATH=${DEPENDS_PATH}/lib/pkgconfig -DCMAKE_BUILD_TYPE=Release -DCMAKE_USER_MAKE_RULES_OVERRIDE=${CMAKE_USER_MAKE_RULES_OVERRIDE} -DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX=${CMAKE_USER_MAKE_RULES_OVERRIDE_CXX} @@ -82,6 +88,8 @@ if(NOT WIN32) include(prepare-env) endif() +add_subdirectory(depends) + ### get and build all the binary addons # look for all the addons to be built file(GLOB_RECURSE addons ${PROJECT_SOURCE_DIR}/addons/*.txt) @@ -106,6 +114,20 @@ foreach(addon ${addons}) foreach(platform ${platforms}) if(${platform} STREQUAL "all" OR ${platform} STREQUAL ${CORE_SYSTEM_NAME}) set(platform_found TRUE) + else() + # check if the platform is defined as "!<platform>" + string(SUBSTRING ${platform} 0 1 platform_first) + if(${platform_first} STREQUAL "!") + # extract the platform + string(LENGTH ${platform} platform_length) + MATH(EXPR platform_length "${platform_length} - 1") + string(SUBSTRING ${platform} 1 ${platform_length} platform) + + # check if the current platform does not match the extracted platform + if (NOT ${platform} STREQUAL ${CORE_SYSTEM_NAME}) + set(platform_found TRUE) + endif() + endif() endif() endforeach() else() @@ -118,30 +140,63 @@ foreach(addon ${addons}) file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/${id}/") endif() - # prepare the setup of the call to externalproject_add() - set(EXTERNALPROJECT_SETUP INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" - CMAKE_ARGS ${BUILD_ARGS}) - # get the URL and revision of the addon list(LENGTH def deflength) list(GET def 1 url) - # check if there's a third parameter in the file + list(GET def 2 revision) + + # download and extract all addons if(deflength GREATER 2) - # the third parameter is considered as a revision of a git repository - list(GET def 2 revision) - - externalproject_add(${id} - GIT_REPOSITORY ${url} - GIT_TAG ${revision} - "${EXTERNALPROJECT_SETUP}" - ) + # if there is a 3rd parameter in the file, we consider it a git revision + # Note: downloading specific revisions via http in the format below is probably github specific + # if we ever use other repositories, this might need adapting + set(url ${url}/archive/${revision}.tar.gz) + endif() + if(NOT EXISTS ${BUILD_DIR}/download/${id}.tar.gz) + file(DOWNLOAD "${url}" "${BUILD_DIR}/download/${id}.tar.gz" STATUS dlstatus LOG dllog SHOW_PROGRESS) + list(GET dlstatus 0 retcode) + if(NOT ${retcode} EQUAL 0) + message(FATAL_ERROR "ERROR downloading ${url} - status: ${dlstatus} log: ${dllog}") + endif() + endif() + if(EXISTS "${BUILD_DIR}/${id}") + file(REMOVE_RECURSE "${BUILD_DIR}/${id}") + endif() + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzvf ${BUILD_DIR}/download/${id}.tar.gz + WORKING_DIRECTORY ${BUILD_DIR}) + file(GLOB extract_dir "${BUILD_DIR}/${id}-${revision}*") + if(extract_dir STREQUAL "") + message(FATAL_ERROR "Error extracting ${BUILD_DIR}/download/${id}.tar.gz") else() - externalproject_add(${id} - URL ${url} - "${EXTERNALPROJECT_SETUP}" - ) + file(RENAME "${extract_dir}" "${BUILD_DIR}/${id}") endif() + + list(APPEND downloaded_addons ${id}) + endif() endif() endif() endforeach() + +foreach(id ${downloaded_addons}) + externalproject_add(${id} + SOURCE_DIR ${BUILD_DIR}/${id} + INSTALL_DIR ${CMAKE_INSTALL_PREFIX} + CMAKE_ARGS ${BUILD_ARGS}) + + # on win32 we need to add the "kodi" dependency to every addon + if (WIN32) + add_dependencies(${id} kodi) + endif() + + set(${id}_DEPENDS_DIR ${BUILD_DIR}/${id}/depends) + + if(EXISTS ${${id}_DEPENDS_DIR}) + include(${APP_ROOT}/project/cmake/scripts/common/handle-depends.cmake) + add_addon_depends(${id} ${${id}_DEPENDS_DIR}) + if (${id}_DEPS AND NOT "${${id}_DEPS}" STREQUAL "") + message(STATUS "${id} DEPENDENCIES: ${${id}_DEPS}") + add_dependencies(${id} ${${id}_DEPS}) + endif() + endif() +endforeach() diff --git a/project/cmake/addons/README b/project/cmake/addons/README index 159f7c5a4b..c66e6681b2 100644 --- a/project/cmake/addons/README +++ b/project/cmake/addons/README @@ -14,7 +14,10 @@ where Reserved filenames (for additional information on how to build an addon) are: - * platforms.txt: list of platforms to build an addon for (or "all") + * platforms.txt: List of platforms to build an addon for (or "all"). It is + also supported to specify negated platforms with a leading exclamation mark + (i), e.g. "!windows". + Available platforms are: linux, windows, darwin, ios, android, rbpi The buildsystem uses the following variables (which can be passed into it when executing cmake with the -D<variable-name>=<value> option) to e.g. access @@ -32,6 +35,8 @@ specific paths: directories of the addons' dependencies. * APP_ROOT points to the root directory of the project (default is the absolute representation of ../../.. starting from this directory). + * BUILD_DIR points to the directory where the addons and their dependencies + will be downloaded and built. * PACKAGE_ZIP=1 will mean the add-ons will be 'packaged' into a common folder, rather than being placed in <CMAKE_INSTALL_PREFIX>/lib/kodi/addons and <CMAKE_INSTALL_PREFIX>/share/kodi/addons. diff --git a/project/cmake/addons/addons/audioencoder.flac/audioencoder.flac.txt b/project/cmake/addons/addons/audioencoder.flac/audioencoder.flac.txt index 4e69085e03..ba6032a605 100644 --- a/project/cmake/addons/addons/audioencoder.flac/audioencoder.flac.txt +++ b/project/cmake/addons/addons/audioencoder.flac/audioencoder.flac.txt @@ -1 +1 @@ -audioencoder.flac https://github.com/xbmc/audioencoder.flac a960eba +audioencoder.flac https://github.com/xbmc/audioencoder.flac 62c2cc8 diff --git a/project/cmake/addons/addons/audioencoder.flac/platforms.txt b/project/cmake/addons/addons/audioencoder.flac/platforms.txt index baa6044435..174a52e762 100644 --- a/project/cmake/addons/addons/audioencoder.flac/platforms.txt +++ b/project/cmake/addons/addons/audioencoder.flac/platforms.txt @@ -1 +1 @@ -all
\ No newline at end of file +!ios
\ No newline at end of file diff --git a/project/cmake/addons/addons/audioencoder.lame/audioencoder.lame.txt b/project/cmake/addons/addons/audioencoder.lame/audioencoder.lame.txt index 6008483fb4..a55dc44944 100644 --- a/project/cmake/addons/addons/audioencoder.lame/audioencoder.lame.txt +++ b/project/cmake/addons/addons/audioencoder.lame/audioencoder.lame.txt @@ -1 +1 @@ -audioencoder.lame https://github.com/xbmc/audioencoder.lame 6f8384f +audioencoder.lame https://github.com/xbmc/audioencoder.lame 3eb59de diff --git a/project/cmake/addons/addons/audioencoder.vorbis/audioencoder.vorbis.txt b/project/cmake/addons/addons/audioencoder.vorbis/audioencoder.vorbis.txt index 14f3bfb125..ed6fa9ac76 100644 --- a/project/cmake/addons/addons/audioencoder.vorbis/audioencoder.vorbis.txt +++ b/project/cmake/addons/addons/audioencoder.vorbis/audioencoder.vorbis.txt @@ -1 +1 @@ -audioencoder.vorbis https://github.com/xbmc/audioencoder.vorbis fa0de15 +audioencoder.vorbis https://github.com/xbmc/audioencoder.vorbis dbf5c62 diff --git a/project/cmake/addons/depends/CMakeLists.txt b/project/cmake/addons/depends/CMakeLists.txt index 6cff41dc60..7141bc3372 100644 --- a/project/cmake/addons/depends/CMakeLists.txt +++ b/project/cmake/addons/depends/CMakeLists.txt @@ -14,13 +14,13 @@ endif() include(ExternalProject) -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX) - set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/../output/depends) +if(NOT DEPENDS_PATH) + set(DEPENDS_PATH ${PROJECT_SOURCE_DIR}/../build/depends) else() - file(TO_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}" CMAKE_INSTALL_PREFIX) + file(TO_CMAKE_PATH "${DEPENDS_PATH}" DEPENDS_PATH) endif() -get_filename_component(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" ABSOLUTE) -list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}) +get_filename_component(DEPENDS_PATH "${DEPENDS_PATH}" ABSOLUTE) +list(APPEND CMAKE_PREFIX_PATH ${DEPENDS_PATH}) if(NOT DEPENDS_TO_BUILD) set(DEPENDS_TO_BUILD "all") @@ -67,11 +67,11 @@ foreach(file ${cmake_input_files}) message(STATUS "${id} extraflags: ${extraflags}") endif() - set(BUILD_ARGS -DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX} + set(BUILD_ARGS -DCMAKE_PREFIX_PATH=${DEPENDS_PATH} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_USER_MAKE_RULES_OVERRIDE=${CMAKE_USER_MAKE_RULES_OVERRIDE} -DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX=${CMAKE_USER_MAKE_RULES_OVERRIDE_CXX} - -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} + -DCMAKE_INSTALL_PREFIX=${DEPENDS_PATH} -DARCH_DEFINES=${ARCH_DEFINES} -DENABLE_STATIC=1 -DBUILD_SHARED_LIBS=0 @@ -97,7 +97,7 @@ foreach(file ${cmake_input_files}) set(INSTALL_COMMAND INSTALL_COMMAND ${CMAKE_COMMAND} -DINPUTDIR=${CMAKE_BINARY_DIR}/build/${id}/src/${id}-build/ -DINPUTFILE=${dir}/install.txt - -DDESTDIR=${CMAKE_INSTALL_PREFIX} + -DDESTDIR=${DEPENDS_PATH} -DENABLE_STATIC=1 "${extraflags}" -P ${PROJECT_SOURCE_DIR}/install.cmake) @@ -153,5 +153,5 @@ if(EXISTS ${PROJECT_SOURCE_DIR}/${CORE_SYSTEM_NAME}/CMakeLists.txt) message(STATUS "Processing ${CORE_SYSTEM_NAME}") add_subdirectory(${CORE_SYSTEM_NAME}) else() - message(FATAL_ERROR "CORE_SYSTEM_NAME: ${PROJECT_SOURCE_DIR}/${CORE_SYSTEM_NAME}/CMakeLists.txt") -endif()
\ No newline at end of file + message(STATUS "No platform specific file ${PROJECT_SOURCE_DIR}/${CORE_SYSTEM_NAME}/CMakeLists.txt found") +endif() diff --git a/project/cmake/addons/depends/README b/project/cmake/addons/depends/README index c26a41c9a6..66e924a201 100644 --- a/project/cmake/addons/depends/README +++ b/project/cmake/addons/depends/README @@ -30,14 +30,14 @@ executing cmake with the -D<variable-name>=<value> option) to e.g. access specific paths: * CMAKE_BUILD_TYPE specifies the type of the build. This can be either "Debug" or "Release" (default is "Release"). - * CMAKE_INSTALL_PREFIX points to the directory where the built dependencies - (their include and library file) will be installed to. * CMAKE_TOOLCHAIN_FILE can be used to pass a toolchain file into the add-on builds. * CORE_SYSTEM_NAME is the name of the platform (e.g. "linux" or "android") in lower-case (defaults to lowercase(CMAKE_SYSTEM_NAME)). * APP_ROOT points to the root directory of the project (default is the absolute representation of ../../.. starting from this directory). + * DEPENDS_PATH points to the directory where the built dependencies + (their include and library file) will be installed to. * ARCH_DEFINES specifies the platform-specific C/C++ preprocessor defines (defaults to empty). * DEPENDS_TO_BUILD is a quoted, space delimited list of <dependency>s that diff --git a/project/cmake/addons/depends/windows/CMakeLists.txt b/project/cmake/addons/depends/windows/CMakeLists.txt index 83df09bb23..4480f1ed5f 100644 --- a/project/cmake/addons/depends/windows/CMakeLists.txt +++ b/project/cmake/addons/depends/windows/CMakeLists.txt @@ -10,13 +10,13 @@ endif() include(ExternalProject) -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX) - message(FATAL_ERROR "CMAKE_INSTALL_PREFIX (${CMAKE_INSTALL_PREFIX}) is not a valid target directory.") +if(NOT DEPENDS_PATH) + message(FATAL_ERROR "DEPENDS_PATH (${DEPENDS_PATH}) is not a valid target directory.") else() - file(TO_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}" CMAKE_INSTALL_PREFIX) + file(TO_CMAKE_PATH "${DEPENDS_PATH}" DEPENDS_PATH) endif() -get_filename_component(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" ABSOLUTE) -list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}) +get_filename_component(DEPENDS_PATH "${DEPENDS_PATH}" ABSOLUTE) +list(APPEND CMAKE_PREFIX_PATH ${DEPENDS_PATH}) if(NOT DEPENDS_TO_BUILD) set(DEPENDS_TO_BUILD "all") @@ -31,7 +31,7 @@ function(add_internal id url inputfile) INSTALL_COMMAND ${CMAKE_COMMAND} -DINPUTDIR=${PROJECT_BINARY_DIR}/build/${id}/src/${id} -DINPUTFILE=${inputfile} - -DDESTDIR=${CMAKE_INSTALL_PREFIX} + -DDESTDIR=${DEPENDS_PATH} -P ${PROJECT_SOURCE_DIR}/install.cmake ) endfunction() diff --git a/project/cmake/addons/depends/windows/prebuilt/flac/flac.txt b/project/cmake/addons/depends/windows/prebuilt/flac/flac.txt deleted file mode 100644 index 098f08f739..0000000000 --- a/project/cmake/addons/depends/windows/prebuilt/flac/flac.txt +++ /dev/null @@ -1 +0,0 @@ -flac http://mirrors.xbmc.org/build-deps/win32/flac-1.2.1-devel-win.zip diff --git a/project/cmake/addons/depends/windows/prebuilt/flac/install.txt b/project/cmake/addons/depends/windows/prebuilt/flac/install.txt deleted file mode 100644 index 8a6437e563..0000000000 --- a/project/cmake/addons/depends/windows/prebuilt/flac/install.txt +++ /dev/null @@ -1,2 +0,0 @@ -include/FLAC/* include/FLAC -lib/libFLAC_static.lib lib diff --git a/project/cmake/addons/depends/windows/prebuilt/lame.txt b/project/cmake/addons/depends/windows/prebuilt/lame.txt deleted file mode 100644 index 6fc7acf9f5..0000000000 --- a/project/cmake/addons/depends/windows/prebuilt/lame.txt +++ /dev/null @@ -1 +0,0 @@ -lame http://mirrors.xbmc.org/build-deps/win32/libmp3lame-3.99.5-static-win32-2.zip
\ No newline at end of file diff --git a/project/cmake/addons/depends/windows/prebuilt/ogg/install.txt b/project/cmake/addons/depends/windows/prebuilt/ogg/install.txt deleted file mode 100644 index a5f8852265..0000000000 --- a/project/cmake/addons/depends/windows/prebuilt/ogg/install.txt +++ /dev/null @@ -1,2 +0,0 @@ -include/ogg/* include/ogg -lib/* lib diff --git a/project/cmake/addons/depends/windows/prebuilt/ogg/ogg.txt b/project/cmake/addons/depends/windows/prebuilt/ogg/ogg.txt deleted file mode 100644 index 801b13b65a..0000000000 --- a/project/cmake/addons/depends/windows/prebuilt/ogg/ogg.txt +++ /dev/null @@ -1 +0,0 @@ -ogg http://mirrors.xbmc.org/build-deps/win32/libogg-vc100-1.2.0-lib.tar.bz2 diff --git a/project/cmake/addons/depends/windows/prebuilt/vorbis/install.txt b/project/cmake/addons/depends/windows/prebuilt/vorbis/install.txt deleted file mode 100644 index 3021f12c1d..0000000000 --- a/project/cmake/addons/depends/windows/prebuilt/vorbis/install.txt +++ /dev/null @@ -1,2 +0,0 @@ -include/vorbis/* include/vorbis -lib/* lib diff --git a/project/cmake/addons/depends/windows/prebuilt/vorbis/vorbis.txt b/project/cmake/addons/depends/windows/prebuilt/vorbis/vorbis.txt deleted file mode 100644 index 23e56e2901..0000000000 --- a/project/cmake/addons/depends/windows/prebuilt/vorbis/vorbis.txt +++ /dev/null @@ -1 +0,0 @@ -vorbis http://mirrors.xbmc.org/build-deps/win32/libvorbis-vc100-1.3.1-lib.tar.bz2 diff --git a/project/cmake/scripts/common/handle-depends.cmake b/project/cmake/scripts/common/handle-depends.cmake new file mode 100644 index 0000000000..994e3627fd --- /dev/null +++ b/project/cmake/scripts/common/handle-depends.cmake @@ -0,0 +1,154 @@ +# handle addon depends +function(add_addon_depends addon searchpath) + # input: string addon string searchpath + + set(OUTPUT_DIR ${DEPENDS_PATH}) + file(GLOB_RECURSE cmake_input_files ${searchpath}/${CORE_SYSTEM_NAME}/*.txt) + file(GLOB_RECURSE cmake_input_files2 ${searchpath}/common/*.txt) + list(APPEND cmake_input_files ${cmake_input_files2}) + + foreach(file ${cmake_input_files}) + if(NOT (file MATCHES CMakeLists.txt OR + file MATCHES install.txt OR + file MATCHES noinstall.txt OR + file MATCHES flags.txt OR + file MATCHES deps.txt)) + message(STATUS "Processing ${file}") + file(STRINGS ${file} def) + separate_arguments(def) + list(LENGTH def deflength) + get_filename_component(dir ${file} PATH) + + # get the id and url of the dependency + set(url "") + if(NOT "${def}" STREQUAL "") + # read the id and the url from the file + list(GET def 0 id) + if(deflength GREATER 1) + list(GET def 1 url) + message(STATUS "${id} url: ${url}") + endif() + else() + # read the id from the filename + get_filename_component(id ${file} NAME_WE) + endif() + + if(NOT TARGET ${id}) + # check if there are any library specific flags that need to be passed on + if(EXISTS ${dir}/flags.txt) + file(STRINGS ${dir}/flags.txt extraflags) + separate_arguments(extraflags) + message(STATUS "${id} extraflags: ${extraflags}") + endif() + + set(BUILD_ARGS -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} + -DOUTPUT_DIR=${DEPENDS_PATH} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_USER_MAKE_RULES_OVERRIDE=${CMAKE_USER_MAKE_RULES_OVERRIDE} + -DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX=${CMAKE_USER_MAKE_RULES_OVERRIDE_CXX} + -DCMAKE_INSTALL_PREFIX=${DEPENDS_PATH} + -DARCH_DEFINES=${ARCH_DEFINES} + -DENABLE_STATIC=1 + -DBUILD_SHARED_LIBS=0) + + if(CMAKE_TOOLCHAIN_FILE) + list(APPEND BUILD_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + MESSAGE("toolchain specified") + MESSAGE(${BUILD_ARGS}) + endif() + + # if there's a CMakeLists.txt use it to prepare the build + if(EXISTS ${dir}/CMakeLists.txt) + file(APPEND ${BUILD_DIR}/${id}/tmp/patch.cmake + "file(COPY ${dir}/CMakeLists.txt + DESTINATION ${BUILD_DIR}/${id}/src/${id})\n") + set(PATCH_COMMAND ${CMAKE_COMMAND} -P ${BUILD_DIR}/${id}/tmp/patch.cmake) + else() + set(PATCH_COMMAND "") + endif() + + # check if we have patches to apply + file(GLOB patches ${dir}/*.patch) + list(SORT patches) + foreach(patch ${patches}) + set(PATCH_COMMAND ${CMAKE_COMMAND} -P ${BUILD_DIR}/${id}/tmp/patch.cmake) + file(APPEND ${BUILD_DIR}/${id}/tmp/patch.cmake + "execute_process(COMMAND patch -p1 -i ${patch})\n") + endforeach() + + + # if there's an install.txt use it to properly install the built files + if(EXISTS ${dir}/install.txt) + set(INSTALL_COMMAND INSTALL_COMMAND ${CMAKE_COMMAND} + -DINPUTDIR=${BUILD_DIR}/${id}/src/${id}-build/ + -DINPUTFILE=${dir}/install.txt + -DDESTDIR=${DEPENDS_PATH} + -DENABLE_STATIC=1 + "${extraflags}" + -P ${PROJECT_SOURCE_DIR}/install.cmake) + elseif(EXISTS ${dir}/noinstall.txt) + set(INSTALL_COMMAND INSTALL_COMMAND "") + else() + set(INSTALL_COMMAND "") + endif() + + # check if there's a deps.txt containing dependencies on other libraries + if(EXISTS ${dir}/deps.txt) + file(STRINGS ${dir}/deps.txt deps) + message(STATUS "${id} depends: ${deps}") + else() + set(deps) + endif() + + # prepare the setup of the call to externalproject_add() + set(EXTERNALPROJECT_SETUP PREFIX ${BUILD_DIR}/${id} + CMAKE_ARGS ${extraflags} ${BUILD_ARGS} + PATCH_COMMAND ${PATCH_COMMAND} + ${INSTALL_COMMAND}) + + # if there's an url defined we need to pass that to externalproject_add() + if(DEFINED url AND NOT "${url}" STREQUAL "") + if(deflength GREATER 2) + list(GET def 2 revision) + externalproject_add(${id} + GIT_REPOSITORY ${url} + GIT_TAG ${revision} + ${EXTERNALPROJECT_SETUP}) + else() + if(WIN32) + set(CONFIGURE_COMMAND "") + else() + set(CONFIGURE_COMMAND PKG_CONFIG_PATH=${OUTPUT_DIR}/lib/pkgconfig + ${CMAKE_COMMAND} -DCMAKE_LIBRARY_PATH=${OUTPUT_DIR}/lib ${extraflags} + ${BUILD_DIR}/${id}/src/${id} + -DPACKAGE_CONFIG_PATH=${OUTPUT_DIR}/lib/pkgconfig + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DOUTPUT_DIR=${OUTPUT_DIR} + -DCMAKE_PREFIX_PATH=${OUTPUT_DIR} + -DCMAKE_INSTALL_PREFIX=${OUTPUT_DIR} + -DCMAKE_EXE_LINKER_FLAGS=-L${OUTPUT_DIR}/lib + -DCMAKE_INCLUDE_PATH=${OUTPUT_DIR}/include) + endif() + + externalproject_add(${id} + URL ${url} + DOWNLOAD_DIR ${BUILD_DIR}/download + CONFIGURE_COMMAND ${CONFIGURE_COMMAND} + ${EXTERNALPROJECT_SETUP}) + endif() + else() + externalproject_add(${id} + SOURCE_DIR ${dir} + ${EXTERNALPROJECT_SETUP}) + endif() + if(deps) + add_dependencies(${id} ${deps}) + endif() + endif() + + set(${addon}_DEPS ${${addon}_DEPS} ${id}) + set(${addon}_DEPS "${${addon}_DEPS}" PARENT_SCOPE) + endif() + endforeach() +endfunction() + diff --git a/system/settings/settings.xml b/system/settings/settings.xml index 063ce1e5d4..a73dad05a0 100644 --- a/system/settings/settings.xml +++ b/system/settings/settings.xml @@ -428,21 +428,6 @@ <default>false</default> <control type="toggle" /> </setting> - <setting id="videoplayer.synctype" type="integer" parent="videoplayer.usedisplayasclock" label="13500" help="36167"> - <level>2</level> - <default>2</default> <!-- SYNC_RESAMPLE --> - <constraints> - <options> - <option label="13501">0</option> <!-- SYNC_DISCON --> - <option label="13502">1</option> <!-- SYNC_SKIPDUP --> - <option label="13503">2</option> <!-- SYNC_RESAMPLE --> - </options> - </constraints> - <dependencies> - <dependency type="enable" setting="videoplayer.usedisplayasclock" operator="is">true</dependency> - </dependencies> - <control type="spinner" format="string" /> - </setting> <setting id="videoplayer.maxspeedadjust" type="number" label="13504" help="36168"> <level>4</level> <default>5.0</default> @@ -455,7 +440,6 @@ <dependency type="enable"> <and> <condition setting="videoplayer.usedisplayasclock" operator="is">true</condition> - <condition setting="videoplayer.synctype" operator="is">2</condition> <!-- SYNC_RESAMPLE --> </and> </dependency> </dependencies> @@ -719,7 +703,7 @@ <dependency type="visible" on="property" name="codecoptionvisible" setting="videoplayer.usevaapivc1" operator="is">true</dependency> </dependencies> <level>3</level> - <default>false</default> + <default>true</default> <control type="toggle" /> </setting> <setting id="videoplayer.prefervaapirender" type="boolean" parent="videoplayer.usevaapi" label="13457" help="36433"> @@ -975,6 +959,11 @@ <heading>657</heading> </control> </setting> + <setting id="subtitles.parsecaptions" type="boolean" label="24130" help="24131"> + <level>1</level> + <default>false</default> + <control type="toggle" /> + </setting> <setting id="subtitles.pauseonsearch" type="boolean" label="24105" help="24123"> <level>1</level> <default>true</default> @@ -1041,6 +1030,27 @@ </setting> </group> </category> + <category id="accessibility" label="37032" help="37033"> + <group id="1"> + <setting id="accessibility.audiovisual" type="boolean" label="37034" help="37035"> + <level>1</level> + <default>false</default> + <control type="toggle" /> + </setting> + <setting id="accessibility.audiohearing" type="boolean" label="37036" help="37037"> + <level>1</level> + <default>false</default> + <control type="toggle" /> + </setting> + </group> + <group id="2"> + <setting id="accessibility.subhearing" type="boolean" label="37038" help="37039"> + <level>1</level> + <default>false</default> + <control type="toggle" /> + </setting> + </group> + </category> <category id="scrapers" label="0" help="36197"> <visible>false</visible> <group id="1"> @@ -1110,6 +1120,13 @@ </dependencies> <control type="button" format="action" /> </setting> + <setting id="pvrmanager.groupmanager" type="action" label="19048" help="36213"> + <level>1</level> + <dependencies> + <dependency type="enable" setting="pvrmanager.enabled">true</dependency> + </dependencies> + <control type="button" format="action" /> + </setting> <setting id="pvrmanager.channelscan" type="action" label="19117" help="36208"> <level>1</level> <dependencies> @@ -1179,7 +1196,7 @@ <constraints> <minimum>1</minimum> <step>1</step> - <maximum>14</maximum> + <maximum>31</maximum> </constraints> <control type="spinner" format="string"> <formatlabel>17999</formatlabel> diff --git a/tools/Linux/kodi.sh.in b/tools/Linux/kodi.sh.in index 10f164b50f..35dee2c323 100644 --- a/tools/Linux/kodi.sh.in +++ b/tools/Linux/kodi.sh.in @@ -57,7 +57,7 @@ migrate_home() command_exists() { - command -v $1 >/dev/null 2>&1 + command -pv $1 >/dev/null 2>&1 } single_stacktrace() diff --git a/tools/TexturePacker/MakeDDS.cpp b/tools/TexturePacker/MakeDDS.cpp deleted file mode 100644 index 110b42e483..0000000000 --- a/tools/TexturePacker/MakeDDS.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#include <sys/types.h> -#include <squish.h> -#include <string> -#include <SDL/SDL.h> -#include <SDL/SDL_image.h> -#include "cmdlineargs.h" -#ifdef TARGET_WINDOWS -#define strncasecmp strnicmp -#endif -#include "DDSImage.h" -#include "XBTF.h" - -#undef main - -const char *GetFormatString(unsigned int format) -{ - switch (format) - { - case squish::kDxt1: - return "DXT1 "; - case squish::kDxt5: - return "YCoCg"; - default: - return "?????"; - } -} - -void CompressImage(const squish::u8 *brga, int width, int height, squish::u8 *compressed, unsigned int flags, double &colorMSE, double &alphaMSE) -{ - squish::CompressImage(brga, width, height, compressed, flags | squish::kSourceBGRA); - squish::ComputeMSE(brga, width, height, compressed, flags | squish::kSourceBGRA, colorMSE, alphaMSE); -} - -void CompressToDDS(SDL_Surface* image, unsigned int format, CDDSImage &out) -{ - // Convert to ARGB - SDL_PixelFormat argbFormat; - memset(&argbFormat, 0, sizeof(SDL_PixelFormat)); - argbFormat.BitsPerPixel = 32; - argbFormat.BytesPerPixel = 4; - -#if SDL_BYTEORDER == SDL_LIL_ENDIAN - argbFormat.Amask = 0xff000000; - argbFormat.Ashift = 24; - argbFormat.Rmask = 0x00ff0000; - argbFormat.Rshift = 16; - argbFormat.Gmask = 0x0000ff00; - argbFormat.Gshift = 8; - argbFormat.Bmask = 0x000000ff; - argbFormat.Bshift = 0; -#else - argbFormat.Amask = 0x000000ff; - argbFormat.Ashift = 0; - argbFormat.Rmask = 0x0000ff00; - argbFormat.Rshift = 8; - argbFormat.Gmask = 0x00ff0000; - argbFormat.Gshift = 16; - argbFormat.Bmask = 0xff000000; - argbFormat.Bshift = 24; -#endif - - SDL_Surface *argbImage = SDL_ConvertSurface(image, &argbFormat, 0); - - double colorMSE, alphaMSE; - if (format == XB_FMT_DXT1) - CompressImage((squish::u8 *)argbImage->pixels, image->w, image->h, out.GetData(), squish::kDxt1, colorMSE, alphaMSE); - else if (format == XB_FMT_DXT5) - CompressImage((squish::u8 *)argbImage->pixels, image->w, image->h, out.GetData(), squish::kDxt5, colorMSE, alphaMSE); - - // print some info about the resulting image - printf("Size: %dx%d %s in %u bytes. Quality: %5.2f\n", image->w, image->h, GetFormatString(format), out.GetSize(), colorMSE); - - SDL_FreeSurface(argbImage); -} - -void Usage() -{ - puts("Usage: MakeDDS [-oN] input [output]"); - puts(" -o1 for DXT1"); - puts(" -o5 for DXT5"); -} - -void createDDS(const std::string& inputFile, const std::string& outputFile, unsigned int format) -{ - // Load the image - SDL_Surface* image = IMG_Load(inputFile.c_str()); - if (!image) - { - printf("...unable to load image %s\n", inputFile.c_str()); - return; - } - - CDDSImage dds(image->w, image->h, format); - CompressToDDS(image, format, dds); - - // write to a DDS file - dds.WriteFile(outputFile); - - SDL_FreeSurface(image); -} - -int main(int argc, char* argv[]) -{ - bool valid = false; - CmdLineArgs args(argc, (const char**)argv); - - if (args.size() == 1) - { - Usage(); - return 1; - } - - std::string inputFile; - std::string outputFile; - - unsigned int format = squish::kDxt1; - for (unsigned int i = 1; i < args.size(); ++i) - { - if (!stricmp(args[i], "--help") || !stricmp(args[i], "-?") || !stricmp(args[i], "?")) - { - Usage(); - return 1; - } - else if (!strncasecmp(args[i], "-o1", 3)) - format = XB_FMT_DXT1; - else if (!strncasecmp(args[i], "-o5", 3)) - format = XB_FMT_DXT5; - else if (!inputFile.size()) - { - inputFile = args[i]; - valid = true; - } - else if (!outputFile.size()) - { - outputFile = args[i]; - valid = true; - } - else - { - printf("Unrecognized command line flag: %s\n", args[i]); - } - } - - if (outputFile.empty()) - { // construct output file from input - rename to .dds - size_t pos = inputFile.find_last_of('.'); - if (pos != std::string::npos) - { - outputFile = inputFile.substr(0, pos); - outputFile += ".dds"; - } - } - - if (!valid) - { - Usage(); - return 1; - } - - createDDS(inputFile, outputFile, format); -} diff --git a/tools/TexturePacker/Makefile.in b/tools/TexturePacker/Makefile.in deleted file mode 100644 index 4f0b610211..0000000000 --- a/tools/TexturePacker/Makefile.in +++ /dev/null @@ -1,37 +0,0 @@ -DEFINES += -DTARGET_POSIX -DUSE_LZO_PACKING -ifneq ($(or $(findstring powerpc,@ARCH@),$(findstring ppc, @ARCH@)),) -DEFINES += -DHOST_BIGENDIAN -endif - -SRCS = \ - md5.cpp \ - SDL_anigif.cpp \ - XBTFWriter.cpp \ - XBMCTex.cpp \ - @abs_top_srcdir@/xbmc/guilib/XBTF.cpp - -TARGET = TexturePacker -CLEAN_FILES = $(TARGET) - -CXXFLAGS_FOR_BUILD += \ - -I. \ - -I@abs_top_srcdir@/lib \ - -I@abs_top_srcdir@/xbmc \ - -I@abs_top_srcdir@/xbmc/linux - -LDFLAGS_FOR_BUILD += -lSDL_image -lSDL -llzo2 -LDFLAGS_FOR_BUILD += -L@abs_top_srcdir@/lib/libsquish -lsquish-native - -ifeq ($(findstring Darwin,$(shell uname -s)),Darwin) -DEFINES += -DTARGET_DARWIN -NATIVE_ARCH=@DARWIN_NATIVE_ARCH@ -endif - -all: $(TARGET) - -$(TARGET): $(SRCS) @abs_top_srcdir@/xbmc/guilib/XBTF.h -# TexturePacker run native on build system, build it with native tools - make -C @abs_top_srcdir@/lib/libsquish/ libsquish-native.so - $(CXX_FOR_BUILD) $(CXXFLAGS_FOR_BUILD) $(DEFINES) $(NATIVE_ARCH) $(SRCS) $(LDFLAGS_FOR_BUILD) -o $(TARGET) - -include @abs_top_srcdir@/Makefile.include diff --git a/tools/TexturePacker/SDL_anigif.cpp b/tools/TexturePacker/SDL_anigif.cpp deleted file mode 100644 index a0bcbcad51..0000000000 --- a/tools/TexturePacker/SDL_anigif.cpp +++ /dev/null @@ -1,777 +0,0 @@ -/* - SDL_anigif: An example animated GIF image loading library for use with SDL - SDL_image Copyright (C) 1997-2006 Sam Lantinga - Animated GIF "derived work" Copyright (C) 2006 Doug McFadyen - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include "SDL_anigif.h" - - - -/* Code from here to end of file has been adapted from XPaint: */ -/* +-------------------------------------------------------------------+ */ -/* | Copyright 1990, 1991, 1993 David Koblas. | */ -/* | Copyright 1996 Torsten Martinsen. | */ -/* | Permission to use, copy, modify, and distribute this software | */ -/* | and its documentation for any purpose and without fee is hereby | */ -/* | granted, provided that the above copyright notice appear in all | */ -/* | copies and that both that copyright notice and this permission | */ -/* | notice appear in supporting documentation. This software is | */ -/* | provided "as is" without express or implied warranty. | */ -/* +-------------------------------------------------------------------+ */ -/* Adapted for use in SDL by Sam Lantinga -- 7/20/98 */ -/* Animated GIF support by Doug McFadyen -- 10/19/06 */ - -#define MAXCOLORMAPSIZE 256 - -#define TRUE 1 -#define FALSE 0 - -#define CM_RED 0 -#define CM_GREEN 1 -#define CM_BLUE 2 - -#define MAX_LWZ_BITS 12 - -#define INTERLACE 0x40 -#define LOCALCOLORMAP 0x80 -#define BitSet(byte,bit) (((byte) & (bit)) == (bit)) -#define LM_to_uint(a,b) (((b)<<8)|(a)) - -#define SDL_SetError(t) ((void)0) /* We're not SDL so ignore error reporting */ - - -typedef struct -{ - unsigned int Width; - unsigned int Height; - unsigned char ColorMap[3][MAXCOLORMAPSIZE]; - unsigned int BitPixel; - unsigned int ColorResolution; - unsigned int Background; - unsigned int AspectRatio; -} gifscreen; - -typedef struct -{ - int transparent; - int delayTime; - int inputFlag; - int disposal; -} gif89; - -typedef struct -{ - /* global data */ - SDL_RWops* src; - gifscreen gs; - gif89 g89; - int zerodatablock; - /* AG_LoadGIF_RW data */ - unsigned char localColorMap[3][MAXCOLORMAPSIZE]; - /* GetCode data */ - unsigned char buf[280]; - int curbit, lastbit, done, lastbyte; - /* LWZReadByte data */ - int fresh, code, incode; - int codesize, setcodesize; - int maxcode, maxcodesize; - int firstcode, oldcode; - int clearcode, endcode; - int table[2][(1 << MAX_LWZ_BITS)]; - int stack[(1 << (MAX_LWZ_BITS))*2], *sp; -} gifdata; - - - -static int ReadColorMap( gifdata* gd, int number, unsigned char buffer[3][MAXCOLORMAPSIZE] ); -static int DoExtension( gifdata* gd, int label ); -static int GetDataBlock( gifdata* gd, unsigned char* buf ); -static int GetCode( gifdata* gd, int code_size, int flag ); -static int LWZReadByte( gifdata* gd, int flag, int input_code_size ); -static SDL_Surface* ReadImage( gifdata* gd, int len, int height, int, unsigned char cmap[3][MAXCOLORMAPSIZE], int interlace, int ignore ); - - - -/*--------------------------------------------------------------------------* - * - *--------------------------------------------------------------------------*/ -int AG_isGIF( SDL_RWops* src ) -{ - int isGIF = FALSE; - - if ( src ) - { - int start = SDL_RWtell( src ); - char magic[6]; - - if ( SDL_RWread(src,magic,sizeof(magic),1) ) - { - if ( (strncmp(magic,"GIF",3) == 0) && ((memcmp(magic+3,"87a",3) == 0) || (memcmp(magic+3,"89a",3) == 0)) ) - { - isGIF = TRUE; - } - } - - SDL_RWseek( src, start, SEEK_SET ); - } - - return isGIF; -} - - - -/*--------------------------------------------------------------------------* - * - *--------------------------------------------------------------------------*/ -int AG_LoadGIF( const char* file, AG_Frame* frames, int size ) -{ - int n = 0; - - SDL_RWops* src = SDL_RWFromFile( file, "rb" ); - - if ( src ) - { - n = AG_LoadGIF_RW( src, frames, size ); - SDL_RWclose( src ); - } - - return n; -} - - - -/*--------------------------------------------------------------------------* - * - *--------------------------------------------------------------------------*/ -void AG_FreeSurfaces( AG_Frame* frames, int nFrames ) -{ - int i; - - if ( frames ) - { - for ( i = 0; i < nFrames; i++ ) - { - if ( frames[i].surface ) - { - SDL_FreeSurface( frames[i].surface ); - frames[i].surface = NULL; - } - } - } -} - - - -/*--------------------------------------------------------------------------* - * - *--------------------------------------------------------------------------*/ -int AG_ConvertSurfacesToDisplayFormat( AG_Frame* frames, int nFrames ) -{ - int i; - int n = 0; - - if ( frames ) - { - for ( i = 0; i < nFrames; i++ ) - { - if ( frames[i].surface ) - { - SDL_Surface* surface = (frames[i].surface->flags & SDL_SRCCOLORKEY) ? SDL_DisplayFormatAlpha(frames[i].surface) : SDL_DisplayFormat(frames[i].surface); - - if ( surface ) - { - SDL_FreeSurface( frames[i].surface ); - frames[i].surface = surface; - n++; - } - } - } - } - - return n; -} - - - -/*--------------------------------------------------------------------------* - * - *--------------------------------------------------------------------------*/ -int AG_NormalizeSurfacesToDisplayFormat( AG_Frame* frames, int nFrames ) -{ - int n = 0; - - if ( nFrames > 0 && frames && frames[0].surface ) - { - SDL_Surface* mainSurface = (frames[0].surface->flags & SDL_SRCCOLORKEY) ? SDL_DisplayFormatAlpha(frames[0].surface) : SDL_DisplayFormat(frames[0].surface); - const int newDispose = (frames[0].surface->flags & SDL_SRCCOLORKEY) ? AG_DISPOSE_RESTORE_BACKGROUND : AG_DISPOSE_NONE; - - if ( mainSurface ) - { - int i; - int lastDispose = AG_DISPOSE_NA; - int iRestore = 0; - const Uint8 alpha = (frames[0].disposal == AG_DISPOSE_NONE) ? SDL_ALPHA_OPAQUE : SDL_ALPHA_TRANSPARENT; - - SDL_FillRect( mainSurface, NULL, SDL_MapRGBA(mainSurface->format,0,0,0,alpha) ); - - for ( i = 0; i < nFrames; i++ ) - { - if ( frames[i].surface ) - { - SDL_Surface* surface = SDL_ConvertSurface( mainSurface, mainSurface->format, mainSurface->flags ); - - if ( surface ) - { - SDL_Rect r; - - if ( lastDispose == AG_DISPOSE_NONE ) - SDL_BlitSurface( frames[i-1].surface, NULL, surface, NULL ); - - if ( lastDispose == AG_DISPOSE_RESTORE_PREVIOUS ) - SDL_BlitSurface( frames[iRestore].surface, NULL, surface, NULL ); - if ( frames[i].disposal != AG_DISPOSE_RESTORE_PREVIOUS ) - iRestore = i; - - r.x = (Sint16)frames[i].x; - r.y = (Sint16)frames[i].y; - SDL_BlitSurface( frames[i].surface, NULL, surface, &r ); - - SDL_FreeSurface( frames[i].surface ); - frames[i].surface = surface; - frames[i].x = frames[i].y = 0; - lastDispose = frames[i].disposal; - frames[i].disposal = newDispose; - n++; - } - } - } - - SDL_FreeSurface( mainSurface ); - } - } - - return n; -} - - - -/*--------------------------------------------------------------------------* - * - *--------------------------------------------------------------------------*/ -int AG_LoadGIF_RW( SDL_RWops* src, AG_Frame* frames, int maxFrames ) -{ - int start; - unsigned char buf[16]; - unsigned char c; - int useGlobalColormap; - int bitPixel; - int iFrame = 0; - char version[4]; - SDL_Surface* image = NULL; - gifdata* gd; - - if ( src == NULL ) - return 0; - - gd = (gifdata*)malloc( sizeof(*gd) ); - memset( gd, 0, sizeof(*gd) ); - gd->src = src; - - start = SDL_RWtell( src ); - - if ( !SDL_RWread(src,buf,6,1) ) - { - SDL_SetError( "error reading magic number" ); - goto done; - } - - if ( strncmp((char*)buf,"GIF",3) != 0 ) - { - SDL_SetError( "not a GIF file" ); - goto done; - } - - strncpy( version, (char*)buf+3, 3 ); - version[3] = '\0'; - - if ( (strcmp(version,"87a") != 0) && (strcmp(version,"89a") != 0) ) - { - SDL_SetError( "bad version number, not '87a' or '89a'" ); - goto done; - } - - gd->g89.transparent = -1; - gd->g89.delayTime = -1; - gd->g89.inputFlag = -1; - gd->g89.disposal = AG_DISPOSE_NA; - - if ( !SDL_RWread(src,buf,7,1) ) - { - SDL_SetError( "failed to read screen descriptor" ); - goto done; - } - - gd->gs.Width = LM_to_uint(buf[0],buf[1]); - gd->gs.Height = LM_to_uint(buf[2],buf[3]); - gd->gs.BitPixel = 2 << (buf[4] & 0x07); - gd->gs.ColorResolution = (((buf[4] & 0x70) >> 3) + 1); - gd->gs.Background = buf[5]; - gd->gs.AspectRatio = buf[6]; - - if ( BitSet(buf[4],LOCALCOLORMAP) ) /* Global Colormap */ - { - if ( ReadColorMap(gd,gd->gs.BitPixel,gd->gs.ColorMap) ) - { - SDL_SetError( "error reading global colormap" ); - goto done; - } - } - - do - { - if ( !SDL_RWread(src,&c,1,1) ) - { - SDL_SetError( "EOF / read error on image data" ); - goto done; - } - - if ( c == ';' ) /* GIF terminator */ - goto done; - - if ( c == '!' ) /* Extension */ - { - if ( !SDL_RWread(src,&c,1,1) ) - { - SDL_SetError( "EOF / read error on extention function code" ); - goto done; - } - DoExtension( gd, c ); - continue; - } - - if ( c != ',' ) /* Not a valid start character */ - continue; - - if ( !SDL_RWread(src,buf,9,1) ) - { - SDL_SetError( "couldn't read left/top/width/height" ); - goto done; - } - - useGlobalColormap = !BitSet(buf[8],LOCALCOLORMAP); - bitPixel = 1 << ((buf[8] & 0x07) + 1); - - if ( !useGlobalColormap ) - { - if ( ReadColorMap(gd,bitPixel,gd->localColorMap) ) - { - SDL_SetError( "error reading local colormap" ); - goto done; - } - image = ReadImage( gd, LM_to_uint(buf[4],buf[5]), LM_to_uint(buf[6],buf[7]), bitPixel, gd->localColorMap, BitSet(buf[8],INTERLACE), (frames==NULL) ); - } - else - { - image = ReadImage( gd, LM_to_uint(buf[4],buf[5]), LM_to_uint(buf[6],buf[7]), gd->gs.BitPixel, gd->gs.ColorMap, BitSet(buf[8],INTERLACE), (frames==NULL) ); - } - - if ( frames ) - { - if ( image == NULL ) - goto done; - - if ( gd->g89.transparent >= 0 ) - SDL_SetColorKey( image, SDL_SRCCOLORKEY, gd->g89.transparent ); - - frames[iFrame].surface = image; - frames[iFrame].x = LM_to_uint(buf[0], buf[1]); - frames[iFrame].y = LM_to_uint(buf[2], buf[3]); - frames[iFrame].disposal = gd->g89.disposal; - frames[iFrame].delay = gd->g89.delayTime*10; -/* gd->g89.transparent = -1; ** Hmmm, not sure if this should be reset for each frame? */ - } - - iFrame++; - } while ( iFrame < maxFrames || frames == NULL ); - -done: - if ( image == NULL ) - SDL_RWseek( src, start, SEEK_SET ); - - free( gd ); - - return iFrame; -} - - - -/*--------------------------------------------------------------------------* - * - *--------------------------------------------------------------------------*/ -static int ReadColorMap( gifdata* gd, int number, unsigned char buffer[3][MAXCOLORMAPSIZE] ) -{ - int i; - unsigned char rgb[3]; - int flag; - - flag = TRUE; - - for ( i = 0; i < number; ++i ) - { - if ( !SDL_RWread(gd->src,rgb,sizeof(rgb),1) ) - { - SDL_SetError( "bad colormap" ); - return 1; - } - - buffer[CM_RED][i] = rgb[0]; - buffer[CM_GREEN][i] = rgb[1]; - buffer[CM_BLUE][i] = rgb[2]; - flag &= (rgb[0] == rgb[1] && rgb[1] == rgb[2]); - } - - return FALSE; -} - - - -/*--------------------------------------------------------------------------* - * - *--------------------------------------------------------------------------*/ -static int DoExtension( gifdata* gd, int label ) -{ - unsigned char buf[256]; - - switch ( label ) - { - case 0x01: /* Plain Text Extension */ - break; - - case 0xff: /* Application Extension */ - break; - - case 0xfe: /* Comment Extension */ - while ( GetDataBlock(gd,buf) != 0 ) - ; - return FALSE; - - case 0xf9: /* Graphic Control Extension */ - (void)GetDataBlock( gd, buf ); - gd->g89.disposal = (buf[0] >> 2) & 0x7; - gd->g89.inputFlag = (buf[0] >> 1) & 0x1; - gd->g89.delayTime = LM_to_uint(buf[1],buf[2]); - if ( (buf[0] & 0x1) != 0 ) - gd->g89.transparent = buf[3]; - - while ( GetDataBlock(gd,buf) != 0 ) - ; - return FALSE; - } - - while ( GetDataBlock(gd,buf) != 0 ) - ; - - return FALSE; -} - - - -/*--------------------------------------------------------------------------* - * - *--------------------------------------------------------------------------*/ -static int GetDataBlock( gifdata* gd, unsigned char* buf ) -{ - unsigned char count; - - if ( !SDL_RWread(gd->src,&count,1,1) ) - { - /* pm_message("error in getting DataBlock size" ); */ - return -1; - } - - gd->zerodatablock = count == 0; - - if ( (count != 0) && !SDL_RWread(gd->src,buf,count,1) ) - { - /* pm_message("error in reading DataBlock" ); */ - return -1; - } - - return count; -} - - - -/*--------------------------------------------------------------------------* - * - *--------------------------------------------------------------------------*/ -static int GetCode( gifdata* gd, int code_size, int flag ) -{ - int i, j, ret; - int count; - - if ( flag ) - { - gd->curbit = 0; - gd->lastbit = 0; - gd->done = FALSE; - return 0; - } - - if ( (gd->curbit + code_size) >= gd->lastbit ) - { - if ( gd->done ) - { - if ( gd->curbit >= gd->lastbit ) - SDL_SetError( "ran off the end of my bits" ); - return -1; - } - - gd->buf[0] = gd->buf[gd->lastbyte - 2]; - gd->buf[1] = gd->buf[gd->lastbyte - 1]; - - if ( (count = GetDataBlock(gd, &gd->buf[2])) == 0 ) - gd->done = TRUE; - - gd->lastbyte = 2 + count; - gd->curbit = (gd->curbit - gd->lastbit) + 16; - gd->lastbit = (2 + count)*8; - } - - ret = 0; - for ( i = gd->curbit, j = 0; j < code_size; ++i, ++j ) - ret |= ((gd->buf[i / 8] & (1 << (i % 8))) != 0) << j; - - gd->curbit += code_size; - - return ret; -} - - - -/*--------------------------------------------------------------------------* - * - *--------------------------------------------------------------------------*/ -static int LWZReadByte( gifdata* gd, int flag, int input_code_size ) -{ - int i, code, incode; - - if ( flag ) - { - gd->setcodesize = input_code_size; - gd->codesize = gd->setcodesize + 1; - gd->clearcode = 1 << gd->setcodesize; - gd->endcode = gd->clearcode + 1; - gd->maxcodesize = gd->clearcode*2; - gd->maxcode = gd->clearcode + 2; - - GetCode( gd, 0, TRUE ); - - gd->fresh = TRUE; - - for ( i = 0; i < gd->clearcode; ++i ) - { - gd->table[0][i] = 0; - gd->table[1][i] = i; - } - - for ( ; i < (1 << MAX_LWZ_BITS); ++i ) - gd->table[0][i] = gd->table[1][0] = 0; - - gd->sp = gd->stack; - return 0; - } - else if ( gd->fresh ) - { - gd->fresh = FALSE; - do - { - gd->firstcode = gd->oldcode = GetCode( gd, gd->codesize, FALSE ); - } while ( gd->firstcode == gd->clearcode ); - return gd->firstcode; - } - - if ( gd->sp > gd->stack ) - return *--gd->sp; - - while ( (code = GetCode(gd,gd->codesize,FALSE)) >= 0 ) - { - if ( code == gd->clearcode ) - { - for ( i = 0; i < gd->clearcode; ++i ) - { - gd->table[0][i] = 0; - gd->table[1][i] = i; - } - - for ( ; i < (1 << MAX_LWZ_BITS); ++i ) - gd->table[0][i] = gd->table[1][i] = 0; - - gd->codesize = gd->setcodesize + 1; - gd->maxcodesize = gd->clearcode*2; - gd->maxcode = gd->clearcode + 2; - gd->sp = gd->stack; - gd->firstcode = gd->oldcode = GetCode( gd, gd->codesize, FALSE ); - return gd->firstcode; - } - else if ( code == gd->endcode ) - { - int count; - unsigned char buf[260]; - - if ( gd->zerodatablock ) - return -2; - - while ( (count = GetDataBlock(gd,buf)) > 0 ) - ; - - if ( count != 0 ) - { - /* pm_message("missing EOD in data stream (common occurence)"); */ - } - return -2; - } - - incode = code; - - if ( code >= gd->maxcode ) - { - *gd->sp++ = gd->firstcode; - code = gd->oldcode; - } - - while ( code >= gd->clearcode ) - { - *gd->sp++ = gd->table[1][code]; - if ( code == gd->table[0][code] ) - SDL_SetError( "circular table entry BIG ERROR" ); - code = gd->table[0][code]; - } - - *gd->sp++ = gd->firstcode = gd->table[1][code]; - - if ( (code = gd->maxcode) < (1 << MAX_LWZ_BITS) ) - { - gd->table[0][code] = gd->oldcode; - gd->table[1][code] = gd->firstcode; - ++gd->maxcode; - if ( (gd->maxcode >= gd->maxcodesize) && (gd->maxcodesize < (1 << MAX_LWZ_BITS)) ) - { - gd->maxcodesize *= 2; - ++gd->codesize; - } - } - - gd->oldcode = incode; - - if ( gd->sp > gd->stack ) - return *--gd->sp; - } - - return code; -} - - - -/*--------------------------------------------------------------------------* - * - *--------------------------------------------------------------------------*/ -static SDL_Surface* ReadImage( gifdata* gd, int len, int height, int cmapSize, unsigned char cmap[3][MAXCOLORMAPSIZE], int interlace, int ignore ) -{ - SDL_Surface* image; - unsigned char c; - int i, v; - int xpos = 0, ypos = 0, pass = 0; - - /* Initialize the compression routines */ - if ( !SDL_RWread(gd->src,&c,1,1) ) - { - SDL_SetError( "EOF / read error on image data" ); - return NULL; - } - - if ( LWZReadByte(gd,TRUE,c) < 0 ) - { - SDL_SetError( "error reading image" ); - return NULL; - } - - /* If this is an "uninteresting picture" ignore it. */ - if ( ignore ) - { - while ( LWZReadByte(gd,FALSE,c) >= 0 ) - ; - return NULL; - } - - image = SDL_AllocSurface( SDL_SWSURFACE, len, height, 8, 0, 0, 0, 0 ); - - for ( i = 0; i < cmapSize; i++ ) - { - image->format->palette->colors[i].r = cmap[CM_RED][i]; - image->format->palette->colors[i].g = cmap[CM_GREEN][i]; - image->format->palette->colors[i].b = cmap[CM_BLUE][i]; - } - - while ( (v = LWZReadByte(gd,FALSE,c)) >= 0 ) - { - ((Uint8*)image->pixels)[xpos + ypos*image->pitch] = (Uint8)v; - ++xpos; - - if ( xpos == len ) - { - xpos = 0; - if ( interlace ) - { - switch ( pass ) - { - case 0: - case 1: ypos += 8; break; - case 2: ypos += 4; break; - case 3: ypos += 2; break; - } - - if ( ypos >= height ) - { - ++pass; - switch ( pass ) - { - case 1: ypos = 4; break; - case 2: ypos = 2; break; - case 3: ypos = 1; break; - default: goto fini; - } - } - } - else - { - ++ypos; - } - } - - if ( ypos >= height ) - break; - } - -fini: - return image; -} - diff --git a/tools/TexturePacker/SDL_anigif.h b/tools/TexturePacker/SDL_anigif.h deleted file mode 100644 index 8635f5b745..0000000000 --- a/tools/TexturePacker/SDL_anigif.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - SDL_anigif: An example animated GIF image loading library for use with SDL - SDL_image Copyright (C) 1997-2006 Sam Lantinga - Animated GIF "derived work" Copyright (C) 2006 Doug McFadyen - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef _SDL_ANIGIF_H -#define _SDL_ANIGIF_H - -#include <SDL/SDL.h> -#include <SDL/begin_code.h> -#ifdef __cplusplus - extern "C" { -#endif - - - -typedef struct -{ - SDL_Surface* surface; /* SDL surface for this frame */ - int x, y; /* Frame offset position */ - int disposal; /* Disposal code */ - int delay; /* Frame delay in ms */ - int user; /* User data (not used by aniGIF) */ -} AG_Frame; - -#define AG_DISPOSE_NA 0 /* No disposal specified */ -#define AG_DISPOSE_NONE 1 /* Do not dispose */ -#define AG_DISPOSE_RESTORE_BACKGROUND 2 /* Restore to background */ -#define AG_DISPOSE_RESTORE_PREVIOUS 3 /* Restore to previous */ - - - -extern DECLSPEC int AG_isGIF( SDL_RWops* src ); -extern DECLSPEC int AG_LoadGIF( const char* file, AG_Frame* frames, int maxFrames ); -extern DECLSPEC void AG_FreeSurfaces( AG_Frame* frames, int nFrames ); -extern DECLSPEC int AG_ConvertSurfacesToDisplayFormat( AG_Frame* frames, int nFrames ); -extern DECLSPEC int AG_NormalizeSurfacesToDisplayFormat( AG_Frame* frames, int nFrames ); -extern DECLSPEC int AG_LoadGIF_RW( SDL_RWops* src, AG_Frame* frames, int size ); - - - -#ifdef __cplusplus - } -#endif -#include <SDL/close_code.h> - -#endif /* _SDL_ANIGIF_H */ diff --git a/tools/TexturePacker/TexturePacker.exe b/tools/TexturePacker/TexturePacker.exe Binary files differdeleted file mode 100644 index 1325f3919c..0000000000 --- a/tools/TexturePacker/TexturePacker.exe +++ /dev/null diff --git a/tools/TexturePacker/Win32/MakeDDS.vcxproj b/tools/TexturePacker/Win32/MakeDDS.vcxproj deleted file mode 100644 index 35f15ae103..0000000000 --- a/tools/TexturePacker/Win32/MakeDDS.vcxproj +++ /dev/null @@ -1,102 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <ProjectGuid>{E85454A0-D9CF-4480-A9AE-AE2A7C3FBAD6}</ProjectGuid> - <RootNamespace>MakeDDS</RootNamespace> - <Keyword>Win32Proj</Keyword> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <CharacterSet>NotSet</CharacterSet> - <WholeProgramOptimization>true</WholeProgramOptimization> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <CharacterSet>NotSet</CharacterSet> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <ImportGroup Label="ExtensionSettings"> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <PropertyGroup Label="UserMacros" /> - <PropertyGroup> - <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir> - <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir> - <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> - </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <Optimization>Disabled</Optimization> - <AdditionalIncludeDirectories>..;..\..\..\xbmc\win32;..\..\..\xbmc\guilib;..\..\..\xbmc;..\..\..\xbmc\lib\libsquish;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;NO_XBMC_FILESYSTEM;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <MinimalRebuild>true</MinimalRebuild> - <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>EditAndContinue</DebugInformationFormat> - </ClCompile> - <Link> - <AdditionalDependencies>SDL.lib;SDL_image.lib;..\..\..\xbmc\lib\libsquish\lib\squishd.lib;%(AdditionalDependencies)</AdditionalDependencies> - <GenerateDebugInformation>true</GenerateDebugInformation> - <SubSystem>Console</SubSystem> - <TargetMachine>MachineX86</TargetMachine> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <Optimization>MaxSpeed</Optimization> - <IntrinsicFunctions>true</IntrinsicFunctions> - <AdditionalIncludeDirectories>..;..\..\..\xbmc\win32;..\..\..\xbmc\guilib;..\..\..\xbmc;..\..\..\xbmc\lib\libsquish;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;NO_XBMC_FILESYSTEM;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> - <FunctionLevelLinking>true</FunctionLevelLinking> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> - </ClCompile> - <Link> - <AdditionalDependencies>SDL.lib;SDL_image.lib;..\..\..\xbmc\lib\libsquish\lib\squish.lib;%(AdditionalDependencies)</AdditionalDependencies> - <GenerateDebugInformation>true</GenerateDebugInformation> - <SubSystem>Console</SubSystem> - <OptimizeReferences>true</OptimizeReferences> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <TargetMachine>MachineX86</TargetMachine> - </Link> - </ItemDefinitionGroup> - <ItemGroup> - <ClCompile Include="..\..\..\xbmc\guilib\DDSImage.cpp" /> - <ClCompile Include="..\MakeDDS.cpp" /> - </ItemGroup> - <ItemGroup> - <ClInclude Include="..\..\..\xbmc\guilib\DDSImage.h" /> - </ItemGroup> - <ItemGroup> - <None Include="ReadMe.txt" /> - </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <ImportGroup Label="ExtensionTargets"> - </ImportGroup> -</Project>
\ No newline at end of file diff --git a/tools/TexturePacker/Win32/MakeDDS.vcxproj.filters b/tools/TexturePacker/Win32/MakeDDS.vcxproj.filters deleted file mode 100644 index 134d242959..0000000000 --- a/tools/TexturePacker/Win32/MakeDDS.vcxproj.filters +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - <Filter Include="Source Files"> - <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> - <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> - </Filter> - <Filter Include="Header Files"> - <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> - <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> - </Filter> - <Filter Include="Resource Files"> - <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> - <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions> - </Filter> - </ItemGroup> - <ItemGroup> - <ClCompile Include="..\..\..\xbmc\guilib\DDSImage.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\MakeDDS.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - </ItemGroup> - <ItemGroup> - <ClInclude Include="..\..\..\xbmc\guilib\DDSImage.h"> - <Filter>Header Files</Filter> - </ClInclude> - </ItemGroup> - <ItemGroup> - <None Include="ReadMe.txt" /> - </ItemGroup> -</Project>
\ No newline at end of file diff --git a/tools/TexturePacker/xwinapi.cpp b/tools/TexturePacker/xwinapi.cpp deleted file mode 100644 index a8a119ef48..0000000000 --- a/tools/TexturePacker/xwinapi.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#include <stdio.h> -#include <stdlib.h> -#include <sys/types.h> -#include <unistd.h> -#include <string.h> -#include <errno.h> -#include "xwinapi.h" -#ifdef TARGET_DARWIN -#include "OSXGNUReplacements.h" -#endif - -// I hope this doesn't need to handle unicode... -LPTSTR GetCommandLine() { - pid_t pid = 0; - char procFile[32], - *cmdline = NULL; - FILE *fp = NULL; - size_t cmdlinelen = 0; - int i; - - pid = getpid(); - sprintf(procFile, "/proc/%u/cmdline", pid); - if((fp = fopen(procFile, "r")) == NULL) - return NULL; - - // getline() allocates memory so be sure to free it - // after calling GetCommandLine() - if (getline(&cmdline, &cmdlinelen, fp) == -1) - { - fclose(fp); - return NULL; - } - - fclose(fp); - fp = NULL; - - for (i = 0; i < (int)cmdlinelen; i++) { - if (cmdline[i] == 0x00) { - if (cmdline[i + 1] == 0x00) - break; - cmdline[i] = ' '; - } - } - - cmdline = (char *)realloc(cmdline, strlen(cmdline) + 1); - return cmdline; -} - -DWORD GetCurrentDirectory(DWORD nBufferLength, LPTSTR lpBuffer) { - bool bSizeTest = (nBufferLength == 0 && lpBuffer == NULL); - if (getcwd(lpBuffer, nBufferLength) == NULL) { - if (errno == ERANGE) { - LPTSTR tmp = NULL; - if (getcwd(tmp, 0) == NULL ) - nBufferLength = 0; - else - nBufferLength = strlen(tmp) + 1; - - free(tmp); - return nBufferLength; - } - return 0; - } - if (bSizeTest) { - nBufferLength = strlen(lpBuffer) + 1; - free(lpBuffer); - lpBuffer = NULL; - return nBufferLength; - } - return strlen(lpBuffer); -} - -BOOL SetCurrentDirectory(LPCTSTR lpPathName) { - return (chdir(lpPathName) == 0); -} - -DWORD GetLastError( ) { - return errno; -} - diff --git a/tools/android/packaging/xbmc/AndroidManifest.xml.in b/tools/android/packaging/xbmc/AndroidManifest.xml.in index ba7ade529c..4232f1a852 100644 --- a/tools/android/packaging/xbmc/AndroidManifest.xml.in +++ b/tools/android/packaging/xbmc/AndroidManifest.xml.in @@ -3,7 +3,7 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.xbmc.@APP_NAME_LC@" android:versionCode="@APP_VERSION_CODE@" - android:versionName="@APP_VERSION_MAJOR@.@APP_VERSION_MINOR@-@APP_VERSION_TAG@" > + android:versionName="@APP_VERSION@" > <!-- This is the platform API where NativeActivity was introduced. --> <uses-sdk android:minSdkVersion="14" /> diff --git a/tools/buildsteps/win32/make-addon-depends.bat b/tools/buildsteps/win32/make-addon-depends.bat deleted file mode 100644 index fd4ac3ce4a..0000000000 --- a/tools/buildsteps/win32/make-addon-depends.bat +++ /dev/null @@ -1,100 +0,0 @@ -@ECHO OFF - -SETLOCAL - -SET EXITCODE=0 - -SET noclean=false -SET dependency= -FOR %%b in (%1, %2) DO ( - IF %%b == noclean ( - SET noclean=true - ) ELSE ( IF %%b == clean ( - SET noclean=false - ) ELSE ( - SET dependency=%%b - )) -) - -rem set Visual C++ build environment -call "%VS120COMNTOOLS%..\..\VC\bin\vcvars32.bat" - -SET WORKDIR=%WORKSPACE% - -IF "%WORKDIR%" == "" ( - SET WORKDIR=%CD%\..\..\.. -) - -rem setup some paths that we need later -SET CUR_PATH=%CD% - -SET BASE_PATH=%WORKDIR%\project\cmake\ -SET SCRIPTS_PATH=%BASE_PATH%\scripts\windows -SET ADDONS_PATH=%BASE_PATH%\addons -SET ADDONS_OUTPUT_PATH=%ADDONS_PATH%\output -SET ADDON_DEPENDS_PATH=%ADDONS_PATH%\depends -SET ADDON_DEPENDS_BUILD_PATH=%ADDON_DEPENDS_PATH%\build - -SET ERRORFILE=%BASE_PATH%\make-addon-depends.error - -IF %noclean% == false ( - rem remove the output directory if it exists - IF EXIST "%ADDONS_OUTPUT_PATH%" ( - RMDIR "%ADDONS_OUTPUT_PATH%" /S /Q > NUL - ) - - rem remove the build directory if it exists - IF EXIST "%ADDON_DEPENDS_BUILD_PATH%" ( - RMDIR "%ADDON_DEPENDS_BUILD_PATH%" /S /Q > NUL - ) -) - -rem create the output directory -IF NOT EXIST "%ADDONS_OUTPUT_PATH%" MKDIR "%ADDONS_OUTPUT_PATH%" - -rem create the build directory -IF NOT EXIST "%ADDON_DEPENDS_BUILD_PATH%" MKDIR "%ADDON_DEPENDS_BUILD_PATH%" - -rem go into the build directory -CD "%ADDON_DEPENDS_BUILD_PATH%" - -SET DEPENDS_TO_BUILD="all" -IF "%dependency%" NEQ "" ( - SET DEPENDS_TO_BUILD="%dependency%" -) - -rem execute cmake to generate makefiles processable by nmake -cmake "%ADDON_DEPENDS_PATH%" -G "NMake Makefiles" ^ - -DCMAKE_BUILD_TYPE=Release ^ - -DCMAKE_USER_MAKE_RULES_OVERRIDE="%SCRIPTS_PATH%/c-flag-overrides.cmake" ^ - -DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX="%SCRIPTS_PATH%/cxx-flag-overrides.cmake" ^ ^ - -DCMAKE_INSTALL_PREFIX=%ADDONS_OUTPUT_PATH% ^ - -DARCH_DEFINES="-DTARGET_WINDOWS -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -D_USE_32BIT_TIME_T -D_WINSOCKAPI_" ^ - -DDEPENDS_TO_BUILD="%DEPENDS_TO_BUILD%" -IF ERRORLEVEL 1 ( - ECHO cmake error level: %ERRORLEVEL% > %ERRORFILE% - GOTO ERROR -) - -rem execute nmake to build the addon depends -nmake %dependency% -IF ERRORLEVEL 1 ( - ECHO nmake error level: %ERRORLEVEL% > %ERRORFILE% - GOTO ERROR -) - -rem everything was fine -GOTO END - -:ERROR -rem something went wrong -ECHO Failed to build addon dependencies -ECHO See %ERRORFILE% for more details -SET EXITCODE=1 - -:END -rem go back to the original directory -cd %CUR_PATH% - -rem exit the script with the defined exitcode -EXIT /B %EXITCODE% diff --git a/tools/buildsteps/win32/make-addons.bat b/tools/buildsteps/win32/make-addons.bat index 48ff14073b..a123b377bb 100644 --- a/tools/buildsteps/win32/make-addons.bat +++ b/tools/buildsteps/win32/make-addons.bat @@ -4,22 +4,17 @@ SETLOCAL SET EXITCODE=0 -SET getdepends=true SET install=false -SET noclean=false +SET clean=false SET addon= FOR %%b in (%1, %2, %3, %4) DO ( - IF %%b == nodepends ( - SET getdepends=false - ) ELSE ( IF %%b == install ( + IF %%b == install ( SET install=true - ) ELSE ( IF %%b == noclean ( - SET noclean=true ) ELSE ( IF %%b == clean ( - SET noclean=false + SET clean=true ) ELSE ( SET addon=%%b - )))) + )) ) rem set Visual C++ build environment @@ -41,33 +36,23 @@ SET ADDONS_BUILD_PATH=%ADDONS_PATH%\build SET ERRORFILE=%BASE_PATH%\make-addons.error -rem determine whether make-addon-depends.bat should be called with noclean or not -SET addon_depends_mode=clean -IF %noclean% == true ( - SET addon_depends_mode=noclean -) - -IF %getdepends% == true ( - ECHO -------------------------------------------------- - ECHO Building addon dependencies - ECHO -------------------------------------------------- - - CALL make-addon-depends.bat %addon_depends_mode% - IF ERRORLEVEL 1 ( - ECHO make-addon-depends error level: %ERRORLEVEL% > %ERRORFILE% - GOTO ERROR - ) - - ECHO. -) - -IF %noclean% == false ( +IF %clean% == true ( rem remove the build directory if it exists IF EXIST "%ADDONS_BUILD_PATH%" ( RMDIR "%ADDONS_BUILD_PATH%" /S /Q > NUL ) + + rem remove the build directory if it exists + IF EXIST "%ADDON_DEPENDS_PATH%" ( + RMDIR "%ADDON_DEPENDS_PATH%" /S /Q > NUL + ) + + GOTO END ) +rem create the depends directory +IF NOT EXIST "%ADDON_DEPENDS_PATH%" MKDIR "%ADDON_DEPENDS_PATH%" + rem create the build directory IF NOT EXIST "%ADDONS_BUILD_PATH%" MKDIR "%ADDONS_BUILD_PATH%" @@ -97,7 +82,8 @@ cmake "%ADDONS_PATH%" -G "NMake Makefiles" ^ -DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX="%SCRIPTS_PATH%/cxx-flag-overrides.cmake" ^ -DCMAKE_INSTALL_PREFIX=%ADDONS_INSTALL_PATH% ^ -DAPP_ROOT=%WORKDIR% ^ - -DCMAKE_PREFIX_PATH=%ADDON_DEPENDS_PATH% ^ + -DBUILD_DIR=%ADDONS_BUILD_PATH% ^ + -DDEPENDS_PATH=%ADDON_DEPENDS_PATH% ^ -DPACKAGE_ZIP=1 ^ -DARCH_DEFINES="-DTARGET_WINDOWS -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -D_USE_32BIT_TIME_T -D_WINSOCKAPI_" ^ -DADDONS_TO_BUILD="%ADDONS_TO_BUILD%" diff --git a/tools/darwin/Configurations/App.xcconfig.in b/tools/darwin/Configurations/App.xcconfig.in index 936815c921..94946d3daf 100644 --- a/tools/darwin/Configurations/App.xcconfig.in +++ b/tools/darwin/Configurations/App.xcconfig.in @@ -22,9 +22,9 @@ XBMC_DEPENDS_ROOT = @DEPENDS_ROOT_FOR_XCODE@ HEADER_SEARCH_PATHS = $(inherited) $SRCROOT xbmc xbmc/linux xbmc/osx xbmc/cores/dvdplayer lib $XBMC_DEPENDS/include $XBMC_DEPENDS/include/libcec $XBMC_DEPENDS/include/mysql $XBMC_DEPENDS/include/freetype2 $XBMC_DEPENDS/include/python2.6 -LIBRARY_SEARCH_PATHS = $(inherited) $(SRCROOT) $(SRCROOT)/lib/libRTV $(SRCROOT)/lib/libXDAAP $(SRCROOT)/lib/cmyth/libcmyth $(SRCROOT)/lib/cmyth/librefmem $(SRCROOT)/lib/libsquish $(SRCROOT)/lib/SlingboxLib $(SRCROOT)/xbmc/interfaces/json-rpc "$(SRCROOT)/xbmc/interfaces/python" "$(SRCROOT)/xbmc/interfaces/legacy" +LIBRARY_SEARCH_PATHS = $(inherited) $(SRCROOT) $(SRCROOT)/lib/libRTV $(SRCROOT)/lib/libXDAAP $(SRCROOT)/lib/cmyth/libcmyth $(SRCROOT)/lib/cmyth/librefmem $(SRCROOT)/lib/SlingboxLib $(SRCROOT)/xbmc/interfaces/json-rpc "$(SRCROOT)/xbmc/interfaces/python" "$(SRCROOT)/xbmc/interfaces/legacy" FRAMEWORK_SEARCH_PATHS = $(inherited) "$(SDKROOT)/System/Library/PrivateFrameworks/" "$(SDKROOT)/System/Library/Frameworks/" -XBMC_OTHER_LDFLAGS_COMMON = $(inherited) -Wl,-headerpad_max_install_names -Wl,-all_load -L$XBMC_DEPENDS/lib -lbz2 -lintl -lexpat -lssl -lgpg-error -lresolv -lffi -lssh -llzo2 -lpcre -lpcrecpp -lfribidi -lfreetype -lfontconfig -lsqlite3 -ltinyxml -lmicrohttpd -lsmbclient -lpython2.6 -lyajl -ljpeg -lcrypto -lgcrypt -lavdevice -lavfilter -lavcodec -lavformat -lpostproc -lavutil -lswresample -lswscale -ltag -L$XBMC_DEPENDS/lib/mysql -lmysqlclient -lxml2 -lxslt +XBMC_OTHER_LDFLAGS_COMMON = $(inherited) -Wl,-headerpad_max_install_names -Wl,-all_load -L$XBMC_DEPENDS/lib -lbz2 -lintl -lexpat -lssl -lgpg-error -lresolv -lffi -lssh -llzo2 -lpcre -lpcrecpp -lfribidi -lfreetype -lfontconfig -lsqlite3 -ltinyxml -lmicrohttpd -lsmbclient -lpython2.6 -lyajl -ljpeg -lcrypto -lgcrypt -lavdevice -lavfilter -lavcodec -lavformat -lpostproc -lavutil -lswresample -lswscale -ltag -L$XBMC_DEPENDS/lib/mysql -lmysqlclient -lxml2 -lxslt -lnettle -lgmp -lhogweed -lgnutls diff --git a/tools/darwin/packaging/atv2/mkdeb-atv2.sh.in b/tools/darwin/packaging/atv2/mkdeb-atv2.sh.in index db637ebcbe..fefc6ce0a7 100644 --- a/tools/darwin/packaging/atv2/mkdeb-atv2.sh.in +++ b/tools/darwin/packaging/atv2/mkdeb-atv2.sh.in @@ -48,7 +48,12 @@ fi PACKAGE=org.xbmc.@APP_NAME_LC@-atv2 VERSION=@APP_VERSION_MAJOR@.@APP_VERSION_MINOR@ -REVISION=0~@APP_VERSION_TAG_LC@ +REVISION=0 + +if [ "@APP_VERSION_TAG_LC@" != "" ]; then + REVISION=$REVISION~@APP_VERSION_TAG_LC@ +fi + ARCHIVE=${PACKAGE}_${VERSION}-${REVISION}_iphoneos-arm.deb SIZE="$(du -s -k ${APP} | awk '{print $1}')" diff --git a/tools/darwin/packaging/ios/mkdeb-ios.sh.in b/tools/darwin/packaging/ios/mkdeb-ios.sh.in index 0ec4e2e848..f159bf9a19 100644 --- a/tools/darwin/packaging/ios/mkdeb-ios.sh.in +++ b/tools/darwin/packaging/ios/mkdeb-ios.sh.in @@ -49,7 +49,12 @@ fi PACKAGE=org.xbmc.@APP_NAME_LC@-ios VERSION=@APP_VERSION_MAJOR@.@APP_VERSION_MINOR@ -REVISION=0~@APP_VERSION_TAG_LC@ +REVISION=0 + +if [ "@APP_VERSION_TAG_LC@" != "" ]; then + REVISION=$REVISION~@APP_VERSION_TAG_LC@ +fi + ARCHIVE=${PACKAGE}_${VERSION}-${REVISION}_iphoneos-arm.deb SIZE="$(du -s -k ${APP} | awk '{print $1}')" diff --git a/tools/darwin/packaging/osx/mkdmg-osx.sh.in b/tools/darwin/packaging/osx/mkdmg-osx.sh.in index 33c13dd45a..2a10ebc081 100755 --- a/tools/darwin/packaging/osx/mkdmg-osx.sh.in +++ b/tools/darwin/packaging/osx/mkdmg-osx.sh.in @@ -25,7 +25,12 @@ ARCHITECTURE=`file $APP/Contents/MacOS/@APP_NAME@ | awk '{print $NF}'` PACKAGE=org.xbmc.@APP_NAME_LC@-osx VERSION=@APP_VERSION_MAJOR@.@APP_VERSION_MINOR@ -REVISION=0~@APP_VERSION_TAG_LC@ +REVISION=0 + +if [ "@APP_VERSION_TAG_LC@" != "" ]; then + REVISION=$REVISION~@APP_VERSION_TAG_LC@ +fi + ARCHIVE=${PACKAGE}_${VERSION}-${REVISION}_macosx-intel-${ARCHITECTURE} echo Creating $PACKAGE package version $VERSION revision $REVISION diff --git a/tools/depends/native/Makefile b/tools/depends/native/Makefile index b03f7a13b6..9b42c196d2 100644 --- a/tools/depends/native/Makefile +++ b/tools/depends/native/Makefile @@ -7,9 +7,9 @@ endif NATIVE= m4-native gettext-native autoconf-native automake-native \ libtool-native pkg-config-native yasm-native cmake-native \ gas-preprocessor-native python26-native zlib-native \ - pcre-native swig-native rpl-native libsdl_image-native \ - tiff-native libpng-native libjpeg-turbo-native liblzo2-native \ - libsdl-native distribute-native distutilscross-native JsonSchemaBuilder + pcre-native swig-native rpl-native libsdl_image-native libsquish-native \ + tiff-native libpng-native libjpeg-turbo-native liblzo2-native giflib-native \ + libsdl-native distribute-native distutilscross-native JsonSchemaBuilder TexturePacker ifeq ($(OS),ios) @@ -41,6 +41,7 @@ python26-native: zlib-native #liblzo2 has stale packaged automake files that cause borked host/build detection liblzo2-native: automake-native JsonSchemaBuilder: automake-native +TexturePacker: automake-native pkg-config-native libsquish-native libpng-native liblzo2-native giflib-native libpng-native native: $(NATIVE) $(NATIVE): diff --git a/tools/depends/native/TexturePacker/Makefile b/tools/depends/native/TexturePacker/Makefile new file mode 100644 index 0000000000..a49b658dcf --- /dev/null +++ b/tools/depends/native/TexturePacker/Makefile @@ -0,0 +1,63 @@ +ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) +-include ../../Makefile.include + +ifeq ($(NATIVEPREFIX),) + PREFIX = $(ROOT_DIR) +else + PREFIX = $(NATIVEPREFIX) +endif + +ifeq ($(NATIVEPLATFORM),) + PLATFORM = native + EXTRA_CONFIGURE = --enable-static +else + PLATFORM = $(NATIVEPLATFORM) +endif + +ifeq ($(OS), linux) + EXTRA_CONFIGURE = --enable-static +endif +ifeq ($(OS), android) + EXTRA_CONFIGURE = --enable-static +endif + +ifeq ($(XBMCROOT),) + XBMCROOT = $(ROOT_DIR)/../../../.. +endif + +SOURCE=$(ROOT_DIR)/src + +APP=$(PLATFORM)/TexturePacker +APPBIN=$(PREFIX)/bin/TexturePacker + +all: .installed-$(PLATFORM) + +$(PLATFORM): ../libsquish-native/.installed-$(PLATFORM) + -rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); cp -a $(SOURCE)/* . + cd $(PLATFORM); ./autogen.sh + cd $(PLATFORM); ./configure --prefix=$(PREFIX) $(EXTRA_CONFIGURE) EXTRA_DEFINES="$(ARCH_DEFINES)" + + +$(APP): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + +../libsquish-native/.installed-$(PLATFORM): + $(MAKE) -C ../libsquish-native + +.installed-$(PLATFORM): $(APP) + $(MAKE) -C $(PLATFORM) install + touch $@ + #TEMP workaround for skins: create legacy link. Remove me when skins are fixed + @mkdir -p $(XBMCROOT)/tools/TexturePacker + @[ -f $(XBMCROOT)/tools/TexturePacker/TexturePacker ] && rm $(XBMCROOT)/tools/TexturePacker/TexturePacker || : + @ln -s $(APPBIN) $(XBMCROOT)/tools/TexturePacker/TexturePacker + @echo "all:" > $(XBMCROOT)/tools/TexturePacker/Makefile + @echo "\t@echo "WARNING: use of tools/TexturePacker/TexturePacker is deprecated, please update your skins Makefile"" >> $(XBMCROOT)/tools/TexturePacker/Makefile + +clean: + $(MAKE) -C $(PLATFORM) clean + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) + -rm -rf bin diff --git a/tools/depends/native/TexturePacker/src/DecoderManager.cpp b/tools/depends/native/TexturePacker/src/DecoderManager.cpp new file mode 100644 index 0000000000..3daf430286 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/DecoderManager.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ +#include <cstdio> +#include "DecoderManager.h" + +std::vector<IDecoder *> DecoderManager::m_decoders; + +// ADD new decoders here +// include decoders +#include "PNGDecoder.h" +#include "JPGDecoder.h" +#include "GIFDecoder.h" + +void DecoderManager::InstantiateDecoders() +{ + m_decoders.push_back(new PNGDecoder()); + m_decoders.push_back(new JPGDecoder()); + m_decoders.push_back(new GIFDecoder()); +} + +void DecoderManager::FreeDecoders() +{ + for (unsigned int i = 0; i < m_decoders.size(); i++) + { + delete m_decoders[i]; + } + m_decoders.clear(); +} + +// returns true for png, bmp, tga, jpg and dds files, otherwise returns false +bool DecoderManager::IsSupportedGraphicsFile(char *strFileName) +{ + std::string filename = strFileName; + if (filename.length() < 4) + return false; + + for (unsigned int i = 0; i < m_decoders.size(); i++) + { + const std::vector<std::string> extensions = m_decoders[i]->GetSupportedExtensions(); + for (unsigned int n = 0; n < extensions.size(); n++) + { + int extLen = extensions[n].length(); + if (std::string::npos != filename.rfind(extensions[n].c_str(), filename.length() - extLen, extLen)) + { + return true; + } + } + } + return false; +} + +bool DecoderManager::LoadFile(const std::string &filename, DecodedFrames &frames) +{ + for (unsigned int i = 0; i < m_decoders.size(); i++) + { + if (m_decoders[i]->CanDecode(filename)) + { + fprintf(stdout, "This is a %s - lets load it via %s...\n", m_decoders[i]->GetImageFormatName(), m_decoders[i]->GetDecoderName()); + return m_decoders[i]->LoadFile(filename, frames); + } + } + return false; +} + +void DecoderManager::FreeDecodedFrames(DecodedFrames &frames) +{ + frames.clear(); +} diff --git a/tools/depends/native/TexturePacker/src/DecoderManager.h b/tools/depends/native/TexturePacker/src/DecoderManager.h new file mode 100644 index 0000000000..e129f0cb06 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/DecoderManager.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#pragma once +#include "IDecoder.h" + +class DecoderManager +{ + public: + static void InstantiateDecoders(); + static void FreeDecoders(); + static bool IsSupportedGraphicsFile(char *strFileName); + static bool LoadFile(const std::string &filename, DecodedFrames &frames); + static void FreeDecodedFrames(DecodedFrames &frames); + private: + static std::vector<IDecoder *> m_decoders; +};
\ No newline at end of file diff --git a/tools/depends/native/TexturePacker/src/Makefile.am b/tools/depends/native/TexturePacker/src/Makefile.am new file mode 100644 index 0000000000..709bd63464 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/Makefile.am @@ -0,0 +1,31 @@ +AUTOMAKE_OPTIONS = subdir-objects + +AM_CFLAGS = -DTARGET_POSIX -DUSE_LZO_PACKING +AM_CFLAGS += @EXTRA_DEFINES@ +AM_CXXFLAGS = $(AM_CFLAGS) + +AM_CPPFLAGS = \ + -I. \ + -I./decoder \ + -I@KODI_SRC_DIR@/lib \ + -I@KODI_SRC_DIR@/xbmc \ + -I@KODI_SRC_DIR@/xbmc/guilib \ + -I@KODI_SRC_DIR@/xbmc/linux \ + @CPPFLAGS@ + +AM_LDFLAGS = @LIBS@ @STATIC_FLAG@ + + +bin_PROGRAMS = TexturePacker +TexturePacker_SOURCES = md5.cpp \ + XBTFWriter.cpp \ + TexturePacker.cpp \ + DecoderManager.cpp \ + decoder/PNGDecoder.cpp \ + decoder/JPGDecoder.cpp \ + decoder/GifHelper.cpp \ + decoder/GIFDecoder.cpp \ + XBTF.cpp + +XBTF.cpp: + @cp @KODI_SRC_DIR@/xbmc/guilib/XBTF.cpp . diff --git a/tools/TexturePacker/SimpleFS.h b/tools/depends/native/TexturePacker/src/SimpleFS.h index d1c72f07e1..c48814c0ad 100644 --- a/tools/TexturePacker/SimpleFS.h +++ b/tools/depends/native/TexturePacker/src/SimpleFS.h @@ -31,6 +31,11 @@ public: { m_file = NULL; } + + ~CFile() + { + Close(); + } bool Open(const std::string &file) { @@ -54,17 +59,48 @@ public: uint64_t Read(void *data, uint64_t size) { - if (fread(data, size, 1, m_file) == 1) + if (fread(data, (size_t)size, 1, m_file) == 1) return size; return 0; } uint64_t Write(const void *data, uint64_t size) { - if (fwrite(data, size, 1, m_file) == 1) + if (fwrite(data, (size_t)size, 1, m_file) == 1) return size; return 0; } + + FILE *getFP() + { + return m_file; + } + + uint64_t GetFileSize() + { + long curPos = ftell(m_file); + uint64_t fileSize = 0; + if (fseek(m_file, 0, SEEK_END) == 0) + { + long size = ftell(m_file); + if (size >= 0) + fileSize = (uint64_t)size; + } + + // restore fileptr + Seek(curPos); + + return fileSize; + } + + uint64_t Seek(uint64_t offset) + { + uint64_t seekedBytes = 0; + int seekRet = fseek(m_file, offset, SEEK_SET); + if (seekRet == 0) + seekedBytes = offset; + return seekedBytes; + } private: FILE* m_file; diff --git a/tools/TexturePacker/XBMCTex.cpp b/tools/depends/native/TexturePacker/src/TexturePacker.cpp index 83a67c4aa4..a84a4606ef 100644 --- a/tools/TexturePacker/XBMCTex.cpp +++ b/tools/depends/native/TexturePacker/src/TexturePacker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2013 Team XBMC + * Copyright (C) 2005-2014 Team XBMC * http://xbmc.org * * This Program is free software; you can redistribute it and/or modify @@ -23,31 +23,30 @@ #include <sys/stat.h> #define __STDC_FORMAT_MACROS #include <inttypes.h> +#define platform_stricmp _stricmp +#else +#define platform_stricmp stricmp #endif -//#include <string> #include <cerrno> -//#include <cstring> #include <dirent.h> #include <map> -#include <SDL/SDL.h> -#include <SDL/SDL_image.h> -#undef main - #include "guilib/XBTF.h" + +#include "DecoderManager.h" + #include "XBTFWriter.h" #include "md5.h" -#include "SDL_anigif.h" #include "cmdlineargs.h" -#include "libsquish/squish.h" +#include "squish.h" #ifdef TARGET_WINDOWS -#define strncasecmp strnicmp +#define strncasecmp _strnicmp #endif #ifdef USE_LZO_PACKING #ifdef TARGET_WINDOWS -#include "../../lib/win32/liblzo/LZO1X.H" +#include "win32/liblzo/LZO1X.H" #else #include <lzo/lzo1x.h> #endif @@ -60,18 +59,6 @@ using namespace std; #define FLAGS_USE_DXT 4 #define DIR_SEPARATOR "/" -#define DIR_SEPARATOR_CHAR '/' - -int NP2( unsigned x ) -{ - --x; - x |= x >> 1; - x |= x >> 2; - x |= x >> 4; - x |= x >> 8; - x |= x >> 16; - return ++x; -} const char *GetFormatString(unsigned int format) { @@ -94,37 +81,6 @@ const char *GetFormatString(unsigned int format) } } -// returns true for png, bmp, tga, jpg and dds files, otherwise returns false -bool IsGraphicsFile(char *strFileName) -{ - size_t n = strlen(strFileName); - if (n < 4) - return false; - - if (strncasecmp(&strFileName[n-4], ".png", 4) && - strncasecmp(&strFileName[n-4], ".bmp", 4) && - strncasecmp(&strFileName[n-4], ".tga", 4) && - strncasecmp(&strFileName[n-4], ".gif", 4) && - strncasecmp(&strFileName[n-4], ".tbn", 4) && - strncasecmp(&strFileName[n-4], ".jpg", 4)) - return false; - - return true; -} - -// returns true for png, bmp, tga, jpg and dds files, otherwise returns false -bool IsGIF(const char *strFileName) -{ - size_t n = strlen(strFileName); - if (n < 4) - return false; - - if (strncasecmp(&strFileName[n-4], ".gif", 4)) - return false; - - return true; -} - void CreateSkeletonHeaderImpl(CXBTF& xbtf, std::string fullPath, std::string relativePath) { struct dirent* dp; @@ -154,7 +110,7 @@ void CreateSkeletonHeaderImpl(CXBTF& xbtf, std::string fullPath, std::string rel CreateSkeletonHeaderImpl(xbtf, fullPath + DIR_SEPARATOR + dp->d_name, tmpPath + dp->d_name); } - else if (IsGraphicsFile(dp->d_name)) + else if (DecoderManager::IsSupportedGraphicsFile(dp->d_name)) { std::string fileName = ""; if (relativePath.size() > 0) @@ -176,7 +132,7 @@ void CreateSkeletonHeaderImpl(CXBTF& xbtf, std::string fullPath, std::string rel } else { - printf("Error opening %s (%s)\n", fullPath.c_str(), strerror(errno)); + fprintf(stderr, "Error opening %s (%s)\n", fullPath.c_str(), strerror(errno)); } } @@ -256,46 +212,19 @@ bool HasAlpha(unsigned char *argb, unsigned int width, unsigned int height) return false; } -CXBTFFrame createXBTFFrame(SDL_Surface* image, CXBTFWriter& writer, double maxMSE, unsigned int flags) +CXBTFFrame createXBTFFrame(RGBAImage &image, CXBTFWriter& writer, double maxMSE, unsigned int flags) { - // Convert to ARGB - SDL_PixelFormat argbFormat; - memset(&argbFormat, 0, sizeof(SDL_PixelFormat)); - argbFormat.BitsPerPixel = 32; - argbFormat.BytesPerPixel = 4; - - // For DXT5 we need RGBA -#if defined(HOST_BIGENDIAN) - argbFormat.Amask = 0x000000ff; - argbFormat.Ashift = 0; - argbFormat.Rmask = 0x0000ff00; - argbFormat.Rshift = 8; - argbFormat.Gmask = 0x00ff0000; - argbFormat.Gshift = 16; - argbFormat.Bmask = 0xff000000; - argbFormat.Bshift = 24; -#else - argbFormat.Amask = 0xff000000; - argbFormat.Ashift = 24; - argbFormat.Rmask = 0x00ff0000; - argbFormat.Rshift = 16; - argbFormat.Gmask = 0x0000ff00; - argbFormat.Gshift = 8; - argbFormat.Bmask = 0x000000ff; - argbFormat.Bshift = 0; -#endif int width, height; unsigned int format = 0; - SDL_Surface *argbImage = SDL_ConvertSurface(image, &argbFormat, 0); - unsigned char* argb = (unsigned char*)argbImage->pixels; + unsigned char* argb = (unsigned char*)image.pixels; unsigned int compressedSize = 0; unsigned char* compressed = NULL; - width = image->w; - height = image->h; + width = image.width; + height = image.height; bool hasAlpha = HasAlpha(argb, width, height); - + if (flags & FLAGS_USE_DXT) { double colorMSE, alphaMSE; @@ -308,18 +237,7 @@ CXBTFFrame createXBTFFrame(SDL_Surface* image, CXBTFWriter& writer, double maxMS compressedSize = squish::GetStorageRequirements(width, height, squish::kDxt1); format = XB_FMT_DXT1; } - /* - if (!format && alphaMSE == 0 && (flags & FLAGS_ALLOW_YCOCG) == FLAGS_ALLOW_YCOCG) - { - // no alpha channel, so DXT5YCoCg is going to be the best DXT5 format - CompressImage(argb, width, height, compressed, squish::kDxt5 | squish::kUseYCoCg, colorMSE, alphaMSE); - if (colorMSE < maxMSE && alphaMSE < maxMSE) - { // success - use it - compressedSize = squish::GetStorageRequirements(width, height, squish::kDxt5); - format = XB_FMT_DXT5_YCoCg; - } - } - */ + if (!format) { // try DXT3 and DXT5 - use whichever is better (color is the same, but alpha will be different) CompressImage(argb, width, height, compressed, squish::kDxt3, colorMSE, alphaMSE); @@ -358,7 +276,6 @@ CXBTFFrame createXBTFFrame(SDL_Surface* image, CXBTFWriter& writer, double maxMS frame = appendContent(writer, width, height, argb, (width * height * 4), format, hasAlpha, flags); } - SDL_FreeSurface(argbImage); return frame; } @@ -417,7 +334,7 @@ int createBundle(const std::string& InputDir, const std::string& OutputFile, dou CXBTFWriter writer(xbtf, OutputFile); if (!writer.Create()) { - printf("Error creating file\n"); + fprintf(stderr, "Error creating file\n"); return 1; } @@ -435,94 +352,60 @@ int createBundle(const std::string& InputDir, const std::string& OutputFile, dou output = output.substr(0, 40); while (output.size() < 46) output += ' '; - if (!IsGIF(fullPath.c_str())) - { - // Load the image - SDL_Surface* image = IMG_Load(fullPath.c_str()); - if (!image) - { - printf("...unable to load image %s\n", file.GetPath()); - continue; - } - bool skip=false; - printf("%s", output.c_str()); - if (dupecheck) - { - MD5Update(&ctx,(const uint8_t*)image->pixels,image->h*image->pitch); - if (checkDupe(&ctx,hashes,dupes,i)) - { - printf("**** duplicate of %s\n", files[dupes[i]].GetPath()); - file.GetFrames().insert(file.GetFrames().end(), - files[dupes[i]].GetFrames().begin(), files[dupes[i]].GetFrames().end()); - skip = true; - } - } + DecodedFrames frames; + bool loaded = DecoderManager::LoadFile(fullPath, frames); - if (!skip) - { - CXBTFFrame frame = createXBTFFrame(image, writer, maxMSE, flags); - - printf("%s%c (%d,%d @ %"PRIu64" bytes)\n", GetFormatString(frame.GetFormat()), frame.HasAlpha() ? ' ' : '*', - frame.GetWidth(), frame.GetHeight(), frame.GetUnpackedSize()); - - file.SetLoop(0); - file.GetFrames().push_back(frame); - } - SDL_FreeSurface(image); + if (!loaded) + { + fprintf(stderr, "...unable to load image %s\n", file.GetPath()); + continue; } - else + + printf("%s\n", output.c_str()); + bool skip=false; + if (dupecheck) { - int gnAG = AG_LoadGIF(fullPath.c_str(), NULL, 0); - AG_Frame* gpAG = new AG_Frame[gnAG]; - AG_LoadGIF(fullPath.c_str(), gpAG, gnAG); + for (unsigned int j = 0; j < frames.frameList.size(); j++) + MD5Update(&ctx, + (const uint8_t*)frames.frameList[j].rgbaImage.pixels, + frames.frameList[j].rgbaImage.height * frames.frameList[j].rgbaImage.pitch); - printf("%s\n", output.c_str()); - bool skip=false; - if (dupecheck) + if (checkDupe(&ctx,hashes,dupes,i)) { - for (int j = 0; j < gnAG; j++) - MD5Update(&ctx, - (const uint8_t*)gpAG[j].surface->pixels, - gpAG[j].surface->h * gpAG[j].surface->pitch); - - if (checkDupe(&ctx,hashes,dupes,i)) - { - printf("**** duplicate of %s\n", files[dupes[i]].GetPath()); - file.GetFrames().insert(file.GetFrames().end(), - files[dupes[i]].GetFrames().begin(), files[dupes[i]].GetFrames().end()); - skip = true; - } + printf("**** duplicate of %s\n", files[dupes[i]].GetPath()); + file.GetFrames().insert(file.GetFrames().end(), + files[dupes[i]].GetFrames().begin(), + files[dupes[i]].GetFrames().end()); + skip = true; } + } - if (!skip) + if (!skip) + { + for (unsigned int j = 0; j < frames.frameList.size(); j++) { - for (int j = 0; j < gnAG; j++) - { - printf(" frame %4i ", j); - CXBTFFrame frame = createXBTFFrame(gpAG[j].surface, writer, maxMSE, flags); - frame.SetDuration(gpAG[j].delay); - file.GetFrames().push_back(frame); - printf("%s%c (%d,%d @ %"PRIu64" bytes)\n", GetFormatString(frame.GetFormat()), frame.HasAlpha() ? ' ' : '*', - frame.GetWidth(), frame.GetHeight(), frame.GetUnpackedSize()); - } + printf(" frame %4i ", j); + CXBTFFrame frame = createXBTFFrame(frames.frameList[j].rgbaImage, writer, maxMSE, flags); + frame.SetDuration(frames.frameList[j].delay); + file.GetFrames().push_back(frame); + printf("%s%c (%d,%d @ %"PRIu64" bytes)\n", GetFormatString(frame.GetFormat()), frame.HasAlpha() ? ' ' : '*', + frame.GetWidth(), frame.GetHeight(), frame.GetUnpackedSize()); } - AG_FreeSurfaces(gpAG, gnAG); - delete [] gpAG; - - file.SetLoop(0); } + DecoderManager::FreeDecodedFrames(frames); + file.SetLoop(0); } if (!writer.UpdateHeader(dupes)) { - printf("Error writing header to file\n"); + fprintf(stderr, "Error writing header to file\n"); return 1; } if (!writer.Close()) { - printf("Error closing file\n"); + fprintf(stderr, "Error closing file\n"); return 1; } @@ -557,12 +440,12 @@ int main(int argc, char* argv[]) for (unsigned int i = 1; i < args.size(); ++i) { - if (!stricmp(args[i], "-help") || !stricmp(args[i], "-h") || !stricmp(args[i], "-?")) + if (!platform_stricmp(args[i], "-help") || !platform_stricmp(args[i], "-h") || !platform_stricmp(args[i], "-?")) { Usage(); return 1; } - else if (!stricmp(args[i], "-input") || !stricmp(args[i], "-i")) + else if (!platform_stricmp(args[i], "-input") || !platform_stricmp(args[i], "-i")) { InputDir = args[++i]; valid = true; @@ -571,7 +454,7 @@ int main(int argc, char* argv[]) { dupecheck = true; } - else if (!stricmp(args[i], "-output") || !stricmp(args[i], "-o")) + else if (!platform_stricmp(args[i], "-output") || !platform_stricmp(args[i], "-o")) { OutputFilename = args[++i]; valid = true; @@ -580,23 +463,23 @@ int main(int argc, char* argv[]) while ((c = (char *)strchr(OutputFilename.c_str(), '\\')) != NULL) *c = '/'; #endif } - else if (!stricmp(args[i], "-use_none")) + else if (!platform_stricmp(args[i], "-use_none")) { flags &= ~FLAGS_USE_DXT; } - else if (!stricmp(args[i], "-use_dxt")) + else if (!platform_stricmp(args[i], "-use_dxt")) { flags |= FLAGS_USE_DXT; } #ifdef USE_LZO_PACKING - else if (!stricmp(args[i], "-use_lzo")) + else if (!platform_stricmp(args[i], "-use_lzo")) { flags |= FLAGS_USE_LZO; } #endif else { - printf("Unrecognized command line flag: %s\n", args[i]); + fprintf(stderr, "Unrecognized command line flag: %s\n", args[i]); } } @@ -611,5 +494,7 @@ int main(int argc, char* argv[]) InputDir += DIR_SEPARATOR; double maxMSE = 1.5; // HQ only please + DecoderManager::InstantiateDecoders(); createBundle(InputDir, OutputFilename, maxMSE, flags, dupecheck); + DecoderManager::FreeDecoders(); } diff --git a/tools/TexturePacker/Win32/TexturePacker.sln b/tools/depends/native/TexturePacker/src/Win32/TexturePacker.sln index f1cacec3c7..07cd920b3f 100644 --- a/tools/TexturePacker/Win32/TexturePacker.sln +++ b/tools/depends/native/TexturePacker/src/Win32/TexturePacker.sln @@ -1,26 +1,22 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C++ Express 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TexturePacker", "TexturePacker.vcxproj", "{57EC0A84-7E0C-4EEA-9E63-BB4EBF2310D7}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MakeDDS", "MakeDDS.vcxproj", "{E85454A0-D9CF-4480-A9AE-AE2A7C3FBAD6}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {57EC0A84-7E0C-4EEA-9E63-BB4EBF2310D7}.Debug|Win32.ActiveCfg = Debug|Win32 - {57EC0A84-7E0C-4EEA-9E63-BB4EBF2310D7}.Debug|Win32.Build.0 = Debug|Win32 - {57EC0A84-7E0C-4EEA-9E63-BB4EBF2310D7}.Release|Win32.ActiveCfg = Release|Win32 - {57EC0A84-7E0C-4EEA-9E63-BB4EBF2310D7}.Release|Win32.Build.0 = Release|Win32 - {E85454A0-D9CF-4480-A9AE-AE2A7C3FBAD6}.Debug|Win32.ActiveCfg = Debug|Win32 - {E85454A0-D9CF-4480-A9AE-AE2A7C3FBAD6}.Debug|Win32.Build.0 = Debug|Win32 - {E85454A0-D9CF-4480-A9AE-AE2A7C3FBAD6}.Release|Win32.ActiveCfg = Release|Win32 - {E85454A0-D9CF-4480-A9AE-AE2A7C3FBAD6}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal +
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.30723.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TexturePacker", "TexturePacker.vcxproj", "{57EC0A84-7E0C-4EEA-9E63-BB4EBF2310D7}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {57EC0A84-7E0C-4EEA-9E63-BB4EBF2310D7}.Debug|Win32.ActiveCfg = Debug|Win32
+ {57EC0A84-7E0C-4EEA-9E63-BB4EBF2310D7}.Debug|Win32.Build.0 = Debug|Win32
+ {57EC0A84-7E0C-4EEA-9E63-BB4EBF2310D7}.Release|Win32.ActiveCfg = Release|Win32
+ {57EC0A84-7E0C-4EEA-9E63-BB4EBF2310D7}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/tools/TexturePacker/Win32/TexturePacker.vcxproj b/tools/depends/native/TexturePacker/src/Win32/TexturePacker.vcxproj index 900a833144..1c75bae91c 100644 --- a/tools/TexturePacker/Win32/TexturePacker.vcxproj +++ b/tools/depends/native/TexturePacker/src/Win32/TexturePacker.vcxproj @@ -1,117 +1,135 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <ProjectGuid>{57EC0A84-7E0C-4EEA-9E63-BB4EBF2310D7}</ProjectGuid> - <RootNamespace>TexturePacker</RootNamespace> - <Keyword>Win32Proj</Keyword> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <CharacterSet>NotSet</CharacterSet> - <WholeProgramOptimization>true</WholeProgramOptimization> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <CharacterSet>NotSet</CharacterSet> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <ImportGroup Label="ExtensionSettings"> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <PropertyGroup Label="UserMacros" /> - <PropertyGroup> - <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir> - <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir> - <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> - <IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;..\..\..\project\BuildDependencies\include</IncludePath> - <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;..\..\..\project\BuildDependencies\lib</LibraryPath> - <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;..\..\..\project\BuildDependencies\include</IncludePath> - <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;..\..\..\project\BuildDependencies\lib</LibraryPath> - </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <Optimization>Disabled</Optimization> - <AdditionalIncludeDirectories>.;..\..\..\xbmc;..\..\..\lib;..\..\..\xbmc\win32%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <MinimalRebuild>true</MinimalRebuild> - <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>EditAndContinue</DebugInformationFormat> - </ClCompile> - <Link> - <AdditionalDependencies>SDL.lib;SDL_image.lib;..\..\..\project\VS2010Express\libs\squish\Debug\squishd.lib;..\..\..\lib\win32\liblzo\lzo.lib;%(AdditionalDependencies)</AdditionalDependencies> - <IgnoreSpecificDefaultLibraries>libc.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> - <GenerateDebugInformation>true</GenerateDebugInformation> - <SubSystem>Console</SubSystem> - <TargetMachine>MachineX86</TargetMachine> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <Optimization>MaxSpeed</Optimization> - <IntrinsicFunctions>true</IntrinsicFunctions> - <AdditionalIncludeDirectories>.;..\..\..\xbmc;..\..\..\lib;..\..\..\xbmc\win32%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;USE_LZO_PACKING;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> - <FunctionLevelLinking>true</FunctionLevelLinking> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> - </ClCompile> - <Link> - <AdditionalDependencies>SDL.lib;SDL_image.lib;..\..\..\project\VS2010Express\libs\squish\Release\squish.lib;..\..\..\lib\win32\liblzo\lzo.lib;%(AdditionalDependencies)</AdditionalDependencies> - <IgnoreSpecificDefaultLibraries>libc.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> - <GenerateDebugInformation>true</GenerateDebugInformation> - <SubSystem>Console</SubSystem> - <OptimizeReferences>true</OptimizeReferences> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <TargetMachine>MachineX86</TargetMachine> - </Link> - </ItemDefinitionGroup> - <ItemGroup> - <ClCompile Include="..\md5.cpp" /> - <ClCompile Include="..\SDL_anigif.cpp" /> - <ClCompile Include="dirent.c" /> - <ClCompile Include="..\XBMCTex.cpp" /> - <ClCompile Include="..\..\..\xbmc\guilib\XBTF.cpp" /> - <ClCompile Include="..\XBTFWriter.cpp" /> - </ItemGroup> - <ItemGroup> - <ClInclude Include="..\cmdlineargs.h" /> - <ClInclude Include="dirent.h" /> - <ClInclude Include="..\md5.h" /> - <ClInclude Include="..\SDL_anigif.h" /> - <ClInclude Include="..\..\..\xbmc\guilib\XBTF.h" /> - <ClInclude Include="..\XBTFWriter.h" /> - </ItemGroup> - <ItemGroup> - <None Include="ReadMe.txt" /> - </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <ImportGroup Label="ExtensionTargets"> - </ImportGroup> +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{57EC0A84-7E0C-4EEA-9E63-BB4EBF2310D7}</ProjectGuid>
+ <RootNamespace>TexturePacker</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>NotSet</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>NotSet</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;..\..\..\..\..\..\project\BuildDependencies\include</IncludePath>
+ <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;..\..\..\..\..\..\project\BuildDependencies\lib</LibraryPath>
+ <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;..\..\..\..\..\..\project\BuildDependencies\include</IncludePath>
+ <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;..\..\..\..\..\..\project\BuildDependencies\lib</LibraryPath>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>.;..;..\decoder;..\..\..\..\..\..\xbmc;..\..\..\..\..\..\lib;..\..\..\libsquish-native\src;$(WindowsSDK_IncludePath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;TARGET_WINDOWS;_ITERATOR_DEBUG_LEVEL=0;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>..\..\..\..\..\..\project\VS2010Express\libs\squish\Debug\squishd.lib;..\..\..\..\..\..\project\BuildDependencies\lib\jpeg-static.lib;..\..\..\..\..\..\project\BuildDependencies\lib\libpng15d.lib;..\..\..\..\..\..\project\BuildDependencies\lib\libgif-static.lib;..\..\..\..\..\..\project\BuildDependencies\lib\zlibd-static.lib;..\..\..\..\..\..\lib\win32\liblzo\lzo.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <IgnoreSpecificDefaultLibraries>libcmtd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineX86</TargetMachine>
+ <AdditionalLibraryDirectories>$(WindowsSDK_LibraryPath_x86);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <AdditionalIncludeDirectories>.;..;..\decoder;..\..\..\..\..\..\xbmc;..\..\..\..\..\..\lib;..\..\..\libsquish-native\src;$(WindowsSDK_IncludePath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;USE_LZO_PACKING;TARGET_WINDOWS;_ITERATOR_DEBUG_LEVEL=0;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>..\..\..\..\..\..\project\VS2010Express\libs\squish\Release\squish.lib;..\..\..\..\..\..\project\BuildDependencies\lib\jpeg-static.lib;..\..\..\..\..\..\project\BuildDependencies\lib\libpng15.lib;..\..\..\..\..\..\project\BuildDependencies\lib\libgif-static.lib;..\..\..\..\..\..\project\BuildDependencies\lib\zlib-static.lib;..\..\..\..\..\..\lib\win32\liblzo\lzo.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <IgnoreSpecificDefaultLibraries>libc.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineX86</TargetMachine>
+ <AdditionalLibraryDirectories>$(WindowsSDK_LibraryPath_x86);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\DecoderManager.cpp" />
+ <ClCompile Include="..\decoder\GIFDecoder.cpp" />
+ <ClCompile Include="..\decoder\GifHelper.cpp" />
+ <ClCompile Include="..\decoder\JPGDecoder.cpp" />
+ <ClCompile Include="..\decoder\PNGDecoder.cpp" />
+ <ClCompile Include="..\md5.cpp" />
+ <ClCompile Include="..\TexturePacker.cpp" />
+ <ClCompile Include="dirent.c" />
+ <ClCompile Include="..\..\..\..\..\..\xbmc\guilib\XBTF.cpp" />
+ <ClCompile Include="..\XBTFWriter.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\cmdlineargs.h" />
+ <ClInclude Include="..\DecoderManager.h" />
+ <ClInclude Include="..\decoder\GIFDecoder.h" />
+ <ClInclude Include="..\decoder\GifHelper.h" />
+ <ClInclude Include="..\decoder\IDecoder.h" />
+ <ClInclude Include="..\decoder\JPGDecoder.h" />
+ <ClInclude Include="..\decoder\PNGDecoder.h" />
+ <ClInclude Include="..\Gif.h" />
+ <ClInclude Include="..\rgbaimage.h" />
+ <ClInclude Include="dirent.h" />
+ <ClInclude Include="..\md5.h" />
+ <ClInclude Include="..\SDL_anigif.h" />
+ <ClInclude Include="..\..\..\..\..\..\xbmc\guilib\XBTF.h" />
+ <ClInclude Include="..\XBTFWriter.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="ReadMe.txt" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
</Project>
\ No newline at end of file diff --git a/tools/TexturePacker/Win32/TexturePacker.vcxproj.filters b/tools/depends/native/TexturePacker/src/Win32/TexturePacker.vcxproj.filters index b212ae080f..a0dbdb2953 100644 --- a/tools/TexturePacker/Win32/TexturePacker.vcxproj.filters +++ b/tools/depends/native/TexturePacker/src/Win32/TexturePacker.vcxproj.filters @@ -1,60 +1,99 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - <Filter Include="Source Files"> - <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> - <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> - </Filter> - <Filter Include="Header Files"> - <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> - <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> - </Filter> - <Filter Include="Resource Files"> - <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> - <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions> - </Filter> - </ItemGroup> - <ItemGroup> - <ClCompile Include="dirent.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\XBMCTex.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\..\xbmc\guilib\XBTF.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\XBTFWriter.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\SDL_anigif.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\md5.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - </ItemGroup> - <ItemGroup> - <ClInclude Include="..\cmdlineargs.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="dirent.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\md5.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\SDL_anigif.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\..\..\xbmc\guilib\XBTF.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\XBTFWriter.h"> - <Filter>Header Files</Filter> - </ClInclude> - </ItemGroup> - <ItemGroup> - <None Include="ReadMe.txt" /> - </ItemGroup> +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
+ </Filter>
+ <Filter Include="decoder">
+ <UniqueIdentifier>{c79bff3f-9118-4c2d-bc31-68b25f7dfbba}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="dirent.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\..\..\xbmc\guilib\XBTF.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\XBTFWriter.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\md5.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\decoder\GIFDecoder.cpp">
+ <Filter>decoder</Filter>
+ </ClCompile>
+ <ClCompile Include="..\decoder\GifHelper.cpp">
+ <Filter>decoder</Filter>
+ </ClCompile>
+ <ClCompile Include="..\decoder\JPGDecoder.cpp">
+ <Filter>decoder</Filter>
+ </ClCompile>
+ <ClCompile Include="..\decoder\PNGDecoder.cpp">
+ <Filter>decoder</Filter>
+ </ClCompile>
+ <ClCompile Include="..\TexturePacker.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\DecoderManager.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\cmdlineargs.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="dirent.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\md5.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\SDL_anigif.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\..\..\xbmc\guilib\XBTF.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\XBTFWriter.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\Gif.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\rgbaimage.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\decoder\GIFDecoder.h">
+ <Filter>decoder</Filter>
+ </ClInclude>
+ <ClInclude Include="..\decoder\GifHelper.h">
+ <Filter>decoder</Filter>
+ </ClInclude>
+ <ClInclude Include="..\decoder\IDecoder.h">
+ <Filter>decoder</Filter>
+ </ClInclude>
+ <ClInclude Include="..\decoder\JPGDecoder.h">
+ <Filter>decoder</Filter>
+ </ClInclude>
+ <ClInclude Include="..\decoder\PNGDecoder.h">
+ <Filter>decoder</Filter>
+ </ClInclude>
+ <ClInclude Include="..\DecoderManager.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="ReadMe.txt" />
+ </ItemGroup>
</Project>
\ No newline at end of file diff --git a/tools/TexturePacker/Win32/dirent.c b/tools/depends/native/TexturePacker/src/Win32/dirent.c index 7b38291c6f..7b38291c6f 100644 --- a/tools/TexturePacker/Win32/dirent.c +++ b/tools/depends/native/TexturePacker/src/Win32/dirent.c diff --git a/tools/TexturePacker/Win32/dirent.h b/tools/depends/native/TexturePacker/src/Win32/dirent.h index 6c85abdb58..6c85abdb58 100644 --- a/tools/TexturePacker/Win32/dirent.h +++ b/tools/depends/native/TexturePacker/src/Win32/dirent.h diff --git a/tools/TexturePacker/XBTFWriter.cpp b/tools/depends/native/TexturePacker/src/XBTFWriter.cpp index 339990c412..339990c412 100644 --- a/tools/TexturePacker/XBTFWriter.cpp +++ b/tools/depends/native/TexturePacker/src/XBTFWriter.cpp diff --git a/tools/TexturePacker/XBTFWriter.h b/tools/depends/native/TexturePacker/src/XBTFWriter.h index c8fb44450c..c8fb44450c 100644 --- a/tools/TexturePacker/XBTFWriter.h +++ b/tools/depends/native/TexturePacker/src/XBTFWriter.h diff --git a/tools/depends/native/TexturePacker/src/autogen.sh b/tools/depends/native/TexturePacker/src/autogen.sh new file mode 100755 index 0000000000..bbec436c4c --- /dev/null +++ b/tools/depends/native/TexturePacker/src/autogen.sh @@ -0,0 +1,3 @@ +#/bin/sh + +autoreconf -vif diff --git a/tools/TexturePacker/cmdlineargs.h b/tools/depends/native/TexturePacker/src/cmdlineargs.h index 740c9038a2..740c9038a2 100644 --- a/tools/TexturePacker/cmdlineargs.h +++ b/tools/depends/native/TexturePacker/src/cmdlineargs.h diff --git a/tools/depends/native/TexturePacker/src/configure.ac b/tools/depends/native/TexturePacker/src/configure.ac new file mode 100644 index 0000000000..a00ad023b5 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/configure.ac @@ -0,0 +1,49 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(TexturePacker, 1.0) +AC_CONFIG_AUX_DIR(config) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_SRCDIR(TexturePacker.cpp) +AM_INIT_AUTOMAKE([foreign]) +AC_PROG_CXX +AC_LANG([C++]) +AC_C_BIGENDIAN + +abs_top_srcdir=${abs_top_srcdir=$(cd $srcdir; pwd)} +KODI_SRC_DIR=${KODI_SRC_DIR:-"${abs_top_srcdir}/../../../../.."} + +AC_ARG_ENABLE([static], + [AS_HELP_STRING([--enable-static], + [build static TexturePacker (default is no)])], + [STATIC_FLAG="-static"], + [STATIC_FLAG=""]) + + +PKG_CHECK_MODULES([PNG], [libpng], + [INCLUDES="$PNG_CFLAGS"; LIBS="$LIBS $(pkg-config --silence-errors --static --libs libpng)"], + AC_MSG_ERROR("libpng not found")) + +AC_CHECK_HEADER([gif_lib.h],, AC_MSG_ERROR("gif_lib.h not found")) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gif_lib.h>]], [[ +#if !defined GIFLIB_MAJOR || GIFLIB_MAJOR < 5 +#error libgif version < 5; +#endif ]])], [], [AC_MSG_NOTICE([[WARNING: libgif version is unsupported, please consider upgrading to 5.0.5 or higher.]])]) + +AC_CHECK_LIB([gif],[main],, AC_MSG_ERROR("libgif not found")) +AC_CHECK_HEADER([jpeglib.h],, AC_MSG_ERROR("jpeglib.h not found")) +AC_CHECK_LIB([jpeg],[main],, AC_MSG_ERROR("libjpeg not found")) +AC_CHECK_HEADER([lzo/lzo1x.h],, AC_MSG_ERROR("lzo/lzo1x.h not found")) +AC_CHECK_LIB([lzo2],[main],, AC_MSG_ERROR("liblzo2 not found")) + +# we don't compile with default upstream squish, so we use our own one +# even on non unified deps platforms +export PKG_CONFIG_PATH="${abs_top_srcdir}/../../libsquish-native/squish-install/lib/pkgconfig:$PKG_CONFIG_PATH" +PKG_CHECK_MODULES([SQUISH], [squish], + [CPPFLAGS="$CPPFLAGS $SQUISH_CFLAGS" LIBS="$LIBS $SQUISH_LIBS"], + AC_MSG_ERROR("libsquish not found")) + + +AC_SUBST(KODI_SRC_DIR) +AC_SUBST(STATIC_FLAG) +AC_SUBST(EXTRA_DEFINES) + +AC_OUTPUT(Makefile) diff --git a/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.cpp b/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.cpp new file mode 100644 index 0000000000..67e6d24389 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.cpp @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include <cstring> +#include "GIFDecoder.h" +#include "GifHelper.h" + +// returns true for gif files, otherwise returns false +bool GIFDecoder::CanDecode(const std::string &filename) +{ + return std::string::npos != filename.rfind(".gif",filename.length() - 4, 4); +} + +bool GIFDecoder::LoadFile(const std::string &filename, DecodedFrames &frames) +{ + int n = 0; + GifHelper *gifImage = new GifHelper(); + if (gifImage->LoadGif(filename.c_str())) + { + std::vector<GifFrame> extractedFrames = gifImage->GetFrames(); + n = extractedFrames.size(); + if (n > 0) + { + for (unsigned int i = 0; i < extractedFrames.size(); i++) + { + DecodedFrame frame; + + frame.rgbaImage.pixels = (char *)new char[extractedFrames[i].m_imageSize]; + memcpy(frame.rgbaImage.pixels, extractedFrames[i].m_pImage, extractedFrames[i].m_imageSize); + frame.rgbaImage.height = extractedFrames[i].m_height; + frame.rgbaImage.width = extractedFrames[i].m_width; + frame.rgbaImage.bbp = 32; + frame.rgbaImage.pitch = extractedFrames[i].m_pitch; + + frame.delay = extractedFrames[i].m_delay; + frame.disposal = extractedFrames[i].m_disposal; + frame.x = extractedFrames[i].m_left; + frame.y = extractedFrames[i].m_top; + + + frames.frameList.push_back(frame); + } + } + frames.user = gifImage; + return true; + } + else + { + delete gifImage; + return false; + } +} + +void GIFDecoder::FreeDecodedFrames(DecodedFrames &frames) +{ + for (unsigned int i = 0; i < frames.frameList.size(); i++) + { + delete [] frames.frameList[i].rgbaImage.pixels; + } + delete (GifHelper *)frames.user; + frames.clear(); +} + +void GIFDecoder::FillSupportedExtensions() +{ + m_supportedExtensions.push_back(".gif"); +} diff --git a/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.h b/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.h new file mode 100644 index 0000000000..ce826daeb6 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#pragma once +#include "IDecoder.h" + +class GIFDecoder : public IDecoder +{ + public: + virtual ~GIFDecoder(){} + virtual bool CanDecode(const std::string &filename); + virtual bool LoadFile(const std::string &filename, DecodedFrames &frames); + virtual void FreeDecodedFrames(DecodedFrames &frames); + virtual const char* GetImageFormatName() { return "GIF"; } + virtual const char* GetDecoderName() { return "libgif"; } + protected: + virtual void FillSupportedExtensions(); +};
\ No newline at end of file diff --git a/tools/depends/native/TexturePacker/src/decoder/GifHelper.cpp b/tools/depends/native/TexturePacker/src/decoder/GifHelper.cpp new file mode 100644 index 0000000000..8b65cf613b --- /dev/null +++ b/tools/depends/native/TexturePacker/src/decoder/GifHelper.cpp @@ -0,0 +1,576 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "GifHelper.h" +#include <algorithm> +#include <stdlib.h> +#include <cstring> + +#define UNSIGNED_LITTLE_ENDIAN(lo, hi) ((lo) | ((hi) << 8)) +#define GIF_MAX_MEMORY 82944000U // about 79 MB, which is equivalent to 10 full hd frames. + +class Gifreader +{ +public: + unsigned char* buffer; + unsigned int buffSize; + unsigned int readPosition; + + Gifreader() : buffer(NULL), buffSize(0), readPosition(0) {} +}; + +int ReadFromMemory(GifFileType* gif, GifByteType* gifbyte, int len) +{ + unsigned int alreadyRead = ((Gifreader*)gif->UserData)->readPosition; + unsigned int buffSizeLeft = ((Gifreader*)gif->UserData)->buffSize - alreadyRead; + int readBytes = len; + + if (len <= 0) + readBytes = 0; + + if ((unsigned int)len > buffSizeLeft) + readBytes = buffSizeLeft; + + if (readBytes > 0) + { + unsigned char* src = ((Gifreader*)gif->UserData)->buffer + alreadyRead; + memcpy(gifbyte, src, readBytes); + ((Gifreader*)gif->UserData)->readPosition += readBytes; + } + return readBytes; +} + +int ReadFromVfs(GifFileType* gif, GifByteType* gifbyte, int len) +{ + CFile *gifFile = (CFile *)gif->UserData; + return (int)gifFile->Read(gifbyte, len); +} + + +GifHelper::GifHelper() : + m_imageSize(0), + m_pitch(0), + m_loops(0), + m_numFrames(0), + m_filename(""), + m_gif(NULL), + m_hasBackground(false), + m_pTemplate(NULL), + m_isAnimated(-1) +{ + m_backColor = new COLOR(); + memset(m_backColor, 0, sizeof(COLOR)); + m_frames.clear(); +} + +GifHelper::~GifHelper() +{ + int err = DGifCloseFile(m_gif); + if (err == D_GIF_ERR_CLOSE_FAILED) + { + fprintf(stderr, "Gif::~Gif(): D_GIF_ERR_CLOSE_FAILED\n"); + free(m_gif); + } + Release(); + delete m_backColor; +} + +void GifHelper::Release() +{ + delete[] m_pTemplate; + m_pTemplate = NULL; + m_globalPalette.clear(); + m_frames.clear(); +} + +void GifHelper::ConvertColorTable(std::vector<COLOR> &dest, ColorMapObject* src, unsigned int size) +{ + for (unsigned int i = 0; i < size; ++i) + { + COLOR c; + + c.r = src->Colors[i].Red; + c.g = src->Colors[i].Green; + c.b = src->Colors[i].Blue; + c.x = 0xff; + dest.push_back(c); + } +} + +bool GifHelper::LoadGifMetaData(GifFileType* file) +{ + if (DGifSlurp(m_gif) == GIF_ERROR) + { +#if GIFLIB_MAJOR >= 5 + char* error = GifErrorString(m_gif->Error); + if (error) + fprintf(stderr, "Gif::LoadGif(): Could not read file %s - %s\n", m_filename.c_str(), error); +#else + int error = GifLastError(); + if (error) + fprintf(stderr, "Gif::LoadGif(): Could not read file %s - %d\n", m_filename.c_str(), error); +#endif + else + fprintf(stderr, "Gif::LoadGif(): Could not read file %s (reasons unknown)\n", m_filename.c_str()); + return false; + } + + m_height = m_gif->SHeight; + m_width = m_gif->SWidth; + if (!m_height || !m_width) + { + fprintf(stderr, "Gif::LoadGif(): Zero sized image. File %s\n", m_filename.c_str()); + return false; + } + + m_numFrames = m_gif->ImageCount; + if (m_numFrames > 0) + { +#if GIFLIB_MAJOR >= 5 + GraphicsControlBlock GCB; + DGifSavedExtensionToGCB(m_gif, 0, &GCB); + ExtensionBlock* extb = m_gif->SavedImages[0].ExtensionBlocks; + if (extb && extb->Function == APPLICATION_EXT_FUNC_CODE) + { + // Read number of loops + if(++extb && extb->Function == CONTINUE_EXT_FUNC_CODE) + { + m_loops = UNSIGNED_LITTLE_ENDIAN(extb->Bytes[1],extb->Bytes[2]); + } + } +#endif + } + else + { + fprintf(stderr, "Gif::LoadGif(): No images found in file %s\n", m_filename.c_str()); + return false; + } + + m_pitch = m_width * sizeof(COLOR); + m_imageSize = m_pitch * m_height; + unsigned long memoryUsage = m_numFrames * m_imageSize; + if (memoryUsage > GIF_MAX_MEMORY) + { + // at least 1 image + m_numFrames = std::max(1U, GIF_MAX_MEMORY / m_imageSize); + fprintf(stderr, "Gif::LoadGif(): Memory consumption too high: %lu bytes. Restricting animation to %u. File %s\n", memoryUsage, m_numFrames, m_filename.c_str()); + } + + return true; +} + +bool GifHelper::LoadGifMetaData(const char* file) +{ + int err = 0; + + if (m_gifFile.Open(file)) +#if GIFLIB_MAJOR >= 5 + m_gif = DGifOpen(&m_gifFile, ReadFromVfs, &err); +#else + m_gif = DGifOpen(&m_gifFile, ReadFromVfs); +#endif + + if (!m_gif) + { +#if GIFLIB_MAJOR >= 5 + char* error = GifErrorString(err); + if (error) + fprintf(stderr, "Gif::LoadGif(): Could not open file %s - %s\n", m_filename.c_str(), error); +#else + int error = GifLastError(); + if (error) + fprintf(stderr, "Gif::LoadGif(): Could not open file %s - %d\n", m_filename.c_str(), error); +#endif + else + fprintf(stderr, "Gif::LoadGif(): Could not open file %s (reasons unknown)\n", m_filename.c_str()); + return false; + } + return LoadGifMetaData(m_gif); +} + +bool GifHelper::LoadGif(const char* file) +{ + m_filename = file; + if (!LoadGifMetaData(m_filename.c_str())) + return false; + + try + { + InitTemplateAndColormap(); + + return ExtractFrames(m_numFrames); + } + catch (std::bad_alloc& ba) + { + fprintf(stderr, "Gif::Load(): Out of memory while reading file %s - %s\n", m_filename.c_str(), ba.what()); + Release(); + return false; + } +} + +bool GifHelper::IsAnimated(const char* file) +{ + if (m_isAnimated < 0) + { + m_isAnimated = 0; + + GifFileType *gif = NULL; + FILE *gifFile; + int err = 0; + gifFile = fopen(file, "rb"); + if (gifFile != NULL) + { +#if GIFLIB_MAJOR >= 5 + gif = DGifOpen(&gifFile, ReadFromVfs, &err); +#else + gif = DGifOpen(&gifFile, ReadFromVfs); +#endif + } + + if (gif) + { + if (DGifSlurp(gif) && gif->ImageCount > 1) + m_isAnimated = 1; + DGifCloseFile(gif); + fclose(gifFile); + } + } + return m_isAnimated > 0; +} + +void GifHelper::InitTemplateAndColormap() +{ + m_pTemplate = new unsigned char[m_imageSize]; + memset(m_pTemplate, 0, m_imageSize); + + if (m_gif->SColorMap) + { + m_globalPalette.clear(); + ConvertColorTable(m_globalPalette, m_gif->SColorMap, m_gif->SColorMap->ColorCount); + + // draw the canvas + *m_backColor = m_globalPalette[m_gif->SBackGroundColor]; + m_hasBackground = true; + + for (unsigned int i = 0; i < m_height * m_width; ++i) + { + unsigned char *dest = m_pTemplate + (i *sizeof(COLOR)); + memcpy(dest, m_backColor, sizeof(COLOR)); + } + } + else + m_globalPalette.clear(); +} + +bool GifHelper::gcbToFrame(GifFrame &frame, unsigned int imgIdx) +{ + int transparent = -1; + frame.m_delay = 0; + frame.m_disposal = 0; +#if GIFLIB_MAJOR >= 5 + if (m_gif->ExtensionBlockCount > 0) + { + GraphicsControlBlock gcb; + if (!DGifSavedExtensionToGCB(m_gif, imgIdx, &gcb)) + { + char* error = GifErrorString(m_gif->Error); + if (error) + fprintf(stderr, "Gif::ExtractFrames(): Could not read GraphicsControlBlock of frame %d - %s\n", imgIdx, error); + else + fprintf(stderr, "Gif::ExtractFrames(): Could not read GraphicsControlBlock of frame %d (reasons unknown)\n", imgIdx); + return false; + } + // delay in ms + frame.m_delay = gcb.DelayTime * 10; + frame.m_disposal = gcb.DisposalMode; + transparent = gcb.TransparentColor; + } +#else + if (m_gif->ImageCount > 0) + { + ExtensionBlock* extb = m_gif->SavedImages[imgIdx].ExtensionBlocks; + while (extb && extb->Function != GRAPHICS_EXT_FUNC_CODE) + extb++; + + if (extb) + { + frame.m_delay = UNSIGNED_LITTLE_ENDIAN(extb->Bytes[1], extb->Bytes[2]) * 10; + frame.m_disposal = (extb->Bytes[0] >> 2) & 0x7; + if (extb->Bytes[0] & 0x1) + transparent = extb->Bytes[3]; + else + transparent = -1; + } + } +#endif + + if (transparent >= 0 && (unsigned)transparent < frame.m_palette.size()) + frame.m_palette[transparent].x = 0; + return true; +} + +bool GifHelper::ExtractFrames(unsigned int count) +{ + if (!m_gif) + return false; + + if (!m_pTemplate) + { + fprintf(stderr, "Gif::ExtractFrames(): No frame template available\n"); + return false; + } + + for (unsigned int i = 0; i < count; i++) + { + GifFrame frame; + SavedImage savedImage = m_gif->SavedImages[i]; + GifImageDesc imageDesc = m_gif->SavedImages[i].ImageDesc; + frame.m_height = imageDesc.Height; + frame.m_width = imageDesc.Width; + frame.m_top = imageDesc.Top; + frame.m_left = imageDesc.Left; + frame.m_pitch = m_pitch; + + if (frame.m_top + frame.m_height > m_height || frame.m_left + frame.m_width > m_width + || !frame.m_width || !frame.m_height) + { + fprintf(stderr, "Gif::ExtractFrames(): Illegal frame dimensions: width: %d, height: %d, left: %d, top: %d instead of (%d,%d)\n", + frame.m_width, frame.m_height, frame.m_left, frame.m_top, m_width, m_height); + return false; + } + + if (imageDesc.ColorMap) + { + frame.m_palette.clear(); + ConvertColorTable(frame.m_palette, imageDesc.ColorMap, imageDesc.ColorMap->ColorCount); + // TODO save a backup of the palette for frames without a table in case there's no gloabl table. + } + else if (m_gif->SColorMap) + { + frame.m_palette = m_globalPalette; + } + + // fill delay, disposal and transparent color into frame + if (!gcbToFrame(frame, i)) + return false; + + frame.m_pImage = new unsigned char[m_imageSize]; + frame.m_imageSize = m_imageSize; + memcpy(frame.m_pImage, m_pTemplate, m_imageSize); + + ConstructFrame(frame, savedImage.RasterBits); + + if(!PrepareTemplate(frame)) + return false; + + m_frames.push_back(frame); + } + return true; +} + +void GifHelper::ConstructFrame(GifFrame &frame, const unsigned char* src) const +{ + for (unsigned int dest_y = frame.m_top, src_y = 0; src_y < frame.m_height; ++dest_y, ++src_y) + { + unsigned char *to = frame.m_pImage + (dest_y * m_pitch) + (frame.m_left * sizeof(COLOR)); + + const unsigned char *from = src + (src_y * frame.m_width); + for (unsigned int src_x = 0; src_x < frame.m_width; ++src_x) + { + COLOR col = frame.m_palette[*from++]; + if (col.x != 0) + { + *to++ = col.b; + *to++ = col.g; + *to++ = col.r; + *to++ = col.x; + } + else + { + to += 4; + } + } + } +} + +bool GifHelper::PrepareTemplate(const GifFrame &frame) +{ +#if GIFLIB_MAJOR >= 5 + switch (frame.m_disposal) + { + /* No disposal specified. */ + case DISPOSAL_UNSPECIFIED: + /* Leave image in place */ + case DISPOSE_DO_NOT: + memcpy(m_pTemplate, frame.m_pImage, m_imageSize); + break; + + /* Set area too background color */ + case DISPOSE_BACKGROUND: + { + if (!m_hasBackground) + { + fprintf(stderr, "Gif::PrepareTemplate(): Disposal method DISPOSE_BACKGROUND encountered, but the gif has no background.\n"); + return false; + } + SetFrameAreaToBack(m_pTemplate, frame); + break; + } + /* Restore to previous content */ + case DISPOSE_PREVIOUS: + { + bool valid = false; + + for (int i = m_frames.size() - 1 ; i >= 0; --i) + { + if (m_frames[i].m_disposal != DISPOSE_PREVIOUS) + { + memcpy(m_pTemplate, m_frames[i].m_pImage, m_imageSize); + valid = true; + break; + } + } + if (!valid) + { + fprintf(stderr, "Gif::PrepareTemplate(): Disposal method DISPOSE_PREVIOUS encountered, but could not find a suitable frame.\n"); + return false; + } + break; + } + default: + { + fprintf(stderr, "Gif::PrepareTemplate(): Unknown disposal method: %d\n", frame.m_disposal); + return false; + } + } +#endif + return true; +} + +void GifHelper::SetFrameAreaToBack(unsigned char* dest, const GifFrame &frame) +{ + for (unsigned int dest_y = frame.m_top, src_y = 0; src_y < frame.m_height; ++dest_y, ++src_y) + { + unsigned char *to = dest + (dest_y * m_pitch) + (frame.m_left * sizeof(COLOR)); + for (unsigned int src_x = 0; src_x < frame.m_width; ++src_x) + { + memcpy(to, m_backColor, sizeof(COLOR)); + to += 4; + } + } +} + +bool GifHelper::LoadImageFromMemory(unsigned char* buffer, unsigned int bufSize, unsigned int width, unsigned int height) +{ + if (!buffer || !bufSize || !width || !height) + return false; + + Gifreader reader; + reader.buffer = buffer; + reader.buffSize = bufSize; + + int err = 0; +#if GIFLIB_MAJOR >= 5 + m_gif = DGifOpen((void *)&reader, (InputFunc)&ReadFromMemory, &err); +#else + m_gif = DGifOpen((void *)&reader, (InputFunc)&ReadFromMemory); +#endif + if (!m_gif) + { +#if GIFLIB_MAJOR >= 5 + char* error = GifErrorString(err); + if (error) + fprintf(stderr, "Gif::LoadImageFromMemory(): Could not open gif from memory - %s\n", error); +#else + int error = GifLastError(); + if (error) + fprintf(stderr, "Gif::LoadImageFromMemory(): Could not open gif from memory - %d\n", error); +#endif + else + fprintf(stderr, "Gif::LoadImageFromMemory(): Could not open gif from memory (reasons unknown)\n"); + return false; + } + + if (!LoadGifMetaData(m_gif)) + return false; + + m_originalWidth = m_width; + m_originalHeight = m_height; + + try + { + InitTemplateAndColormap(); + + if (!ExtractFrames(m_numFrames)) + return false; + } + catch (std::bad_alloc& ba) + { + fprintf(stderr, "Gif::LoadImageFromMemory(): Out of memory while extracting gif frames - %s\n", ba.what()); + Release(); + return false; + } + + return true; +} + +GifFrame::GifFrame() : + m_pImage(NULL), + m_delay(0), + m_imageSize(0), + m_height(0), + m_width(0), + m_top(0), + m_left(0), + m_disposal(0), + m_transparent(0), + m_pitch(0) +{} + + +GifFrame::GifFrame(const GifFrame& src) : + m_pImage(NULL), + m_delay(src.m_delay), + m_imageSize(src.m_imageSize), + m_height(src.m_height), + m_width(src.m_width), + m_top(src.m_top), + m_left(src.m_left), + m_disposal(src.m_disposal), + m_transparent(src.m_transparent), + m_pitch(src.m_pitch) +{ + if (src.m_pImage) + { + m_pImage = new unsigned char[m_imageSize]; + memcpy(m_pImage, src.m_pImage, m_imageSize); + } + + if (src.m_palette.size()) + { + m_palette = src.m_palette; + } +} + +GifFrame::~GifFrame() +{ + delete[] m_pImage; + m_pImage = NULL; +} diff --git a/tools/depends/native/TexturePacker/src/decoder/GifHelper.h b/tools/depends/native/TexturePacker/src/decoder/GifHelper.h new file mode 100644 index 0000000000..dae24589e0 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/decoder/GifHelper.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#pragma once + +#include "gif_lib.h" +#include <vector> +#include <string> +#include "SimpleFS.h" + + +#pragma pack(1) +struct COLOR { unsigned char b, g, r, x; }; // Windows GDI expects 4bytes per color +#pragma pack() + +class CFile; + +class GifFrame +{ + friend class GifHelper; +public: + + GifFrame(); + virtual ~GifFrame(); + void Release(); + + GifFrame(const GifFrame& src); + + unsigned char* m_pImage; + unsigned int m_delay; + unsigned int m_top; + unsigned int m_left; + unsigned int m_disposal; + unsigned int m_height; + unsigned int m_width; + unsigned int m_pitch; + unsigned int m_imageSize; + +private: + + std::vector<COLOR> m_palette; + int m_transparent; +}; + + + +class GifHelper +{ + friend class GifFrame; +public: + GifHelper(); + virtual ~GifHelper(); + + bool LoadGifMetaData(const char* file); + bool LoadGif(const char* file); + + virtual bool LoadImageFromMemory(unsigned char* buffer, unsigned int bufSize, unsigned int width, unsigned int height); + //virtual bool Decode(const unsigned char *pixels, unsigned int pitch, unsigned int format); + bool IsAnimated(const char* file); + std::vector<GifFrame>& GetFrames() { return m_frames; } + unsigned int GetPitch() const { return m_pitch; } + unsigned int GetNumLoops() const { return m_loops; } + +private: + std::vector<GifFrame> m_frames; + unsigned int m_imageSize; + unsigned int m_pitch; + unsigned int m_loops; + unsigned int m_numFrames; + + std::string m_filename; + GifFileType* m_gif; + bool m_hasBackground; + COLOR* m_backColor; + std::vector<COLOR> m_globalPalette; + unsigned char* m_pTemplate; + int m_isAnimated; + CFile m_gifFile; + + unsigned int m_width; + unsigned int m_height; + unsigned int m_originalWidth; ///< original image width before scaling or cropping + unsigned int m_originalHeight; ///< original image height before scaling or cropping + unsigned int m_orientation; + bool m_hasAlpha; + + void InitTemplateAndColormap(); + bool LoadGifMetaData(GifFileType* file); + static void ConvertColorTable(std::vector<COLOR> &dest, ColorMapObject* src, unsigned int size); + bool gcbToFrame(GifFrame &frame, unsigned int imgIdx); + bool ExtractFrames(unsigned int count); + void SetFrameAreaToBack(unsigned char* dest, const GifFrame &frame); + void ConstructFrame(GifFrame &frame, const unsigned char* src) const; + bool PrepareTemplate(const GifFrame &frame); + void Release(); +}; diff --git a/tools/depends/native/TexturePacker/src/decoder/IDecoder.h b/tools/depends/native/TexturePacker/src/decoder/IDecoder.h new file mode 100644 index 0000000000..def1eca8b1 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/decoder/IDecoder.h @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#pragma once +#include <string> +#include <vector> + +class RGBAImage +{ +public: + RGBAImage() : pixels(NULL), width(0), height(0), bbp(0), pitch(0) {} + + char *pixels;//image data + int width;// width + int height;// height + int bbp;// bits per pixel + int pitch;// rowsize in bytes +}; + +class DecodedFrame +{ + public: + DecodedFrame() : x(0), y(0), disposal(0), delay(0) { } + RGBAImage rgbaImage; /* rgbaimage for this frame */ + int x, y; /* Frame offset position */ + int disposal; /* Disposal code */ + int delay; /* Frame delay in ms */ +}; + +class DecodedFrames +{ + public: + DecodedFrames(): user(NULL) {} + std::vector<DecodedFrame> frameList; + void *user; /* used internally*/ + + void clear() + { + frameList.clear(); + user = NULL; + } +}; + +class IDecoder +{ + public: + virtual ~IDecoder(){} + virtual bool CanDecode(const std::string &filename) = 0; + virtual bool LoadFile(const std::string &filename, DecodedFrames &frames) = 0; + virtual void FreeDecodedFrames(DecodedFrames &frames) = 0; + virtual const char* GetImageFormatName() = 0; + virtual const char* GetDecoderName() = 0; + + const std::vector<std::string>& GetSupportedExtensions() + { + m_supportedExtensions.clear(); + FillSupportedExtensions(); + return m_supportedExtensions; + } + + protected: + virtual void FillSupportedExtensions() = 0; + //fill this with extensions in FillSupportedExtensions like ".png" + std::vector<std::string> m_supportedExtensions; +};
\ No newline at end of file diff --git a/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.cpp b/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.cpp new file mode 100644 index 0000000000..53f5e9beb7 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.cpp @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "JPGDecoder.h" +#include "jpeglib.h" +#include "SimpleFS.h" + +bool JPGDecoder::CanDecode(const std::string &filename) +{ + CFile *fp = new CFile(); + bool ret = false; + unsigned char magic[2]; + if (fp->Open(filename)) + { + + //JPEG image files begin with FF D8 and end with FF D9. + // check for FF D8 big + little endian on start + uint64_t readbytes = fp->Read(magic, 2); + if (readbytes == 2) + { + if ((magic[0] == 0xd8 && magic[1] == 0xff) || + (magic[1] == 0xd8 && magic[0] == 0xff)) + ret = true; + } + + if (ret) + { + ret = false; + //check on FF D9 big + little endian on end + uint64_t fileSize = fp->GetFileSize(); + fp->Seek(fileSize - 2); + readbytes = fp->Read(magic, 2); + if (readbytes == 2) + { + if ((magic[0] == 0xd9 && magic[1] == 0xff) || + (magic[1] == 0xd9 && magic[0] == 0xff)) + ret = true; + } + } + } + delete fp; + return ret; +} + +bool JPGDecoder::LoadFile(const std::string &filename, DecodedFrames &frames) +{ + #define WIDTHBYTES(bits) ((((bits) + 31) / 32) * 4) + CFile *arq = new CFile(); + if (!arq->Open(filename)) + { + delete arq; + return false; + } + + struct jpeg_decompress_struct cinfo; + struct jpeg_error_mgr jerr; + + char *linha; + int ImageSize; + + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_decompress(&cinfo); + + jpeg_stdio_src(&cinfo, arq->getFP()); + jpeg_read_header(&cinfo, TRUE); + jpeg_start_decompress(&cinfo); + + // Image Size is calculated as (width * height * bytes per pixel = 4 + ImageSize = cinfo.image_width * cinfo.image_height * 4; + + frames.user = NULL; + DecodedFrame frame; + + frame.rgbaImage.pixels = (char *)new char[ImageSize]; + linha = (char *)frame.rgbaImage.pixels; + + unsigned char *scanlinebuff = new unsigned char[3 * cinfo.image_width]; + unsigned char *dst = (unsigned char *)frame.rgbaImage.pixels; + while (cinfo.output_scanline < cinfo.output_height) + { + jpeg_read_scanlines(&cinfo,&scanlinebuff,1); + + unsigned char *src2 = scanlinebuff; + unsigned char *dst2 = dst; + for (unsigned int x = 0; x < cinfo.image_width; x++, src2 += 3) + { + *dst2++ = src2[2]; + *dst2++ = src2[1]; + *dst2++ = src2[0]; + *dst2++ = 0xff; + } + dst += cinfo.image_width * 4; + } + delete [] scanlinebuff; + + jpeg_finish_decompress(&cinfo); + jpeg_destroy_decompress(&cinfo); + + frame.rgbaImage.height = cinfo.image_height; + frame.rgbaImage.width = cinfo.image_width; + frame.rgbaImage.bbp = 32; + frame.rgbaImage.pitch = 4 * cinfo.image_width; + frames.frameList.push_back(frame); + + delete arq; + return true; +} + +void JPGDecoder::FreeDecodedFrames(DecodedFrames &frames) +{ + for (unsigned int i = 0; i < frames.frameList.size(); i++) + { + delete [] frames.frameList[i].rgbaImage.pixels; + } + + frames.clear(); +} + +void JPGDecoder::FillSupportedExtensions() +{ + m_supportedExtensions.push_back(".jpg"); + m_supportedExtensions.push_back(".jpeg"); +} diff --git a/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.h b/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.h new file mode 100644 index 0000000000..598a62b98b --- /dev/null +++ b/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#pragma once +#include "IDecoder.h" + +class JPGDecoder : public IDecoder +{ + public: + virtual ~JPGDecoder(){} + virtual bool CanDecode(const std::string &filename); + virtual bool LoadFile(const std::string &filename, DecodedFrames &frames); + virtual void FreeDecodedFrames(DecodedFrames &frames); + virtual const char* GetImageFormatName() { return "JPG"; } + virtual const char* GetDecoderName() { return "libjpeg"; } + protected: + virtual void FillSupportedExtensions(); +};
\ No newline at end of file diff --git a/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.cpp b/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.cpp new file mode 100644 index 0000000000..38b8afa738 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.cpp @@ -0,0 +1,235 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "PNGDecoder.h" +#include "png.h" +#include "SimpleFS.h" + +#ifndef png_jmpbuf +# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#endif + +/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp() + * returns zero if the image is a PNG and nonzero if it isn't a PNG. + * + * The function check_if_png() shown here, but not used, returns nonzero (true) + * if the file can be opened and is a PNG, 0 (false) otherwise. + * + * If this call is successful, and you are going to keep the file open, + * you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once + * you have created the png_ptr, so that libpng knows your application + * has read that many bytes from the start of the file. Make sure you + * don't call png_set_sig_bytes() with more than 8 bytes read or give it + * an incorrect number of bytes read, or you will either have read too + * many bytes (your fault), or you are telling libpng to read the wrong + * number of magic bytes (also your fault). + * + * Many applications already read the first 2 or 4 bytes from the start + * of the image to determine the file type, so it would be easiest just + * to pass the bytes to png_sig_cmp() or even skip that if you know + * you have a PNG file, and call png_set_sig_bytes(). + */ +bool PNGDecoder::CanDecode(const std::string &filename) +{ + #define PNG_BYTES_TO_CHECK 4 + CFile fp; + char buf[PNG_BYTES_TO_CHECK]; + + /* Open the prospective PNG file. */ + if (!fp.Open(filename)) + return false; + + /* Read in some of the signature bytes */ + if (fp.Read(buf, PNG_BYTES_TO_CHECK) != PNG_BYTES_TO_CHECK) + { + fprintf(stderr, "error reading header ...\n"); + return false; + } + fp.Close(); + + /* Compare the first PNG_BYTES_TO_CHECK bytes of the signature. + Return nonzero (true) if they match */ + return(!png_sig_cmp((png_bytep)buf, (png_size_t)0, PNG_BYTES_TO_CHECK)); +} + +bool PNGDecoder::LoadFile(const std::string &filename, DecodedFrames &frames) +{ + png_byte header[8]; + RGBAImage *ret = NULL; + + CFile fp; + if (!fp.Open(filename)) + { + perror(filename.c_str()); + return false; + } + + // read the header + fp.Read(header, 8); + + if (png_sig_cmp(header, 0, 8)) + { + fprintf(stderr, "error: %s is not a PNG.\n", filename.c_str()); + return false; + } + + png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (!png_ptr) + { + fprintf(stderr, "error: png_create_read_struct returned 0.\n"); + return false; + } + + // create png info struct + png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + { + fprintf(stderr, "error: png_create_info_struct returned 0.\n"); + png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL); + return false; + } + + // create png info struct + png_infop end_info = png_create_info_struct(png_ptr); + if (!end_info) + { + fprintf(stderr, "error: png_create_info_struct returned 0.\n"); + png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL); + return false; + } + + // the code in this if statement gets called if libpng encounters an error + if (setjmp(png_jmpbuf(png_ptr))) { + fprintf(stderr, "error from libpng\n"); + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); + return false; + } + + // init png reading + png_init_io(png_ptr, fp.getFP()); + + // let libpng know you already read the first 8 bytes + png_set_sig_bytes(png_ptr, 8); + + // read all the info up to the image data + png_read_info(png_ptr, info_ptr); + + // variables to pass to get info + int bit_depth, color_type; + png_uint_32 temp_width, temp_height; + + // get info about png + png_get_IHDR(png_ptr, info_ptr, &temp_width, &temp_height, &bit_depth, &color_type, + NULL, NULL, NULL); + + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) + { + png_set_tRNS_to_alpha(png_ptr); + } + + //set it to 32bit pixeldepth + png_color_8 sig_bit; + sig_bit.red = 32; + sig_bit.green = 32; + sig_bit.blue = 32; + // if the image has an alpha channel then + sig_bit.alpha = 32; + png_set_sBIT(png_ptr, info_ptr, &sig_bit); + + + /* Add filler (or alpha) byte (before/after each RGB triplet) */ + png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); + + + if (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) + png_set_bgr(png_ptr); + + /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ + //png_set_swap_alpha(png_ptr); + + + // Update the png info struct. + png_read_update_info(png_ptr, info_ptr); + + // Row size in bytes. + int rowbytes = png_get_rowbytes(png_ptr, info_ptr); + + // glTexImage2d requires rows to be 4-byte aligned + // rowbytes += 3 - ((rowbytes-1) % 4); + + // Allocate the image_data as a big block, to be given to opengl + png_byte * image_data; + image_data = (png_byte*)new png_byte[rowbytes * temp_height * sizeof(png_byte)+15]; + if (image_data == NULL) + { + fprintf(stderr, "error: could not allocate memory for PNG image data\n"); + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); + return false; + } + + // row_pointers is for pointing to image_data for reading the png with libpng + png_bytep * row_pointers = (png_bytep*) new png_bytep[temp_height * sizeof(png_bytep)]; + if (row_pointers == NULL) + { + fprintf(stderr, "error: could not allocate memory for PNG row pointers\n"); + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); + delete [] image_data; + return false; + } + + // set the individual row_pointers to point at the correct offsets of image_data + for (unsigned int i = 0; i < temp_height; i++) + { + row_pointers[i] = image_data + i * rowbytes; + } + + // read the png into image_data through row_pointers + png_read_image(png_ptr, row_pointers); + + frames.user = NULL; + DecodedFrame frame; + + frame.rgbaImage.pixels = (char *)image_data; + frame.rgbaImage.height = temp_height; + frame.rgbaImage.width = temp_width; + frame.rgbaImage.bbp = 32; + frame.rgbaImage.pitch = 4 * temp_width; + frames.frameList.push_back(frame); + // clean up + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); + delete [] row_pointers; + return true; +} + +void PNGDecoder::FreeDecodedFrames(DecodedFrames &frames) +{ + for (unsigned int i = 0; i < frames.frameList.size(); i++) + { + delete [] frames.frameList[i].rgbaImage.pixels; + } + + frames.clear(); +} + +void PNGDecoder::FillSupportedExtensions() +{ + m_supportedExtensions.push_back(".png"); +} diff --git a/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.h b/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.h new file mode 100644 index 0000000000..78c7fe4ca8 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#pragma once +#include "IDecoder.h" + +class PNGDecoder : public IDecoder +{ + public: + virtual ~PNGDecoder(){} + virtual bool CanDecode(const std::string &filename); + virtual bool LoadFile(const std::string &filename, DecodedFrames &frames); + virtual void FreeDecodedFrames(DecodedFrames &frames); + virtual const char* GetImageFormatName() { return "PNG"; } + virtual const char* GetDecoderName() { return "libpng"; } + protected: + virtual void FillSupportedExtensions(); +};
\ No newline at end of file diff --git a/tools/TexturePacker/md5.cpp b/tools/depends/native/TexturePacker/src/md5.cpp index ce0c310963..ce0c310963 100644 --- a/tools/TexturePacker/md5.cpp +++ b/tools/depends/native/TexturePacker/src/md5.cpp diff --git a/tools/TexturePacker/md5.h b/tools/depends/native/TexturePacker/src/md5.h index 456e5be17f..456e5be17f 100644 --- a/tools/TexturePacker/md5.h +++ b/tools/depends/native/TexturePacker/src/md5.h diff --git a/tools/TexturePacker/xwinapi.h b/tools/depends/native/TexturePacker/src/xwinapi.h index 8f31384dd2..8f31384dd2 100644 --- a/tools/TexturePacker/xwinapi.h +++ b/tools/depends/native/TexturePacker/src/xwinapi.h diff --git a/tools/depends/native/cmake-native/Makefile b/tools/depends/native/cmake-native/Makefile index c925958a7e..45f1249a05 100644 --- a/tools/depends/native/cmake-native/Makefile +++ b/tools/depends/native/cmake-native/Makefile @@ -11,7 +11,7 @@ ARCHIVE=$(SOURCE).tar.gz SETENV=CC=$(CC_FOR_BUILD) CXX=$(CXX_FOR_BUILD) LD=$(LD_FOR_BUILD) CFLAGS=$(NATIVE_CFLAGS) \ CXXFLAGS=$(NATIVE_CXXFLAGS) LDFLAGS=$(NATIVE_LDFLAGS) -CONFIGURE=./bootstrap --prefix=$(NATIVEPREFIX) +CONFIGURE=./bootstrap --prefix=$(NATIVEPREFIX) --system-curl APP=$(PLATFORM)/bin/$(APPNAME) diff --git a/tools/depends/native/giflib-native/Makefile b/tools/depends/native/giflib-native/Makefile new file mode 100644 index 0000000000..03d2fd1fdc --- /dev/null +++ b/tools/depends/native/giflib-native/Makefile @@ -0,0 +1,41 @@ +include ../../Makefile.include +DEPS= ../../Makefile.include Makefile +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) + +# lib name, version +LIBNAME=giflib +VERSION=5.0.5 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.bz2 + +# configuration settings +CONFIGURE=./configure --prefix=$(PREFIX) + +LIBDYLIB=$(PLATFORM)/lib/.libs/libgif.a + +CLEAN_FILES=$(ARCHIVE) $(PLATFORM) + +all: .installed-$(PLATFORM) + +$(TARBALLS_LOCATION)/$(ARCHIVE): + cd $(TARBALLS_LOCATION); $(RETRIEVE_TOOL) $(RETRIEVE_TOOL_FLAGS) $(BASE_URL)/$(ARCHIVE) + +$(PLATFORM): $(TARBALLS_LOCATION)/$(ARCHIVE) $(DEPS) + -rm -rf $(PLATFORM); mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); $(CONFIGURE) + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(PLATFORM) install + touch $@ +clean: + $(MAKE) -C $(PLATFORM) clean + rm -r .installed-$(PLATFORM) + rm -rf $(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/libsquish-native/Makefile b/tools/depends/native/libsquish-native/Makefile new file mode 100644 index 0000000000..7bf6e5e5b6 --- /dev/null +++ b/tools/depends/native/libsquish-native/Makefile @@ -0,0 +1,46 @@ +DEPS= ../../Makefile.include.in Makefile +ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) +-include ../../Makefile.include + +ifeq ($(NATIVEPREFIX),) + PREFIX = $(ROOT_DIR)/squish-install +else + PREFIX = $(NATIVEPREFIX) +endif + +ifeq ($(NATIVEPLATFORM),) + PLATFORM = native +else + PLATFORM = $(NATIVEPLATFORM) +endif + +APPNAME=squish +SOURCE=$(ROOT_DIR)/src + +DYLIB=$(PLATFORM)/libsquish.a + +all: .installed-$(PLATFORM) + +$(PLATFORM): +ifeq ($(PREFIX),) + @echo + @echo "ERROR: please set PREFIX to the xbmc install path e.g. make PREFIX=/usr/local" + @exit 1 +endif + -rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); cp -a $(SOURCE)/* . + cd $(PLATFORM); sed "s|@PREFIX@|$(PREFIX)|" config.in > config + cd $(PLATFORM); mkdir -p $(PREFIX)/include; mkdir -p $(PREFIX)/lib/pkgconfig + +$(DYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + +.installed-$(PLATFORM): $(DYLIB) + $(MAKE) -C $(PLATFORM) install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/lib/libsquish/ChangeLog b/tools/depends/native/libsquish-native/src/ChangeLog index ba03f4c574..ba03f4c574 100644 --- a/lib/libsquish/ChangeLog +++ b/tools/depends/native/libsquish-native/src/ChangeLog diff --git a/lib/libsquish/Doxyfile b/tools/depends/native/libsquish-native/src/Doxyfile index 3ec51e4bde..3ec51e4bde 100644 --- a/lib/libsquish/Doxyfile +++ b/tools/depends/native/libsquish-native/src/Doxyfile diff --git a/tools/depends/native/libsquish-native/src/Makefile b/tools/depends/native/libsquish-native/src/Makefile new file mode 100644 index 0000000000..d560e0af6d --- /dev/null +++ b/tools/depends/native/libsquish-native/src/Makefile @@ -0,0 +1,33 @@ + +include config + +SRC = alpha.cpp clusterfit.cpp colourblock.cpp colourfit.cpp colourset.cpp maths.cpp rangefit.cpp singlecolourfit.cpp squish.cpp + +OBJ = $(SRC:%.cpp=%.o) + +LIB = libsquish.a + +all : $(LIB) squish.pc + +install : $(LIB) squish.pc + install squish.h $(INSTALL_DIR)/include + install libsquish.a $(INSTALL_DIR)/lib + install squish.pc $(INSTALL_DIR)/lib/pkgconfig + +uninstall: + $(RM) $(INSTALL_DIR)/include/squish.h + $(RM) $(INSTALL_DIR)/lib/libsquish.a + +$(LIB) : $(OBJ) + $(AR) cr $@ $? + ranlib $@ + +%.o : %.cpp + $(CXX) $(CPPFLAGS) -I. $(CXXFLAGS) -o$@ -c $< + +clean : + $(RM) $(OBJ) $(LIB) + +squish.pc: + sed 's|@PREFIX@|$(INSTALL_DIR)|' $@.in > $@ + diff --git a/tools/depends/native/libsquish-native/src/Makefile.target b/tools/depends/native/libsquish-native/src/Makefile.target new file mode 100644 index 0000000000..03d6732764 --- /dev/null +++ b/tools/depends/native/libsquish-native/src/Makefile.target @@ -0,0 +1,34 @@ +include ../../../Makefile.include + +SRCS= \ + alpha.cpp \ + clusterfit.cpp \ + colourblock.cpp \ + colourfit.cpp \ + colourset.cpp \ + maths.cpp \ + rangefit.cpp \ + singlecolourfit.cpp \ + squish.cpp + +CXXFLAGS += -I. +LIB = libsquish.a + +OBJ = $(SRCS:%.cpp=%.o) + +%.o : %.cpp + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o$@ -c $< + +$(LIB): $(OBJ) + $(AR) cr $@ $? + $(RANLIB) $@ + +install: $(LIB) squish.pc + install squish.h $(PREFIX)/include + install libsquish.a $(PREFIX)/lib + install squish.pc $(PREFIX)/lib/pkgconfig + +squish.pc: squish.pc.in + sed 's|@PREFIX@|$(PREFIX)|' $@.in > $@ + +all: $(LIB) diff --git a/lib/libsquish/README b/tools/depends/native/libsquish-native/src/README index d26b72ed5c..d26b72ed5c 100644 --- a/lib/libsquish/README +++ b/tools/depends/native/libsquish-native/src/README diff --git a/lib/libsquish/alpha.cpp b/tools/depends/native/libsquish-native/src/alpha.cpp index 30c1f55a01..30c1f55a01 100644 --- a/lib/libsquish/alpha.cpp +++ b/tools/depends/native/libsquish-native/src/alpha.cpp diff --git a/lib/libsquish/alpha.h b/tools/depends/native/libsquish-native/src/alpha.h index 5736052551..5736052551 100644 --- a/lib/libsquish/alpha.h +++ b/tools/depends/native/libsquish-native/src/alpha.h diff --git a/lib/libsquish/clusterfit.cpp b/tools/depends/native/libsquish-native/src/clusterfit.cpp index 96704460ec..96704460ec 100644 --- a/lib/libsquish/clusterfit.cpp +++ b/tools/depends/native/libsquish-native/src/clusterfit.cpp diff --git a/lib/libsquish/clusterfit.h b/tools/depends/native/libsquish-native/src/clusterfit.h index ef5959c45a..ef5959c45a 100644 --- a/lib/libsquish/clusterfit.h +++ b/tools/depends/native/libsquish-native/src/clusterfit.h diff --git a/lib/libsquish/colourblock.cpp b/tools/depends/native/libsquish-native/src/colourblock.cpp index e6a5788b74..e6a5788b74 100644 --- a/lib/libsquish/colourblock.cpp +++ b/tools/depends/native/libsquish-native/src/colourblock.cpp diff --git a/lib/libsquish/colourblock.h b/tools/depends/native/libsquish-native/src/colourblock.h index df0a47217f..df0a47217f 100644 --- a/lib/libsquish/colourblock.h +++ b/tools/depends/native/libsquish-native/src/colourblock.h diff --git a/lib/libsquish/colourfit.cpp b/tools/depends/native/libsquish-native/src/colourfit.cpp index 11efa46748..11efa46748 100644 --- a/lib/libsquish/colourfit.cpp +++ b/tools/depends/native/libsquish-native/src/colourfit.cpp diff --git a/lib/libsquish/colourfit.h b/tools/depends/native/libsquish-native/src/colourfit.h index 5b684a923a..5b684a923a 100644 --- a/lib/libsquish/colourfit.h +++ b/tools/depends/native/libsquish-native/src/colourfit.h diff --git a/lib/libsquish/colourset.cpp b/tools/depends/native/libsquish-native/src/colourset.cpp index 97d29d9873..97d29d9873 100644 --- a/lib/libsquish/colourset.cpp +++ b/tools/depends/native/libsquish-native/src/colourset.cpp diff --git a/lib/libsquish/colourset.h b/tools/depends/native/libsquish-native/src/colourset.h index dcf56ae28e..dcf56ae28e 100644 --- a/lib/libsquish/colourset.h +++ b/tools/depends/native/libsquish-native/src/colourset.h diff --git a/lib/libsquish/config.h b/tools/depends/native/libsquish-native/src/config.h index 00a2d068bf..00a2d068bf 100644 --- a/lib/libsquish/config.h +++ b/tools/depends/native/libsquish-native/src/config.h diff --git a/lib/libsquish/config b/tools/depends/native/libsquish-native/src/config.in index 00040d2645..fdca022003 100644 --- a/lib/libsquish/config +++ b/tools/depends/native/libsquish-native/src/config.in @@ -18,4 +18,4 @@ CXXFLAGS += -msse endif # where should we install to -INSTALL_DIR ?= /usr/local +INSTALL_DIR ?= @PREFIX@ diff --git a/lib/libsquish/extra/squishgen.cpp b/tools/depends/native/libsquish-native/src/extra/squishgen.cpp index d7d1ee0d90..d7d1ee0d90 100644 --- a/lib/libsquish/extra/squishgen.cpp +++ b/tools/depends/native/libsquish-native/src/extra/squishgen.cpp diff --git a/lib/libsquish/extra/squishpng.cpp b/tools/depends/native/libsquish-native/src/extra/squishpng.cpp index f443656dab..f443656dab 100644 --- a/lib/libsquish/extra/squishpng.cpp +++ b/tools/depends/native/libsquish-native/src/extra/squishpng.cpp diff --git a/lib/libsquish/extra/squishtest.cpp b/tools/depends/native/libsquish-native/src/extra/squishtest.cpp index fb09208694..fb09208694 100644 --- a/lib/libsquish/extra/squishtest.cpp +++ b/tools/depends/native/libsquish-native/src/extra/squishtest.cpp diff --git a/lib/libsquish/maths.cpp b/tools/depends/native/libsquish-native/src/maths.cpp index 9af4197d38..9af4197d38 100644 --- a/lib/libsquish/maths.cpp +++ b/tools/depends/native/libsquish-native/src/maths.cpp diff --git a/lib/libsquish/maths.h b/tools/depends/native/libsquish-native/src/maths.h index 769ae463f7..769ae463f7 100644 --- a/lib/libsquish/maths.h +++ b/tools/depends/native/libsquish-native/src/maths.h diff --git a/lib/libsquish/rangefit.cpp b/tools/depends/native/libsquish-native/src/rangefit.cpp index 3fca1245eb..3fca1245eb 100644 --- a/lib/libsquish/rangefit.cpp +++ b/tools/depends/native/libsquish-native/src/rangefit.cpp diff --git a/lib/libsquish/rangefit.h b/tools/depends/native/libsquish-native/src/rangefit.h index 0207bd1c3f..0207bd1c3f 100644 --- a/lib/libsquish/rangefit.h +++ b/tools/depends/native/libsquish-native/src/rangefit.h diff --git a/lib/libsquish/simd.h b/tools/depends/native/libsquish-native/src/simd.h index 22bd10a460..22bd10a460 100644 --- a/lib/libsquish/simd.h +++ b/tools/depends/native/libsquish-native/src/simd.h diff --git a/lib/libsquish/simd_float.h b/tools/depends/native/libsquish-native/src/simd_float.h index e6351b80eb..e6351b80eb 100644 --- a/lib/libsquish/simd_float.h +++ b/tools/depends/native/libsquish-native/src/simd_float.h diff --git a/lib/libsquish/simd_sse.h b/tools/depends/native/libsquish-native/src/simd_sse.h index e584f2a0e5..e584f2a0e5 100644 --- a/lib/libsquish/simd_sse.h +++ b/tools/depends/native/libsquish-native/src/simd_sse.h diff --git a/lib/libsquish/simd_ve.h b/tools/depends/native/libsquish-native/src/simd_ve.h index 70cb32621e..70cb32621e 100644 --- a/lib/libsquish/simd_ve.h +++ b/tools/depends/native/libsquish-native/src/simd_ve.h diff --git a/lib/libsquish/singlecolourfit.cpp b/tools/depends/native/libsquish-native/src/singlecolourfit.cpp index e8a0117698..e8a0117698 100644 --- a/lib/libsquish/singlecolourfit.cpp +++ b/tools/depends/native/libsquish-native/src/singlecolourfit.cpp diff --git a/lib/libsquish/singlecolourfit.h b/tools/depends/native/libsquish-native/src/singlecolourfit.h index 0388fda028..0388fda028 100644 --- a/lib/libsquish/singlecolourfit.h +++ b/tools/depends/native/libsquish-native/src/singlecolourfit.h diff --git a/lib/libsquish/singlecolourlookup.inl b/tools/depends/native/libsquish-native/src/singlecolourlookup.inl index f1c95a1028..f1c95a1028 100644 --- a/lib/libsquish/singlecolourlookup.inl +++ b/tools/depends/native/libsquish-native/src/singlecolourlookup.inl diff --git a/lib/libsquish/squish-Info.plist b/tools/depends/native/libsquish-native/src/squish-Info.plist index 5cb05e056c..5cb05e056c 100644 --- a/lib/libsquish/squish-Info.plist +++ b/tools/depends/native/libsquish-native/src/squish-Info.plist diff --git a/lib/libsquish/squish.cpp b/tools/depends/native/libsquish-native/src/squish.cpp index c0ce058457..c0ce058457 100644 --- a/lib/libsquish/squish.cpp +++ b/tools/depends/native/libsquish-native/src/squish.cpp diff --git a/lib/libsquish/squish.h b/tools/depends/native/libsquish-native/src/squish.h index c68f5c548e..c68f5c548e 100644 --- a/lib/libsquish/squish.h +++ b/tools/depends/native/libsquish-native/src/squish.h diff --git a/tools/depends/native/libsquish-native/src/squish.pc.in b/tools/depends/native/libsquish-native/src/squish.pc.in new file mode 100644 index 0000000000..ca04334393 --- /dev/null +++ b/tools/depends/native/libsquish-native/src/squish.pc.in @@ -0,0 +1,13 @@ +prefix=@PREFIX@ +exec_prefix=${prefix} +libdir=${prefix}/lib +sharedlibdir=${libdir} +includedir=${prefix}/include + +Name: squish +Description: squish DXT lib +Version: 1.0.0-kodi + +Requires: +Libs: -L${libdir} -L${sharedlibdir} -lsquish +Cflags: -I${includedir} diff --git a/lib/libsquish/texture_compression_s3tc.txt b/tools/depends/native/libsquish-native/src/texture_compression_s3tc.txt index f229cf3678..f229cf3678 100644 --- a/lib/libsquish/texture_compression_s3tc.txt +++ b/tools/depends/native/libsquish-native/src/texture_compression_s3tc.txt diff --git a/lib/libsquish/vs7/squish.sln b/tools/depends/native/libsquish-native/src/vs7/squish.sln index ae23f85c46..ae23f85c46 100644 --- a/lib/libsquish/vs7/squish.sln +++ b/tools/depends/native/libsquish-native/src/vs7/squish.sln diff --git a/lib/libsquish/vs7/squish/squish_2010.vcxproj b/tools/depends/native/libsquish-native/src/vs7/squish/squish_2010.vcxproj index dfcecbc8eb..dfcecbc8eb 100644 --- a/lib/libsquish/vs7/squish/squish_2010.vcxproj +++ b/tools/depends/native/libsquish-native/src/vs7/squish/squish_2010.vcxproj diff --git a/lib/libsquish/vs7/squish/squish_2010.vcxproj.filters b/tools/depends/native/libsquish-native/src/vs7/squish/squish_2010.vcxproj.filters index a898002d4b..a898002d4b 100644 --- a/lib/libsquish/vs7/squish/squish_2010.vcxproj.filters +++ b/tools/depends/native/libsquish-native/src/vs7/squish/squish_2010.vcxproj.filters diff --git a/lib/libsquish/vs7/squishpng/squishpng.vcproj b/tools/depends/native/libsquish-native/src/vs7/squishpng/squishpng.vcproj index 1154d7bc9a..1154d7bc9a 100644 --- a/lib/libsquish/vs7/squishpng/squishpng.vcproj +++ b/tools/depends/native/libsquish-native/src/vs7/squishpng/squishpng.vcproj diff --git a/lib/libsquish/vs7/squishtest/squishtest.vcproj b/tools/depends/native/libsquish-native/src/vs7/squishtest/squishtest.vcproj index 930bfc4077..930bfc4077 100644 --- a/lib/libsquish/vs7/squishtest/squishtest.vcproj +++ b/tools/depends/native/libsquish-native/src/vs7/squishtest/squishtest.vcproj diff --git a/tools/depends/target/Makefile b/tools/depends/target/Makefile index 3598d1968e..d1a0e69044 100644 --- a/tools/depends/target/Makefile +++ b/tools/depends/target/Makefile @@ -10,7 +10,7 @@ DEPENDS = \ openssl gmp nettle gnutls libssh2 curl \ libjpeg-turbo tiff jasper libpng \ libogg libvorbis libflac fribidi libmpeg2 \ - libass \ + libass libsquish \ libmodplug librtmp libxml2 yajl libmicrohttpd mysql libffi \ python26 afpfs-ng libshairplay \ libplist libcec libbluray boost tinyxml dummy-libxbmc \ @@ -18,6 +18,8 @@ DEPENDS = \ xbmc-pvr-addons xbmc-audioencoder-addons \ pythonmodule-pil libxslt ffmpeg +FFMPEG_DEPENDS = gnutls + ifeq ($(ENABLE_GPLV3),1) DEPENDS+=samba-gplv3 libcdio-gplv3 else @@ -26,17 +28,16 @@ endif ifeq ($(OS),ios) DEPENDS += Backrow - EXCLUDED_DEPENDS = libcec libusb gmp nettle gnutls + EXCLUDED_DEPENDS = libcec libusb endif ifeq ($(OS),osx) DEPENDS += libGLEW libsdl - EXCLUDED_DEPENDS = libusb gmp nettle gnutls + EXCLUDED_DEPENDS = libusb endif ifeq ($(OS),android) DEPENDS += mdnsresponder android-sources-ics - EXCLUDED_DEPENDS = gmp nettle gnutls endif DEPENDS := $(filter-out $(EXCLUDED_DEPENDS),$(DEPENDS)) @@ -63,7 +64,6 @@ ifeq ($(OS),linux) endif DEPENDS += alsa-lib ALSA_LIB = alsa-lib - FFMPEG_DEPENDS = gnutls endif .PHONY: $(DEPENDS) diff --git a/tools/depends/target/Toolchain.cmake.in b/tools/depends/target/Toolchain.cmake.in index c8aee4af1a..857c21bf80 100644 --- a/tools/depends/target/Toolchain.cmake.in +++ b/tools/depends/target/Toolchain.cmake.in @@ -1,7 +1,19 @@ SET(OS "@platform_os@") +SET(CPU "@use_cpu@") +SET(PLATFORM "@use_platform@") IF("${OS}" STREQUAL "linux" OR "${OS}" STREQUAL "android") SET(CMAKE_SYSTEM_NAME Linux) ENDIF() + +# set special CORE_SYSTEM_NAME +IF("${OS}" STREQUAL "android") +SET(CORE_SYSTEM_NAME android) +ELSEIF("${OS}" STREQUAL "ios") +SET(CORE_SYSTEM_NAME ios) +ELSEIF("${PLATFORM}" STREQUAL "raspberry-pi") +SET(CORE_SYSTEM_NAME rbpi) +ENDIF() + IF("${OS}" STREQUAL "ios" OR "${OS}" STREQUAL "osx") SET(CMAKE_OSX_SYSROOT @use_sdk_path@) ENDIF() @@ -31,6 +43,6 @@ SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # Binary Addons -IF(NOT LINUX) +IF(NOT OS STREQUAL "linux") SET(ADDONS_PREFER_STATIC_LIBS ON) ENDIF() diff --git a/tools/depends/target/curl/0001-HTTP-reset-expected-DL-UL-sizes-on-redirects.patch b/tools/depends/target/curl/0001-HTTP-reset-expected-DL-UL-sizes-on-redirects.patch deleted file mode 100644 index 7855f428ff..0000000000 --- a/tools/depends/target/curl/0001-HTTP-reset-expected-DL-UL-sizes-on-redirects.patch +++ /dev/null @@ -1,83 +0,0 @@ -From c44d45db86b880df5facd6b560491e03530f876e Mon Sep 17 00:00:00 2001 -From: Daniel Stenberg <daniel@haxx.se> -Date: Fri, 23 Mar 2012 23:42:37 +0100 -Subject: [PATCH] HTTP: reset expected DL/UL sizes on redirects - -With FOLLOWLOCATION enabled. When a 3xx page is downloaded and the -download size was known (like with a Content-Length header), but the -subsequent URL (transfered after the 3xx page) was chunked encoded, then -the previous "known download size" would linger and cause the progress -meter to get incorrect information, ie the former value would remain -being sent in. This could easily result in downloads that were WAY -larger than "expected" and would cause >100% outputs with the curl -command line tool. - -Test case 599 was created and it was used to repeat the bug and then -verify the fix. - -Bug: http://curl.haxx.se/bug/view.cgi?id=3510057 -Reported by: Michael Wallner ---- - lib/progress.c | 9 +++-- - lib/progress.h | 4 +-- - lib/transfer.c | 2 +- - tests/data/Makefile.am | 2 +- - tests/data/test599 | 83 +++++++++++++++++++++++++++++++++++++++++++ - tests/libtest/Makefile.inc | 4 ++- - tests/libtest/lib599.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++ - 7 files changed, 184 insertions(+), 8 deletions(-) - create mode 100644 tests/data/test599 - create mode 100644 tests/libtest/lib599.c - -diff --git a/lib/progress.c b/lib/progress.c -index 1eeb780..4c9a63a 100644 ---- a/lib/progress.c -+++ b/lib/progress.c -@@ -146,13 +146,16 @@ void Curl_pgrsDone(struct connectdata *conn) - data->progress.speeder_c = 0; /* reset the progress meter display */ - } - --/* reset all times except redirect */ --void Curl_pgrsResetTimes(struct SessionHandle *data) -+/* reset all times except redirect, and reset the known transfer sizes */ -+void Curl_pgrsResetTimesSizes(struct SessionHandle *data) - { - data->progress.t_nslookup = 0.0; - data->progress.t_connect = 0.0; - data->progress.t_pretransfer = 0.0; - data->progress.t_starttransfer = 0.0; -+ -+ Curl_pgrsSetDownloadSize(data, 0); -+ Curl_pgrsSetUploadSize(data, 0); - } - - void Curl_pgrsTime(struct SessionHandle *data, timerid timer) -diff --git a/lib/progress.h b/lib/progress.h -index f5cc540..a41d5f9 100644 ---- a/lib/progress.h -+++ b/lib/progress.h -@@ -46,7 +46,7 @@ void Curl_pgrsSetUploadSize(struct SessionHandle *data, curl_off_t size); - void Curl_pgrsSetDownloadCounter(struct SessionHandle *data, curl_off_t size); - void Curl_pgrsSetUploadCounter(struct SessionHandle *data, curl_off_t size); - int Curl_pgrsUpdate(struct connectdata *); --void Curl_pgrsResetTimes(struct SessionHandle *data); -+void Curl_pgrsResetTimesSizes(struct SessionHandle *data); - void Curl_pgrsTime(struct SessionHandle *data, timerid timer); - - -diff --git a/lib/transfer.c b/lib/transfer.c -index d6061be..d872719 100644 ---- a/lib/transfer.c -+++ b/lib/transfer.c -@@ -1924,7 +1924,7 @@ CURLcode Curl_follow(struct SessionHandle *data, - break; - } - Curl_pgrsTime(data, TIMER_REDIRECT); -- Curl_pgrsResetTimes(data); -+ Curl_pgrsResetTimesSizes(data); - - return CURLE_OK; - #endif /* CURL_DISABLE_HTTP */ --- -1.8.4.3 - diff --git a/tools/depends/target/curl/Makefile b/tools/depends/target/curl/Makefile index f81c01228c..9ca896c380 100644 --- a/tools/depends/target/curl/Makefile +++ b/tools/depends/target/curl/Makefile @@ -1,9 +1,9 @@ include ../../Makefile.include -DEPS= ../../Makefile.include Makefile 0001-HTTP-reset-expected-DL-UL-sizes-on-redirects.patch +DEPS= ../../Makefile.include Makefile # lib name, version LIBNAME=curl -VERSION=7.21.6 +VERSION=7.39.0 SOURCE=$(LIBNAME)-$(VERSION) ARCHIVE=$(SOURCE).tar.bz2 # configuration settings @@ -22,7 +22,6 @@ $(TARBALLS_LOCATION)/$(ARCHIVE): $(PLATFORM): $(TARBALLS_LOCATION)/$(ARCHIVE) $(DEPS) rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) - cd $(PLATFORM); patch -p1 < ../0001-HTTP-reset-expected-DL-UL-sizes-on-redirects.patch cd $(PLATFORM); $(CONFIGURE) $(LIBDYLIB): $(PLATFORM) @@ -37,7 +36,7 @@ $(LIBDYLIB): $(PLATFORM) $(MAKE) -C $(PLATFORM) install-pkgconfigDATA ifeq ($(OS),android) rm -f $(PREFIX)/lib/libcurl.la $(PREFIX)/lib/libcurl.so $(PREFIX)/lib/libcurl.so.5 - mv -f $(PREFIX)/lib/libcurl.so.5.2.0 $(PREFIX)/lib/libcurl.so + mv -f $(PREFIX)/lib/libcurl.so.5.3.0 $(PREFIX)/lib/libcurl.so $(RPL) -e "libcurl.so.5" "libcurl.so\x00\x00" $(PREFIX)/lib/libcurl.so -$(READELF) --dynamic $(PREFIX)/lib/libcurl.so | grep ibrary endif diff --git a/tools/depends/target/ffmpeg/FFMPEG-VERSION b/tools/depends/target/ffmpeg/FFMPEG-VERSION index 5db0feb9af..a2df8328bd 100644 --- a/tools/depends/target/ffmpeg/FFMPEG-VERSION +++ b/tools/depends/target/ffmpeg/FFMPEG-VERSION @@ -1,5 +1,5 @@ LIBNAME=ffmpeg BASE_URL=https://github.com/xbmc/FFmpeg/archive -VERSION=2.4.4-Helix +VERSION=2.5.2-Isengard-alpha ARCHIVE=$(LIBNAME)-$(VERSION).tar.gz diff --git a/tools/depends/target/ffmpeg/Makefile b/tools/depends/target/ffmpeg/Makefile index 0e08dcf1e5..5d486663cf 100644 --- a/tools/depends/target/ffmpeg/Makefile +++ b/tools/depends/target/ffmpeg/Makefile @@ -10,7 +10,7 @@ APPLY_PATCHES=no ffmpg_config = --prefix=$(PREFIX) --extra-version="xbmc-$(VERSION)" ffmpg_config += --cc=$(CC) --cxx=$(CXX) ffmpg_config += --disable-devices --disable-doc -ffmpg_config += --disable-ffplay --disable-ffmpeg +ffmpg_config += --disable-ffplay --disable-ffmpeg --disable-sdl ffmpg_config += --disable-ffprobe --disable-ffserver ffmpg_config += --enable-gpl --enable-runtime-cpudetect ffmpg_config += --enable-postproc --enable-pthreads @@ -18,12 +18,14 @@ ffmpg_config += --enable-muxer=spdif --enable-muxer=adts ffmpg_config += --enable-muxer=asf --enable-muxer=ipod ffmpg_config += --enable-encoder=ac3 --enable-encoder=aac ffmpg_config += --enable-encoder=wmav2 --enable-protocol=http +ffmpg_config += --enable-gnutls + ifeq ($(CROSS_COMPILING), yes) ffmpg_config += --arch=$(CPU) --enable-cross-compile endif ifeq ($(OS), linux) ffmpg_config += --target-os=$(OS) --cpu=$(CPU) - ffmpg_config += --enable-vdpau --enable-vaapi --enable-gnutls + ffmpg_config += --enable-vdpau --enable-vaapi ffmpg_config += --enable-libvorbis --enable-muxer=ogg --enable-encoder=libvorbis endif ifeq ($(OS), android) diff --git a/tools/depends/target/ffmpeg/autobuild.sh b/tools/depends/target/ffmpeg/autobuild.sh index 21e40ab849..592cc11076 100755 --- a/tools/depends/target/ffmpeg/autobuild.sh +++ b/tools/depends/target/ffmpeg/autobuild.sh @@ -131,6 +131,7 @@ CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS" \ --disable-devices \ --disable-ffplay \ --disable-ffmpeg \ + --disable-sdl \ --disable-ffprobe \ --disable-ffserver \ --disable-doc \ diff --git a/tools/depends/target/gmp/Makefile b/tools/depends/target/gmp/Makefile index 213a7ba630..11f8dcbd09 100644 --- a/tools/depends/target/gmp/Makefile +++ b/tools/depends/target/gmp/Makefile @@ -18,11 +18,16 @@ ifeq ($(OS),linux) endif endif +ifeq ($(OS),ios) +CONFIGURE_FLAGS=CC_FOR_BUILD=llvm-gcc CPP_FOR_BUILD="llvm-gcc -E" --disable-assembly +endif + # configuration settings CONFIGURE=cp -f $(CONFIG_SUB) $(CONFIG_GUESS) .; \ - ./configure --prefix=$(PREFIX) --disable-shared $(ABI) + ./configure --prefix=$(PREFIX) --disable-shared $(ABI) $(CONFIGURE_FLAGS) + -LIBDYLIB=$(PLATFORM)/src/.libs/$(LIBNAME).a +LIBDYLIB=$(PLATFORM)/.libs/lib$(LIBNAME).a CLEAN_FILES=$(ARCHIVE) $(PLATFORM) @@ -31,12 +36,13 @@ all: .installed-$(PLATFORM) $(TARBALLS_LOCATION)/$(ARCHIVE): cd $(TARBALLS_LOCATION); $(RETRIEVE_TOOL) $(RETRIEVE_TOOL_FLAGS) $(BASE_URL)/$(ARCHIVE) -$(PLATFORM): $(TARBALLS_LOCATION)/$(ARCHIVE) $(DEPS) +$(PLATFORM)/config.status: $(TARBALLS_LOCATION)/$(ARCHIVE) $(DEPS) rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) cd $(PLATFORM); $(CONFIGURE) -$(LIBDYLIB): $(PLATFORM) +$(LIBDYLIB): $(PLATFORM)/config.status + @echo "DYLIB: $(LIBDYLIB)" $(MAKE) -C $(PLATFORM) .installed-$(PLATFORM): $(LIBDYLIB) diff --git a/tools/depends/target/gnutls/Makefile b/tools/depends/target/gnutls/Makefile index 7e7ec69bcc..df45d17f18 100644 --- a/tools/depends/target/gnutls/Makefile +++ b/tools/depends/target/gnutls/Makefile @@ -3,7 +3,7 @@ DEPS= ../../Makefile.include Makefile # lib name, version LIBNAME=gnutls -VERSION=3.1.14 +VERSION=3.3.10 SOURCE=$(LIBNAME)-$(VERSION) ARCHIVE=$(SOURCE).tar.xz @@ -14,9 +14,9 @@ endif # configuration settings CONFIGURE=cp -f $(CONFIG_SUB) $(CONFIG_GUESS) .; \ - ./configure --prefix=$(PREFIX) --disable-shared --without-p11-kit --disable-nls + ./configure --prefix=$(PREFIX) --disable-shared --without-p11-kit --disable-nls --enable-local-libopts -LIBDYLIB=$(PLATFORM)/src/.libs/$(LIBNAME).a +LIBDYLIB=$(PLATFORM)/lib/.libs/lib$(LIBNAME).a CLEAN_FILES=$(ARCHIVE) $(PLATFORM) @@ -28,6 +28,7 @@ $(TARBALLS_LOCATION)/$(ARCHIVE): $(PLATFORM): $(TARBALLS_LOCATION)/$(ARCHIVE) $(DEPS) rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); patch -p0 < ../size-max.patch cd $(PLATFORM); $(CONFIGURE) $(LIBDYLIB): $(PLATFORM) diff --git a/tools/depends/target/gnutls/size-max.patch b/tools/depends/target/gnutls/size-max.patch new file mode 100644 index 0000000000..f2adfc65e0 --- /dev/null +++ b/tools/depends/target/gnutls/size-max.patch @@ -0,0 +1,10 @@ +--- gl/read-file.c.orig 2014-11-24 10:06:35.473877332 +0100 ++++ gl/read-file.c 2014-11-24 10:03:34.005876607 +0100 +@@ -27,6 +27,7 @@ + + /* Get SIZE_MAX. */ + #include <stdint.h> ++#include <limits.h> + + /* Get malloc, realloc, free. */ + #include <stdlib.h> diff --git a/tools/depends/target/libgcrypt/01-asm-Allow-building-x86-and-amd64-using-old-compilers.patch b/tools/depends/target/libgcrypt/01-asm-Allow-building-x86-and-amd64-using-old-compilers.patch new file mode 100644 index 0000000000..864c4fe989 --- /dev/null +++ b/tools/depends/target/libgcrypt/01-asm-Allow-building-x86-and-amd64-using-old-compilers.patch @@ -0,0 +1,55 @@ +From 5eec04a43e6c562e956353449be931dd43dfe1cc Mon Sep 17 00:00:00 2001 +From: Werner Koch <wk@gnupg.org> +Date: Tue, 2 Sep 2014 09:25:20 +0200 +Subject: [PATCH] asm: Allow building x86 and amd64 using old compilers. + +* src/hwf-x86.c (get_xgetbv): Build only if AVX support is enabled. +-- + +Old as(1) versions do not support the xgetvb instruction. Thus build +this function only if asm support has been requested. + +GnuPG-bug-id: 1708 +--- + src/hwf-x86.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/hwf-x86.c b/src/hwf-x86.c +index 0591b4f..7ee246d 100644 +--- a/src/hwf-x86.c ++++ b/src/hwf-x86.c +@@ -96,6 +96,7 @@ get_cpuid(unsigned int in, unsigned int *eax, unsigned int *ebx, + *edx = regs[3]; + } + ++#if defined(ENABLE_AVX_SUPPORT) || defined(ENABLE_AVX2_SUPPORT) + static unsigned int + get_xgetbv(void) + { +@@ -109,6 +110,7 @@ get_xgetbv(void) + + return t_eax; + } ++#endif /* ENABLE_AVX_SUPPORT || ENABLE_AVX2_SUPPORT */ + + #endif /* i386 && GNUC */ + +@@ -145,6 +147,7 @@ get_cpuid(unsigned int in, unsigned int *eax, unsigned int *ebx, + *edx = regs[3]; + } + ++#if defined(ENABLE_AVX_SUPPORT) || defined(ENABLE_AVX2_SUPPORT) + static unsigned int + get_xgetbv(void) + { +@@ -158,6 +161,7 @@ get_xgetbv(void) + + return t_eax; + } ++#endif /* ENABLE_AVX_SUPPORT || ENABLE_AVX2_SUPPORT */ + + #endif /* x86-64 && GNUC */ + +-- +1.8.4.3 + diff --git a/tools/depends/target/libgcrypt/01-inline-gcc.patch b/tools/depends/target/libgcrypt/01-inline-gcc.patch deleted file mode 100644 index 3a0fe015ac..0000000000 --- a/tools/depends/target/libgcrypt/01-inline-gcc.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 5abc06114e91beca0177331e1c79815f5fb6d7be Mon Sep 17 00:00:00 2001 -From: Werner Koch <wk@gnupg.org> -Date: Thu, 8 Nov 2012 15:38:44 +0100 -Subject: [PATCH] Fix extern inline use for gcc > 4.3 in c99 mode - -* mpi/mpi-inline.h [!G10_MPI_INLINE_DECL]: Take care of changed extern -inline semantics in gcc. --- - -I am not use how this will work out with non-gcc. However, we had no -problems in the past and thus this change is the least invasive for -non-gcc compilers. - -GnuPG-bug-id: 1406, 1435 ---- - mpi/mpi-inline.h | 9 ++++++++- - 1 files changed, 8 insertions(+), 1 deletions(-) - -diff --git a/mpi/mpi-inline.h b/mpi/mpi-inline.h -index 88d9f56..94e2aec 100644 ---- a/mpi/mpi-inline.h -+++ b/mpi/mpi-inline.h -@@ -28,8 +28,15 @@ - #ifndef G10_MPI_INLINE_H - #define G10_MPI_INLINE_H - -+/* Starting with gcc 4.3 "extern inline" conforms in c99 mode to the -+ c99 semantics. To keep the useful old semantics we use an -+ attribute. */ - #ifndef G10_MPI_INLINE_DECL --#define G10_MPI_INLINE_DECL extern __inline__ -+# ifdef __GNUC_STDC_INLINE__ -+# define G10_MPI_INLINE_DECL extern inline __attribute__ ((__gnu_inline__)) -+# else -+# define G10_MPI_INLINE_DECL extern __inline__ -+# endif - #endif - - G10_MPI_INLINE_DECL mpi_limb_t --- -1.7.2.5 - diff --git a/tools/depends/target/libgcrypt/Makefile b/tools/depends/target/libgcrypt/Makefile index 3e21bd5f7d..dc1e8008fa 100644 --- a/tools/depends/target/libgcrypt/Makefile +++ b/tools/depends/target/libgcrypt/Makefile @@ -3,7 +3,7 @@ DEPS= ../../Makefile.include 03-gcrypt-android-select.patch Makefile # lib name, version LIBNAME=libgcrypt -VERSION=1.4.5 +VERSION=1.6.2 SOURCE=$(LIBNAME)-$(VERSION) ARCHIVE=$(SOURCE).tar.bz2 @@ -12,7 +12,7 @@ CONFIGURE=cp -f $(CONFIG_SUB) $(CONFIG_GUESS) .; \ ./configure --prefix=$(PREFIX) --disable-shared \ ifeq ($(OS),osx) -CONFIGURE+=--disable-asm +CONFIGURE+=--disable-asm --disable-avx-support --disable-avx2-support endif LIBDYLIB=$(PLATFORM)/src/.libs/$(LIBNAME).a @@ -27,10 +27,10 @@ $(TARBALLS_LOCATION)/$(ARCHIVE): $(PLATFORM): $(TARBALLS_LOCATION)/$(ARCHIVE) $(DEPS) rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) - cd $(PLATFORM); patch -p1 < ../01-inline-gcc.patch - cd $(PLATFORM); patch -p0 < ../02-armasm.patch + cd $(PLATFORM); patch -p1 < ../01-asm-Allow-building-x86-and-amd64-using-old-compilers.patch + #cd $(PLATFORM); patch -p0 < ../02-armasm.patch cd $(PLATFORM); patch -p0 < ../03-gcrypt-android-select.patch - cd $(PLATFORM); patch -p0 < ../04-oflagmunging.patch + #cd $(PLATFORM); patch -p0 < ../04-oflagmunging.patch cd $(PLATFORM); $(CONFIGURE) $(LIBDYLIB): $(PLATFORM) diff --git a/tools/depends/target/libnfs/Makefile b/tools/depends/target/libnfs/Makefile index e39d00ceb1..642fba8f8a 100644 --- a/tools/depends/target/libnfs/Makefile +++ b/tools/depends/target/libnfs/Makefile @@ -3,12 +3,12 @@ DEPS= ../../Makefile.include Makefile # lib name, version LIBNAME=libnfs -VERSION=1.6.0 +VERSION=1.9.6 SOURCE=$(LIBNAME)-$(VERSION) ARCHIVE=$(SOURCE).tar.gz # configuration settings -CONFIGURE=./configure --prefix=$(PREFIX) +CONFIGURE=CFLAGS="-DHAVE_NET_IF_H" ./configure --prefix=$(PREFIX) LIBDYLIB=$(PLATFORM)/lib/.libs/$(LIBNAME).a @@ -23,7 +23,8 @@ $(PLATFORM): $(TARBALLS_LOCATION)/$(ARCHIVE) $(DEPS) -rm -rf $(PLATFORM); mkdir -p $(PLATFORM) cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) cd $(PLATFORM); ./bootstrap - cd $(PLATFORM); patch -p0 < ../timeval.patch + cd $(PLATFORM); patch -p0 < ../utils.patch + cd $(PLATFORM); patch -p1 < ../readahead.patch cd $(PLATFORM); $(CONFIGURE) $(LIBDYLIB): $(PLATFORM) @@ -32,9 +33,9 @@ $(LIBDYLIB): $(PLATFORM) .installed-$(PLATFORM): $(LIBDYLIB) $(MAKE) -C $(PLATFORM) install ifeq ($(OS),android) - rm -f $(PREFIX)/lib/libnfs.la $(PREFIX)/lib/libnfs.so $(PREFIX)/lib/libnfs.so.1 - mv -f $(PREFIX)/lib/libnfs.so.1.0.6 $(PREFIX)/lib/libnfs.so - $(RPL) -e "libnfs.so.1" "libnfs.so\x00\x00" $(PREFIX)/lib/libnfs.so + rm -f $(PREFIX)/lib/libnfs.la $(PREFIX)/lib/libnfs.so $(PREFIX)/lib/libnfs.so.4 + mv -f $(PREFIX)/lib/libnfs.so.4.3.0 $(PREFIX)/lib/libnfs.so + $(RPL) -e "libnfs.so.4" "libnfs.so\x00\x00" $(PREFIX)/lib/libnfs.so -$(READELF) --dynamic $(PREFIX)/lib/libnfs.so | grep ibrary endif touch $@ diff --git a/tools/depends/target/libnfs/readahead.patch b/tools/depends/target/libnfs/readahead.patch new file mode 100644 index 0000000000..ae7ec4ac0a --- /dev/null +++ b/tools/depends/target/libnfs/readahead.patch @@ -0,0 +1,23 @@ +From 5f6442d1b24dfe98a7134ffdb5c47490f140e6e3 Mon Sep 17 00:00:00 2001 +From: Ronnie Sahlberg <ronniesahlberg@gmail.com> +Date: Fri, 5 Dec 2014 08:44:15 -0800 +Subject: [PATCH] libnfs.c: fix typo, it is readahead not readahaed + +Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com> +--- + lib/libnfs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/libnfs.c b/lib/libnfs.c +index 2bacd91..8a81a94 100644 +--- a/lib/libnfs.c ++++ b/lib/libnfs.c +@@ -248,7 +248,7 @@ static int nfs_set_context_args(struct nfs_context *nfs, char *arg, char *val) + rpc_set_uid(nfs_get_rpc_context(nfs), atoi(val)); + } else if (!strcmp(arg, "gid")) { + rpc_set_gid(nfs_get_rpc_context(nfs), atoi(val)); +- } else if (!strcmp(arg, "readahaed")) { ++ } else if (!strcmp(arg, "readahead")) { + rpc_set_readahead(nfs_get_rpc_context(nfs), atoi(val)); + } + return 0; diff --git a/tools/depends/target/libnfs/timeval.patch b/tools/depends/target/libnfs/timeval.patch deleted file mode 100644 index 7f453d6c6f..0000000000 --- a/tools/depends/target/libnfs/timeval.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- include/nfsc/libnfs.h.orig 2013-05-28 21:59:32.000000000 +0200 -+++ include/nfsc/libnfs.h 2013-05-28 21:59:56.000000000 +0200 -@@ -18,12 +18,7 @@ - * This is the highlevel interface to access NFS resources using a posix-like interface - */ - #include <stdint.h> --#if defined(ANDROID) - #include <sys/time.h> --#endif --#if defined(AROS) --#include <sys/time.h> --#endif - - struct nfs_context; - struct rpc_context; diff --git a/tools/depends/target/libnfs/utils.patch b/tools/depends/target/libnfs/utils.patch new file mode 100644 index 0000000000..9b0d21cb9a --- /dev/null +++ b/tools/depends/target/libnfs/utils.patch @@ -0,0 +1,19 @@ +--- utils/nfs-ls.c.orig 2014-12-30 13:50:44.225840102 +0100 ++++ utils/nfs-ls.c 2014-12-30 13:51:03.753840180 +0100 +@@ -35,11 +35,15 @@ + #include <inttypes.h> + #include <string.h> + #include <sys/stat.h> +-#include <sys/statvfs.h> + #ifndef AROS ++#ifdef ANDROID ++#define statvfs statfs ++#include <sys/vfs.h> ++#else + #include <sys/statvfs.h> + #endif + #endif ++#endif + + #ifdef HAVE_UNISTD_H + #include <unistd.h> diff --git a/tools/depends/target/libsquish/Makefile b/tools/depends/target/libsquish/Makefile new file mode 100644 index 0000000000..50e9e3c9c4 --- /dev/null +++ b/tools/depends/target/libsquish/Makefile @@ -0,0 +1,28 @@ +include ../../Makefile.include +DEPS = ../../Makefile.include.in Makefile + +# reuse native src +SOURCE=$(abs_top_srcdir)/native/libsquish-native/src + +DYLIB=$(PLATFORM)/libsquish.a + +all: .installed-$(PLATFORM) + +$(PLATFORM): + -rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); cp -a $(SOURCE)/* . + cd $(PLATFORM); mv Makefile.target Makefile + cd $(PLATFORM); mkdir -p $(PREFIX)/include; mkdir -p $(PREFIX)/lib/pkgconfig + +$(DYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + +.installed-$(PLATFORM): $(DYLIB) + $(MAKE) -C $(PLATFORM) install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/target/libssh/Makefile b/tools/depends/target/libssh/Makefile index ae9d3f0f7e..d7af794730 100644 --- a/tools/depends/target/libssh/Makefile +++ b/tools/depends/target/libssh/Makefile @@ -1,9 +1,9 @@ include ../../Makefile.include -DEPS= ../../Makefile.include Makefile removelegacy.patch android.patch +DEPS= ../../Makefile.include Makefile removelegacy.patch android.patch ntohl.patch md5.patch # lib name, version LIBNAME=libssh -VERSION=0.5.0 +VERSION=0.7.0a SOURCE=$(LIBNAME)-$(VERSION) ARCHIVE=$(SOURCE).tar.gz @@ -20,18 +20,19 @@ $(PLATFORM): $(TARBALLS_LOCATION)/$(ARCHIVE) $(DEPS) cd $(PLATFORM); rm -rf build; mkdir -p build cd $(PLATFORM); patch -p0 < ../removelegacy.patch cd $(PLATFORM); patch -p0 < ../android.patch + cd $(PLATFORM); patch -p0 < ../ntohl.patch cd $(PLATFORM); patch -p0 < ../md5.patch cd $(PLATFORM); patch -p1 < ../darwin.patch sed -ie "s|-fstack-protector|-fnostack-protector|" "$(PLATFORM)/cmake/Modules/DefineCompilerFlags.cmake" sed -ie "s|add_subdirectory(examples)||" "$(PLATFORM)/CMakeLists.txt" - cd $(PLATFORM)/build; $(CMAKE) -DWITH_STATIC_LIB=1 -DTHREADS_PTHREAD_ARG=0 VERBOSE=1 .. + cd $(PLATFORM)/build; $(CMAKE) -DWITH_STATIC_LIB=1 -DWITH_EXAMPLES=0 -DTHREADS_PTHREAD_ARG=0 -DWITH_GSSAPI=0 VERBOSE=1 .. $(LIBDYLIB): $(PLATFORM) make -j 1 -C $(PLATFORM)/build .installed-$(PLATFORM): $(LIBDYLIB) make -C $(PLATFORM)/build install - rm -f $(PREFIX)/lib/libssh.so $(PREFIX)/lib/libssh.so.4.2.0 $(PREFIX)/lib/libssh.so.4 + rm -f $(PREFIX)/lib/libssh.so $(PREFIX)/lib/libssh.so.4.3.0 $(PREFIX)/lib/libssh.so.4 rm -f $(PREFIX)/lib/libssh.*dylib* touch $@ diff --git a/tools/depends/target/libssh/android.patch b/tools/depends/target/libssh/android.patch index 96bafd8550..8df5945608 100644 --- a/tools/depends/target/libssh/android.patch +++ b/tools/depends/target/libssh/android.patch @@ -1,20 +1,6 @@ ---- src/connect.c 2011-05-31 10:29:52.000000000 -0400 -+++ src/connect.c 2013-01-03 00:38:13.572737322 -0500 -@@ -159,7 +159,11 @@ - int timeout_ms; - ssh_pollfd_t fds; - int rc = 0; -+#ifdef ANDROID -+ socklen_t len = sizeof(rc); -+#else - unsigned int len = sizeof(rc); -+#endif - - enter_function(); - --- src/misc.c 2011-05-31 10:29:52.000000000 -0400 +++ src/misc.c 2013-01-03 00:37:37.652737345 -0500 -@@ -208,6 +208,9 @@ +@@ -207,6 +208,9 @@ char *ssh_get_user_home_dir(void) { char *szPath = NULL; @@ -24,7 +10,7 @@ struct passwd pwd; struct passwd *pwdbuf; char buf[NSS_BUFLEN_PASSWD]; -@@ -219,7 +222,7 @@ +@@ -225,7 +222,7 @@ } szPath = strdup(pwd.pw_dir); @@ -33,17 +19,15 @@ return szPath; } -@@ -233,6 +236,19 @@ +@@ -239,6 +236,17 @@ } - char *ssh_get_local_username(ssh_session session) { + char *ssh_get_local_username(void) { +#ifdef ANDROID + char *name = NULL; + struct passwd *pwd = NULL; + pwd = getpwuid(getuid()); + if ( pwd == NULL) { -+ ssh_set_error(session, SSH_FATAL, -+ "Couldn't retrieve information for current user!"); + return NULL; + } + @@ -53,11 +37,10 @@ struct passwd pwd; struct passwd *pwdbuf; char buf[NSS_BUFLEN_PASSWD]; -@@ -248,6 +264,7 @@ +@@ -252,6 +264,7 @@ name = strdup(pwd.pw_name); +#endif if (name == NULL) { - ssh_set_error_oom(session); return NULL; diff --git a/tools/depends/target/libssh/darwin.patch b/tools/depends/target/libssh/darwin.patch index 3288d295f7..2f37854a10 100644 --- a/tools/depends/target/libssh/darwin.patch +++ b/tools/depends/target/libssh/darwin.patch @@ -1,37 +1,17 @@ -diff --git a/include/libssh/misc.h b/include/libssh/misc.h -index 9897c4e..fe4f602 100644 ---- a/include/libssh/misc.h -+++ b/include/libssh/misc.h -@@ -35,8 +35,12 @@ int ssh_is_ipaddr_v4(const char *str); - int ssh_is_ipaddr(const char *str); +--- a/ConfigureChecks.cmake 2014-12-27 04:30:13.000000000 -0600 ++++ b/ConfigureChecks.cmake 2015-01-07 12:20:43.000000000 -0600 +@@ -104,8 +104,14 @@ + check_function_exists(poll HAVE_POLL) + check_function_exists(select HAVE_SELECT) + check_function_exists(getaddrinfo HAVE_GETADDRINFO) ++ ++if (APPLE) ++check_symbol_exists(ntohll sys/_endian.h HAVE_NTOHLL) ++check_symbol_exists(htonll sys/_endian.h HAVE_HTONLL) ++else (APPLE) + check_function_exists(ntohll HAVE_NTOHLL) + check_function_exists(htonll HAVE_HTONLL) ++endif(APPLE) - /* macro for byte ordering */ -+#if !defined(ntohll) - uint64_t ntohll(uint64_t); -+#endif -+#if !defined(htonll) - #define htonll(x) ntohll(x) -+#endif - - /* list processing */ - -diff --git a/src/misc.c b/src/misc.c -index 008be1b..3c2d8bb 100644 ---- a/src/misc.c -+++ b/src/misc.c -@@ -286,6 +286,7 @@ int ssh_is_ipaddr(const char *str) { - - #endif /* _WIN32 */ - -+#if !defined(ntohll) - uint64_t ntohll(uint64_t a) { - #ifdef WORDS_BIGENDIAN - return a; -@@ -298,6 +299,7 @@ uint64_t ntohll(uint64_t a) { - return ((((uint64_t) low) << 32) | ( high)); - #endif - } -+#endif - - char *ssh_lowercase(const char* str) { - char *new, *p; + if (WIN32) + check_function_exists(_strtoui64 HAVE__STRTOUI64) diff --git a/tools/depends/target/libssh/md5.patch b/tools/depends/target/libssh/md5.patch index b5985f0be8..84f4bec0ef 100644 --- a/tools/depends/target/libssh/md5.patch +++ b/tools/depends/target/libssh/md5.patch @@ -1,19 +1,17 @@ -diff -ruN include/libssh/wrapper.h include/libssh/wrapper.h ---- include/libssh/wrapper.h 2011-05-31 10:29:52.000000000 -0400 -+++ include/libssh/wrapper.h 2012-07-26 00:21:16.021511996 -0400 -@@ -26,7 +26,7 @@ - #include "libssh/libcrypto.h" - #include "libssh/libgcrypt.h" +--- include/libssh/wrapper.h.orig 2014-12-27 12:03:55.521114159 +0100 ++++ include/libssh/wrapper.h 2014-12-27 12:06:35.072310640 +0100 +@@ -52,7 +52,7 @@ + }; + typedef struct ssh_mac_ctx_struct *ssh_mac_ctx; -MD5CTX md5_init(void); +MD5CTX ssh_md5_init(void); void md5_update(MD5CTX c, const void *data, unsigned long len); void md5_final(unsigned char *md,MD5CTX c); - SHACTX sha1_init(void); -diff -ruN src/dh.c src/dh.c ---- src/dh.c 2011-05-31 10:29:52.000000000 -0400 -+++ src/dh.c 2012-07-26 00:19:52.961512049 -0400 -@@ -854,7 +854,7 @@ + +--- src/dh.c.orig 2014-12-27 12:08:07.441537435 +0100 ++++ src/dh.c 2014-12-27 12:09:25.539205892 +0100 +@@ -906,7 +906,7 @@ return SSH_ERROR; } @@ -22,10 +20,18 @@ diff -ruN src/dh.c src/dh.c if (ctx == NULL) { SAFE_FREE(h); return SSH_ERROR; -diff -ruN src/kex.c src/kex.c ---- src/kex.c 2011-05-31 10:29:52.000000000 -0400 -+++ src/kex.c 2012-07-26 00:20:37.671512021 -0400 -@@ -509,7 +509,7 @@ +@@ -1037,7 +1037,7 @@ + goto out; + } + +- ctx = md5_init(); ++ ctx = ssh_md5_init(); + if (ctx == NULL) { + free(h); + rc = -1; +--- src/kex1.c.orig 2014-12-27 12:11:18.307842585 +0100 ++++ src/kex1.c 2014-12-27 12:11:38.999225682 +0100 +@@ -78,7 +78,7 @@ ssh_string hostn) { MD5CTX md5 = NULL; @@ -34,23 +40,10 @@ diff -ruN src/kex.c src/kex.c if (md5 == NULL) { return -1; } -diff -ruN src/keyfiles.c src/keyfiles.c ---- src/keyfiles.c 2011-05-31 10:29:52.000000000 -0400 -+++ src/keyfiles.c 2012-07-26 00:20:51.801512011 -0400 -@@ -223,7 +223,7 @@ - unsigned int md_not_empty; - - for (j = 0, md_not_empty = 0; j < keylen; ) { -- md = md5_init(); -+ md = ssh_md5_init(); - if (md == NULL) { - return -1; - } -diff -ruN src/libcrypto.c src/libcrypto.c ---- src/libcrypto.c 2011-05-31 10:29:52.000000000 -0400 -+++ src/libcrypto.c 2012-07-26 00:20:07.061512022 -0400 -@@ -89,7 +89,7 @@ - SHA1(digest, len, hash); +--- src/libcrypto.c.orig 2014-12-27 12:12:40.977378184 +0100 ++++ src/libcrypto.c 2014-12-27 12:13:14.716372667 +0100 +@@ -234,7 +234,7 @@ + SHA512(digest, len, hash); } -MD5CTX md5_init(void) { @@ -58,11 +51,10 @@ diff -ruN src/libcrypto.c src/libcrypto.c MD5CTX c = malloc(sizeof(*c)); if (c == NULL) { return NULL; -diff -ruN src/libgcrypt.c src/libgcrypt.c ---- src/libgcrypt.c 2011-05-31 10:29:52.000000000 -0400 -+++ src/libgcrypt.c 2012-07-26 00:20:19.401512036 -0400 -@@ -62,7 +62,7 @@ - gcry_md_hash_buffer(GCRY_MD_SHA1, hash, digest, len); +--- src/libgcrypt.c.orig 2014-12-27 12:13:46.319430927 +0100 ++++ src/libgcrypt.c 2014-12-27 12:13:59.611034883 +0100 +@@ -132,7 +132,7 @@ + gcry_md_hash_buffer(GCRY_MD_SHA512, hash, digest, len); } -MD5CTX md5_init(void) { diff --git a/tools/depends/target/libssh/ntohl.patch b/tools/depends/target/libssh/ntohl.patch new file mode 100644 index 0000000000..2c0c0272a2 --- /dev/null +++ b/tools/depends/target/libssh/ntohl.patch @@ -0,0 +1,12 @@ +--- src/packet_cb.c.orig 2014-12-26 09:41:09.220220531 +0100 ++++ src/packet_cb.c 2014-12-26 09:39:49.850555189 +0100 +@@ -36,6 +36,9 @@ + #include "libssh/socket.h" + #include "libssh/ssh2.h" + #include "libssh/curve25519.h" ++#ifdef ANDROID ++#include <sys/endian.h> ++#endif + + + /** diff --git a/tools/depends/target/nettle/Makefile b/tools/depends/target/nettle/Makefile index e48741531c..df823eacf2 100644 --- a/tools/depends/target/nettle/Makefile +++ b/tools/depends/target/nettle/Makefile @@ -7,11 +7,17 @@ VERSION=2.7.1 SOURCE=$(LIBNAME)-$(VERSION) ARCHIVE=$(SOURCE).tar.gz +ifeq ($(OS),ios) + ifneq (,$(findstring 3.,$(XCODE_VERSION))) + CONFIGURE_FLAGS=-disable-assembler + endif +endif + # configuration settings CONFIGURE=cp -f $(CONFIG_SUB) $(CONFIG_GUESS) .; \ - ./configure --prefix=$(PREFIX) --disable-shared --disable-openssl + ./configure --prefix=$(PREFIX) --disable-shared --disable-openssl $(CONFIGURE_FLAGS) -LIBDYLIB=$(PLATFORM)/src/.libs/$(LIBNAME).a +LIBDYLIB=$(PLATFORM)/lib$(LIBNAME).a CLEAN_FILES=$(ARCHIVE) $(PLATFORM) diff --git a/tools/depends/target/openssl/Makefile b/tools/depends/target/openssl/Makefile index 8ea7208297..11a04bd3be 100644 --- a/tools/depends/target/openssl/Makefile +++ b/tools/depends/target/openssl/Makefile @@ -3,7 +3,7 @@ DEPS= ../../Makefile.include Makefile # lib name, version LIBNAME=openssl -VERSION=0.9.8r +VERSION=1.0.1j SOURCE=$(LIBNAME)-$(VERSION) ARCHIVE=$(SOURCE).tar.gz @@ -37,8 +37,6 @@ $(PLATFORM): $(TARBALLS_LOCATION)/$(ARCHIVE) $(DEPS) #when compiled on darwin it just won't realise that we do crosscompiling #so it would stick in -arch i386 or -arch x86_64 into the cflags #that would break the cross compile so we have to get rid of these - cd $(PLATFORM); patch -p1 < ../libz.patch - cd $(PLATFORM); patch -p1 < ../fix_alert_handling.patch cd $(PLATFORM); CFLAGS="$(CFLAGS)" CC=$(CC) RANLIB=$(RANLIB) $(CONFIGURE) if test "$(OS)" = "osx"; then \ sed -ie "s|CC= /usr/bin/gcc-4.2|CC= $(CC)|" "$(PLATFORM)/Makefile"; \ diff --git a/tools/depends/target/openssl/fix_alert_handling.patch b/tools/depends/target/openssl/fix_alert_handling.patch deleted file mode 100644 index 09152f3908..0000000000 --- a/tools/depends/target/openssl/fix_alert_handling.patch +++ /dev/null @@ -1,301 +0,0 @@ -From: mancha <mancha1@hush.com> -Date: Thu, 27 Mar 2014 00:47:14 +0000 (+0000) -Subject: Fix alert handling. -X-Git-Url: -http://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff_plain;h=a375025e4dd58a05e926a5384774a85671695dd9;hp=d471adf351b92d38992cbe2374ad6e9d81a51a75 - -Fix alert handling. - -Fix OpenSSL 0.9.8 alert handling. - -PR#3038 ---- - -diff --git a/apps/s_cb.c b/apps/s_cb.c -index 97caffc..df922f3 100644 ---- a/apps/s_cb.c -+++ b/apps/s_cb.c -@@ -518,6 +518,24 @@ void MS_CALLBACK msg_cb(int write_p, int version, int content_type, const void * - case 100: - str_details2 = " no_renegotiation"; - break; -+ case 110: -+ str_details2 = " unsupported_extension"; -+ break; -+ case 111: -+ str_details2 = " certificate_unobtainable"; -+ break; -+ case 112: -+ str_details2 = " unrecognized_name"; -+ break; -+ case 113: -+ str_details2 = " bad_certificate_status_response"; -+ break; -+ case 114: -+ str_details2 = " bad_certificate_hash_value"; -+ break; -+ case 115: -+ str_details2 = " unknown_psk_identity"; -+ break; - } - } - } -diff --git a/crypto/err/openssl.ec b/crypto/err/openssl.ec -index 8688266..1a580c5 100644 ---- a/crypto/err/openssl.ec -+++ b/crypto/err/openssl.ec -@@ -71,6 +71,11 @@ R SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071 - R SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 - R SSL_R_TLSV1_ALERT_USER_CANCELLED 1090 - R SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 -+R SSL_R_TLSV1_UNSUPPORTED_EXTENSION 1110 -+R SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE 1111 -+R SSL_R_TLSV1_UNRECOGNIZED_NAME 1112 -+R SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE 1113 -+R SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE 1114 - - R RSAREF_R_CONTENT_ENCODING 0x0400 - R RSAREF_R_DATA 0x0401 -diff --git a/ssl/s23_clnt.c b/ssl/s23_clnt.c -index c6b9142..830eff0 100644 ---- a/ssl/s23_clnt.c -+++ b/ssl/s23_clnt.c -@@ -509,7 +509,7 @@ static int ssl23_get_server_hello(SSL *s) - /* use special padding (SSL 3.0 draft/RFC 2246, App. E.2) */ - s->s2->ssl2_rollback=1; - -- /* setup the 5 bytes we have read so we get them from -+ /* setup the 7 bytes we have read so we get them from - * the sslv2 buffer */ - s->rstate=SSL_ST_READ_HEADER; - s->packet_length=n; -@@ -525,27 +525,13 @@ static int ssl23_get_server_hello(SSL *s) - s->handshake_func=s->method->ssl_connect; - #endif - } -- else if ((p[0] == SSL3_RT_HANDSHAKE) && -- (p[1] == SSL3_VERSION_MAJOR) && -- ((p[2] == SSL3_VERSION_MINOR) || -- (p[2] == TLS1_VERSION_MINOR)) && -- (p[5] == SSL3_MT_SERVER_HELLO)) -+ else if (p[1] == SSL3_VERSION_MAJOR && -+ ((p[2] == SSL3_VERSION_MINOR) || -+ (p[2] == TLS1_VERSION_MINOR)) && -+ ((p[0] == SSL3_RT_HANDSHAKE && p[5] == SSL3_MT_SERVER_HELLO) || -+ (p[0] == SSL3_RT_ALERT && p[3] == 0 && p[4] == 2))) - { -- /* we have sslv3 or tls1 */ -- -- if (!ssl_init_wbio_buffer(s,1)) goto err; -- -- /* we are in this state */ -- s->state=SSL3_ST_CR_SRVR_HELLO_A; -- -- /* put the 5 bytes we have read into the input buffer -- * for SSLv3 */ -- s->rstate=SSL_ST_READ_HEADER; -- s->packet_length=n; -- s->packet= &(s->s3->rbuf.buf[0]); -- memcpy(s->packet,buf,n); -- s->s3->rbuf.left=n; -- s->s3->rbuf.offset=0; -+ /* we have sslv3 or tls1 (server hello or alert) */ - - if ((p[2] == SSL3_VERSION_MINOR) && - !(s->options & SSL_OP_NO_SSLv3)) -@@ -572,35 +558,52 @@ static int ssl23_get_server_hello(SSL *s) - SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,SSL_R_UNSUPPORTED_PROTOCOL); - goto err; - } -- -- s->handshake_func=s->method->ssl_connect; -- } -- else if ((p[0] == SSL3_RT_ALERT) && -- (p[1] == SSL3_VERSION_MAJOR) && -- ((p[2] == SSL3_VERSION_MINOR) || -- (p[2] == TLS1_VERSION_MINOR)) && -- (p[3] == 0) && -- (p[4] == 2)) -- { -- void (*cb)(const SSL *ssl,int type,int val)=NULL; -- int j; -- -- /* An alert */ -- if (s->info_callback != NULL) -- cb=s->info_callback; -- else if (s->ctx->info_callback != NULL) -- cb=s->ctx->info_callback; -- -- i=p[5]; -- if (cb != NULL) -+ -+ if (p[0] == SSL3_RT_ALERT && p[5] != SSL3_AL_WARNING) - { -- j=(i<<8)|p[6]; -- cb(s,SSL_CB_READ_ALERT,j); -+ /* fatal alert */ -+ -+ void (*cb)(const SSL *ssl,int type,int val)=NULL; -+ int j; -+ -+ if (s->info_callback != NULL) -+ cb=s->info_callback; -+ else if (s->ctx->info_callback != NULL) -+ cb=s->ctx->info_callback; -+ -+ i=p[5]; -+ if (cb != NULL) -+ { -+ j=(i<<8)|p[6]; -+ cb(s,SSL_CB_READ_ALERT,j); -+ } -+ -+ if (s->msg_callback) -+ s->msg_callback(0, s->version, SSL3_RT_ALERT, p+5, 2, s, s->msg_callback_arg); -+ -+ s->rwstate=SSL_NOTHING; -+ SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,SSL_AD_REASON_OFFSET+p[6]); -+ goto err; - } - -- s->rwstate=SSL_NOTHING; -- SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,SSL_AD_REASON_OFFSET+p[6]); -- goto err; -+ if (!ssl_init_wbio_buffer(s,1)) goto err; -+ -+ /* we are in this state */ -+ s->state=SSL3_ST_CR_SRVR_HELLO_A; -+ -+ /* put the 7 bytes we have read into the input buffer -+ * for SSLv3 */ -+ s->rstate=SSL_ST_READ_HEADER; -+ s->packet_length=n; -+ if (s->s3->rbuf.buf == NULL) -+ if (!ssl3_setup_buffers(s)) -+ goto err; -+ s->packet= &(s->s3->rbuf.buf[0]); -+ memcpy(s->packet,buf,n); -+ s->s3->rbuf.left=n; -+ s->s3->rbuf.offset=0; -+ -+ s->handshake_func=s->method->ssl_connect; - } - else - { -diff --git a/ssl/s3_enc.c b/ssl/s3_enc.c -index 5d8f8ae..736bfac 100644 ---- a/ssl/s3_enc.c -+++ b/ssl/s3_enc.c -@@ -758,6 +758,12 @@ int ssl3_alert_code(int code) - case SSL_AD_INTERNAL_ERROR: return(SSL3_AD_HANDSHAKE_FAILURE); - case SSL_AD_USER_CANCELLED: return(SSL3_AD_HANDSHAKE_FAILURE); - case SSL_AD_NO_RENEGOTIATION: return(-1); /* Don't send it :-) */ -+ case SSL_AD_UNSUPPORTED_EXTENSION: return(SSL3_AD_HANDSHAKE_FAILURE); -+ case SSL_AD_CERTIFICATE_UNOBTAINABLE: return(SSL3_AD_HANDSHAKE_FAILURE); -+ case SSL_AD_UNRECOGNIZED_NAME: return(SSL3_AD_HANDSHAKE_FAILURE); -+ case SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE: return(SSL3_AD_HANDSHAKE_FAILURE); -+ case SSL_AD_BAD_CERTIFICATE_HASH_VALUE: return(SSL3_AD_HANDSHAKE_FAILURE); -+ case SSL_AD_UNKNOWN_PSK_IDENTITY:return(TLS1_AD_UNKNOWN_PSK_IDENTITY); - default: return(-1); - } - } -diff --git a/ssl/ssl.h b/ssl/ssl.h -index eebc99e..5f2a04e 100644 ---- a/ssl/ssl.h -+++ b/ssl/ssl.h -@@ -1207,6 +1207,8 @@ size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count); - #define SSL_AD_CERTIFICATE_UNOBTAINABLE TLS1_AD_CERTIFICATE_UNOBTAINABLE - #define SSL_AD_UNRECOGNIZED_NAME TLS1_AD_UNRECOGNIZED_NAME - #define SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE -+#define SSL_AD_BAD_CERTIFICATE_HASH_VALUE TLS1_AD_BAD_CERTIFICATE_HASH_VALUE -+#define SSL_AD_UNKNOWN_PSK_IDENTITY TLS1_AD_UNKNOWN_PSK_IDENTITY /* fatal */ - - #define SSL_ERROR_NONE 0 - #define SSL_ERROR_SSL 1 -@@ -2077,6 +2079,11 @@ void ERR_load_SSL_strings(void); - #define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW 1022 - #define SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048 - #define SSL_R_TLSV1_ALERT_USER_CANCELLED 1090 -+#define SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE 1114 -+#define SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE 1113 -+#define SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE 1111 -+#define SSL_R_TLSV1_UNRECOGNIZED_NAME 1112 -+#define SSL_R_TLSV1_UNSUPPORTED_EXTENSION 1110 - #define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER 232 - #define SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST 227 - #define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 233 -diff --git a/ssl/ssl_err.c b/ssl/ssl_err.c -index 60e7e9d..9e28dfd 100644 ---- a/ssl/ssl_err.c -+++ b/ssl/ssl_err.c -@@ -475,6 +475,11 @@ static ERR_STRING_DATA SSL_str_reasons[]= - {ERR_REASON(SSL_R_TLSV1_ALERT_RECORD_OVERFLOW),"tlsv1 alert record overflow"}, - {ERR_REASON(SSL_R_TLSV1_ALERT_UNKNOWN_CA),"tlsv1 alert unknown ca"}, - {ERR_REASON(SSL_R_TLSV1_ALERT_USER_CANCELLED),"tlsv1 alert user cancelled"}, -+{ERR_REASON(SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE),"tlsv1 bad certificate hash value"}, -+{ERR_REASON(SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE),"tlsv1 bad certificate status response"}, -+{ERR_REASON(SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE),"tlsv1 certificate unobtainable"}, -+{ERR_REASON(SSL_R_TLSV1_UNRECOGNIZED_NAME),"tlsv1 unrecognized name"}, -+{ERR_REASON(SSL_R_TLSV1_UNSUPPORTED_EXTENSION),"tlsv1 unsupported extension"}, - {ERR_REASON(SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER),"tls client cert req with anon cipher"}, - {ERR_REASON(SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST),"tls invalid ecpointformat list"}, - {ERR_REASON(SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST),"tls peer did not respond with certificate list"}, -diff --git a/ssl/ssl_stat.c b/ssl/ssl_stat.c -index e7509f0..cd52184 100644 ---- a/ssl/ssl_stat.c -+++ b/ssl/ssl_stat.c -@@ -414,6 +414,12 @@ const char *SSL_alert_desc_string(int value) - case TLS1_AD_INTERNAL_ERROR: str="IE"; break; - case TLS1_AD_USER_CANCELLED: str="US"; break; - case TLS1_AD_NO_RENEGOTIATION: str="NR"; break; -+ case TLS1_AD_UNSUPPORTED_EXTENSION: str="UE"; break; -+ case TLS1_AD_CERTIFICATE_UNOBTAINABLE: str="CO"; break; -+ case TLS1_AD_UNRECOGNIZED_NAME: str="UN"; break; -+ case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE: str="BR"; break; -+ case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE: str="BH"; break; -+ case TLS1_AD_UNKNOWN_PSK_IDENTITY: str="UP"; break; - default: str="UK"; break; - } - return(str); -@@ -497,6 +503,24 @@ const char *SSL_alert_desc_string_long(int value) - case TLS1_AD_NO_RENEGOTIATION: - str="no renegotiation"; - break; -+ case TLS1_AD_UNSUPPORTED_EXTENSION: -+ str="unsupported extension"; -+ break; -+ case TLS1_AD_CERTIFICATE_UNOBTAINABLE: -+ str="certificate unobtainable"; -+ break; -+ case TLS1_AD_UNRECOGNIZED_NAME: -+ str="unrecognized name"; -+ break; -+ case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE: -+ str="bad certificate status response"; -+ break; -+ case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE: -+ str="bad certificate hash value"; -+ break; -+ case TLS1_AD_UNKNOWN_PSK_IDENTITY: -+ str="unknown PSK identity"; -+ break; - default: str="unknown"; break; - } - return(str); -diff --git a/ssl/t1_enc.c b/ssl/t1_enc.c -index 323d384..ad6b637 100644 ---- a/ssl/t1_enc.c -+++ b/ssl/t1_enc.c -@@ -853,6 +853,12 @@ int tls1_alert_code(int code) - case SSL_AD_INTERNAL_ERROR: return(TLS1_AD_INTERNAL_ERROR); - case SSL_AD_USER_CANCELLED: return(TLS1_AD_USER_CANCELLED); - case SSL_AD_NO_RENEGOTIATION: return(TLS1_AD_NO_RENEGOTIATION); -+ case SSL_AD_UNSUPPORTED_EXTENSION: return(TLS1_AD_UNSUPPORTED_EXTENSION); -+ case SSL_AD_CERTIFICATE_UNOBTAINABLE: return(TLS1_AD_CERTIFICATE_UNOBTAINABLE); -+ case SSL_AD_UNRECOGNIZED_NAME: return(TLS1_AD_UNRECOGNIZED_NAME); -+ case SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE: return(TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE); -+ case SSL_AD_BAD_CERTIFICATE_HASH_VALUE: return(TLS1_AD_BAD_CERTIFICATE_HASH_VALUE); -+ case SSL_AD_UNKNOWN_PSK_IDENTITY:return(TLS1_AD_UNKNOWN_PSK_IDENTITY); - #ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE - case DTLS1_AD_MISSING_HANDSHAKE_MESSAGE: return - (DTLS1_AD_MISSING_HANDSHAKE_MESSAGE); diff --git a/tools/depends/target/openssl/libz.patch b/tools/depends/target/openssl/libz.patch deleted file mode 100644 index 6e9f7508a4..0000000000 --- a/tools/depends/target/openssl/libz.patch +++ /dev/null @@ -1,43 +0,0 @@ -diff -ur openssl/Configure openssl/Configure ---- openssl/Configure 2009-02-19 05:43:18.000000000 -0400 -+++ openssl/Configure 2009-04-02 15:39:19.000000000 -0400 -@@ -1218,7 +1218,14 @@ - $cflags = "-DZLIB $cflags"; - if (defined($disabled{"zlib-dynamic"})) - { -- $lflags = "$lflags -lz"; -+ if (defined($withargs{"zlib-lib"})) -+ { -+ $lflags = "$lflags -L" . $withargs{"zlib-lib"} . " -lz"; -+ } -+ else -+ { -+ $lflags = "$lflags -lz"; -+ } - } - else - { ---- openssl//Makefile.org 2010-01-27 11:06:36.000000000 -0500 -+++ openssl/Makefile.org 20102012-12-31 17:47:43.392861820 -0500 -@@ -210,6 +210,7 @@ - MAKEDEPPROG='${MAKEDEPPROG}' \ - SHARED_LDFLAGS='${SHARED_LDFLAGS}' \ - KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' \ -+ ZLIB_INCLUDE='$(ZLIB_INCLUDE)' LIBZLIB='$(LIBZLIB)' \ - EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' \ - SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' \ - PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' \ ---- openssl/crypto/Makefile 2008-09-17 13:10:55.000000000 -0400 -+++ openssl/crypto/Makefile 2012-12-31 17:46:36.292861863 -0500 -@@ -5,9 +5,9 @@ - DIR= crypto - TOP= .. - CC= cc --INCLUDE= -I. -I$(TOP) -I../include -+INCLUDE= -I. -I$(TOP) -I../include $(ZLIB_INCLUDE) - # INCLUDES targets sudbirs! --INCLUDES= -I.. -I../.. -I../../include -+INCLUDES= -I.. -I../.. -I../../include $(ZLIB_INCLUDE) - CFLAG= -g - MAKEDEPPROG= makedepend - MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) diff --git a/tools/depends/target/xbmc-audioencoder-addons/Makefile b/tools/depends/target/xbmc-audioencoder-addons/Makefile index 9153a24787..bd9307375e 100644 --- a/tools/depends/target/xbmc-audioencoder-addons/Makefile +++ b/tools/depends/target/xbmc-audioencoder-addons/Makefile @@ -1,40 +1,5 @@ --include ../../Makefile.include - +BUILDDIR := $(shell pwd) ADDONS = "audioencoder.flac audioencoder.lame audioencoder.vorbis audioencoder.wav" -ifeq ($(PLATFORM),) - PLATFORM = native -endif -ifeq ($(CMAKE),) - CMAKE = cmake -endif - -CMAKE_EXTRA = -ifeq (darwin, $(findstring darwin, $(HOST))) - INSTALL_PREFIX = ../../../../../addons/ - CMAKE_EXTRA = -DPACKAGE_ZIP=1 -DDEPENDS_PATH=$(PREFIX) -else ifneq ($(PREFIX),) - INSTALL_PREFIX = $(PREFIX) - CMAKE_EXTRA = -DDEPENDS_PATH=$(PREFIX) -endif - -all: .installed-$(PLATFORM) - -clean: - rm -f .installed-$(PLATFORM) - -distclean: - rm -rf $(PLATFORM) .installed-$(PLATFORM) native - -.installed-$(PLATFORM): -ifeq ($(PREFIX),) - @echo - @echo "ERROR: please set PREFIX to the xbmc install path e.g. make PREFIX=/usr/local" - @exit 1 -endif - mkdir -p $(PLATFORM); \ - cd $(PLATFORM); \ - $(CMAKE) -DCMAKE_INSTALL_PREFIX=$(INSTALL_PREFIX) -DCMAKE_PREFIX_PATH=$(PREFIX) $(CMAKE_EXTRA) \ - -DADDONS_TO_BUILD=$(ADDONS) ../../../../../project/cmake/addons/ ;\ - $(MAKE); - touch $@ +-include ../../Makefile.include +include ../../xbmc-addons.include diff --git a/tools/depends/target/xbmc-pvr-addons/Makefile b/tools/depends/target/xbmc-pvr-addons/Makefile index 987fc0e0cf..2dc8eba520 100644 --- a/tools/depends/target/xbmc-pvr-addons/Makefile +++ b/tools/depends/target/xbmc-pvr-addons/Makefile @@ -2,7 +2,7 @@ include ../../Makefile.include #DEPS= ../../Makefile.include Makefile LIBNAME=xbmc-pvr-addons -VERSION=9f63d1bc39ffcb28f8aea580ea0669211e4d16e5 +VERSION=1d60b822d132ac4a8f9fbfc1f4048e941ad6371e GIT_DIR=$(TARBALLS_LOCATION)/$(LIBNAME).git BASE_URL=git://github.com/opdenkamp/$(LIBNAME).git DYLIB=$(PLATFORM)/addons/pvr.demo/.libs/libpvrdemo-addon.so diff --git a/tools/depends/xbmc-addons.include b/tools/depends/xbmc-addons.include new file mode 100644 index 0000000000..5f0822dfdf --- /dev/null +++ b/tools/depends/xbmc-addons.include @@ -0,0 +1,36 @@ +ifeq ($(PLATFORM),) + PLATFORM = native +endif +ifeq ($(CMAKE),) + CMAKE = cmake +endif + +CMAKE_EXTRA = +ifeq (darwin, $(findstring darwin, $(HOST))) + INSTALL_PREFIX = ../../../../../addons/ + CMAKE_EXTRA = -DPACKAGE_ZIP=1 -DDEPENDS_PATH=$(PREFIX) +else ifneq ($(PREFIX),) + INSTALL_PREFIX = $(PREFIX) +endif + +all: .installed-$(PLATFORM) + + +clean: + rm -f .installed-$(PLATFORM) + +distclean: + rm -rf $(PLATFORM) .installed-$(PLATFORM) native + +.installed-$(PLATFORM): +ifeq ($(PREFIX),) + @echo + @echo "ERROR: please set PREFIX to the xbmc install path e.g. make PREFIX=/usr/local" + @exit 1 +endif + mkdir -p $(PLATFORM); \ + cd $(PLATFORM); \ + $(CMAKE) -DCMAKE_INSTALL_PREFIX=$(INSTALL_PREFIX) $(CMAKE_EXTRA) \ + -DADDONS_TO_BUILD=$(ADDONS) ../../../../../project/cmake/addons/ -DBUILD_DIR=$(BUILDDIR)/$(PLATFORM)/build ;\ + $(MAKE); + touch $@ diff --git a/tools/windows/CompileInfo.bat b/tools/windows/CompileInfo.bat index ef8af0a36c..a94664a410 100644 --- a/tools/windows/CompileInfo.bat +++ b/tools/windows/CompileInfo.bat @@ -15,6 +15,11 @@ FOR /f %%i IN ('%msys_bin_dir%\awk.exe "/VERSION_MINOR/ {print $2}" %base_dir%\v FOR /f %%i IN ('%msys_bin_dir%\awk.exe "/VERSION_TAG/ {print $2}" %base_dir%\version.txt') DO SET tag=%%i FOR /f %%i IN ('%msys_bin_dir%\awk.exe "/ADDON_API/ {print $2}" %base_dir%\version.txt') DO SET addon_api=%%i +SET app_version=%major%.%minor% +IF NOT [%tag%] == [] ( + SET app_version=%app_version%-%tag% +) + REM XBMC_PC.rc.in requires a comma-separated version of addon_api SET separator=, CALL SET file_version=%%addon_api:.=%separator%%%%separator%0 @@ -22,5 +27,5 @@ CALL SET file_version=%%addon_api:.=%separator%%%%separator%0 REM create the files with the proper version information "%msys_bin_dir%\sed.exe" -e s/@APP_NAME@/%app_name%/g -e s/@APP_VERSION_MAJOR@/%major%/g -e s/@APP_VERSION_MINOR@/%minor%/g -e s/@APP_VERSION_TAG@/%tag%/g "%base_dir%\xbmc\CompileInfo.cpp.in" > "%base_dir%\xbmc\CompileInfo.cpp" "%msys_bin_dir%\sed.exe" s/@APP_ADDON_API@/%addon_api%/g "%base_dir%\addons\xbmc.addon\addon.xml.in" > "%base_dir%\addons\xbmc.addon\addon.xml" -"%msys_bin_dir%\sed.exe" -e s/@APP_NAME@/%app_name%/g -e s/@COMPANY_NAME@/%company_name%/g -e s/@APP_VERSION_MAJOR@/%major%/g -e s/@APP_VERSION_MINOR@/%minor%/g -e s/@APP_VERSION_TAG@/%tag%/g -e s/@FILE_VERSION@/%file_version%/g "%base_dir%\xbmc\win32\XBMC_PC.rc.in" > "%base_dir%\xbmc\win32\XBMC_PC.rc" +"%msys_bin_dir%\sed.exe" -e s/@APP_NAME@/%app_name%/g -e s/@COMPANY_NAME@/%company_name%/g -e s/@APP_VERSION_MAJOR@/%major%/g -e s/@APP_VERSION_MINOR@/%minor%/g -e s/@APP_VERSION_TAG@/%tag%/g -e s/@FILE_VERSION@/%file_version%/g -e s/@APP_VERSION@/%app_version%/g "%base_dir%\xbmc\win32\XBMC_PC.rc.in" > "%base_dir%\xbmc\win32\XBMC_PC.rc" diff --git a/xbmc/AppParamParser.cpp b/xbmc/AppParamParser.cpp index 10e8540785..491f7a8e70 100644 --- a/xbmc/AppParamParser.cpp +++ b/xbmc/AppParamParser.cpp @@ -119,7 +119,7 @@ void CAppParamParser::EnableDebugMode() CLog::SetLogLevel(g_advancedSettings.m_logLevel); } -void CAppParamParser::ParseArg(const CStdString &arg) +void CAppParamParser::ParseArg(const std::string &arg) { if (arg == "-fs" || arg == "--fullscreen") g_advancedSettings.m_startFullScreen = true; diff --git a/xbmc/AppParamParser.h b/xbmc/AppParamParser.h index 78d6174b6f..ee88dbf47f 100644 --- a/xbmc/AppParamParser.h +++ b/xbmc/AppParamParser.h @@ -18,7 +18,6 @@ * */ -#include "utils/StdString.h" #include "FileItem.h" class CAppParamParser @@ -30,7 +29,7 @@ class CAppParamParser private: bool m_testmode; CFileItemList m_playlist; - void ParseArg(const CStdString &arg); + void ParseArg(const std::string &arg); void DisplayHelp(); void DisplayVersion(); void EnableDebugMode(); diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index 042df8e304..1fa4ed7a13 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -565,13 +565,13 @@ extern "C" void __stdcall cleanup_emu_environ(); // Utility function used to copy files from the application bundle // over to the user data directory in Application Support/Kodi. // -static void CopyUserDataIfNeeded(const CStdString &strPath, const CStdString &file) +static void CopyUserDataIfNeeded(const std::string &strPath, const std::string &file) { - CStdString destPath = URIUtils::AddFileToFolder(strPath, file); + std::string destPath = URIUtils::AddFileToFolder(strPath, file); if (!CFile::Exists(destPath)) { // need to copy it across - CStdString srcPath = URIUtils::AddFileToFolder("special://xbmc/userdata/", file); + std::string srcPath = URIUtils::AddFileToFolder("special://xbmc/userdata/", file); CFile::Copy(srcPath, destPath); } } @@ -586,7 +586,7 @@ void CApplication::Preflight() // run any platform preflight scripts. #if defined(TARGET_DARWIN_OSX) - CStdString install_path; + std::string install_path; CUtil::GetHomePath(install_path); setenv("KODI_HOME", install_path.c_str(), 0); @@ -595,7 +595,7 @@ void CApplication::Preflight() #endif } -bool CApplication::Create() +bool CApplication::SetupNetwork() { #if defined(HAS_LINUX_NETWORK) m_network = new CNetworkLinux(); @@ -605,6 +605,12 @@ bool CApplication::Create() m_network = new CNetwork(); #endif + return m_network != NULL; +} + +bool CApplication::Create() +{ + SetupNetwork(); Preflight(); for (int i = RES_HDTV_1080i; i <= RES_PAL60_16x9; i++) @@ -732,16 +738,18 @@ bool CApplication::Create() #endif CSpecialProtocol::LogPaths(); - CStdString executable = CUtil::ResolveExecutablePath(); + std::string executable = CUtil::ResolveExecutablePath(); CLog::Log(LOGNOTICE, "The executable running is: %s", executable.c_str()); - CLog::Log(LOGNOTICE, "Local hostname: %s", m_network->GetHostName().c_str()); + std::string hostname("[unknown]"); + m_network->GetHostName(hostname); + CLog::Log(LOGNOTICE, "Local hostname: %s", hostname.c_str()); std::string lowerAppName = CCompileInfo::GetAppName(); StringUtils::ToLower(lowerAppName); CLog::Log(LOGNOTICE, "Log File is located: %s%s.log", g_advancedSettings.m_logFolder.c_str(), lowerAppName.c_str()); CRegExp::LogCheckUtf8Support(); CLog::Log(LOGNOTICE, "-----------------------------------------------------------------------"); - CStdString strExecutablePath; + std::string strExecutablePath; CUtil::GetHomePath(strExecutablePath); #ifdef HAS_XRANDR @@ -803,17 +811,17 @@ bool CApplication::Create() update_emu_environ();//apply the GUI settings // Load the langinfo to have user charset <-> utf-8 conversion - CStdString strLanguage = CSettings::Get().GetString("locale.language"); + std::string strLanguage = CSettings::Get().GetString("locale.language"); strLanguage[0] = toupper(strLanguage[0]); - CStdString strLangInfoPath = StringUtils::Format("special://xbmc/language/%s/langinfo.xml", strLanguage.c_str()); + std::string strLangInfoPath = StringUtils::Format("special://xbmc/language/%s/langinfo.xml", strLanguage.c_str()); CLog::Log(LOGINFO, "load language info file: %s", strLangInfoPath.c_str()); g_langInfo.Load(strLangInfoPath); g_langInfo.SetAudioLanguage(CSettings::Get().GetString("locale.audiolanguage")); g_langInfo.SetSubtitleLanguage(CSettings::Get().GetString("locale.subtitlelanguage")); - CStdString strLanguagePath = "special://xbmc/language/"; + std::string strLanguagePath = "special://xbmc/language/"; CLog::Log(LOGINFO, "load %s language file, from path: %s", strLanguage.c_str(), strLanguagePath.c_str()); if (!g_localizeStrings.Load(strLanguagePath, strLanguage)) @@ -979,7 +987,7 @@ bool CApplication::CreateGUI() if (g_advancedSettings.m_splashImage) { - CStdString strUserSplash = "special://home/media/Splash.png"; + std::string strUserSplash = "special://home/media/Splash.png"; if (CFile::Exists(strUserSplash)) { CLog::Log(LOGINFO, "load user splash image: %s", CSpecialProtocol::TranslatePath(strUserSplash).c_str()); @@ -1089,7 +1097,6 @@ bool CApplication::InitDirectoriesLinux() const char* envAppBinHome = "KODI_BIN_HOME"; const char* envAppTemp = "KODI_TEMP"; - CUtil::GetHomePath(appBinPath, envAppBinHome); if (getenv(envAppHome)) appPath = getenv(envAppHome); @@ -1122,7 +1129,7 @@ bool CApplication::InitDirectoriesLinux() CSpecialProtocol::SetHomePath(userHome + "/" + dotLowerAppName); CSpecialProtocol::SetMasterProfilePath(userHome + "/" + dotLowerAppName + "/userdata"); - CStdString strTempPath = userHome; + std::string strTempPath = userHome; strTempPath = URIUtils::AddFileToFolder(strTempPath, dotLowerAppName + "/temp"); if (getenv(envAppTemp)) strTempPath = getenv(envAppTemp); @@ -1144,7 +1151,7 @@ bool CApplication::InitDirectoriesLinux() CSpecialProtocol::SetHomePath(URIUtils::AddFileToFolder(appPath, "portable_data")); CSpecialProtocol::SetMasterProfilePath(URIUtils::AddFileToFolder(appPath, "portable_data/userdata")); - CStdString strTempPath = appPath; + std::string strTempPath = appPath; strTempPath = URIUtils::AddFileToFolder(strTempPath, "portable_data/temp"); if (getenv(envAppTemp)) strTempPath = getenv(envAppTemp); @@ -1164,7 +1171,7 @@ bool CApplication::InitDirectoriesLinux() bool CApplication::InitDirectoriesOSX() { #if defined(TARGET_DARWIN) - CStdString userName; + std::string userName; if (getenv("USER")) userName = getenv("USER"); else @@ -1181,13 +1188,13 @@ bool CApplication::InitDirectoriesOSX() setenv("KODI_HOME", appPath.c_str(), 0); #if defined(TARGET_DARWIN_IOS) - CStdString fontconfigPath; + std::string fontconfigPath; fontconfigPath = appPath + "/system/players/dvdplayer/etc/fonts/fonts.conf"; setenv("FONTCONFIG_FILE", fontconfigPath.c_str(), 0); #endif // setup path to our internal dylibs so loader can find them - CStdString frameworksPath = CUtil::GetFrameworksPath(); + std::string frameworksPath = CUtil::GetFrameworksPath(); CSpecialProtocol::SetXBMCFrameworksPath(frameworksPath); // OSX always runs with m_bPlatformDirectories == true @@ -1239,7 +1246,7 @@ bool CApplication::InitDirectoriesOSX() CSpecialProtocol::SetHomePath(URIUtils::AddFileToFolder(appPath, "portable_data")); CSpecialProtocol::SetMasterProfilePath(URIUtils::AddFileToFolder(appPath, "portable_data/userdata")); - CStdString strTempPath = URIUtils::AddFileToFolder(appPath, "portable_data/temp"); + std::string strTempPath = URIUtils::AddFileToFolder(appPath, "portable_data/temp"); CSpecialProtocol::SetTempPath(strTempPath); URIUtils::AddSlashAtEnd(strTempPath); @@ -1255,14 +1262,14 @@ bool CApplication::InitDirectoriesOSX() bool CApplication::InitDirectoriesWin32() { #ifdef TARGET_WINDOWS - CStdString xbmcPath; + std::string xbmcPath; CUtil::GetHomePath(xbmcPath); CEnvironment::setenv("KODI_HOME", xbmcPath); CSpecialProtocol::SetXBMCBinPath(xbmcPath); CSpecialProtocol::SetXBMCPath(xbmcPath); - CStdString strWin32UserFolder = CWIN32Util::GetProfilePath(); + std::string strWin32UserFolder = CWIN32Util::GetProfilePath(); g_advancedSettings.m_logFolder = strWin32UserFolder; CSpecialProtocol::SetHomePath(strWin32UserFolder); @@ -1660,7 +1667,7 @@ void CApplication::OnSettingChanged(const CSetting *setting) else if (settingId == "lookandfeel.skintheme") { // also set the default color theme - CStdString colorTheme = ((CSettingString*)setting)->GetValue(); + std::string colorTheme = ((CSettingString*)setting)->GetValue(); URIUtils::RemoveExtension(colorTheme); if (StringUtils::EqualsNoCase(colorTheme, "Textures")) colorTheme = "defaults"; @@ -1906,7 +1913,7 @@ bool CApplication::Save(TiXmlNode *settings) const return true; } -bool CApplication::LoadSkin(const CStdString& skinID) +bool CApplication::LoadSkin(const std::string& skinID) { AddonPtr addon; if (CAddonMgr::Get().GetAddon(skinID, addon, ADDON_SKIN)) @@ -1969,7 +1976,7 @@ bool CApplication::LoadSkin(const SkinPtr& skin) g_fontManager.LoadFonts(CSettings::Get().GetString("lookandfeel.font")); // load in the skin strings - CStdString langPath = URIUtils::AddFileToFolder(skin->Path(), "language"); + std::string langPath = URIUtils::AddFileToFolder(skin->Path(), "language"); URIUtils::AddSlashAtEnd(langPath); g_localizeStrings.LoadSkinStrings(langPath, CSettings::Get().GetString("locale.language")); @@ -2087,7 +2094,7 @@ bool CApplication::LoadUserWindows() { if (items[i]->m_bIsFolder) continue; - CStdString skinFile = URIUtils::GetFileName(items[i]->GetPath()); + std::string skinFile = URIUtils::GetFileName(items[i]->GetPath()); if (StringUtils::StartsWithNoCase(skinFile, "custom")) { CXBMCTinyXML xmlDoc; @@ -2099,8 +2106,8 @@ bool CApplication::LoadUserWindows() // Root element should be <window> TiXmlElement* pRootElement = xmlDoc.RootElement(); - CStdString strValue = pRootElement->Value(); - if (!strValue.Equals("window")) + std::string strValue = pRootElement->Value(); + if (!StringUtils::EqualsNoCase(strValue, "window")) { CLog::Log(LOGERROR, "file: %s doesnt contain <window>", skinFile.c_str()); continue; @@ -2109,7 +2116,7 @@ bool CApplication::LoadUserWindows() // Read the <type> element to get the window type to create // If no type is specified, create a CGUIWindow as default CGUIWindow* pWindow = NULL; - CStdString strType; + std::string strType; if (pRootElement->Attribute("type")) strType = pRootElement->Attribute("type"); else @@ -2125,14 +2132,14 @@ bool CApplication::LoadUserWindows() if (pType && pType->FirstChild()) id = atol(pType->FirstChild()->Value()); } - CStdString visibleCondition; + std::string visibleCondition; CGUIControlFactory::GetConditionalVisibility(pRootElement, visibleCondition); - if (strType.Equals("dialog")) + if (StringUtils::EqualsNoCase(strType, "dialog")) pWindow = new CGUIDialog(id + WINDOW_HOME, skinFile); - else if (strType.Equals("submenu")) + else if (StringUtils::EqualsNoCase(strType, "submenu")) pWindow = new CGUIDialogSubMenu(id + WINDOW_HOME, skinFile); - else if (strType.Equals("buttonmenu")) + else if (StringUtils::EqualsNoCase(strType, "buttonmenu")) pWindow = new CGUIDialogButtonMenu(id + WINDOW_HOME, skinFile); else pWindow = new CGUIWindow(id + WINDOW_HOME, skinFile); @@ -2590,8 +2597,12 @@ bool CApplication::OnAction(const CAction &action) // built in functions : execute the built-in if (action.GetID() == ACTION_BUILT_IN_FUNCTION) { - CBuiltins::Execute(action.GetName()); - m_navigationTimer.StartZero(); + if (!CBuiltins::IsSystemPowerdownCommand(action.GetName()) || + g_PVRManager.CanSystemPowerdown()) + { + CBuiltins::Execute(action.GetName()); + m_navigationTimer.StartZero(); + } return true; } @@ -2969,7 +2980,7 @@ bool CApplication::ProcessGamepad(float frameTime) } int actionID; - CStdString actionName; + std::string actionName; bool fullrange; keymapId = joyId + 1; if (CButtonTranslator::GetInstance().TranslateJoystickString(iWin, joyName, keymapId, JACTIVE_BUTTON, actionID, actionName, fullrange)) @@ -2988,7 +2999,7 @@ bool CApplication::ProcessGamepad(float frameTime) } int actionID; - CStdString actionName; + std::string actionName; bool fullrange; if (CButtonTranslator::GetInstance().TranslateJoystickString(iWin, joyName, keymapId, JACTIVE_AXIS, actionID, actionName, fullrange)) { @@ -3019,7 +3030,7 @@ bool CApplication::ProcessGamepad(float frameTime) } int actionID; - CStdString actionName; + std::string actionName; bool fullrange; keymapId = position << 16 | keymapId; @@ -3239,7 +3250,7 @@ bool CApplication::ProcessJoystickEvent(const std::string& joystickName, int wKe int iWin = GetActiveWindowID(); int actionID; - CStdString actionName; + std::string actionName; bool fullRange = false; // Translate using regular joystick translator. @@ -3582,6 +3593,7 @@ void CApplication::Stop(int exitCode) g_Windowing.DestroyWindow(); g_Windowing.DestroyWindowSystem(); + g_audioManager.DeInitialize(); // shutdown the AudioEngine CAEFactory::Shutdown(); CAEFactory::UnLoadEngine(); @@ -3701,7 +3713,7 @@ PlayBackRet CApplication::PlayStack(const CFileItem& item, bool bRestart) if (dbs.Open()) { CBookmark bookmark; - CStdString path = item.GetPath(); + std::string path = item.GetPath(); if (item.HasProperty("original_listitem_url") && URIUtils::IsPlugin(item.GetProperty("original_listitem_url").asString())) path = item.GetProperty("original_listitem_url").asString(); if( dbs.GetResumeBookMark(path, bookmark) ) @@ -3789,7 +3801,7 @@ PlayBackRet CApplication::PlayStack(const CFileItem& item, bool bRestart) { // can only resume seek here, not dvdstate CBookmark bookmark; - CStdString path = item.GetPath(); + std::string path = item.GetPath(); if (item.HasProperty("original_listitem_url") && URIUtils::IsPlugin(item.GetProperty("original_listitem_url").asString())) path = item.GetProperty("original_listitem_url").asString(); if( dbs.GetResumeBookMark(path, bookmark) ) @@ -3966,7 +3978,7 @@ PlayBackRet CApplication::PlayFile(const CFileItem& item, bool bRestart) { options.starttime = 0.0f; CBookmark bookmark; - CStdString path = item.GetPath(); + std::string path = item.GetPath(); if (item.HasVideoInfoTag() && StringUtils::StartsWith(item.GetVideoInfoTag()->m_strFileNameAndPath, "removable://")) path = item.GetVideoInfoTag()->m_strFileNameAndPath; else if (item.HasProperty("original_listitem_url") && URIUtils::IsPlugin(item.GetProperty("original_listitem_url").asString())) @@ -4723,7 +4735,7 @@ void CApplication::CheckShutdown() || m_musicInfoScanner->IsScanning() || m_videoInfoScanner->IsScanning() || g_windowManager.IsWindowActive(WINDOW_DIALOG_PROGRESS) // progress dialog is onscreen - || (CSettings::Get().GetBool("pvrmanager.enabled") && !g_PVRManager.IsIdle())) + || !g_PVRManager.CanSystemPowerdown(false)) { m_shutdownTimer.StartZero(); return; @@ -4999,7 +5011,11 @@ bool CApplication::ExecuteXBMCAction(std::string actionStr) // user has asked for something to be executed if (CBuiltins::HasCommand(actionStr)) - CBuiltins::Execute(actionStr); + { + if (!CBuiltins::IsSystemPowerdownCommand(actionStr) || + g_PVRManager.CanSystemPowerdown()) + CBuiltins::Execute(actionStr); + } else { // try translating the action from our ButtonTranslator @@ -5068,7 +5084,7 @@ void CApplication::Process() m_loggingIn = false; // autoexec.py - profile - CStdString strAutoExecPy = CSpecialProtocol::TranslatePath("special://profile/autoexec.py"); + std::string strAutoExecPy = CSpecialProtocol::TranslatePath("special://profile/autoexec.py"); if (XFILE::CFile::Exists(strAutoExecPy)) CScriptInvocationManager::Get().Execute(strAutoExecPy); @@ -5276,7 +5292,7 @@ void CApplication::Restart(bool bSamePosition) double time = GetTime(); // get player state, needed for dvd's - CStdString state = m_pPlayer->GetPlayerState(); + std::string state = m_pPlayer->GetPlayerState(); // set the requested starttime m_itemCurrentFile->m_lStartOffset = (long)(time * 75.0); @@ -5656,7 +5672,7 @@ void CApplication::StartVideoCleanup(bool userInitiated /* = true */) } } -void CApplication::StartVideoScan(const CStdString &strDirectory, bool userInitiated /* = true */, bool scanAll /* = false */) +void CApplication::StartVideoScan(const std::string &strDirectory, bool userInitiated /* = true */, bool scanAll /* = false */) { if (m_videoInfoScanner->IsScanning()) return; @@ -5680,7 +5696,7 @@ void CApplication::StartMusicCleanup(bool userInitiated /* = true */) } } -void CApplication::StartMusicScan(const CStdString &strDirectory, bool userInitiated /* = true */, int flags /* = 0 */) +void CApplication::StartMusicScan(const std::string &strDirectory, bool userInitiated /* = true */, int flags /* = 0 */) { if (m_musicInfoScanner->IsScanning()) return; @@ -5699,7 +5715,7 @@ void CApplication::StartMusicScan(const CStdString &strDirectory, bool userIniti m_musicInfoScanner->Start(strDirectory, flags); } -void CApplication::StartMusicAlbumScan(const CStdString& strDirectory, +void CApplication::StartMusicAlbumScan(const std::string& strDirectory, bool refresh) { if (m_musicInfoScanner->IsScanning()) @@ -5710,7 +5726,7 @@ void CApplication::StartMusicAlbumScan(const CStdString& strDirectory, m_musicInfoScanner->FetchAlbumInfo(strDirectory,refresh); } -void CApplication::StartMusicArtistScan(const CStdString& strDirectory, +void CApplication::StartMusicArtistScan(const std::string& strDirectory, bool refresh) { if (m_musicInfoScanner->IsScanning()) @@ -5745,7 +5761,7 @@ void CApplication::CheckPlayingProgress() } } -bool CApplication::ProcessAndStartPlaylist(const CStdString& strPlayList, CPlayList& playlist, int iPlaylist, int track) +bool CApplication::ProcessAndStartPlaylist(const std::string& strPlayList, CPlayList& playlist, int iPlaylist, int track) { CLog::Log(LOGDEBUG,"CApplication::ProcessAndStartPlaylist(%s, %i)",strPlayList.c_str(), iPlaylist); @@ -5785,20 +5801,20 @@ bool CApplication::AlwaysProcess(const CAction& action) // check if this button is mapped to a built-in function if (!action.GetName().empty()) { - CStdString builtInFunction; + std::string builtInFunction; vector<string> params; CUtil::SplitExecFunction(action.GetName(), builtInFunction, params); StringUtils::ToLower(builtInFunction); // should this button be handled normally or just cancel the screensaver? - if ( builtInFunction.Equals("powerdown") - || builtInFunction.Equals("reboot") - || builtInFunction.Equals("restart") - || builtInFunction.Equals("restartapp") - || builtInFunction.Equals("suspend") - || builtInFunction.Equals("hibernate") - || builtInFunction.Equals("quit") - || builtInFunction.Equals("shutdown")) + if ( builtInFunction == "powerdown" + || builtInFunction == "reboot" + || builtInFunction == "restart" + || builtInFunction == "restartapp" + || builtInFunction == "suspend" + || builtInFunction == "hibernate" + || builtInFunction == "quit" + || builtInFunction == "shutdown") { return true; } @@ -5830,12 +5846,12 @@ CPerformanceStats &CApplication::GetPerformanceStats() } #endif -bool CApplication::SetLanguage(const CStdString &strLanguage) +bool CApplication::SetLanguage(const std::string &strLanguage) { - CStdString strPreviousLanguage = CSettings::Get().GetString("locale.language"); + std::string strPreviousLanguage = CSettings::Get().GetString("locale.language"); if (strLanguage != strPreviousLanguage) { - CStdString strLangInfoPath = StringUtils::Format("special://xbmc/language/%s/langinfo.xml", strLanguage.c_str()); + std::string strLangInfoPath = StringUtils::Format("special://xbmc/language/%s/langinfo.xml", strLanguage.c_str()); if (!g_langInfo.Load(strLangInfoPath)) return false; diff --git a/xbmc/Application.h b/xbmc/Application.h index 0a332ff988..711db3da16 100644 --- a/xbmc/Application.h +++ b/xbmc/Application.h @@ -25,9 +25,9 @@ #include "guilib/IMsgTargetCallback.h" #include "utils/GlobalsHandling.h" -#include "utils/StdString.h" #include <map> +#include <string> class CAction; class CFileItem; @@ -174,7 +174,7 @@ public: virtual void OnPlayBackSpeedChanged(int iSpeed); bool PlayMedia(const CFileItem& item, int iPlaylist = PLAYLIST_MUSIC); bool PlayMediaSync(const CFileItem& item, int iPlaylist = PLAYLIST_MUSIC); - bool ProcessAndStartPlaylist(const CStdString& strPlayList, PLAYLIST::CPlayList& playlist, int iPlaylist, int track=0); + bool ProcessAndStartPlaylist(const std::string& strPlayList, PLAYLIST::CPlayList& playlist, int iPlaylist, int track=0); PlayBackRet PlayFile(const CFileItem& item, bool bRestart = false); void SaveFileState(bool bForeground = false); void UpdateFileState(); @@ -196,6 +196,7 @@ public: void CheckScreenSaverAndDPMS(); void CheckPlayingProgress(); void ActivateScreenSaver(bool forceType = false); + bool SetupNetwork(); void CloseNetworkShares(); void ShowAppMigrationMessage(); @@ -257,7 +258,7 @@ public: \param userInitiated Whether the action was initiated by the user (either via GUI or any other method) or not. It is meant to hide or show dialogs. \param scanAll Whether to scan everything not already scanned (regardless of whether the user normally doesn't want a folder scanned). */ - void StartVideoScan(const CStdString &path, bool userInitiated = true, bool scanAll = false); + void StartVideoScan(const std::string &path, bool userInitiated = true, bool scanAll = false); /*! \brief Starts a music library cleanup. @@ -271,9 +272,9 @@ public: \param userInitiated Whether the action was initiated by the user (either via GUI or any other method) or not. It is meant to hide or show dialogs. \param flags Flags for controlling the scanning process. See xbmc/music/infoscanner/MusicInfoScanner.h for possible values. */ - void StartMusicScan(const CStdString &path, bool userInitiated = true, int flags = 0); - void StartMusicAlbumScan(const CStdString& strDirectory, bool refresh=false); - void StartMusicArtistScan(const CStdString& strDirectory, bool refresh=false); + void StartMusicScan(const std::string &path, bool userInitiated = true, int flags = 0); + void StartMusicAlbumScan(const std::string& strDirectory, bool refresh = false); + void StartMusicArtistScan(const std::string& strDirectory, bool refresh = false); void UpdateLibraries(); void CheckMusicPlaylist(); @@ -316,7 +317,7 @@ public: CKaraokeLyricsManager* m_pKaraokeMgr; PLAYERCOREID m_eForcedNextPlayer; - CStdString m_strPlayListFile; + std::string m_strPlayListFile; int GlobalIdleTime(); @@ -374,7 +375,7 @@ public: void SetRenderGUI(bool renderGUI); bool GetRenderGUI() const { return m_renderGUI; }; - bool SetLanguage(const CStdString &strLanguage); + bool SetLanguage(const std::string &strLanguage); ReplayGainSettings& GetReplayGainSettings() { return m_replayGainSettings; } @@ -390,7 +391,7 @@ protected: virtual void OnSettingAction(const CSetting *setting); virtual bool OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode); - bool LoadSkin(const CStdString& skinID); + bool LoadSkin(const std::string& skinID); bool LoadSkin(const boost::shared_ptr<ADDON::CSkinInfo>& skin); bool m_skinReverting; @@ -431,7 +432,7 @@ protected: CFileItemList* m_currentStack; CFileItemPtr m_stackFileItemToUpdate; - CStdString m_prevMedia; + std::string m_prevMedia; CSplash* m_splash; ThreadIdentifier m_threadID; // application thread ID. Used in applicationMessanger to know where we are firing a thread with delay from. bool m_bInitializing; diff --git a/xbmc/ApplicationMessenger.cpp b/xbmc/ApplicationMessenger.cpp index 2f4d6517bc..9bb0f33c45 100644 --- a/xbmc/ApplicationMessenger.cpp +++ b/xbmc/ApplicationMessenger.cpp @@ -448,8 +448,8 @@ void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg) pSlideShow->Reset(); CFileItemList items; - CStdString strPath = pMsg->strParam; - CStdString extensions = g_advancedSettings.m_pictureExtensions; + std::string strPath = pMsg->strParam; + std::string extensions = g_advancedSettings.m_pictureExtensions; if (pMsg->param1) extensions += "|.tbn"; CUtil::GetRecursiveListing(strPath, items, extensions); @@ -891,7 +891,7 @@ void CApplicationMessenger::ProcessWindowMessages() } } -int CApplicationMessenger::SetResponse(CStdString response) +int CApplicationMessenger::SetResponse(std::string response) { CSingleLock lock (m_critBuffer); bufferResponse=response; @@ -899,16 +899,16 @@ int CApplicationMessenger::SetResponse(CStdString response) return 0; } -CStdString CApplicationMessenger::GetResponse() +std::string CApplicationMessenger::GetResponse() { - CStdString tmp; + std::string tmp; CSingleLock lock (m_critBuffer); tmp=bufferResponse; lock.Leave(); return tmp; } -void CApplicationMessenger::ExecBuiltIn(const CStdString &command, bool wait) +void CApplicationMessenger::ExecBuiltIn(const std::string &command, bool wait) { ThreadMessage tMsg = {TMSG_EXECUTE_BUILT_IN}; tMsg.strParam = command; @@ -921,15 +921,15 @@ void CApplicationMessenger::MediaPlay(string filename) MediaPlay(item); } -void CApplicationMessenger::MediaPlay(const CFileItem &item) +void CApplicationMessenger::MediaPlay(const CFileItem &item, bool wait) { CFileItemList list; list.Add(CFileItemPtr(new CFileItem(item))); - MediaPlay(list); + MediaPlay(list, 0, wait); } -void CApplicationMessenger::MediaPlay(const CFileItemList &list, int song) +void CApplicationMessenger::MediaPlay(const CFileItemList &list, int song, bool wait) { ThreadMessage tMsg = {TMSG_MEDIA_PLAY}; CFileItemList* listcopy = new CFileItemList(); @@ -937,7 +937,7 @@ void CApplicationMessenger::MediaPlay(const CFileItemList &list, int song) tMsg.lpVoid = (void*)listcopy; tMsg.param1 = song; tMsg.param2 = 1; - SendMessage(tMsg, true); + SendMessage(tMsg, wait); } void CApplicationMessenger::MediaPlay(int playlistid, int song /* = -1 */) @@ -1211,7 +1211,7 @@ void CApplicationMessenger::Minimize(bool wait) SendMessage(tMsg, wait); } -void CApplicationMessenger::DoModal(CGUIDialog *pDialog, int iWindowID, const CStdString ¶m) +void CApplicationMessenger::DoModal(CGUIDialog *pDialog, int iWindowID, const std::string ¶m) { ThreadMessage tMsg = {TMSG_GUI_DO_MODAL}; tMsg.lpVoid = pDialog; @@ -1220,7 +1220,7 @@ void CApplicationMessenger::DoModal(CGUIDialog *pDialog, int iWindowID, const CS SendMessage(tMsg, true); } -void CApplicationMessenger::ExecOS(const CStdString &command, bool waitExit) +void CApplicationMessenger::ExecOS(const std::string &command, bool waitExit) { ThreadMessage tMsg = {TMSG_EXECUTE_OS}; tMsg.strParam = command; @@ -1316,7 +1316,7 @@ void CApplicationMessenger::ShowVolumeBar(bool up) SendMessage(tMsg, false); } -void CApplicationMessenger::SetSplashMessage(const CStdString& message) +void CApplicationMessenger::SetSplashMessage(const std::string& message) { ThreadMessage tMsg = {TMSG_SPLASH_MESSAGE}; tMsg.strParam = message; diff --git a/xbmc/ApplicationMessenger.h b/xbmc/ApplicationMessenger.h index 543e0654c8..dc629b5052 100644 --- a/xbmc/ApplicationMessenger.h +++ b/xbmc/ApplicationMessenger.h @@ -20,7 +20,6 @@ * */ -#include "utils/StdString.h" #include "guilib/WindowIDs.h" #include "threads/Thread.h" #include <boost/shared_ptr.hpp> @@ -120,7 +119,7 @@ typedef struct unsigned int dwMessage; int param1; int param2; - CStdString strParam; + std::string strParam; std::vector<std::string> params; boost::shared_ptr<CEvent> waitEvent; void* lpVoid; @@ -167,8 +166,8 @@ public: void MediaPlay(std::string filename); - void MediaPlay(const CFileItem &item); - void MediaPlay(const CFileItemList &item, int song = 0); + void MediaPlay(const CFileItem &item, bool wait = true); + void MediaPlay(const CFileItemList &item, int song = 0, bool wait = true); void MediaPlay(int playlistid, int song = -1); void MediaStop(bool bWait = true, int playlistid = -1); void MediaPause(); @@ -208,7 +207,7 @@ public: void ActivateScreensaver(); void SwitchToFullscreen(); // void Minimize(bool wait = false); - void ExecOS(const CStdString &command, bool waitExit = false); + void ExecOS(const std::string &command, bool waitExit = false); void UserEvent(int code); //! \brief Set the tag for the currently playing song void SetCurrentSongTag(const MUSIC_INFO::CMusicInfoTag& tag); @@ -222,13 +221,13 @@ public: void CECActivateSource(); void CECStandby(); - CStdString GetResponse(); - int SetResponse(CStdString response); - void ExecBuiltIn(const CStdString &command, bool wait = false); + std::string GetResponse(); + int SetResponse(std::string response); + void ExecBuiltIn(const std::string &command, bool wait = false); void NetworkMessage(int dwMessage, int dwParam = 0); - void DoModal(CGUIDialog *pDialog, int iWindowID, const CStdString ¶m = ""); + void DoModal(CGUIDialog *pDialog, int iWindowID, const std::string ¶m = ""); void Show(CGUIDialog *pDialog); void Close(CGUIWindow *window, bool forceClose, bool waitResult = true, int nextWindowID = 0, bool enableSound = true); void ActivateWindow(int windowID, const std::vector<std::string> ¶ms, bool swappingWindows); @@ -250,7 +249,7 @@ public: void ShowVolumeBar(bool up); - void SetSplashMessage(const CStdString& message); + void SetSplashMessage(const std::string& message); void SetSplashMessage(int stringID); bool SetupDisplay(); @@ -270,7 +269,7 @@ private: std::queue<ThreadMessage*> m_vecWindowMessages; CCriticalSection m_critSection; CCriticalSection m_critBuffer; - CStdString bufferResponse; + std::string bufferResponse; }; XBMC_GLOBAL_REF(CApplicationMessenger,s_messenger); diff --git a/xbmc/Autorun.cpp b/xbmc/Autorun.cpp index dfe4cc0d23..bb98d3e723 100644 --- a/xbmc/Autorun.cpp +++ b/xbmc/Autorun.cpp @@ -39,6 +39,7 @@ #include "storage/MediaManager.h" #include "video/VideoDatabase.h" #include "dialogs/GUIDialogYesNo.h" +#include "utils/StringUtils.h" #include "utils/URIUtils.h" #include "utils/log.h" #include "video/windows/GUIWindowVideoBase.h" @@ -59,7 +60,7 @@ CAutorun::CAutorun() CAutorun::~CAutorun() {} -void CAutorun::ExecuteAutorun(const CStdString& path, bool bypassSettings, bool ignoreplaying, bool startFromBeginning ) +void CAutorun::ExecuteAutorun(const std::string& path, bool bypassSettings, bool ignoreplaying, bool startFromBeginning ) { if ((!ignoreplaying && (g_application.m_pPlayer->IsPlayingAudio() || g_application.m_pPlayer->IsPlayingVideo() || g_windowManager.HasModalDialog())) || g_windowManager.GetActiveWindow() == WINDOW_LOGIN_SCREEN) return ; @@ -82,7 +83,7 @@ void CAutorun::ExecuteAutorun(const CStdString& path, bool bypassSettings, bool PlayDisc(path, bypassSettings, startFromBeginning); } -bool CAutorun::PlayDisc(const CStdString& path, bool bypassSettings, bool startFromBeginning) +bool CAutorun::PlayDisc(const std::string& path, bool bypassSettings, bool startFromBeginning) { if ( !bypassSettings && CSettings::Get().GetInt("audiocds.autoaction") != AUTOCD_PLAY && !CSettings::Get().GetBool("dvds.autorun")) return false; @@ -90,7 +91,7 @@ bool CAutorun::PlayDisc(const CStdString& path, bool bypassSettings, bool startF int nSize = g_playlistPlayer.GetPlaylist( PLAYLIST_MUSIC ).size(); int nAddedToPlaylist = 0; - CStdString mediaPath; + std::string mediaPath; CCdInfo* pInfo = g_mediaManager.GetCdInfo(path); if (pInfo == NULL) @@ -129,7 +130,7 @@ bool CAutorun::PlayDisc(const CStdString& path, bool bypassSettings, bool startF /** * This method tries to determine what type of disc is located in the given drive and starts to play the content appropriately. */ -bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAddedToPlaylist, bool bRoot, bool bypassSettings /* = false */, bool startFromBeginning /* = false */) +bool CAutorun::RunDisc(IDirectory* pDir, const std::string& strDrive, int& nAddedToPlaylist, bool bRoot, bool bypassSettings /* = false */, bool startFromBeginning /* = false */) { bool bPlaying(false); CFileItemList vecItems; @@ -156,7 +157,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded // is this a root folder we have to check the content to determine a disc type if( bRoot ) { - CStdString hddvdname = ""; + std::string hddvdname = ""; CFileItemPtr phddvdItem; // check root folders next, for normal structured dvd's @@ -167,15 +168,15 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded // is the current item a (non system) folder? if (pItem->m_bIsFolder && pItem->GetPath() != "." && pItem->GetPath() != "..") { - CStdString name = pItem->GetPath(); + std::string name = pItem->GetPath(); URIUtils::RemoveSlashAtEnd(name); name = URIUtils::GetFileName(name); // Check if the current foldername indicates a DVD structure (name is "VIDEO_TS") - if (name.Equals("VIDEO_TS") && bAllowVideo + if (StringUtils::EqualsNoCase(name, "VIDEO_TS") && bAllowVideo && (bypassSettings || CSettings::Get().GetBool("dvds.autorun"))) { - CStdString path = URIUtils::AddFileToFolder(pItem->GetPath(), "VIDEO_TS.IFO"); + std::string path = URIUtils::AddFileToFolder(pItem->GetPath(), "VIDEO_TS.IFO"); if(!CFile::Exists(path)) path = URIUtils::AddFileToFolder(pItem->GetPath(), "video_ts.ifo"); CFileItemPtr item(new CFileItem(path, false)); @@ -196,7 +197,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded // Check if the current foldername indicates a Blu-Ray structure (default is "BDMV"). // A BR should also include an "AACS" folder for encryption, Sony-BRs can also include update folders for PS3 (PS3_UPDATE / PS3_VPRM). // ToDo: for the time beeing, the DVD autorun settings are used to determine if the BR should be started automatically. - if (name.Equals("BDMV") && bAllowVideo + if (StringUtils::EqualsNoCase(name, "BDMV") && bAllowVideo && (bypassSettings || CSettings::Get().GetBool("dvds.autorun"))) { CFileItemPtr item(new CFileItem(URIUtils::AddFileToFolder(pItem->GetPath(), "index.bdmv"), false)); @@ -222,7 +223,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded CFileItemList items, sitems; // Advanced Content HD DVD (most discs?) - if (name.Equals("ADV_OBJ")) + if (StringUtils::EqualsNoCase(name, "ADV_OBJ")) { CLog::Log(LOGINFO,"HD DVD: Checking for playlist."); // find playlist file @@ -239,7 +240,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded } // Standard Content HD DVD (few discs?) - if (name.Equals("HVDVD_TS") && bAllowVideo + if (StringUtils::EqualsNoCase(name, "HVDVD_TS") && bAllowVideo && (bypassSettings || CSettings::Get().GetBool("dvds.autorun"))) { if (hddvdname == "") @@ -300,7 +301,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded item.m_lStartOffset = STARTOFFSET_RESUME; // get playername - CStdString hddvdplayer = CPlayerCoreFactory::Get().GetPlayerName(CPlayerCoreFactory::Get().GetDefaultPlayer(item)); + std::string hddvdplayer = CPlayerCoreFactory::Get().GetPlayerName(CPlayerCoreFactory::Get().GetDefaultPlayer(item)); // Single *.xpl or *.ifo files require an external player to handle playback. // If no matching rule was found, DVDPlayer will be default player. @@ -324,10 +325,10 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded } // Video CDs can have multiple file formats. First we need to determine which one is used on the CD - CStdString strExt; - if (name.Equals("MPEGAV")) + std::string strExt; + if (StringUtils::EqualsNoCase(name, "MPEGAV")) strExt = ".dat"; - if (name.Equals("MPEG2")) + if (StringUtils::EqualsNoCase(name, "MPEG2")) strExt = ".mpg"; // If a file format was extracted we are sure this is a VCD. Autoplay if settings indicate we should. @@ -351,7 +352,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded && (bypassSettings)) { bPlaying = true; - CStdString strExec = StringUtils::Format("RecursiveSlideShow(%s)", pItem->GetPath().c_str()); + std::string strExec = StringUtils::Format("RecursiveSlideShow(%s)", pItem->GetPath().c_str()); CBuiltins::Execute(strExec); return true; } @@ -428,7 +429,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded if (!pItem->m_bIsFolder && pItem->IsPicture()) { bPlaying = true; - CStdString strExec = StringUtils::Format("RecursiveSlideShow(%s)", strDrive.c_str()); + std::string strExec = StringUtils::Format("RecursiveSlideShow(%s)", strDrive.c_str()); CBuiltins::Execute(strExec); break; } @@ -491,14 +492,14 @@ bool CAutorun::IsEnabled() const return m_bEnable; } -bool CAutorun::PlayDiscAskResume(const CStdString& path) +bool CAutorun::PlayDiscAskResume(const std::string& path) { return PlayDisc(path, true, !CanResumePlayDVD(path) || CGUIDialogYesNo::ShowAndGetInput(341, -1, -1, -1, 13404, 12021)); } -bool CAutorun::CanResumePlayDVD(const CStdString& path) +bool CAutorun::CanResumePlayDVD(const std::string& path) { - CStdString strUniqueId = g_mediaManager.GetDiskUniqueId(path); + std::string strUniqueId = g_mediaManager.GetDiskUniqueId(path); if (!strUniqueId.empty()) { CVideoDatabase dbs; diff --git a/xbmc/Autorun.h b/xbmc/Autorun.h index 04b1787a07..37f8e6b752 100644 --- a/xbmc/Autorun.h +++ b/xbmc/Autorun.h @@ -32,7 +32,8 @@ #ifdef HAS_DVD_DRIVE -#include "utils/StdString.h" +#include <string> +#include <vector> namespace XFILE { @@ -55,19 +56,19 @@ class CAutorun public: CAutorun(); virtual ~CAutorun(); - static bool CanResumePlayDVD(const CStdString& path); - static bool PlayDisc(const CStdString& path="", bool bypassSettings = false, bool startFromBeginning = false); - static bool PlayDiscAskResume(const CStdString& path=""); + static bool CanResumePlayDVD(const std::string& path); + static bool PlayDisc(const std::string& path="", bool bypassSettings = false, bool startFromBeginning = false); + static bool PlayDiscAskResume(const std::string& path=""); bool IsEnabled() const; void Enable(); void Disable(); void HandleAutorun(); - static void ExecuteAutorun(const CStdString& path = "", bool bypassSettings = false, bool ignoreplaying = false, bool startFromBeginning = false); + static void ExecuteAutorun(const std::string& path = "", bool bypassSettings = false, bool ignoreplaying = false, bool startFromBeginning = false); static void SettingOptionAudioCdActionsFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t, void *data); protected: - static bool RunDisc(XFILE::IDirectory* pDir, const CStdString& strDrive, int& nAddedToPlaylist, bool bRoot, bool bypassSettings, bool startFromBeginning); + static bool RunDisc(XFILE::IDirectory* pDir, const std::string& strDrive, int& nAddedToPlaylist, bool bRoot, bool bypassSettings, bool startFromBeginning); bool m_bEnable; }; } diff --git a/xbmc/CueDocument.cpp b/xbmc/CueDocument.cpp index 64dbd17a99..2d5e27c197 100644 --- a/xbmc/CueDocument.cpp +++ b/xbmc/CueDocument.cpp @@ -87,14 +87,14 @@ CCueDocument::~CCueDocument(void) // Function: Parse() // Opens the .cue file for reading, and constructs the track database information //////////////////////////////////////////////////////////////////////////////////// -bool CCueDocument::Parse(const CStdString &strFile) +bool CCueDocument::Parse(const std::string &strFile) { if (!m_file.Open(strFile)) return false; - CStdString strLine; + std::string strLine; m_iTotalTracks = -1; - CStdString strCurrentFile = ""; + std::string strCurrentFile = ""; bool bCurrentFileChanged = false; int time; @@ -243,17 +243,17 @@ void CCueDocument::GetSongs(VECSONGS &songs) } } -void CCueDocument::GetMediaFiles(vector<CStdString>& mediaFiles) +void CCueDocument::GetMediaFiles(vector<std::string>& mediaFiles) { - set<CStdString> uniqueFiles; + set<std::string> uniqueFiles; for (int i = 0; i < m_iTotalTracks; i++) uniqueFiles.insert(m_Track[i].strFile); - for (set<CStdString>::iterator it = uniqueFiles.begin(); it != uniqueFiles.end(); it++) + for (set<std::string>::iterator it = uniqueFiles.begin(); it != uniqueFiles.end(); it++) mediaFiles.push_back(*it); } -CStdString CCueDocument::GetMediaTitle() +std::string CCueDocument::GetMediaTitle() { return m_strAlbum; } @@ -265,7 +265,7 @@ CStdString CCueDocument::GetMediaTitle() // Returns the next non-blank line of the textfile, stripping any whitespace from // the left. //////////////////////////////////////////////////////////////////////////////////// -bool CCueDocument::ReadNextLine(CStdString &szLine) +bool CCueDocument::ReadNextLine(std::string &szLine) { // Read the next line. while (m_file.ReadString(m_szBuffer, 1023)) // Bigger than MAX_PATH_SIZE, for usage with relax! @@ -284,7 +284,7 @@ bool CCueDocument::ReadNextLine(CStdString &szLine) // Function: ExtractInfo() // Extracts the information in quotes from the string line, returning it in quote //////////////////////////////////////////////////////////////////////////////////// -CStdString CCueDocument::ExtractInfo(const CStdString &line) +std::string CCueDocument::ExtractInfo(const std::string &line) { size_t left = line.find('\"'); if (left != std::string::npos) @@ -292,12 +292,12 @@ CStdString CCueDocument::ExtractInfo(const CStdString &line) size_t right = line.find('\"', left + 1); if (right != std::string::npos) { - CStdString text = line.substr(left + 1, right - left - 1); + std::string text = line.substr(left + 1, right - left - 1); g_charsetConverter.unknownToUTF8(text); return text; } } - CStdString text = line; + std::string text = line; StringUtils::Trim(text); g_charsetConverter.unknownToUTF8(text); return text; @@ -310,10 +310,10 @@ CStdString CCueDocument::ExtractInfo(const CStdString &line) // Assumed format is: // MM:SS:FF where MM is minutes, SS seconds, and FF frames (75 frames in a second) //////////////////////////////////////////////////////////////////////////////////// -int CCueDocument::ExtractTimeFromIndex(const CStdString &index) +int CCueDocument::ExtractTimeFromIndex(const std::string &index) { // Get rid of the index number and any whitespace - CStdString numberTime = index.substr(5); + std::string numberTime = index.substr(5); StringUtils::TrimLeft(numberTime); while (!numberTime.empty()) { @@ -338,9 +338,9 @@ int CCueDocument::ExtractTimeFromIndex(const CStdString &index) // Function: ExtractNumericInfo() // Extracts the numeric info from the string info, returning it as an integer value //////////////////////////////////////////////////////////////////////////////////// -int CCueDocument::ExtractNumericInfo(const CStdString &info) +int CCueDocument::ExtractNumericInfo(const std::string &info) { - CStdString number(info); + std::string number(info); StringUtils::TrimLeft(number); if (number.empty() || !StringUtils::isasciidigit(number[0])) return -1; @@ -352,10 +352,10 @@ int CCueDocument::ExtractNumericInfo(const CStdString &info) // Determines whether strPath is a relative path or not, and if so, converts it to an // absolute path using the path information in strBase //////////////////////////////////////////////////////////////////////////////////// -bool CCueDocument::ResolvePath(CStdString &strPath, const CStdString &strBase) +bool CCueDocument::ResolvePath(std::string &strPath, const std::string &strBase) { - CStdString strDirectory = URIUtils::GetDirectory(strBase); - CStdString strFilename = URIUtils::GetFileName(strPath); + std::string strDirectory = URIUtils::GetDirectory(strBase); + std::string strFilename = URIUtils::GetFileName(strPath); strPath = URIUtils::AddFileToFolder(strDirectory, strFilename); diff --git a/xbmc/CueDocument.h b/xbmc/CueDocument.h index 650ffd2409..0040f6f59b 100644 --- a/xbmc/CueDocument.h +++ b/xbmc/CueDocument.h @@ -38,9 +38,9 @@ class CCueDocument replayGainTrackGain = 0.0f; replayGainTrackPeak = 0.0f; } - CStdString strArtist; - CStdString strTitle; - CStdString strFile; + std::string strArtist; + std::string strTitle; + std::string strFile; int iTrackNumber; int iStartTime; int iEndTime; @@ -52,11 +52,11 @@ public: CCueDocument(void); ~CCueDocument(void); // USED - bool Parse(const CStdString &strFile); + bool Parse(const std::string &strFile); void GetSongs(VECSONGS &songs); - CStdString GetMediaPath(); - CStdString GetMediaTitle(); - void GetMediaFiles(std::vector<CStdString>& mediaFiles); + std::string GetMediaPath(); + std::string GetMediaTitle(); + void GetMediaFiles(std::vector<std::string>& mediaFiles); private: @@ -65,9 +65,9 @@ private: char m_szBuffer[1024]; // Member variables - CStdString m_strArtist; // album artist - CStdString m_strAlbum; // album title - CStdString m_strGenre; // album genre + std::string m_strArtist; // album artist + std::string m_strAlbum; // album title + std::string m_strGenre; // album genre int m_iYear; //album year int m_iTrack; // current track int m_iTotalTracks; // total tracks @@ -78,9 +78,9 @@ private: // cuetrack array std::vector<CCueTrack> m_Track; - bool ReadNextLine(CStdString &strLine); - CStdString ExtractInfo(const CStdString &line); - int ExtractTimeFromIndex(const CStdString &index); - int ExtractNumericInfo(const CStdString &info); - bool ResolvePath(CStdString &strPath, const CStdString &strBase); + bool ReadNextLine(std::string &strLine); + std::string ExtractInfo(const std::string &line); + int ExtractTimeFromIndex(const std::string &index); + int ExtractNumericInfo(const std::string &info); + bool ResolvePath(std::string &strPath, const std::string &strBase); }; diff --git a/xbmc/DynamicDll.cpp b/xbmc/DynamicDll.cpp index 764689b8ac..96796eb474 100644 --- a/xbmc/DynamicDll.cpp +++ b/xbmc/DynamicDll.cpp @@ -31,7 +31,7 @@ DllDynamic::DllDynamic() m_DelayUnload=true; } -DllDynamic::DllDynamic(const CStdString& strDllName) +DllDynamic::DllDynamic(const std::string& strDllName) { m_strDllName=strDllName; m_dll=NULL; @@ -83,7 +83,7 @@ bool DllDynamic::EnableDelayedUnload(bool bOnOff) return true; } -bool DllDynamic::SetFile(const CStdString& strDllName) +bool DllDynamic::SetFile(const std::string& strDllName) { if (m_dll) return false; diff --git a/xbmc/DynamicDll.h b/xbmc/DynamicDll.h index 3cf4e9bb7b..a0b817f1d4 100644 --- a/xbmc/DynamicDll.h +++ b/xbmc/DynamicDll.h @@ -20,7 +20,7 @@ */ #include "cores/DllLoader/LibraryLoader.h" -#include "utils/StdString.h" +#include <string> #include "DllPaths.h" /////////////////////////////////////////////////////////// @@ -520,20 +520,20 @@ class DllDynamic { public: DllDynamic(); - DllDynamic(const CStdString& strDllName); + DllDynamic(const std::string& strDllName); virtual ~DllDynamic(); virtual bool Load(); virtual void Unload(); virtual bool IsLoaded() const { return m_dll!=NULL; } bool CanLoad(); bool EnableDelayedUnload(bool bOnOff); - bool SetFile(const CStdString& strDllName); - const CStdString &GetFile() const { return m_strDllName; } + bool SetFile(const std::string& strDllName); + const std::string &GetFile() const { return m_strDllName; } protected: virtual bool ResolveExports()=0; virtual bool LoadSymbols() { return false; } bool m_DelayUnload; LibraryLoader* m_dll; - CStdString m_strDllName; + std::string m_strDllName; }; diff --git a/xbmc/FileItem.cpp b/xbmc/FileItem.cpp index 19a7289198..f307ead31c 100644 --- a/xbmc/FileItem.cpp +++ b/xbmc/FileItem.cpp @@ -110,22 +110,24 @@ CFileItem::CFileItem(const CVideoInfoTag& movie) SetFromVideoInfoTag(movie); } -CFileItem::CFileItem(const CEpgInfoTag& tag) +CFileItem::CFileItem(const CEpgInfoTagPtr& tag) { Initialize(); - m_strPath = tag.Path(); m_bIsFolder = false; - *GetEPGInfoTag() = tag; - SetLabel(tag.Title()); - m_strLabel2 = tag.Plot(); - m_dateTime = tag.StartAsLocalTime(); - - if (!tag.Icon().empty()) - SetIconImage(tag.Icon()); - else if (tag.HasPVRChannel() && !tag.ChannelTag()->IconPath().empty()) - SetIconImage(tag.ChannelTag()->IconPath()); + m_epgInfoTag = tag; + if (tag) + { + m_strPath = tag->Path(); + SetLabel(tag->Title()); + m_strLabel2 = tag->Plot(); + m_dateTime = tag->StartAsLocalTime(); + if (!tag->Icon().empty()) + SetIconImage(tag->Icon()); + else if (tag->HasPVRChannel() && !tag->ChannelTag()->IconPath().empty()) + SetIconImage(tag->ChannelTag()->IconPath()); + } FillInMimeType(false); } @@ -133,14 +135,13 @@ CFileItem::CFileItem(const CPVRChannel& channel) { Initialize(); - CEpgInfoTag epgNow; - bool bHasEpgNow = channel.GetEPGNow(epgNow); + CEpgInfoTagPtr epgNow(channel.GetEPGNow()); m_strPath = channel.Path(); m_bIsFolder = false; *GetPVRChannelInfoTag() = channel; SetLabel(channel.ChannelName()); - m_strLabel2 = bHasEpgNow ? epgNow.Title() : + m_strLabel2 = epgNow ? epgNow->Title() : CSettings::Get().GetBool("epg.hidenoinfoavailable") ? "" : g_localizeStrings.Get(19055); // no information available @@ -153,9 +154,9 @@ CFileItem::CFileItem(const CPVRChannel& channel) musictag->SetTitle(m_strLabel2); musictag->SetArtist(channel.ChannelName()); musictag->SetAlbumArtist(channel.ChannelName()); - if (bHasEpgNow) - musictag->SetGenre(epgNow.Genre()); - musictag->SetDuration(bHasEpgNow ? epgNow.GetDuration() : 3600); + if (epgNow) + musictag->SetGenre(epgNow->Genre()); + musictag->SetDuration(epgNow ? epgNow->GetDuration() : 3600); musictag->SetLoaded(true); musictag->SetComment(""); musictag->SetLyrics(""); @@ -228,7 +229,6 @@ CFileItem::CFileItem(const CFileItem& item): CGUIListItem() { m_musicInfoTag = NULL; m_videoInfoTag = NULL; - m_epgInfoTag = NULL; m_pvrChannelInfoTag = NULL; m_pvrRecordingInfoTag = NULL; m_pvrTimerInfoTag = NULL; @@ -258,6 +258,12 @@ CFileItem::CFileItem(const std::string& strLabel) SetLabel(strLabel); } +CFileItem::CFileItem(const char* strLabel) +{ + Initialize(); + SetLabel(std::string(strLabel)); +} + CFileItem::CFileItem(const CURL& path, bool bIsFolder) { Initialize(); @@ -308,7 +314,6 @@ CFileItem::~CFileItem(void) { delete m_musicInfoTag; delete m_videoInfoTag; - delete m_epgInfoTag; delete m_pvrChannelInfoTag; delete m_pvrRecordingInfoTag; delete m_pvrTimerInfoTag; @@ -316,7 +321,6 @@ CFileItem::~CFileItem(void) m_musicInfoTag = NULL; m_videoInfoTag = NULL; - m_epgInfoTag = NULL; m_pvrChannelInfoTag = NULL; m_pvrRecordingInfoTag = NULL; m_pvrTimerInfoTag = NULL; @@ -360,18 +364,9 @@ const CFileItem& CFileItem::operator=(const CFileItem& item) } if (item.HasEPGInfoTag()) - { - m_epgInfoTag = GetEPGInfoTag(); - if (m_epgInfoTag) - *m_epgInfoTag = *item.m_epgInfoTag; - } + m_epgInfoTag = item.m_epgInfoTag; else - { - if (m_epgInfoTag) - delete m_epgInfoTag; - - m_epgInfoTag = NULL; - } + m_epgInfoTag.reset(); if (item.HasPVRChannelInfoTag()) { @@ -450,7 +445,6 @@ void CFileItem::Initialize() { m_musicInfoTag = NULL; m_videoInfoTag = NULL; - m_epgInfoTag = NULL; m_pvrChannelInfoTag = NULL; m_pvrRecordingInfoTag = NULL; m_pvrTimerInfoTag = NULL; @@ -493,8 +487,7 @@ void CFileItem::Reset() m_musicInfoTag=NULL; delete m_videoInfoTag; m_videoInfoTag=NULL; - delete m_epgInfoTag; - m_epgInfoTag=NULL; + m_epgInfoTag.reset(); delete m_pvrChannelInfoTag; m_pvrChannelInfoTag=NULL; delete m_pvrRecordingInfoTag; @@ -1954,7 +1947,7 @@ void CFileItemList::Archive(CArchive& ar) ar << (int)m_sortDetails.size(); for (unsigned int j = 0; j < m_sortDetails.size(); ++j) { - const SORT_METHOD_DETAILS &details = m_sortDetails[j]; + const GUIViewSortDetails &details = m_sortDetails[j]; ar << (int)details.m_sortDescription.sortBy; ar << (int)details.m_sortDescription.sortOrder; ar << (int)details.m_sortDescription.sortAttributes; @@ -2020,7 +2013,7 @@ void CFileItemList::Archive(CArchive& ar) ar >> detailSize; for (unsigned int j = 0; j < detailSize; ++j) { - SORT_METHOD_DETAILS details; + GUIViewSortDetails details; ar >> (int&)tempint; details.m_sortDescription.sortBy = (SortBy)tempint; ar >> (int&)tempint; @@ -2130,11 +2123,11 @@ void CFileItemList::FilterCueItems() VECSONGS newitems; cuesheet.GetSongs(newitems); - std::vector<CStdString> MediaFileVec; + std::vector<std::string> MediaFileVec; cuesheet.GetMediaFiles(MediaFileVec); // queue the cue sheet and the underlying media file for deletion - for(std::vector<CStdString>::iterator itMedia = MediaFileVec.begin(); itMedia != MediaFileVec.end(); itMedia++) + for(std::vector<std::string>::iterator itMedia = MediaFileVec.begin(); itMedia != MediaFileVec.end(); itMedia++) { std::string strMediaFile = *itMedia; std::string fileFromCue = strMediaFile; // save the file from the cue we're matching against, @@ -3084,7 +3077,7 @@ void CFileItemList::AddSortMethod(SortBy sortBy, SortAttribute sortAttributes, i void CFileItemList::AddSortMethod(SortDescription sortDescription, int buttonLabel, const LABEL_MASKS &labelMasks) { - SORT_METHOD_DETAILS sort; + GUIViewSortDetails sort; sort.m_sortDescription = sortDescription; sort.m_buttonLabel = buttonLabel; sort.m_labelMasks = labelMasks; @@ -3112,14 +3105,6 @@ CVideoInfoTag* CFileItem::GetVideoInfoTag() return m_videoInfoTag; } -CEpgInfoTag* CFileItem::GetEPGInfoTag() -{ - if (!m_epgInfoTag) - m_epgInfoTag = new CEpgInfoTag; - - return m_epgInfoTag; -} - CPVRChannel* CFileItem::GetPVRChannelInfoTag() { if (!m_pvrChannelInfoTag) diff --git a/xbmc/FileItem.h b/xbmc/FileItem.h index 3da11eba4e..45366aad1b 100644 --- a/xbmc/FileItem.h +++ b/xbmc/FileItem.h @@ -44,6 +44,7 @@ class CVideoInfoTag; namespace EPG { class CEpgInfoTag; + typedef boost::shared_ptr<EPG::CEpgInfoTag> CEpgInfoTagPtr; } namespace PVR { @@ -90,6 +91,7 @@ public: CFileItem(const CFileItem& item); CFileItem(const CGUIListItem& item); explicit CFileItem(const std::string& strLabel); + explicit CFileItem(const char* strLabel); CFileItem(const CURL& path, bool bIsFolder); CFileItem(const std::string& strPath, bool bIsFolder); CFileItem(const CSong& song); @@ -99,7 +101,7 @@ public: CFileItem(const CGenre& genre); CFileItem(const MUSIC_INFO::CMusicInfoTag& music); CFileItem(const CVideoInfoTag& movie); - CFileItem(const EPG::CEpgInfoTag& tag); + CFileItem(const EPG::CEpgInfoTagPtr& tag); CFileItem(const PVR::CPVRChannel& channel); CFileItem(const PVR::CPVRRecording& record); CFileItem(const PVR::CPVRTimerInfoTag& timer); @@ -257,16 +259,19 @@ public: inline bool HasEPGInfoTag() const { - return m_epgInfoTag != NULL; + return m_epgInfoTag.get() != NULL; } - EPG::CEpgInfoTag* GetEPGInfoTag(); - - inline const EPG::CEpgInfoTag* GetEPGInfoTag() const + inline const EPG::CEpgInfoTagPtr GetEPGInfoTag() const { return m_epgInfoTag; } + inline void SetEPGInfoTag(const EPG::CEpgInfoTagPtr& tag) + { + m_epgInfoTag = tag; + } + inline bool HasPVRChannelInfoTag() const { return m_pvrChannelInfoTag != NULL; @@ -478,7 +483,7 @@ private: std::string m_extrainfo; MUSIC_INFO::CMusicInfoTag* m_musicInfoTag; CVideoInfoTag* m_videoInfoTag; - EPG::CEpgInfoTag* m_epgInfoTag; + EPG::CEpgInfoTagPtr m_epgInfoTag; PVR::CPVRChannel* m_pvrChannelInfoTag; PVR::CPVRRecording* m_pvrRecordingInfoTag; PVR::CPVRTimerInfoTag * m_pvrTimerInfoTag; @@ -638,8 +643,8 @@ public: void AddSortMethod(SortBy sortBy, int buttonLabel, const LABEL_MASKS &labelMasks, SortAttribute sortAttributes = SortAttributeNone); void AddSortMethod(SortBy sortBy, SortAttribute sortAttributes, int buttonLabel, const LABEL_MASKS &labelMasks); void AddSortMethod(SortDescription sortDescription, int buttonLabel, const LABEL_MASKS &labelMasks); - bool HasSortDetails() const { return m_sortDetails.size() != 0; }; - const std::vector<SORT_METHOD_DETAILS> &GetSortDetails() const { return m_sortDetails; }; + bool HasSortDetails() const { return m_sortDetails.size() != 0; } + const std::vector<GUIViewSortDetails> &GetSortDetails() const { return m_sortDetails; } /*! \brief Specify whether this list should be sorted with folders separate from files By default we sort with folders listed (and sorted separately) except for those sort modes @@ -680,7 +685,7 @@ private: bool m_replaceListing; std::string m_content; - std::vector<SORT_METHOD_DETAILS> m_sortDetails; + std::vector<GUIViewSortDetails> m_sortDetails; CCriticalSection m_lock; }; diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index 9356511f2f..54473d45e7 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -155,10 +155,10 @@ bool CGUIInfoManager::OnMessage(CGUIMessage &message) /// efficient retrieval of data. Can handle combined strings on the form /// Player.Caching + VideoPlayer.IsFullscreen (Logical and) /// Player.HasVideo | Player.HasAudio (Logical or) -int CGUIInfoManager::TranslateString(const CStdString &condition) +int CGUIInfoManager::TranslateString(const std::string &condition) { // translate $LOCALIZE as required - CStdString strCondition(CGUIInfoLabel::ReplaceLocalize(condition)); + std::string strCondition(CGUIInfoLabel::ReplaceLocalize(condition)); return TranslateSingleString(strCondition); } @@ -744,7 +744,7 @@ const int picture_slide_map[] = {/* LISTITEM_PICTURE_RESOLUTION => */ SLIDE_RES /* LISTITEM_PICTURE_GPS_LON => */ SLIDE_EXIF_GPS_LONGITUDE, /* LISTITEM_PICTURE_GPS_ALT => */ SLIDE_EXIF_GPS_ALTITUDE }; -CGUIInfoManager::Property::Property(const CStdString &property, const CStdString ¶meters) +CGUIInfoManager::Property::Property(const std::string &property, const std::string ¶meters) : name(property) { CUtil::SplitParams(parameters, params); @@ -762,14 +762,14 @@ unsigned int CGUIInfoManager::Property::num_params() const return params.size(); } -void CGUIInfoManager::SplitInfoString(const CStdString &infoString, vector<Property> &info) +void CGUIInfoManager::SplitInfoString(const std::string &infoString, vector<Property> &info) { // our string is of the form: // category[(params)][.info(params).info2(params)] ... // so we need to split on . while taking into account of () pairs unsigned int parentheses = 0; - CStdString property; - CStdString param; + std::string property; + std::string param; for (size_t i = 0; i < infoString.size(); ++i) { if (infoString[i] == '(') @@ -811,13 +811,13 @@ void CGUIInfoManager::SplitInfoString(const CStdString &infoString, vector<Prope /// \brief Translates a string as given by the skin into an int that we use for more /// efficient retrieval of data. -int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition) +int CGUIInfoManager::TranslateSingleString(const std::string &strCondition) { bool listItemDependent; return TranslateSingleString(strCondition, listItemDependent); } -int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition, bool &listItemDependent) +int CGUIInfoManager::TranslateSingleString(const std::string &strCondition, bool &listItemDependent) { /* We need to disable caching in INFO::InfoBool::Get if either of the following are true: * 1. if condition is between LISTITEM_START and LISTITEM_END @@ -826,7 +826,7 @@ int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition, bool * This is achieved by setting the bool pointed at by listItemDependent, either here or in a recursive call */ // trim whitespaces - CStdString strTest = strCondition; + std::string strTest = strCondition; StringUtils::Trim(strTest); vector< Property> info; @@ -851,7 +851,7 @@ int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition, bool if (info2 > 0) return AddMultiInfo(GUIInfo(STRING_COMPARE, info, -info2)); // pipe our original string through the localize parsing then make it lowercase (picks up $LBRACKET etc.) - CStdString label = CGUIInfoLabel::GetLabel(cat.param(1)); + std::string label = CGUIInfoLabel::GetLabel(cat.param(1)); StringUtils::ToLower(label); int compareString = ConditionalStringParameter(label); return AddMultiInfo(GUIInfo(STRING_COMPARE, info, compareString)); @@ -865,7 +865,7 @@ int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition, bool else if (cat.name == "substring" && cat.num_params() >= 2) { int info = TranslateSingleString(cat.param(0), listItemDependent); - CStdString label = CGUIInfoLabel::GetLabel(cat.param(1)); + std::string label = CGUIInfoLabel::GetLabel(cat.param(1)); StringUtils::ToLower(label); int compareString = ConditionalStringParameter(label); if (cat.num_params() > 2) @@ -935,7 +935,7 @@ int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition, bool } if (prop.num_params() == 1) { - const CStdString ¶m = prop.param(); + const std::string ¶m = prop.param(); if (prop.name == "getbool") { std::string paramCopy = param; @@ -960,7 +960,7 @@ int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition, bool int infoLabel = TranslateSingleString(param, listItemDependent); if (infoLabel > 0) return AddMultiInfo(GUIInfo(SYSTEM_ADDON_TITLE, infoLabel, 0)); - CStdString label = CGUIInfoLabel::GetLabel(param); + std::string label = CGUIInfoLabel::GetLabel(param); StringUtils::ToLower(label); return AddMultiInfo(GUIInfo(SYSTEM_ADDON_TITLE, ConditionalStringParameter(label), 1)); } @@ -969,7 +969,7 @@ int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition, bool int infoLabel = TranslateSingleString(param, listItemDependent); if (infoLabel > 0) return AddMultiInfo(GUIInfo(SYSTEM_ADDON_ICON, infoLabel, 0)); - CStdString label = CGUIInfoLabel::GetLabel(param); + std::string label = CGUIInfoLabel::GetLabel(param); StringUtils::ToLower(label); return AddMultiInfo(GUIInfo(SYSTEM_ADDON_ICON, ConditionalStringParameter(label), 1)); } @@ -978,7 +978,7 @@ int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition, bool int infoLabel = TranslateSingleString(param, listItemDependent); if (infoLabel > 0) return AddMultiInfo(GUIInfo(SYSTEM_ADDON_VERSION, infoLabel, 0)); - CStdString label = CGUIInfoLabel::GetLabel(param); + std::string label = CGUIInfoLabel::GetLabel(param); StringUtils::ToLower(label); return AddMultiInfo(GUIInfo(SYSTEM_ADDON_VERSION, ConditionalStringParameter(label), 1)); } @@ -1023,7 +1023,7 @@ int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition, bool else if (prop.name == "isscanningmusic") return LIBRARY_IS_SCANNING_MUSIC; else if (prop.name == "hascontent" && prop.num_params()) { - CStdString cat = prop.param(0); + std::string cat = prop.param(0); StringUtils::ToLower(cat); if (cat == "music") return LIBRARY_HAS_MUSIC; else if (cat == "video") return LIBRARY_HAS_VIDEO; @@ -1260,12 +1260,12 @@ int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition, bool { if (info[0].name == "system" && info[1].name == "platform") { // TODO: replace with a single system.platform - CStdString platform = info[2].name; + std::string platform = info[2].name; if (platform == "linux") { if (info.size() == 4) { - CStdString device = info[3].name; + std::string device = info[3].name; if (device == "raspberrypi") return SYSTEM_PLATFORM_LINUX_RASPBERRY_PI; } else return SYSTEM_PLATFORM_LINUX; @@ -1336,7 +1336,7 @@ int CGUIInfoManager::TranslateListItem(const Property &info) return 0; } -int CGUIInfoManager::TranslateMusicPlayerString(const CStdString &info) const +int CGUIInfoManager::TranslateMusicPlayerString(const std::string &info) const { for (size_t i = 0; i < sizeof(musicplayer) / sizeof(infomap); i++) { @@ -1346,29 +1346,29 @@ int CGUIInfoManager::TranslateMusicPlayerString(const CStdString &info) const return 0; } -TIME_FORMAT CGUIInfoManager::TranslateTimeFormat(const CStdString &format) +TIME_FORMAT CGUIInfoManager::TranslateTimeFormat(const std::string &format) { if (format.empty()) return TIME_FORMAT_GUESS; - else if (format.Equals("hh")) return TIME_FORMAT_HH; - else if (format.Equals("mm")) return TIME_FORMAT_MM; - else if (format.Equals("ss")) return TIME_FORMAT_SS; - else if (format.Equals("hh:mm")) return TIME_FORMAT_HH_MM; - else if (format.Equals("mm:ss")) return TIME_FORMAT_MM_SS; - else if (format.Equals("hh:mm:ss")) return TIME_FORMAT_HH_MM_SS; - else if (format.Equals("hh:mm:ss xx")) return TIME_FORMAT_HH_MM_SS_XX; - else if (format.Equals("h")) return TIME_FORMAT_H; - else if (format.Equals("h:mm:ss")) return TIME_FORMAT_H_MM_SS; - else if (format.Equals("h:mm:ss xx")) return TIME_FORMAT_H_MM_SS_XX; - else if (format.Equals("xx")) return TIME_FORMAT_XX; + else if (StringUtils::EqualsNoCase(format, "hh")) return TIME_FORMAT_HH; + else if (StringUtils::EqualsNoCase(format, "mm")) return TIME_FORMAT_MM; + else if (StringUtils::EqualsNoCase(format, "ss")) return TIME_FORMAT_SS; + else if (StringUtils::EqualsNoCase(format, "hh:mm")) return TIME_FORMAT_HH_MM; + else if (StringUtils::EqualsNoCase(format, "mm:ss")) return TIME_FORMAT_MM_SS; + else if (StringUtils::EqualsNoCase(format, "hh:mm:ss")) return TIME_FORMAT_HH_MM_SS; + else if (StringUtils::EqualsNoCase(format, "hh:mm:ss xx")) return TIME_FORMAT_HH_MM_SS_XX; + else if (StringUtils::EqualsNoCase(format, "h")) return TIME_FORMAT_H; + else if (StringUtils::EqualsNoCase(format, "h:mm:ss")) return TIME_FORMAT_H_MM_SS; + else if (StringUtils::EqualsNoCase(format, "h:mm:ss xx")) return TIME_FORMAT_H_MM_SS_XX; + else if (StringUtils::EqualsNoCase(format, "xx")) return TIME_FORMAT_XX; return TIME_FORMAT_GUESS; } -CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, std::string *fallback) +std::string CGUIInfoManager::GetLabel(int info, int contextWindow, std::string *fallback) { if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END) return GetSkinVariableString(info, false); - CStdString strLabel; + std::string strLabel; if (info >= MULTI_INFO_START && info <= MULTI_INFO_END) return GetMultiInfoLabel(m_multiInfo[info - MULTI_INFO_START], contextWindow); @@ -1381,7 +1381,7 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, std::string *f if (!m_currentFile) return ""; - CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START-MUSICPLAYER_PROPERTY_OFFSET]; + std::string property = m_listitemProperties[info - LISTITEM_PROPERTY_START-MUSICPLAYER_PROPERTY_OFFSET]; return m_currentFile->GetProperty(property).asString(); } @@ -1528,12 +1528,11 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, std::string *f { if (m_currentFile->HasPVRChannelInfoTag()) { - CEpgInfoTag tag; - return m_currentFile->GetPVRChannelInfoTag()->GetEPGNow(tag) ? - tag.Title() : + CEpgInfoTagPtr tag(m_currentFile->GetPVRChannelInfoTag()->GetEPGNow()); + return tag ? + tag->Title() : CSettings::Get().GetBool("epg.hidenoinfoavailable") ? - StringUtils::EmptyString : - g_localizeStrings.Get(19055); // no information available + "" : g_localizeStrings.Get(19055); // no information available } if (m_currentFile->HasPVRRecordingInfoTag() && !m_currentFile->GetPVRRecordingInfoTag()->m_strTitle.empty()) return m_currentFile->GetPVRRecordingInfoTag()->m_strTitle; @@ -1920,9 +1919,13 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, std::string *f break; case SYSTEM_FRIENDLY_NAME: { - CStdString friendlyName = CSettings::Get().GetString("services.devicename"); - if (friendlyName.Equals(CCompileInfo::GetAppName())) - strLabel = StringUtils::Format("%s (%s)", friendlyName.c_str(), g_application.getNetwork().GetHostName().c_str()); + std::string friendlyName = CSettings::Get().GetString("services.devicename"); + if (StringUtils::EqualsNoCase(friendlyName, CCompileInfo::GetAppName())) + { + std::string hostname("[unknown]"); + g_application.getNetwork().GetHostName(hostname); + strLabel = StringUtils::Format("%s (%s)", friendlyName.c_str(), hostname.c_str()); + } else strLabel = friendlyName; } @@ -1981,13 +1984,13 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, std::string *f break; case NETWORK_DHCP_ADDRESS: { - CStdString dhcpserver; + std::string dhcpserver; return dhcpserver; } break; case NETWORK_LINK_STATE: { - CStdString linkStatus = g_localizeStrings.Get(151); + std::string linkStatus = g_localizeStrings.Get(151); linkStatus += " "; CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface(); if (iface && iface->IsConnected()) @@ -2177,9 +2180,9 @@ struct InfoBoolFinder InfoBool m_bool; }; -INFO::InfoPtr CGUIInfoManager::Register(const CStdString &expression, int context) +INFO::InfoPtr CGUIInfoManager::Register(const std::string &expression, int context) { - CStdString condition(CGUIInfoLabel::ReplaceLocalize(expression)); + std::string condition(CGUIInfoLabel::ReplaceLocalize(expression)); StringUtils::Trim(condition); if (condition.empty()) @@ -2199,7 +2202,7 @@ INFO::InfoPtr CGUIInfoManager::Register(const CStdString &expression, int contex return m_bools.back(); } -bool CGUIInfoManager::EvaluateBool(const CStdString &expression, int contextWindow) +bool CGUIInfoManager::EvaluateBool(const std::string &expression, int contextWindow) { bool result = false; INFO::InfoPtr info = Register(expression, contextWindow); @@ -2644,10 +2647,7 @@ bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListI break; case VIDEOPLAYER_HAS_EPG: if (m_currentFile->HasPVRChannelInfoTag()) - { - CEpgInfoTag epgTag; - bReturn = m_currentFile->GetPVRChannelInfoTag()->GetEPGNow(epgTag); - } + bReturn = (m_currentFile->GetPVRChannelInfoTag()->GetEPGNow().get() != NULL); break; case VIDEOPLAYER_IS_STEREOSCOPIC: if(g_application.m_pPlayer->IsPlaying()) @@ -2718,7 +2718,7 @@ bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, c break; case SKIN_HAS_THEME: { - CStdString theme = CSettings::Get().GetString("lookandfeel.skintheme"); + std::string theme = CSettings::Get().GetString("lookandfeel.skintheme"); URIUtils::RemoveExtension(theme); bReturn = StringUtils::EqualsNoCase(theme, m_stringParameters[info.GetData1()]); } @@ -2732,7 +2732,7 @@ bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, c break; case STRING_COMPARE: { - CStdString compare; + std::string compare; if (info.GetData2() < 0) // info labels are stored with negative numbers { int info2 = -info.GetData2(); @@ -2746,9 +2746,9 @@ bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, c compare = m_stringParameters[info.GetData2()]; } if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END) - bReturn = GetItemImage((const CFileItem *)item, info.GetData1()).Equals(compare); + bReturn = StringUtils::EqualsNoCase(GetItemImage((const CFileItem *)item, info.GetData1()), compare); else - bReturn = GetImage(info.GetData1(), contextWindow).Equals(compare); + bReturn = StringUtils::EqualsNoCase(GetImage(info.GetData1(), contextWindow), compare); } break; case INTEGER_GREATER_THAN: @@ -2758,7 +2758,7 @@ bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, c bReturn = integer > info.GetData2(); else { - CStdString value; + std::string value; if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END) value = GetItemImage((const CFileItem *)item, info.GetData1()); @@ -2778,10 +2778,10 @@ bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, c case STRING_STR_LEFT: case STRING_STR_RIGHT: { - CStdString compare = m_stringParameters[info.GetData2()]; + std::string compare = m_stringParameters[info.GetData2()]; // our compare string is already in lowercase, so lower case our label as well - // as CStdString::Find() is case sensitive - CStdString label; + // as std::string::Find() is case sensitive + std::string label; if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END) { label = GetItemImage((const CFileItem *)item, info.GetData1()); @@ -2931,7 +2931,7 @@ bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, c break; case CONTAINER_CONTENT: { - CStdString content; + std::string content; CGUIWindow *window = GetWindowWithCondition(contextWindow, 0); if (window) { @@ -2992,7 +2992,7 @@ bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, c } case VIDEOPLAYER_CONTENT: { - CStdString strContent="files"; + std::string strContent="files"; if (m_currentFile->HasVideoInfoTag() && m_currentFile->GetVideoInfoTag()->m_type == MediaTypeMovie) strContent = "movies"; if (m_currentFile->HasVideoInfoTag() && m_currentFile->GetVideoInfoTag()->m_iSeason > -1) // episode @@ -3024,7 +3024,7 @@ bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, c { const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState(); if (viewState) - bReturn = ((unsigned int)viewState->GetDisplaySortOrder() == info.GetData1()); + bReturn = ((unsigned int)viewState->GetSortOrder() == info.GetData1()); } break; } @@ -3133,7 +3133,7 @@ bool CGUIInfoManager::GetMultiInfoInt(int &value, const GUIInfo &info, int conte } /// \brief Examines the multi information sent and returns the string as appropriate -CStdString CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWindow, std::string *fallback) +std::string CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWindow, std::string *fallback) { if (info.m_info == SKIN_STRING) { @@ -3182,9 +3182,9 @@ CStdString CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWi else if (info.m_info == PLAYER_FINISH_TIME) { CDateTime time; - CEpgInfoTag currentTag; - if (GetEpgInfoTag(currentTag)) - time = currentTag.EndAsLocalTime(); + CEpgInfoTagPtr currentTag(GetEpgInfoTag()); + if (currentTag) + time = currentTag->EndAsLocalTime(); else { time = CDateTime::GetCurrentDateTime(); @@ -3195,9 +3195,9 @@ CStdString CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWi else if (info.m_info == PLAYER_START_TIME) { CDateTime time; - CEpgInfoTag currentTag; - if (GetEpgInfoTag(currentTag)) - time = currentTag.StartAsLocalTime(); + CEpgInfoTagPtr currentTag(GetEpgInfoTag()); + if (currentTag) + time = currentTag->StartAsLocalTime(); else { time = CDateTime::GetCurrentDateTime(); @@ -3207,7 +3207,7 @@ CStdString CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWi } else if (info.m_info == PLAYER_TIME_SPEED) { - CStdString strTime; + std::string strTime; if (g_application.m_pPlayer->GetPlaySpeed() != 1) strTime = StringUtils::Format("%s (%ix)", GetCurrentPlayTime((TIME_FORMAT)info.GetData1()).c_str(), g_application.m_pPlayer->GetPlaySpeed()); else @@ -3224,7 +3224,7 @@ CStdString CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWi } else if (info.m_info == PLAYER_SEEKOFFSET) { - CStdString seekOffset = StringUtils::SecondsToTimeString(abs(m_seekOffset / 1000), (TIME_FORMAT)info.GetData1()); + std::string seekOffset = StringUtils::SecondsToTimeString(abs(m_seekOffset / 1000), (TIME_FORMAT)info.GetData1()); if (m_seekOffset < 0) return "-" + seekOffset; if (m_seekOffset > 0) @@ -3270,7 +3270,7 @@ CStdString CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWi } else if (info.m_info == SYSTEM_GET_CORE_USAGE) { - CStdString strCpu = StringUtils::Format("%4.2f", g_cpuInfo.GetCoreInfo(atoi(m_stringParameters[info.GetData1()].c_str())).m_fPct); + std::string strCpu = StringUtils::Format("%4.2f", g_cpuInfo.GetCoreInfo(atoi(m_stringParameters[info.GetData1()].c_str())).m_fPct); return strCpu; } else if (info.m_info >= MUSICPLAYER_TITLE && info.m_info <= MUSICPLAYER_ALBUM_ARTIST) @@ -3350,11 +3350,11 @@ CStdString CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWi return GetPlaylistLabel(info.m_info, playlistid); } - return StringUtils::EmptyString; + return ""; } /// \brief Obtains the filename of the image to show from whichever subsystem is needed -CStdString CGUIInfoManager::GetImage(int info, int contextWindow, std::string *fallback) +std::string CGUIInfoManager::GetImage(int info, int contextWindow, std::string *fallback) { if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END) return GetSkinVariableString(info, true); @@ -3367,7 +3367,7 @@ CStdString CGUIInfoManager::GetImage(int info, int contextWindow, std::string *f return g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON); else if (info == SYSTEM_PROFILETHUMB) { - CStdString thumb = CProfilesManager::Get().GetCurrentProfile().getThumb(); + std::string thumb = CProfilesManager::Get().GetCurrentProfile().getThumb(); if (thumb.empty()) thumb = "unknown-user.png"; return thumb; @@ -3412,21 +3412,21 @@ CStdString CGUIInfoManager::GetImage(int info, int contextWindow, std::string *f return GetLabel(info, contextWindow, fallback); } -CStdString CGUIInfoManager::GetDate(bool bNumbersOnly) +std::string CGUIInfoManager::GetDate(bool bNumbersOnly) { CDateTime time=CDateTime::GetCurrentDateTime(); return time.GetAsLocalizedDate(!bNumbersOnly); } -CStdString CGUIInfoManager::GetTime(TIME_FORMAT format) const +std::string CGUIInfoManager::GetTime(TIME_FORMAT format) const { CDateTime time=CDateTime::GetCurrentDateTime(); return LocalizeTime(time, format); } -CStdString CGUIInfoManager::LocalizeTime(const CDateTime &time, TIME_FORMAT format) const +std::string CGUIInfoManager::LocalizeTime(const CDateTime &time, TIME_FORMAT format) const { - const CStdString timeFormat = g_langInfo.GetTimeFormat(); + const std::string timeFormat = g_langInfo.GetTimeFormat(); bool use12hourclock = timeFormat.find('h') != std::string::npos; switch (format) { @@ -3462,7 +3462,7 @@ CStdString CGUIInfoManager::LocalizeTime(const CDateTime &time, TIME_FORMAT form return time.GetAsLocalizedTime("", false); } -CStdString CGUIInfoManager::GetDuration(TIME_FORMAT format) const +std::string CGUIInfoManager::GetDuration(TIME_FORMAT format) const { if (g_application.m_pPlayer->IsPlayingAudio() && m_currentFile->HasMusicInfoTag()) { @@ -3478,7 +3478,7 @@ CStdString CGUIInfoManager::GetDuration(TIME_FORMAT format) const return ""; } -CStdString CGUIInfoManager::GetMusicPartyModeLabel(int item) +std::string CGUIInfoManager::GetMusicPartyModeLabel(int item) { // get song counts if (item >= MUSICPM_SONGSPLAYED && item <= MUSICPM_RANDOMSONGSPICKED) @@ -3519,13 +3519,13 @@ CStdString CGUIInfoManager::GetMusicPartyModeLabel(int item) } if (iSongs < 0) return ""; - CStdString strLabel = StringUtils::Format("%i", iSongs); + std::string strLabel = StringUtils::Format("%i", iSongs); return strLabel; } return ""; } -const CStdString CGUIInfoManager::GetMusicPlaylistInfo(const GUIInfo& info) +const std::string CGUIInfoManager::GetMusicPlaylistInfo(const GUIInfo& info) { PLAYLIST::CPlayList& playlist = g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC); if (playlist.size() < 1) @@ -3556,7 +3556,7 @@ const CStdString CGUIInfoManager::GetMusicPlaylistInfo(const GUIInfo& info) } if (info.m_info == MUSICPLAYER_PLAYLISTPOS) { - CStdString strPosition = StringUtils::Format("%i", index + 1); + std::string strPosition = StringUtils::Format("%i", index + 1); return strPosition; } else if (info.m_info == MUSICPLAYER_COVER) @@ -3564,7 +3564,7 @@ const CStdString CGUIInfoManager::GetMusicPlaylistInfo(const GUIInfo& info) return GetMusicTagLabel(info.m_info, playlistItem.get()); } -CStdString CGUIInfoManager::GetPlaylistLabel(int item, int playlistid /* = PLAYLIST_NONE */) const +std::string CGUIInfoManager::GetPlaylistLabel(int item, int playlistid /* = PLAYLIST_NONE */) const { if (playlistid <= PLAYLIST_NONE && !g_application.m_pPlayer->IsPlaying()) return ""; @@ -3601,7 +3601,7 @@ CStdString CGUIInfoManager::GetPlaylistLabel(int item, int playlistid /* = PLAYL return ""; } -CStdString CGUIInfoManager::GetMusicLabel(int item) +std::string CGUIInfoManager::GetMusicLabel(int item) { if (!g_application.m_pPlayer->IsPlaying() || !m_currentFile->HasMusicInfoTag()) return ""; @@ -3621,7 +3621,7 @@ CStdString CGUIInfoManager::GetMusicLabel(int item) break; case MUSICPLAYER_BITRATE: { - CStdString strBitrate = ""; + std::string strBitrate = ""; if (m_audioInfo.bitrate > 0) strBitrate = StringUtils::Format("%i", MathUtils::round_int((double)m_audioInfo.bitrate / 1000.0)); return strBitrate; @@ -3629,7 +3629,7 @@ CStdString CGUIInfoManager::GetMusicLabel(int item) break; case MUSICPLAYER_CHANNELS: { - CStdString strChannels = ""; + std::string strChannels = ""; if (m_audioInfo.channels > 0) { strChannels = StringUtils::Format("%i", m_audioInfo.channels); @@ -3639,7 +3639,7 @@ CStdString CGUIInfoManager::GetMusicLabel(int item) break; case MUSICPLAYER_BITSPERSAMPLE: { - CStdString strBitsPerSample = ""; + std::string strBitsPerSample = ""; if (m_audioInfo.bitspersample > 0) strBitsPerSample = StringUtils::Format("%i", m_audioInfo.bitspersample); return strBitsPerSample; @@ -3647,7 +3647,7 @@ CStdString CGUIInfoManager::GetMusicLabel(int item) break; case MUSICPLAYER_SAMPLERATE: { - CStdString strSampleRate = ""; + std::string strSampleRate = ""; if (m_audioInfo.samplerate > 0) strSampleRate = StringUtils::Format("%.5g", ((double)m_audioInfo.samplerate / 1000.0)); return strSampleRate; @@ -3664,7 +3664,7 @@ CStdString CGUIInfoManager::GetMusicLabel(int item) return GetMusicTagLabel(item, m_currentFile); } -CStdString CGUIInfoManager::GetMusicTagLabel(int info, const CFileItem *item) +std::string CGUIInfoManager::GetMusicTagLabel(int info, const CFileItem *item) { if (!item->HasMusicInfoTag()) return ""; const CMusicInfoTag &tag = *item->GetMusicInfoTag(); @@ -3693,7 +3693,7 @@ CStdString CGUIInfoManager::GetMusicTagLabel(int info, const CFileItem *item) break; case MUSICPLAYER_TRACK_NUMBER: { - CStdString strTrack; + std::string strTrack; if (tag.Loaded() && tag.GetTrackNumber() > 0) { return StringUtils::Format("%02i", tag.GetTrackNumber()); @@ -3746,7 +3746,7 @@ CStdString CGUIInfoManager::GetMusicTagLabel(int info, const CFileItem *item) return ""; } -CStdString CGUIInfoManager::GetVideoLabel(int item) +std::string CGUIInfoManager::GetVideoLabel(int item) { if (!g_application.m_pPlayer->IsPlaying()) return ""; @@ -3769,58 +3769,70 @@ CStdString CGUIInfoManager::GetVideoLabel(int item) else if (m_currentFile->HasPVRChannelInfoTag()) { CPVRChannel* tag = m_currentFile->GetPVRChannelInfoTag(); - CEpgInfoTag epgTag; + CEpgInfoTagPtr epgTag; switch (item) { /* Now playing infos */ case VIDEOPLAYER_ORIGINALTITLE: - return tag->GetEPGNow(epgTag) ? - epgTag.Title() : + epgTag = tag->GetEPGNow(); + return epgTag ? + epgTag->Title() : CSettings::Get().GetBool("epg.hidenoinfoavailable") ? - StringUtils::EmptyString : - g_localizeStrings.Get(19055); // no information available + "" : g_localizeStrings.Get(19055); // no information available case VIDEOPLAYER_GENRE: - return tag->GetEPGNow(epgTag) ? StringUtils::Join(epgTag.Genre(), g_advancedSettings.m_videoItemSeparator) : ""; + epgTag = tag->GetEPGNow(); + return epgTag ? StringUtils::Join(epgTag->Genre(), g_advancedSettings.m_videoItemSeparator) : ""; case VIDEOPLAYER_PLOT: - return tag->GetEPGNow(epgTag) ? epgTag.Plot() : ""; + epgTag = tag->GetEPGNow(); + return epgTag ? epgTag->Plot() : ""; case VIDEOPLAYER_PLOT_OUTLINE: - return tag->GetEPGNow(epgTag) ? epgTag.PlotOutline() : ""; + epgTag = tag->GetEPGNow(); + return epgTag ? epgTag->PlotOutline() : ""; case VIDEOPLAYER_STARTTIME: - return tag->GetEPGNow(epgTag) ? epgTag.StartAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false); + epgTag = tag->GetEPGNow(); + return epgTag ? epgTag->StartAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false); case VIDEOPLAYER_ENDTIME: - return tag->GetEPGNow(epgTag) ? epgTag.EndAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false); + epgTag = tag->GetEPGNow(); + return epgTag ? epgTag->EndAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false); /* Next playing infos */ case VIDEOPLAYER_NEXT_TITLE: - return tag->GetEPGNext(epgTag) ? - epgTag.Title() : + epgTag = tag->GetEPGNext(); + return epgTag ? + epgTag->Title() : CSettings::Get().GetBool("epg.hidenoinfoavailable") ? - StringUtils::EmptyString : - g_localizeStrings.Get(19055); // no information available + "" : g_localizeStrings.Get(19055); // no information available case VIDEOPLAYER_NEXT_GENRE: - return tag->GetEPGNext(epgTag) ? StringUtils::Join(epgTag.Genre(), g_advancedSettings.m_videoItemSeparator) : ""; + epgTag = tag->GetEPGNext(); + return epgTag ? StringUtils::Join(epgTag->Genre(), g_advancedSettings.m_videoItemSeparator) : ""; case VIDEOPLAYER_NEXT_PLOT: - return tag->GetEPGNext(epgTag) ? epgTag.Plot() : ""; + epgTag = tag->GetEPGNext(); + return epgTag ? epgTag->Plot() : ""; case VIDEOPLAYER_NEXT_PLOT_OUTLINE: - return tag->GetEPGNext(epgTag) ? epgTag.PlotOutline() : ""; + epgTag = tag->GetEPGNext(); + return epgTag ? epgTag->PlotOutline() : ""; case VIDEOPLAYER_NEXT_STARTTIME: - return tag->GetEPGNext(epgTag) ? epgTag.StartAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false); + epgTag = tag->GetEPGNext(); + return epgTag ? epgTag->StartAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false); case VIDEOPLAYER_NEXT_ENDTIME: - return tag->GetEPGNext(epgTag) ? epgTag.EndAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false); + epgTag = tag->GetEPGNext(); + return epgTag ? epgTag->EndAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false); case VIDEOPLAYER_NEXT_DURATION: { - CStdString duration; - if (tag->GetEPGNext(epgTag) && epgTag.GetDuration() > 0) - duration = StringUtils::SecondsToTimeString(epgTag.GetDuration()); + std::string duration; + epgTag = tag->GetEPGNext(); + if (epgTag && epgTag->GetDuration() > 0) + duration = StringUtils::SecondsToTimeString(epgTag->GetDuration()); return duration; } case VIDEOPLAYER_PARENTAL_RATING: { - CStdString rating; - if (tag->GetEPGNow(epgTag) && epgTag.ParentalRating() > 0) - rating = StringUtils::Format("%i", epgTag.ParentalRating()); + std::string rating; + epgTag = tag->GetEPGNow(); + if (epgTag && epgTag->ParentalRating() > 0) + rating = StringUtils::Format("%i", epgTag->ParentalRating()); return rating; } break; @@ -3860,7 +3872,7 @@ CStdString CGUIInfoManager::GetVideoLabel(int item) break; case VIDEOPLAYER_RATING: { - CStdString strRating; + std::string strRating; if (m_currentFile->GetVideoInfoTag()->m_fRating > 0.f) strRating = StringUtils::Format("%.1f", m_currentFile->GetVideoInfoTag()->m_fRating); return strRating; @@ -3868,7 +3880,7 @@ CStdString CGUIInfoManager::GetVideoLabel(int item) break; case VIDEOPLAYER_RATING_AND_VOTES: { - CStdString strRatingAndVotes; + std::string strRatingAndVotes; if (m_currentFile->GetVideoInfoTag()->m_fRating > 0.f) { if (m_currentFile->GetVideoInfoTag()->m_strVotes.empty()) @@ -3887,7 +3899,7 @@ CStdString CGUIInfoManager::GetVideoLabel(int item) return m_currentFile->GetVideoInfoTag()->m_strVotes; case VIDEOPLAYER_YEAR: { - CStdString strYear; + std::string strYear; if (m_currentFile->GetVideoInfoTag()->m_iYear > 0) strYear = StringUtils::Format("%i", m_currentFile->GetVideoInfoTag()->m_iYear); return strYear; @@ -3915,7 +3927,7 @@ CStdString CGUIInfoManager::GetVideoLabel(int item) case VIDEOPLAYER_EPISODE: if (m_currentFile->GetVideoInfoTag()->m_iEpisode > 0) { - CStdString strEpisode; + std::string strEpisode; if (m_currentFile->GetVideoInfoTag()->m_iSeason == 0) // prefix episode with 'S' strEpisode = StringUtils::Format("S%i", m_currentFile->GetVideoInfoTag()->m_iEpisode); else @@ -3940,7 +3952,7 @@ CStdString CGUIInfoManager::GetVideoLabel(int item) return m_currentFile->GetVideoInfoTag()->m_strMPAARating; case VIDEOPLAYER_TOP250: { - CStdString strTop250; + std::string strTop250; if (m_currentFile->GetVideoInfoTag()->m_iTop250 > 0) strTop250 = StringUtils::Format("%i", m_currentFile->GetVideoInfoTag()->m_iTop250); return strTop250; @@ -3966,7 +3978,7 @@ CStdString CGUIInfoManager::GetVideoLabel(int item) } case VIDEOPLAYER_PLAYCOUNT: { - CStdString strPlayCount; + std::string strPlayCount; if (m_currentFile->GetVideoInfoTag()->m_playCount > 0) strPlayCount = StringUtils::Format("%i", m_currentFile->GetVideoInfoTag()->m_playCount); return strPlayCount; @@ -3987,7 +3999,7 @@ int64_t CGUIInfoManager::GetPlayTime() const return 0; } -CStdString CGUIInfoManager::GetCurrentPlayTime(TIME_FORMAT format) const +std::string CGUIInfoManager::GetCurrentPlayTime(TIME_FORMAT format) const { if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600) format = TIME_FORMAT_HH_MM_SS; @@ -3996,7 +4008,7 @@ CStdString CGUIInfoManager::GetCurrentPlayTime(TIME_FORMAT format) const return ""; } -CStdString CGUIInfoManager::GetCurrentSeekTime(TIME_FORMAT format) const +std::string CGUIInfoManager::GetCurrentSeekTime(TIME_FORMAT format) const { if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600) format = TIME_FORMAT_HH_MM_SS; @@ -4016,7 +4028,7 @@ int CGUIInfoManager::GetPlayTimeRemaining() const return iReverse > 0 ? iReverse : 0; } -CStdString CGUIInfoManager::GetCurrentPlayTimeRemaining(TIME_FORMAT format) const +std::string CGUIInfoManager::GetCurrentPlayTimeRemaining(TIME_FORMAT format) const { if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600) format = TIME_FORMAT_HH_MM_SS; @@ -4043,19 +4055,19 @@ void CGUIInfoManager::SetCurrentItem(CFileItem &item) SetCurrentMovie(item); if (item.HasEPGInfoTag()) - *m_currentFile->GetEPGInfoTag() = *item.GetEPGInfoTag(); + m_currentFile->SetEPGInfoTag(item.GetEPGInfoTag()); else if (item.HasPVRChannelInfoTag()) { - CEpgInfoTag tag; - if (item.GetPVRChannelInfoTag()->GetEPGNow(tag)) - *m_currentFile->GetEPGInfoTag() = tag; + CEpgInfoTagPtr tag(item.GetPVRChannelInfoTag()->GetEPGNow()); + if (tag) + m_currentFile->SetEPGInfoTag(tag); } SetChanged(); NotifyObservers(ObservableMessageCurrentItem); } -void CGUIInfoManager::SetCurrentAlbumThumb(const CStdString &thumbFileName) +void CGUIInfoManager::SetCurrentAlbumThumb(const std::string &thumbFileName) { if (CFile::Exists(thumbFileName)) m_currentFile->SetArt("thumb", thumbFileName); @@ -4114,8 +4126,8 @@ void CGUIInfoManager::SetCurrentMovie(CFileItem &item) CVideoDatabase dbs; if (dbs.Open()) { - CStdString path = item.GetPath(); - CStdString videoInfoTagPath(item.GetVideoInfoTag()->m_strFileNameAndPath); + std::string path = item.GetPath(); + std::string videoInfoTagPath(item.GetVideoInfoTag()->m_strFileNameAndPath); if (videoInfoTagPath.find("removable://") == 0) path = videoInfoTagPath; dbs.LoadVideoInfo(path, *m_currentFile->GetVideoInfoTag()); @@ -4167,7 +4179,7 @@ string CGUIInfoManager::GetSystemHeatInfo(int info) #endif } - CStdString text; + std::string text; switch(info) { case SYSTEM_CPU_TEMPERATURE: @@ -4201,7 +4213,7 @@ CTemperature CGUIInfoManager::GetGPUTemperature() value = SMCGetTemperature(SMC_KEY_GPU_TEMP); return CTemperature::CreateFromCelsius(value); #else - CStdString cmd = g_advancedSettings.m_gpuTempCmd; + std::string cmd = g_advancedSettings.m_gpuTempCmd; int ret = 0; FILE *p = NULL; @@ -4232,17 +4244,17 @@ std::string CGUIInfoManager::GetVersionShort(void) return StringUtils::Format("%d.%d-%s", CCompileInfo::GetMajor(), CCompileInfo::GetMinor(), CCompileInfo::GetSuffix()); } -CStdString CGUIInfoManager::GetVersion() +std::string CGUIInfoManager::GetVersion() { return GetVersionShort() + " Git:" + CCompileInfo::GetSCMID(); } -CStdString CGUIInfoManager::GetBuild() +std::string CGUIInfoManager::GetBuild() { return StringUtils::Format("%s", __DATE__); } -CStdString CGUIInfoManager::GetAppName() +std::string CGUIInfoManager::GetAppName() { return CCompileInfo::GetAppName(); } @@ -4322,7 +4334,7 @@ void CGUIInfoManager::UpdateAVInfo() } } -int CGUIInfoManager::AddListItemProp(const CStdString &str, int offset) +int CGUIInfoManager::AddListItemProp(const std::string &str, int offset) { for (int i=0; i < (int)m_listitemProperties.size(); i++) if (m_listitemProperties[i] == str) @@ -4352,7 +4364,7 @@ int CGUIInfoManager::AddMultiInfo(const GUIInfo &info) return id; } -int CGUIInfoManager::ConditionalStringParameter(const CStdString ¶meter, bool caseSensitive /*= false*/) +int CGUIInfoManager::ConditionalStringParameter(const std::string ¶meter, bool caseSensitive /*= false*/) { // check to see if we have this parameter already if (caseSensitive) @@ -4383,9 +4395,9 @@ bool CGUIInfoManager::GetItemInt(int &value, const CGUIListItem *item, int info) if (info >= LISTITEM_PROPERTY_START && info - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size()) { // grab the property - CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START]; - CStdString val = item->GetProperty(property).asString(); - value = atoi(val); + std::string property = m_listitemProperties[info - LISTITEM_PROPERTY_START]; + std::string val = item->GetProperty(property).asString(); + value = atoi(val.c_str()); return true; } @@ -4399,9 +4411,9 @@ bool CGUIInfoManager::GetItemInt(int &value, const CGUIListItem *item, int info) const CFileItem *pItem = (const CFileItem *)item; if (pItem && pItem->HasPVRChannelInfoTag()) { - CEpgInfoTag epgNow; - if (pItem->GetPVRChannelInfoTag()->GetEPGNow(epgNow)) - value = (int) epgNow.ProgressPercentage(); + CEpgInfoTagPtr epgNow(pItem->GetPVRChannelInfoTag()->GetEPGNow()); + if (epgNow) + value = (int) epgNow->ProgressPercentage(); } else if (pItem && pItem->HasEPGInfoTag()) { @@ -4426,7 +4438,7 @@ bool CGUIInfoManager::GetItemInt(int &value, const CGUIListItem *item, int info) return false; } -CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::string *fallback) +std::string CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::string *fallback) { if (!item) return ""; @@ -4441,7 +4453,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s if (info >= LISTITEM_PROPERTY_START && info - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size()) { // grab the property - CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START]; + std::string property = m_listitemProperties[info - LISTITEM_PROPERTY_START]; return item->GetProperty(property).asString(); } @@ -4457,12 +4469,11 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s case LISTITEM_TITLE: if (item->HasPVRChannelInfoTag()) { - CEpgInfoTag epgTag; - return item->GetPVRChannelInfoTag()->GetEPGNow(epgTag) ? - epgTag.Title() : + CEpgInfoTagPtr epgTag(item->GetPVRChannelInfoTag()->GetEPGNow()); + return epgTag ? + epgTag->Title() : CSettings::Get().GetBool("epg.hidenoinfoavailable") ? - StringUtils::EmptyString : - g_localizeStrings.Get(19055); // no information available + "" : g_localizeStrings.Get(19055); // no information available } if (item->HasPVRRecordingInfoTag()) return item->GetPVRRecordingInfoTag()->m_strTitle; @@ -4481,7 +4492,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s break; case LISTITEM_PLAYCOUNT: { - CStdString strPlayCount; + std::string strPlayCount; if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_playCount > 0) strPlayCount = StringUtils::Format("%i", item->GetVideoInfoTag()->m_playCount); if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetPlayCount() > 0) @@ -4502,7 +4513,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s } case LISTITEM_TRACKNUMBER: { - CStdString track; + std::string track; if (item->HasMusicInfoTag()) track = StringUtils::Format("%i", item->GetMusicInfoTag()->GetTrackNumber()); if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iTrack > -1 ) @@ -4511,7 +4522,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s } case LISTITEM_DISC_NUMBER: { - CStdString disc; + std::string disc; if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDiscNumber() > 0) disc = StringUtils::Format("%i", item->GetMusicInfoTag()->GetDiscNumber()); return disc; @@ -4539,7 +4550,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s case LISTITEM_YEAR: if (item->HasVideoInfoTag()) { - CStdString strResult; + std::string strResult; if (item->GetVideoInfoTag()->m_iYear > 0) strResult = StringUtils::Format("%i",item->GetVideoInfoTag()->m_iYear); return strResult; @@ -4568,8 +4579,8 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s return StringUtils::Join(item->GetMusicInfoTag()->GetGenre(), g_advancedSettings.m_musicItemSeparator); if (item->HasPVRChannelInfoTag()) { - CEpgInfoTag epgTag; - return item->GetPVRChannelInfoTag()->GetEPGNow(epgTag) ? StringUtils::Join(epgTag.Genre(), g_advancedSettings.m_videoItemSeparator) : ""; + CEpgInfoTagPtr epgTag(item->GetPVRChannelInfoTag()->GetEPGNow()); + return epgTag ? StringUtils::Join(epgTag->Genre(), g_advancedSettings.m_videoItemSeparator) : ""; } if (item->HasPVRRecordingInfoTag()) return StringUtils::Join(item->GetPVRRecordingInfoTag()->m_genre, g_advancedSettings.m_videoItemSeparator); @@ -4579,7 +4590,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s case LISTITEM_FILENAME: case LISTITEM_FILE_EXTENSION: { - CStdString strFile; + std::string strFile; if (item->IsMusicDb() && item->HasMusicInfoTag()) strFile = URIUtils::GetFileName(item->GetMusicInfoTag()->GetURL()); else if (item->IsVideoDb() && item->HasVideoInfoTag()) @@ -4589,7 +4600,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s if (info==LISTITEM_FILE_EXTENSION) { - CStdString strExtension = URIUtils::GetExtension(strFile); + std::string strExtension = URIUtils::GetExtension(strFile); return StringUtils::TrimLeft(strExtension, "."); } return strFile; @@ -4600,8 +4611,8 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s return item->GetEPGInfoTag()->StartAsLocalTime().GetAsLocalizedDateTime(false, false); if (item->HasPVRChannelInfoTag()) { - CEpgInfoTag epgTag; - return item->GetPVRChannelInfoTag()->GetEPGNow(epgTag) ? epgTag.StartAsLocalTime().GetAsLocalizedDateTime(false, false) : CDateTime::GetCurrentDateTime().GetAsLocalizedDateTime(false, false); + CEpgInfoTagPtr epgTag(item->GetPVRChannelInfoTag()->GetEPGNow()); + return epgTag ? epgTag->StartAsLocalTime().GetAsLocalizedDateTime(false, false) : CDateTime::GetCurrentDateTime().GetAsLocalizedDateTime(false, false); } if (item->HasPVRRecordingInfoTag()) return item->GetPVRRecordingInfoTag()->RecordingTimeAsLocalTime().GetAsLocalizedDateTime(false, false); @@ -4616,7 +4627,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s break; case LISTITEM_RATING: { - CStdString rating; + std::string rating; if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_fRating > 0.f) // movie rating rating = StringUtils::Format("%.1f", item->GetVideoInfoTag()->m_fRating); else if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetRating() > '0') @@ -4629,7 +4640,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s { if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_fRating > 0.f) // movie rating { - CStdString strRatingAndVotes; + std::string strRatingAndVotes; if (item->GetVideoInfoTag()->m_strVotes.empty()) strRatingAndVotes = StringUtils::Format("%.1f", item->GetVideoInfoTag()->m_fRating); @@ -4652,14 +4663,17 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s } case LISTITEM_DURATION: { - CStdString duration; + std::string duration; if (item->HasPVRChannelInfoTag()) { const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL; - CEpgInfoTag tag; - if (channel && channel->GetEPGNow(tag)) - return StringUtils::SecondsToTimeString(tag.GetDuration()); - return StringUtils::EmptyString; + if (channel) + { + CEpgInfoTagPtr tag(channel->GetEPGNow()); + if (tag) + return StringUtils::SecondsToTimeString(tag->GetDuration()); + } + return ""; } else if (item->HasPVRRecordingInfoTag()) { @@ -4687,10 +4701,13 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s if (item->HasPVRChannelInfoTag()) { const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL; - CEpgInfoTag tag; - if (channel && channel->GetEPGNow(tag)) - return tag.Plot(); - return StringUtils::EmptyString; + if (channel) + { + CEpgInfoTagPtr tag(channel->GetEPGNow()); + if (tag) + return tag->Plot(); + } + return ""; } if (item->HasEPGInfoTag()) return item->GetEPGInfoTag()->Plot(); @@ -4709,10 +4726,13 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s if (item->HasPVRChannelInfoTag()) { const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL; - CEpgInfoTag tag; - if (channel && channel->GetEPGNow(tag)) - return tag.PlotOutline(); - return StringUtils::EmptyString; + if (channel) + { + CEpgInfoTagPtr tag(channel->GetEPGNow()); + if (tag) + return tag->PlotOutline(); + } + return ""; } if (item->HasEPGInfoTag()) return item->GetEPGInfoTag()->PlotOutline(); @@ -4724,7 +4744,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s case LISTITEM_EPISODE: if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iEpisode > 0) { - CStdString strResult; + std::string strResult; if (item->GetVideoInfoTag()->m_iSeason == 0) // prefix episode with 'S' strResult = StringUtils::Format("S%d",item->GetVideoInfoTag()->m_iEpisode); else @@ -4752,7 +4772,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s return item->GetIconImage(); case LISTITEM_ICON: { - CStdString strThumb = item->GetArt("thumb"); + std::string strThumb = item->GetArt("thumb"); if (strThumb.empty()) strThumb = item->GetIconImage(); if (fallback) @@ -4768,7 +4788,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s case LISTITEM_FOLDERNAME: case LISTITEM_PATH: { - CStdString path; + std::string path; if (item->IsMusicDb() && item->HasMusicInfoTag()) path = URIUtils::GetDirectory(item->GetMusicInfoTag()->GetURL()); else if (item->IsVideoDb() && item->HasVideoInfoTag()) @@ -4790,7 +4810,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s } case LISTITEM_FILENAME_AND_PATH: { - CStdString path; + std::string path; if (item->IsMusicDb() && item->HasMusicInfoTag()) path = item->GetMusicInfoTag()->GetURL(); else if (item->IsVideoDb() && item->HasVideoInfoTag()) @@ -4839,7 +4859,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s case LISTITEM_TOP250: if (item->HasVideoInfoTag()) { - CStdString strResult; + std::string strResult; if (item->GetVideoInfoTag()->m_iTop250 > 0) strResult = StringUtils::Format("%i",item->GetVideoInfoTag()->m_iTop250); return strResult; @@ -4847,7 +4867,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s break; case LISTITEM_SORT_LETTER: { - CStdString letter; + std::string letter; std::wstring character(1, item->GetSortLabel()[0]); StringUtils::ToUpper(character); g_charsetConverter.wToUTF8(character, letter); @@ -4875,7 +4895,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s case LISTITEM_AUDIO_CHANNELS: if (item->HasVideoInfoTag()) { - CStdString strResult; + std::string strResult; int iChannels = item->GetVideoInfoTag()->m_streamDetails.GetAudioChannels(); if (iChannels > -1) strResult = StringUtils::Format("%i", iChannels); @@ -4894,9 +4914,12 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s if (item->HasPVRChannelInfoTag()) { const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL; - CEpgInfoTag tag; - if (channel && channel->GetEPGNow(tag)) - return tag.StartAsLocalTime().GetAsLocalizedTime("", false); + if (channel) + { + CEpgInfoTagPtr tag(channel->GetEPGNow()); + if (tag) + return tag->StartAsLocalTime().GetAsLocalizedTime("", false); + } return CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false); } if (item->HasEPGInfoTag()) @@ -4912,9 +4935,12 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s if (item->HasPVRChannelInfoTag()) { const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL; - CEpgInfoTag tag; - if (channel && channel->GetEPGNow(tag)) - return tag.EndAsLocalTime().GetAsLocalizedTime("", false); + if (channel) + { + CEpgInfoTagPtr tag(channel->GetEPGNow()); + if (tag) + return tag->EndAsLocalTime().GetAsLocalizedTime("", false); + } return CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false); } if (item->HasEPGInfoTag()) @@ -4926,9 +4952,12 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s if (item->HasPVRChannelInfoTag()) { const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL; - CEpgInfoTag tag; - if (channel && channel->GetEPGNow(tag)) - return tag.StartAsLocalTime().GetAsLocalizedDate(true); + if (channel) + { + CEpgInfoTagPtr tag(channel->GetEPGNow()); + if (tag) + return tag->StartAsLocalTime().GetAsLocalizedDate(true); + } return CDateTime::GetCurrentDateTime().GetAsLocalizedDate(true); } if (item->HasEPGInfoTag()) @@ -4944,9 +4973,12 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s if (item->HasPVRChannelInfoTag()) { const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL; - CEpgInfoTag tag; - if (channel && channel->GetEPGNow(tag)) - return tag.EndAsLocalTime().GetAsLocalizedDate(true); + if (channel) + { + CEpgInfoTagPtr tag(channel->GetEPGNow()); + if (tag) + return tag->EndAsLocalTime().GetAsLocalizedDate(true); + } return CDateTime::GetCurrentDateTime().GetAsLocalizedDate(true); } if (item->HasEPGInfoTag()) @@ -4956,7 +4988,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s break; case LISTITEM_CHANNEL_NUMBER: { - CStdString number; + std::string number; if (item->HasPVRChannelInfoTag()) number = StringUtils::Format("%i", item->GetPVRChannelInfoTag()->ChannelNumber()); if (item->HasEPGInfoTag() && item->GetEPGInfoTag()->HasPVRChannel()) @@ -4969,7 +5001,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s break; case LISTITEM_SUB_CHANNEL_NUMBER: { - CStdString number; + std::string number; if (item->HasPVRChannelInfoTag()) number = StringUtils::Format("%i", item->GetPVRChannelInfoTag()->SubChannelNumber()); if (item->HasEPGInfoTag() && item->GetEPGInfoTag()->HasPVRChannel()) @@ -5008,78 +5040,105 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s case LISTITEM_NEXT_STARTTIME: { const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL; - CEpgInfoTag tag; - if (channel && channel->GetEPGNext(tag)) - return tag.StartAsLocalTime().GetAsLocalizedTime("", false); + if (channel) + { + CEpgInfoTagPtr tag(channel->GetEPGNext()); + if (tag) + return tag->StartAsLocalTime().GetAsLocalizedTime("", false); + } } return CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false); case LISTITEM_NEXT_ENDTIME: { const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL; - CEpgInfoTag tag; - if (channel && channel->GetEPGNext(tag)) - return tag.EndAsLocalTime().GetAsLocalizedTime("", false); + if (channel) + { + CEpgInfoTagPtr tag(channel->GetEPGNext()); + if (tag) + return tag->EndAsLocalTime().GetAsLocalizedTime("", false); + } } return CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false); case LISTITEM_NEXT_STARTDATE: { const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL; - CEpgInfoTag tag; - if (channel && channel->GetEPGNext(tag)) - return tag.StartAsLocalTime().GetAsLocalizedDate(true); + if (channel) + { + CEpgInfoTagPtr tag(channel->GetEPGNext()); + if (tag) + return tag->StartAsLocalTime().GetAsLocalizedDate(true); + } } return CDateTime::GetCurrentDateTime().GetAsLocalizedDate(true); case LISTITEM_NEXT_ENDDATE: { const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL; - CEpgInfoTag tag; - if (channel && channel->GetEPGNext(tag)) - return tag.EndAsLocalTime().GetAsLocalizedDate(true); + if (channel) + { + CEpgInfoTagPtr tag(channel->GetEPGNext()); + if (tag) + return tag->EndAsLocalTime().GetAsLocalizedDate(true); + } } return CDateTime::GetCurrentDateTime().GetAsLocalizedDate(true); case LISTITEM_NEXT_PLOT: { const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL; - CEpgInfoTag tag; - if (channel && channel->GetEPGNext(tag)) - return tag.Plot(); + if (channel) + { + CEpgInfoTagPtr tag(channel->GetEPGNext()); + if (tag) + return tag->Plot(); + } } - return StringUtils::EmptyString; + return ""; case LISTITEM_NEXT_PLOT_OUTLINE: { const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL; - CEpgInfoTag tag; - if (channel && channel->GetEPGNext(tag)) - return tag.PlotOutline(); + if (channel) + { + CEpgInfoTagPtr tag(channel->GetEPGNext()); + if (tag) + return tag->PlotOutline(); + } } - return StringUtils::EmptyString; + return ""; case LISTITEM_NEXT_DURATION: { const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL; - CEpgInfoTag tag; - if (channel && channel->GetEPGNext(tag)) - return StringUtils::SecondsToTimeString(tag.GetDuration()); + if (channel) + { + CEpgInfoTagPtr tag(channel->GetEPGNext()); + if (tag) + return StringUtils::SecondsToTimeString(tag->GetDuration()); + } } - return StringUtils::EmptyString; + return ""; case LISTITEM_NEXT_GENRE: { const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL; - CEpgInfoTag tag; - if (channel && channel->GetEPGNext(tag)) - return StringUtils::Join(tag.Genre(), g_advancedSettings.m_videoItemSeparator); + if (channel) + { + CEpgInfoTagPtr tag(channel->GetEPGNext()); + if (tag) + return StringUtils::Join(tag->Genre(), g_advancedSettings.m_videoItemSeparator); + } } - return StringUtils::EmptyString; + return ""; case LISTITEM_NEXT_TITLE: { const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL; - CEpgInfoTag tag; - if (channel && channel->GetEPGNext(tag)) - return tag.Title(); + if (channel) + { + CEpgInfoTagPtr tag(channel->GetEPGNext()); + if (tag) + return tag->Title(); + } } - return StringUtils::EmptyString; + return ""; case LISTITEM_PARENTALRATING: { - CStdString rating; + std::string rating; if (item->HasEPGInfoTag() && item->GetEPGInfoTag()->ParentalRating() > 0) rating = StringUtils::Format("%i", item->GetEPGInfoTag()->ParentalRating()); return rating; @@ -5123,7 +5182,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::s return ""; } -CStdString CGUIInfoManager::GetItemImage(const CFileItem *item, int info, std::string *fallback) +std::string CGUIInfoManager::GetItemImage(const CFileItem *item, int info, std::string *fallback) { if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END) return GetSkinVariableString(info, true, item); @@ -5140,7 +5199,7 @@ CStdString CGUIInfoManager::GetItemImage(const CFileItem *item, int info, std::s break; case LISTITEM_STAR_RATING: { - CStdString rating; + std::string rating; if (item->HasVideoInfoTag()) { // rating for videos is assumed 0..10, so convert to 0..5 rating = StringUtils::Format("rating%ld.png", (long)((item->GetVideoInfoTag()->m_fRating * 0.5f) + 0.5f)); @@ -5162,7 +5221,7 @@ bool CGUIInfoManager::GetItemBool(const CGUIListItem *item, int condition) const if (!item) return false; if (condition >= LISTITEM_PROPERTY_START && condition - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size()) { // grab the property - CStdString property = m_listitemProperties[condition - LISTITEM_PROPERTY_START]; + std::string property = m_listitemProperties[condition - LISTITEM_PROPERTY_START]; return item->GetProperty(property).asBoolean(); } else if (condition == LISTITEM_ISPLAYING) @@ -5243,8 +5302,7 @@ bool CGUIInfoManager::GetItemBool(const CGUIListItem *item, int condition) const { if (pItem->HasPVRChannelInfoTag()) { - CEpgInfoTag epgTag; - return pItem->GetPVRChannelInfoTag()->GetEPGNow(epgTag); + return (pItem->GetPVRChannelInfoTag()->GetEPGNow().get() != NULL); } else { @@ -5314,7 +5372,7 @@ void CGUIInfoManager::UpdateFromTuxBox() g_tuxbox.sCurSrvData.current_event_description != "-" && g_tuxbox.sCurSrvData.next_event_description != "-") { - CStdString genre = StringUtils::Format("%s %s - (%s: %s)", + std::string genre = StringUtils::Format("%s %s - (%s: %s)", g_localizeStrings.Get(143).c_str(), g_tuxbox.sCurSrvData.current_event_description.c_str(), g_localizeStrings.Get(209).c_str(), @@ -5330,13 +5388,13 @@ void CGUIInfoManager::UpdateFromTuxBox() } } -CStdString CGUIInfoManager::GetPictureLabel(int info) +std::string CGUIInfoManager::GetPictureLabel(int info) { if (info == SLIDE_FILE_NAME) return GetItemLabel(m_currentSlide, LISTITEM_FILENAME); else if (info == SLIDE_FILE_PATH) { - CStdString path = URIUtils::GetDirectory(m_currentSlide->GetPath()); + std::string path = URIUtils::GetDirectory(m_currentSlide->GetPath()); return CURL(path).GetWithoutUserDetails(); } else if (info == SLIDE_FILE_SIZE) @@ -5580,7 +5638,7 @@ int CGUIInfoManager::RegisterSkinVariableString(const CSkinVariableString* info) return CONDITIONAL_LABEL_START + m_skinVariableStrings.size() - 1; } -int CGUIInfoManager::TranslateSkinVariableString(const CStdString& name, int context) +int CGUIInfoManager::TranslateSkinVariableString(const std::string& name, int context) { for (vector<CSkinVariableString>::const_iterator it = m_skinVariableStrings.begin(); it != m_skinVariableStrings.end(); ++it) @@ -5591,7 +5649,7 @@ int CGUIInfoManager::TranslateSkinVariableString(const CStdString& name, int con return 0; } -CStdString CGUIInfoManager::GetSkinVariableString(int info, +std::string CGUIInfoManager::GetSkinVariableString(int info, bool preferImage /*= false*/, const CGUIListItem *item /*= NULL*/) { @@ -5612,18 +5670,14 @@ bool CGUIInfoManager::ConditionsChangedValues(const std::map<INFO::InfoPtr, bool return false; } -bool CGUIInfoManager::GetEpgInfoTag(CEpgInfoTag& tag) const +CEpgInfoTagPtr CGUIInfoManager::GetEpgInfoTag() const { + CEpgInfoTagPtr currentTag; if (m_currentFile->HasEPGInfoTag()) { - CEpgInfoTag* currentTag = m_currentFile->GetEPGInfoTag(); + currentTag = m_currentFile->GetEPGInfoTag(); while (currentTag && !currentTag->IsActive()) - currentTag = currentTag->GetNextEvent().get(); - if (currentTag) - { - tag = *currentTag; - return true; - } + currentTag = currentTag->GetNextEvent(); } - return false; + return currentTag; } diff --git a/xbmc/GUIInfoManager.h b/xbmc/GUIInfoManager.h index a6ab129a00..f0e0cf9925 100644 --- a/xbmc/GUIInfoManager.h +++ b/xbmc/GUIInfoManager.h @@ -672,7 +672,11 @@ namespace INFO // forward class CGUIWindow; -namespace EPG { class CEpgInfoTag; } +namespace EPG +{ + class CEpgInfoTag; + typedef boost::shared_ptr<EPG::CEpgInfoTag> CEpgInfoTagPtr; +} // Info Flags // Stored in the top 8 bits of GUIInfo::m_data1 @@ -730,7 +734,7 @@ public: \param context the context window \return an identifier used to reference this expression */ - INFO::InfoPtr Register(const CStdString &expression, int context = 0); + INFO::InfoPtr Register(const std::string &expression, int context = 0); /*! \brief Evaluate a boolean expression \param expression the expression to evaluate @@ -738,9 +742,9 @@ public: \return the value of the evaluated expression. \sa Register */ - bool EvaluateBool(const CStdString &expression, int context = 0); + bool EvaluateBool(const std::string &expression, int context = 0); - int TranslateString(const CStdString &strCondition); + int TranslateString(const std::string &strCondition); /*! \brief Get integer value of info. \param value int reference to pass value of given info @@ -751,20 +755,20 @@ public: \sa GetItemInt, GetMultiInfoInt */ bool GetInt(int &value, int info, int contextWindow = 0, const CGUIListItem *item = NULL) const; - CStdString GetLabel(int info, int contextWindow = 0, std::string *fallback = NULL); + std::string GetLabel(int info, int contextWindow = 0, std::string *fallback = NULL); - CStdString GetImage(int info, int contextWindow, std::string *fallback = NULL); + std::string GetImage(int info, int contextWindow, std::string *fallback = NULL); - CStdString GetTime(TIME_FORMAT format = TIME_FORMAT_GUESS) const; - CStdString GetDate(bool bNumbersOnly = false); - CStdString GetDuration(TIME_FORMAT format = TIME_FORMAT_GUESS) const; + std::string GetTime(TIME_FORMAT format = TIME_FORMAT_GUESS) const; + std::string GetDate(bool bNumbersOnly = false); + std::string GetDuration(TIME_FORMAT format = TIME_FORMAT_GUESS) const; void SetCurrentItem(CFileItem &item); void ResetCurrentItem(); // Current song stuff /// \brief Retrieves tag info (if necessary) and fills in our current song path. void SetCurrentSong(CFileItem &item); - void SetCurrentAlbumThumb(const CStdString &thumbFileName); + void SetCurrentAlbumThumb(const std::string &thumbFileName); void SetCurrentMovie(CFileItem &item); void SetCurrentSlide(CFileItem &item); const CFileItem &GetCurrentSlide() const; @@ -775,24 +779,24 @@ public: const MUSIC_INFO::CMusicInfoTag *GetCurrentSongTag() const; const CVideoInfoTag* GetCurrentMovieTag() const; - CStdString GetMusicLabel(int item); - CStdString GetMusicTagLabel(int info, const CFileItem *item); - CStdString GetVideoLabel(int item); - CStdString GetPlaylistLabel(int item, int playlistid = -1 /* PLAYLIST_NONE */) const; - CStdString GetMusicPartyModeLabel(int item); - const CStdString GetMusicPlaylistInfo(const GUIInfo& info); - CStdString GetPictureLabel(int item); + std::string GetMusicLabel(int item); + std::string GetMusicTagLabel(int info, const CFileItem *item); + std::string GetVideoLabel(int item); + std::string GetPlaylistLabel(int item, int playlistid = -1 /* PLAYLIST_NONE */) const; + std::string GetMusicPartyModeLabel(int item); + const std::string GetMusicPlaylistInfo(const GUIInfo& info); + std::string GetPictureLabel(int item); int64_t GetPlayTime() const; // in ms - CStdString GetCurrentPlayTime(TIME_FORMAT format = TIME_FORMAT_GUESS) const; - CStdString GetCurrentSeekTime(TIME_FORMAT format = TIME_FORMAT_GUESS) const; + std::string GetCurrentPlayTime(TIME_FORMAT format = TIME_FORMAT_GUESS) const; + std::string GetCurrentSeekTime(TIME_FORMAT format = TIME_FORMAT_GUESS) const; int GetPlayTimeRemaining() const; int GetTotalPlayTime() const; - CStdString GetCurrentPlayTimeRemaining(TIME_FORMAT format) const; + std::string GetCurrentPlayTimeRemaining(TIME_FORMAT format) const; std::string GetVersionShort(void); - CStdString GetAppName(); - CStdString GetVersion(); - CStdString GetBuild(); + std::string GetAppName(); + std::string GetVersion(); + std::string GetBuild(); bool GetDisplayAfterSeek(); void SetDisplayAfterSeek(unsigned int timeOut = 2500, int seekOffset = 0); @@ -816,8 +820,8 @@ public: void ResetCache(); bool GetItemInt(int &value, const CGUIListItem *item, int info) const; - CStdString GetItemLabel(const CFileItem *item, int info, std::string *fallback = NULL); - CStdString GetItemImage(const CFileItem *item, int info, std::string *fallback = NULL); + std::string GetItemLabel(const CFileItem *item, int info, std::string *fallback = NULL); + std::string GetItemImage(const CFileItem *item, int info, std::string *fallback = NULL); // Called from tuxbox service thread to update current status void UpdateFromTuxBox(); @@ -836,13 +840,13 @@ public: void SetLibraryBool(int condition, bool value); bool GetLibraryBool(int condition); void ResetLibraryBools(); - CStdString LocalizeTime(const CDateTime &time, TIME_FORMAT format) const; + std::string LocalizeTime(const CDateTime &time, TIME_FORMAT format) const; - int TranslateSingleString(const CStdString &strCondition); + int TranslateSingleString(const std::string &strCondition); int RegisterSkinVariableString(const INFO::CSkinVariableString* info); - int TranslateSkinVariableString(const CStdString& name, int context); - CStdString GetSkinVariableString(int info, bool preferImage = false, const CGUIListItem *item=NULL); + int TranslateSkinVariableString(const std::string& name, int context); + std::string GetSkinVariableString(int info, bool preferImage = false, const CGUIListItem *item=NULL); /// \brief iterates through boolean conditions and compares their stored values to current values. Returns true if any condition changed value. bool ConditionsChangedValues(const std::map<INFO::InfoPtr, bool>& map); @@ -850,7 +854,7 @@ public: protected: friend class INFO::InfoSingle; bool GetBool(int condition, int contextWindow = 0, const CGUIListItem *item=NULL); - int TranslateSingleString(const CStdString &strCondition, bool &listItemDependent); + int TranslateSingleString(const std::string &strCondition, bool &listItemDependent); // routines for window retrieval bool CheckWindowCondition(CGUIWindow *window, int condition) const; @@ -861,22 +865,22 @@ protected: class Property { public: - Property(const CStdString &property, const CStdString ¶meters); + Property(const std::string &property, const std::string ¶meters); const std::string ¶m(unsigned int n = 0) const; unsigned int num_params() const; - CStdString name; + std::string name; private: std::vector<std::string> params; }; bool GetMultiInfoBool(const GUIInfo &info, int contextWindow = 0, const CGUIListItem *item = NULL); bool GetMultiInfoInt(int &value, const GUIInfo &info, int contextWindow = 0) const; - CStdString GetMultiInfoLabel(const GUIInfo &info, int contextWindow = 0, std::string *fallback = NULL); + std::string GetMultiInfoLabel(const GUIInfo &info, int contextWindow = 0, std::string *fallback = NULL); int TranslateListItem(const Property &info); - int TranslateMusicPlayerString(const CStdString &info) const; - TIME_FORMAT TranslateTimeFormat(const CStdString &format); + int TranslateMusicPlayerString(const std::string &info) const; + TIME_FORMAT TranslateTimeFormat(const std::string &format); bool GetItemBool(const CGUIListItem *item, int condition) const; /*! \brief Split an info string into it's constituent parts and parameters @@ -889,20 +893,19 @@ protected: \param infoString the original string \param info the resulting pairs of info and parameters. */ - void SplitInfoString(const CStdString &infoString, std::vector<Property> &info); + void SplitInfoString(const std::string &infoString, std::vector<Property> &info); // Conditional string parameters for testing are stored in a vector for later retrieval. // The offset into the string parameters array is returned. - int ConditionalStringParameter(const CStdString &strParameter, bool caseSensitive = false); + int ConditionalStringParameter(const std::string &strParameter, bool caseSensitive = false); int AddMultiInfo(const GUIInfo &info); - int AddListItemProp(const CStdString &str, int offset=0); + int AddListItemProp(const std::string &str, int offset=0); /*! * @brief Get the EPG tag that is currently active - * @param tag The active tag - * @return True if an EPG tag is active and 'tag' was updated, false otherwise + * @return the currently active tag or NULL if no active tag was found */ - bool GetEpgInfoTag(EPG::CEpgInfoTag& tag) const; + EPG::CEpgInfoTagPtr GetEpgInfoTag() const; // Conditional string parameters are stored here std::vector<std::string> m_stringParameters; @@ -911,11 +914,11 @@ protected: std::vector<GUIInfo> m_multiInfo; std::vector<std::string> m_listitemProperties; - CStdString m_currentMovieDuration; + std::string m_currentMovieDuration; // Current playing stuff CFileItem* m_currentFile; - CStdString m_currentMovieThumb; + std::string m_currentMovieThumb; CFileItem* m_currentSlide; // fan stuff diff --git a/xbmc/GUILargeTextureManager.cpp b/xbmc/GUILargeTextureManager.cpp index ba1e0044d6..0450ffe987 100644 --- a/xbmc/GUILargeTextureManager.cpp +++ b/xbmc/GUILargeTextureManager.cpp @@ -32,7 +32,7 @@ using namespace std; -CImageLoader::CImageLoader(const CStdString &path, const bool useCache) +CImageLoader::CImageLoader(const std::string &path, const bool useCache) { m_path = path; m_texture = NULL; @@ -47,9 +47,9 @@ CImageLoader::~CImageLoader() bool CImageLoader::DoWork() { bool needsChecking = false; - CStdString loadPath; + std::string loadPath; - CStdString texturePath = g_TextureManager.GetTexturePath(m_path); + std::string texturePath = g_TextureManager.GetTexturePath(m_path); if (m_use_cache) loadPath = CTextureCache::Get().CheckCachedImage(texturePath, true, needsChecking); else @@ -78,7 +78,7 @@ bool CImageLoader::DoWork() return true; } -CGUILargeTextureManager::CLargeTexture::CLargeTexture(const CStdString &path) +CGUILargeTextureManager::CLargeTexture::CLargeTexture(const std::string &path) { m_path = path; m_refCount = 1; @@ -153,7 +153,7 @@ void CGUILargeTextureManager::CleanupUnusedImages(bool immediately) // if available, increment reference count, and return the image. // else, add to the queue list if appropriate. -bool CGUILargeTextureManager::GetImage(const CStdString &path, CTextureArray &texture, bool firstRequest, const bool useCache) +bool CGUILargeTextureManager::GetImage(const std::string &path, CTextureArray &texture, bool firstRequest, const bool useCache) { CSingleLock lock(m_listSection); for (listIterator it = m_allocated.begin(); it != m_allocated.end(); ++it) @@ -174,7 +174,7 @@ bool CGUILargeTextureManager::GetImage(const CStdString &path, CTextureArray &te return true; } -void CGUILargeTextureManager::ReleaseImage(const CStdString &path, bool immediately) +void CGUILargeTextureManager::ReleaseImage(const std::string &path, bool immediately) { CSingleLock lock(m_listSection); for (listIterator it = m_allocated.begin(); it != m_allocated.end(); ++it) @@ -202,7 +202,7 @@ void CGUILargeTextureManager::ReleaseImage(const CStdString &path, bool immediat } // queue the image, and start the background loader if necessary -void CGUILargeTextureManager::QueueImage(const CStdString &path, bool useCache) +void CGUILargeTextureManager::QueueImage(const std::string &path, bool useCache) { CSingleLock lock(m_listSection); for (queueIterator it = m_queued.begin(); it != m_queued.end(); ++it) diff --git a/xbmc/GUILargeTextureManager.h b/xbmc/GUILargeTextureManager.h index 4bc957a289..108cbdbad2 100644 --- a/xbmc/GUILargeTextureManager.h +++ b/xbmc/GUILargeTextureManager.h @@ -35,7 +35,7 @@ class CImageLoader : public CJob { public: - CImageLoader(const CStdString &path, const bool useCache); + CImageLoader(const std::string &path, const bool useCache); virtual ~CImageLoader(); /*! @@ -44,7 +44,7 @@ public: virtual bool DoWork(); bool m_use_cache; ///< Whether or not to use any caching with this image - CStdString m_path; ///< path of image to load + std::string m_path; ///< path of image to load CBaseTexture *m_texture; ///< Texture object to load the image into \sa CBaseTexture. }; @@ -86,7 +86,7 @@ public: \return true if the image exists, else false. \sa CGUITextureArray and CGUITexture */ - bool GetImage(const CStdString &path, CTextureArray &texture, bool firstRequest, bool useCache = true); + bool GetImage(const std::string &path, CTextureArray &texture, bool firstRequest, bool useCache = true); /*! \brief Request a texture to be unloaded. @@ -99,7 +99,7 @@ public: \param immediately if set true the image is immediately unloaded once its reference count reaches zero rather than being unloaded after a delay. */ - void ReleaseImage(const CStdString &path, bool immediately = false); + void ReleaseImage(const std::string &path, bool immediately = false); /*! \brief Cleanup images that are no longer in use. @@ -116,7 +116,7 @@ private: class CLargeTexture { public: - CLargeTexture(const CStdString &path); + CLargeTexture(const std::string &path); virtual ~CLargeTexture(); void AddRef(); @@ -124,19 +124,19 @@ private: bool DeleteIfRequired(bool deleteImmediately = false); void SetTexture(CBaseTexture* texture); - const CStdString &GetPath() const { return m_path; }; + const std::string &GetPath() const { return m_path; }; const CTextureArray &GetTexture() const { return m_texture; }; private: static const unsigned int TIME_TO_DELETE = 2000; unsigned int m_refCount; - CStdString m_path; + std::string m_path; CTextureArray m_texture; unsigned int m_timeToDelete; }; - void QueueImage(const CStdString &path, bool useCache = true); + void QueueImage(const std::string &path, bool useCache = true); std::vector< std::pair<unsigned int, CLargeTexture *> > m_queued; std::vector<CLargeTexture *> m_allocated; diff --git a/xbmc/GUIPassword.cpp b/xbmc/GUIPassword.cpp index ff8637c694..3fe2b0a9b4 100644 --- a/xbmc/GUIPassword.cpp +++ b/xbmc/GUIPassword.cpp @@ -46,7 +46,7 @@ CGUIPassword::CGUIPassword(void) CGUIPassword::~CGUIPassword(void) {} -bool CGUIPassword::IsItemUnlocked(CFileItem* pItem, const CStdString &strType) +bool CGUIPassword::IsItemUnlocked(CFileItem* pItem, const std::string &strType) { // \brief Tests if the user is allowed to access the share folder // \param pItem The share folder item to access @@ -57,8 +57,8 @@ bool CGUIPassword::IsItemUnlocked(CFileItem* pItem, const CStdString &strType) while (pItem->m_iHasLock > 1) { - CStdString strLockCode = pItem->m_strLockCode; - CStdString strLabel = pItem->GetLabel(); + std::string strLockCode = pItem->m_strLockCode; + std::string strLabel = pItem->GetLabel(); int iResult = 0; // init to user succeeded state, doing this to optimize switch statement below char buffer[33]; // holds 32 places plus sign character if(g_passwordManager.bMasterUser)// Check if we are the MasterUser! @@ -73,7 +73,7 @@ bool CGUIPassword::IsItemUnlocked(CFileItem* pItem, const CStdString &strType) return false; } // show the appropriate lock dialog - CStdString strHeading = ""; + std::string strHeading = ""; if (pItem->m_bIsFolder) strHeading = g_localizeStrings.Get(12325); else @@ -124,11 +124,11 @@ bool CGUIPassword::CheckStartUpLock() { // prompt user for mastercode if the mastercode was set b4 or by xml int iVerifyPasswordResult = -1; - CStdString strHeader = g_localizeStrings.Get(20075); + std::string strHeader = g_localizeStrings.Get(20075); if (iMasterLockRetriesLeft == -1) iMasterLockRetriesLeft = CSettings::Get().GetInt("masterlock.maxretries"); if (g_passwordManager.iMasterLockRetriesLeft == 0) g_passwordManager.iMasterLockRetriesLeft = 1; - CStdString strPassword = CProfilesManager::Get().GetMasterProfile().getLockCode(); + std::string strPassword = CProfilesManager::Get().GetMasterProfile().getLockCode(); if (CProfilesManager::Get().GetMasterProfile().getLockMode() == 0) iVerifyPasswordResult = 0; else @@ -138,10 +138,10 @@ bool CGUIPassword::CheckStartUpLock() iVerifyPasswordResult = VerifyPassword(CProfilesManager::Get().GetMasterProfile().getLockMode(), strPassword, strHeader); if (iVerifyPasswordResult != 0 ) { - CStdString strLabel1; + std::string strLabel1; strLabel1 = g_localizeStrings.Get(12343); int iLeft = g_passwordManager.iMasterLockRetriesLeft-i; - CStdString strLabel = StringUtils::Format("%i %s", iLeft, strLabel1.c_str()); + std::string strLabel = StringUtils::Format("%i %s", iLeft, strLabel1.c_str()); // PopUp OK and Display: MasterLock mode has changed but no new Mastercode has been set! CGUIDialogOK::ShowAndGetInput(12360, 12367, 12368, strLabel); @@ -245,8 +245,8 @@ bool CGUIPassword::IsMasterLockUnlocked(bool bPromptUser, bool& bCanceled) // no, unlock since we are allowed to prompt int iVerifyPasswordResult = -1; - CStdString strHeading = g_localizeStrings.Get(20075); - CStdString strPassword = CProfilesManager::Get().GetMasterProfile().getLockCode(); + std::string strHeading = g_localizeStrings.Get(20075); + std::string strPassword = CProfilesManager::Get().GetMasterProfile().getLockCode(); iVerifyPasswordResult = VerifyPassword(CProfilesManager::Get().GetMasterProfile().getLockMode(), strPassword, strHeading); if (1 == iVerifyPasswordResult) UpdateMasterLockRetryCount(false); @@ -286,7 +286,7 @@ void CGUIPassword::UpdateMasterLockRetryCount(bool bResetCount) return ; } } - CStdString dlgLine1 = ""; + std::string dlgLine1 = ""; if (0 < g_passwordManager.iMasterLockRetriesLeft) dlgLine1 = StringUtils::Format("%d %s", g_passwordManager.iMasterLockRetriesLeft, @@ -297,21 +297,21 @@ void CGUIPassword::UpdateMasterLockRetryCount(bool bResetCount) g_passwordManager.iMasterLockRetriesLeft = CSettings::Get().GetInt("masterlock.maxretries"); // user entered correct mastercode, reset retries to max allowed } -bool CGUIPassword::CheckLock(LockType btnType, const CStdString& strPassword, int iHeading) +bool CGUIPassword::CheckLock(LockType btnType, const std::string& strPassword, int iHeading) { bool bDummy; return CheckLock(btnType,strPassword,iHeading,bDummy); } -bool CGUIPassword::CheckLock(LockType btnType, const CStdString& strPassword, int iHeading, bool& bCanceled) +bool CGUIPassword::CheckLock(LockType btnType, const std::string& strPassword, int iHeading, bool& bCanceled) { bCanceled = false; - if (btnType == LOCK_MODE_EVERYONE || strPassword.Equals("-") || + if (btnType == LOCK_MODE_EVERYONE || strPassword == "-" || CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE || g_passwordManager.bMasterUser) return true; int iVerifyPasswordResult = -1; - CStdString strHeading = g_localizeStrings.Get(iHeading); + std::string strHeading = g_localizeStrings.Get(iHeading); iVerifyPasswordResult = VerifyPassword(btnType, strPassword, strHeading); if (iVerifyPasswordResult == -1) @@ -423,7 +423,7 @@ bool CGUIPassword::CheckMenuLock(int iWindowID) return true; } -bool CGUIPassword::LockSource(const CStdString& strType, const CStdString& strName, bool bState) +bool CGUIPassword::LockSource(const std::string& strType, const std::string& strName, bool bState) { VECSOURCES* pShares = CMediaSourceSettings::Get().GetSources(strType); bool bResult = false; @@ -480,7 +480,7 @@ void CGUIPassword::RemoveSourceLocks() g_windowManager.SendThreadMessage(msg); } -bool CGUIPassword::IsDatabasePathUnlocked(const CStdString& strPath, VECSOURCES& vecSources) +bool CGUIPassword::IsDatabasePathUnlocked(const std::string& strPath, VECSOURCES& vecSources) { if (g_passwordManager.bMasterUser || CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE) return true; @@ -506,19 +506,19 @@ void CGUIPassword::OnSettingAction(const CSetting *setting) SetMasterLockMode(); } -int CGUIPassword::VerifyPassword(LockType btnType, const CStdString& strPassword, const CStdString& strHeading) +int CGUIPassword::VerifyPassword(LockType btnType, const std::string& strPassword, const std::string& strHeading) { int iVerifyPasswordResult; switch (btnType) { case LOCK_MODE_NUMERIC: - iVerifyPasswordResult = CGUIDialogNumeric::ShowAndVerifyPassword(const_cast<CStdString&>(strPassword), strHeading, 0); + iVerifyPasswordResult = CGUIDialogNumeric::ShowAndVerifyPassword(const_cast<std::string&>(strPassword), strHeading, 0); break; case LOCK_MODE_GAMEPAD: - iVerifyPasswordResult = CGUIDialogGamepad::ShowAndVerifyPassword(const_cast<CStdString&>(strPassword), strHeading, 0); + iVerifyPasswordResult = CGUIDialogGamepad::ShowAndVerifyPassword(const_cast<std::string&>(strPassword), strHeading, 0); break; case LOCK_MODE_QWERTY: - iVerifyPasswordResult = CGUIKeyboardFactory::ShowAndVerifyPassword(const_cast<CStdString&>(strPassword), strHeading, 0); + iVerifyPasswordResult = CGUIKeyboardFactory::ShowAndVerifyPassword(const_cast<std::string&>(strPassword), strHeading, 0); break; default: // must not be supported, treat as unlocked iVerifyPasswordResult = 0; diff --git a/xbmc/GUIPassword.h b/xbmc/GUIPassword.h index a090a82da2..490e149616 100644 --- a/xbmc/GUIPassword.h +++ b/xbmc/GUIPassword.h @@ -21,10 +21,10 @@ */ #include <map> +#include <string> #include <vector> #include "settings/lib/ISettingCallback.h" -#include "utils/StdString.h" #include "settings/lib/Setting.h" class CFileItem; @@ -62,10 +62,10 @@ class CGUIPassword : public ISettingCallback public: CGUIPassword(void); virtual ~CGUIPassword(void); - bool IsItemUnlocked(CFileItem* pItem, const CStdString &strType); - bool IsItemUnlocked(CMediaSource* pItem, const CStdString &strType); - bool CheckLock(LockType btnType, const CStdString& strPassword, int iHeading); - bool CheckLock(LockType btnType, const CStdString& strPassword, int iHeading, bool& bCanceled); + bool IsItemUnlocked(CFileItem* pItem, const std::string &strType); + bool IsItemUnlocked(CMediaSource* pItem, const std::string &strType); + bool CheckLock(LockType btnType, const std::string& strPassword, int iHeading); + bool CheckLock(LockType btnType, const std::string& strPassword, int iHeading, bool& bCanceled); bool IsProfileLockUnlocked(int iProfile=-1); bool IsProfileLockUnlocked(int iProfile, bool& bCanceled, bool prompt = true); bool IsMasterLockUnlocked(bool bPromptUser); @@ -82,10 +82,10 @@ public: bool CheckSettingLevelLock(const SettingLevel& level, bool enforce = false); bool CheckMenuLock(int iWindowID); bool SetMasterLockMode(bool bDetails=true); - bool LockSource(const CStdString& strType, const CStdString& strName, bool bState); + bool LockSource(const std::string& strType, const std::string& strName, bool bState); void LockSources(bool lock); void RemoveSourceLocks(); - bool IsDatabasePathUnlocked(const CStdString& strPath, VECSOURCES& vecSources); + bool IsDatabasePathUnlocked(const std::string& strPath, VECSOURCES& vecSources); virtual void OnSettingAction(const CSetting *setting); @@ -93,7 +93,7 @@ public: int iMasterLockRetriesLeft; private: - int VerifyPassword(LockType btnType, const CStdString& strPassword, const CStdString& strHeading); + int VerifyPassword(LockType btnType, const std::string& strPassword, const std::string& strHeading); }; extern CGUIPassword g_passwordManager; diff --git a/xbmc/GUIUserMessages.h b/xbmc/GUIUserMessages.h index 9ffec7f01f..86eaa2a45e 100644 --- a/xbmc/GUIUserMessages.h +++ b/xbmc/GUIUserMessages.h @@ -31,8 +31,8 @@ // General playlist items changed #define GUI_MSG_PLAYLIST_CHANGED GUI_MSG_USER + 3 -// Start Slideshow in my pictures lpVoid = CStdString -// Param lpVoid: CStdString* that points to the Directory +// Start Slideshow in my pictures lpVoid = std::string +// Param lpVoid: std::string* that points to the Directory // to start the slideshow in. #define GUI_MSG_START_SLIDESHOW GUI_MSG_USER + 4 @@ -134,5 +134,4 @@ #define GUI_MSG_SHOW_PICTURE GUI_MSG_USER + 36 // Sent to text field to support 'input method' -#define GUI_MSG_INPUT_TEXT GUI_MSG_USER + 37 #define GUI_MSG_INPUT_TEXT_EDIT GUI_MSG_USER + 38 diff --git a/xbmc/MediaSource.cpp b/xbmc/MediaSource.cpp index ec03caacce..4935f042dc 100644 --- a/xbmc/MediaSource.cpp +++ b/xbmc/MediaSource.cpp @@ -34,7 +34,7 @@ bool CMediaSource::IsWritable() const return CUtil::SupportsWriteFileOperations(strPath); } -void CMediaSource::FromNameAndPaths(const CStdString &category, const CStdString &name, const vector<string> &paths) +void CMediaSource::FromNameAndPaths(const std::string &category, const std::string &name, const vector<string> &paths) { vecPaths = paths; if (paths.size() == 0) @@ -97,7 +97,7 @@ void AddOrReplace(VECSOURCES& sources, const VECSOURCES& extras) unsigned int j; for ( j=0;j<sources.size();++j) { - if (sources[j].strPath.Equals(extras[i].strPath)) + if (StringUtils::EqualsNoCase(sources[j].strPath, extras[i].strPath)) { sources[j] = extras[i]; break; @@ -113,7 +113,7 @@ void AddOrReplace(VECSOURCES& sources, const CMediaSource& source) unsigned int i; for( i=0;i<sources.size();++i ) { - if (sources[i].strPath.Equals(source.strPath)) + if (StringUtils::EqualsNoCase(sources[i].strPath, source.strPath)) { sources[i] = source; break; diff --git a/xbmc/MediaSource.h b/xbmc/MediaSource.h index 174617decd..7dfe21a527 100644 --- a/xbmc/MediaSource.h +++ b/xbmc/MediaSource.h @@ -19,7 +19,7 @@ * */ -#include "utils/StdString.h" +#include <string> #include <vector> #include "GUIPassword.h" @@ -46,12 +46,12 @@ public: bool operator==(const CMediaSource &right) const; - void FromNameAndPaths(const CStdString &category, const CStdString &name, const std::vector<std::string> &paths); + void FromNameAndPaths(const std::string &category, const std::string &name, const std::vector<std::string> &paths); bool IsWritable() const; - CStdString strName; ///< Name of the share, can be choosen freely. - CStdString strStatus; ///< Status of the share (eg has disk etc.) - CStdString strDiskUniqueId; ///< removable:// + DVD Label + DVD ID for resume point storage, if available - CStdString strPath; ///< Path of the share, eg. iso9660:// or F: + std::string strName; ///< Name of the share, can be choosen freely. + std::string strStatus; ///< Status of the share (eg has disk etc.) + std::string strDiskUniqueId; ///< removable:// + DVD Label + DVD ID for resume point storage, if available + std::string strPath; ///< Path of the share, eg. iso9660:// or F: /*! \brief The type of the media source. @@ -90,11 +90,11 @@ public: Value is unknown or unspecified. */ LockType m_iLockMode; - CStdString m_strLockCode; ///< Input code for Lock UI to verify, can be chosen freely. + std::string m_strLockCode; ///< Input code for Lock UI to verify, can be chosen freely. int m_iHasLock; int m_iBadPwdCount; ///< Number of wrong passwords user has entered since share was last unlocked - CStdString m_strThumbnailImage; ///< Path to a thumbnail image for the share, or blank for default + std::string m_strThumbnailImage; ///< Path to a thumbnail image for the share, or blank for default std::vector<std::string> vecPaths; bool m_ignore; /// <Do not store in xml diff --git a/xbmc/NfoFile.cpp b/xbmc/NfoFile.cpp index 3e6afc54bb..ead5f7d017 100644 --- a/xbmc/NfoFile.cpp +++ b/xbmc/NfoFile.cpp @@ -37,7 +37,7 @@ using namespace std; using namespace XFILE; using namespace ADDON; -CNfoFile::NFOResult CNfoFile::Create(const CStdString& strPath, const ScraperPtr& info, int episode) +CNfoFile::NFOResult CNfoFile::Create(const std::string& strPath, const ScraperPtr& info, int episode) { m_info = info; // assume we can use these settings m_type = ScraperTypeFromContent(info->Content()); @@ -158,7 +158,7 @@ int CNfoFile::Scrape(ScraperPtr& scraper) return m_scurl.m_url.empty() ? 1 : 0; } -int CNfoFile::Load(const CStdString& strFile) +int CNfoFile::Load(const std::string& strFile) { Close(); XFILE::CFile file; diff --git a/xbmc/NfoFile.h b/xbmc/NfoFile.h index 8672ab2b2e..b86739df1a 100644 --- a/xbmc/NfoFile.h +++ b/xbmc/NfoFile.h @@ -25,10 +25,10 @@ #define AFX_NfoFile_H__641CCF68_6D2A_426E_9204_C0E4BEF12D00__INCLUDED_ #pragma once +#include <string> #include "addons/Scraper.h" #include "utils/CharsetConverter.h" -#include "utils/StdString.h" class CNfoFile { @@ -45,7 +45,7 @@ public: ERROR_NFO = 4 }; - NFOResult Create(const CStdString&, const ADDON::ScraperPtr&, int episode=-1); + NFOResult Create(const std::string&, const ADDON::ScraperPtr&, int episode=-1); template<class T> bool GetDetails(T& details,const char* document=NULL, bool prioritise=false) { @@ -73,7 +73,7 @@ private: ADDON::TYPE m_type; CScraperUrl m_scurl; - int Load(const CStdString&); + int Load(const std::string&); int Scrape(ADDON::ScraperPtr& scraper); }; diff --git a/xbmc/PartyModeManager.cpp b/xbmc/PartyModeManager.cpp index 5348c74227..fe95bf0353 100644 --- a/xbmc/PartyModeManager.cpp +++ b/xbmc/PartyModeManager.cpp @@ -55,11 +55,11 @@ CPartyModeManager::~CPartyModeManager(void) { } -bool CPartyModeManager::Enable(PartyModeContext context /*= PARTYMODECONTEXT_MUSIC*/, const CStdString& strXspPath /*= ""*/) +bool CPartyModeManager::Enable(PartyModeContext context /*= PARTYMODECONTEXT_MUSIC*/, const std::string& strXspPath /*= ""*/) { // Filter using our PartyMode xml file CSmartPlaylist playlist; - CStdString partyModePath; + std::string partyModePath; bool playlistLoaded; m_bIsVideo = context == PARTYMODECONTEXT_VIDEO; @@ -78,13 +78,15 @@ bool CPartyModeManager::Enable(PartyModeContext context /*= PARTYMODECONTEXT_MUS if (context == PARTYMODECONTEXT_UNKNOWN) { //get it from the xsp file - m_bIsVideo = (m_type.Equals("video") || m_type.Equals("musicvideos") || m_type.Equals("mixed")); + m_bIsVideo = (StringUtils::EqualsNoCase(m_type, "video") || + StringUtils::EqualsNoCase(m_type, "musicvideos") || + StringUtils::EqualsNoCase(m_type, "mixed")); } - if (m_type.Equals("mixed")) + if (StringUtils::EqualsNoCase(m_type, "mixed")) playlist.SetType("songs"); - if (m_type.Equals("mixed")) + if (StringUtils::EqualsNoCase(m_type, "mixed")) playlist.SetType("video"); playlist.SetType(m_type); @@ -108,7 +110,8 @@ bool CPartyModeManager::Enable(PartyModeContext context /*= PARTYMODECONTEXT_MUS ClearState(); unsigned int time = XbmcThreads::SystemClockMillis(); vector< pair<int,int> > songIDs; - if (m_type.Equals("songs") || m_type.Equals("mixed")) + if (StringUtils::EqualsNoCase(m_type, "songs") || + StringUtils::EqualsNoCase(m_type, "mixed")) { CMusicDatabase db; if (db.Open()) @@ -119,24 +122,25 @@ bool CPartyModeManager::Enable(PartyModeContext context /*= PARTYMODECONTEXT_MUS CLog::Log(LOGINFO, "PARTY MODE MANAGER: Registering filter:[%s]", m_strCurrentFilterMusic.c_str()); m_iMatchingSongs = (int)db.GetSongIDs(m_strCurrentFilterMusic, songIDs); - if (m_iMatchingSongs < 1 && m_type.Equals("songs")) + if (m_iMatchingSongs < 1 && StringUtils::EqualsNoCase(m_type, "songs")) { pDialog->Close(); db.Close(); - OnError(16031, (CStdString)"Party mode found no matching songs. Aborting."); + OnError(16031, (std::string)"Party mode found no matching songs. Aborting."); return false; } } else { pDialog->Close(); - OnError(16033, (CStdString)"Party mode could not open database. Aborting."); + OnError(16033, (std::string)"Party mode could not open database. Aborting."); return false; } db.Close(); } - if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) + if (StringUtils::EqualsNoCase(m_type, "musicvideos") || + StringUtils::EqualsNoCase(m_type, "mixed")) { vector< pair<int,int> > songIDs2; CVideoDatabase db; @@ -152,14 +156,14 @@ bool CPartyModeManager::Enable(PartyModeContext context /*= PARTYMODECONTEXT_MUS { pDialog->Close(); db.Close(); - OnError(16031, (CStdString)"Party mode found no matching songs. Aborting."); + OnError(16031, (std::string)"Party mode found no matching songs. Aborting."); return false; } } else { pDialog->Close(); - OnError(16033, (CStdString)"Party mode could not open database. Aborting."); + OnError(16033, (std::string)"Party mode could not open database. Aborting."); return false; } db.Close(); @@ -200,7 +204,7 @@ bool CPartyModeManager::Enable(PartyModeContext context /*= PARTYMODECONTEXT_MUS pDialog->Close(); // open now playing window - if (m_type.Equals("songs")) + if (StringUtils::EqualsNoCase(m_type, "songs")) { if (g_windowManager.GetActiveWindow() != WINDOW_MUSIC_PLAYLIST) g_windowManager.ActivateWindow(WINDOW_MUSIC_PLAYLIST); @@ -311,7 +315,7 @@ bool CPartyModeManager::AddRandomSongs(int iSongs /* = 0 */) // distribute between types if mixed int iSongsToAdd=iSongs; int iVidsToAdd=iSongs; - if (m_type.Equals("mixed")) + if (StringUtils::EqualsNoCase(m_type, "mixed")) { if (iSongs == 1) { @@ -330,7 +334,8 @@ bool CPartyModeManager::AddRandomSongs(int iSongs /* = 0 */) } // add songs to fill queue - if (m_type.Equals("songs") || m_type.Equals("mixed")) + if (StringUtils::EqualsNoCase(m_type, "songs") || + StringUtils::EqualsNoCase(m_type, "mixed")) { CMusicDatabase database; if (database.Open()) @@ -348,7 +353,7 @@ bool CPartyModeManager::AddRandomSongs(int iSongs /* = 0 */) bool error(false); for (int i = 0; i < iSongsToAdd; i++) { - pair<CStdString,CStdString> whereClause = GetWhereClauseWithHistory(); + pair<std::string,std::string> whereClause = GetWhereClauseWithHistory(); CFileItemPtr item(new CFileItem); int songID; if (database.GetRandomSong(item.get(), songID, whereClause.first)) @@ -366,18 +371,19 @@ bool CPartyModeManager::AddRandomSongs(int iSongs /* = 0 */) if (error) { database.Close(); - OnError(16034, (CStdString)"Cannot get songs from database. Aborting."); + OnError(16034, (std::string)"Cannot get songs from database. Aborting."); return false; } } else { - OnError(16033, (CStdString)"Party mode could not open database. Aborting."); + OnError(16033, (std::string)"Party mode could not open database. Aborting."); return false; } database.Close(); } - if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) + if (StringUtils::EqualsNoCase(m_type, "musicvideos") || + StringUtils::EqualsNoCase(m_type, "mixed")) { CVideoDatabase database; if (database.Open()) @@ -395,7 +401,7 @@ bool CPartyModeManager::AddRandomSongs(int iSongs /* = 0 */) bool error(false); for (int i = 0; i < iVidsToAdd; i++) { - pair<CStdString,CStdString> whereClause = GetWhereClauseWithHistory(); + pair<std::string,std::string> whereClause = GetWhereClauseWithHistory(); CFileItemPtr item(new CFileItem); int songID; if (database.GetRandomMusicVideo(item.get(), songID, whereClause.second)) @@ -413,13 +419,13 @@ bool CPartyModeManager::AddRandomSongs(int iSongs /* = 0 */) if (error) { database.Close(); - OnError(16034, (CStdString)"Cannot get songs from database. Aborting."); + OnError(16034, (std::string)"Cannot get songs from database. Aborting."); return false; } } else { - OnError(16033, (CStdString)"Party mode could not open database. Aborting."); + OnError(16033, (std::string)"Party mode could not open database. Aborting."); return false; } database.Close(); @@ -504,7 +510,7 @@ void CPartyModeManager::Play(int iPos) Process(); } -void CPartyModeManager::OnError(int iError, const CStdString& strLogMessage) +void CPartyModeManager::OnError(int iError, const std::string& strLogMessage) { // open error dialog CGUIDialogOK::ShowAndGetInput(257, 16030, iError, 0); @@ -601,12 +607,12 @@ bool CPartyModeManager::AddInitialSongs(vector<pair<int,int> > &songIDs) vector<pair<int,int> > chosenSongIDs; GetRandomSelection(songIDs, iMissingSongs, chosenSongIDs); - CStdString sqlWhereMusic = "songview.idSong IN ("; - CStdString sqlWhereVideo = "idMVideo IN ("; + std::string sqlWhereMusic = "songview.idSong IN ("; + std::string sqlWhereVideo = "idMVideo IN ("; for (vector< pair<int,int> >::iterator it = chosenSongIDs.begin(); it != chosenSongIDs.end(); it++) { - CStdString song = StringUtils::Format("%i,", it->second); + std::string song = StringUtils::Format("%i,", it->second); if (it->first == 1) sqlWhereMusic += song; if (it->first == 2) @@ -642,7 +648,7 @@ bool CPartyModeManager::AddInitialSongs(vector<pair<int,int> > &songIDs) return true; } -pair<CStdString,CStdString> CPartyModeManager::GetWhereClauseWithHistory() const +pair<std::string,std::string> CPartyModeManager::GetWhereClauseWithHistory() const { // now add this on to the normal where clause std::vector<std::string> historyItemsMusic; diff --git a/xbmc/PartyModeManager.h b/xbmc/PartyModeManager.h index ef5719b898..b7ac7b9b13 100644 --- a/xbmc/PartyModeManager.h +++ b/xbmc/PartyModeManager.h @@ -19,7 +19,8 @@ * */ -#include "utils/StdString.h" +#include <string> +#include <vector> #include <boost/shared_ptr.hpp> @@ -43,7 +44,7 @@ public: CPartyModeManager(void); virtual ~CPartyModeManager(void); - bool Enable(PartyModeContext context=PARTYMODECONTEXT_MUSIC, const CStdString& strXspPath = ""); + bool Enable(PartyModeContext context=PARTYMODECONTEXT_MUSIC, const std::string& strXspPath = ""); void Disable(); void Play(int iPos); void OnSongChange(bool bUpdatePlayed = false); @@ -66,10 +67,10 @@ private: bool ReapSongs(); bool MovePlaying(); void SendUpdateMessage(); - void OnError(int iError, const CStdString& strLogMessage); + void OnError(int iError, const std::string& strLogMessage); void ClearState(); void UpdateStats(); - std::pair<CStdString,CStdString> GetWhereClauseWithHistory() const; + std::pair<std::string,std::string> GetWhereClauseWithHistory() const; void AddToHistory(int type, int songID); void GetRandomSelection(std::vector< std::pair<int,int> > &in, unsigned int number, std::vector< std::pair<int, int> > &out); void Announce(); @@ -78,9 +79,9 @@ private: bool m_bEnabled; bool m_bIsVideo; int m_iLastUserSong; - CStdString m_strCurrentFilterMusic; - CStdString m_strCurrentFilterVideo; - CStdString m_type; + std::string m_strCurrentFilterMusic; + std::string m_strCurrentFilterVideo; + std::string m_type; // statistics int m_iSongsPlayed; diff --git a/xbmc/PasswordManager.cpp b/xbmc/PasswordManager.cpp index 68a439d13e..3579078702 100644 --- a/xbmc/PasswordManager.cpp +++ b/xbmc/PasswordManager.cpp @@ -46,8 +46,8 @@ bool CPasswordManager::AuthenticateURL(CURL &url) if (!m_loaded) Load(); - CStdString lookup(GetLookupPath(url)); - map<CStdString, CStdString>::const_iterator it = m_temporaryCache.find(lookup); + std::string lookup(GetLookupPath(url)); + map<std::string, std::string>::const_iterator it = m_temporaryCache.find(lookup); if (it == m_temporaryCache.end()) { // second step, try something that doesn't quite match it = m_temporaryCache.find(GetServerLookup(lookup)); @@ -89,8 +89,8 @@ void CPasswordManager::SaveAuthenticatedURL(const CURL &url, bool saveToProfile) CSingleLock lock(m_critSection); - CStdString path = GetLookupPath(url); - CStdString authenticatedPath = url.Get(); + std::string path = GetLookupPath(url); + std::string authenticatedPath = url.Get(); if (!m_loaded) Load(); @@ -116,7 +116,7 @@ void CPasswordManager::Clear() void CPasswordManager::Load() { Clear(); - CStdString passwordsFile = CProfilesManager::Get().GetUserDataItem("passwords.xml"); + std::string passwordsFile = CProfilesManager::Get().GetUserDataItem("passwords.xml"); if (XFILE::CFile::Exists(passwordsFile)) { CXBMCTinyXML doc; @@ -133,7 +133,7 @@ void CPasswordManager::Load() const TiXmlElement *path = root->FirstChildElement("path"); while (path) { - CStdString from, to; + std::string from, to; if (XMLUtils::GetPath(path, "from", from) && XMLUtils::GetPath(path, "to", to)) { m_permanentCache[from] = to; @@ -157,7 +157,7 @@ void CPasswordManager::Save() const if (!root) return; - for (map<CStdString, CStdString>::const_iterator i = m_permanentCache.begin(); i != m_permanentCache.end(); ++i) + for (map<std::string, std::string>::const_iterator i = m_permanentCache.begin(); i != m_permanentCache.end(); ++i) { TiXmlElement pathElement("path"); TiXmlNode *path = root->InsertEndChild(pathElement); @@ -168,12 +168,12 @@ void CPasswordManager::Save() const doc.SaveFile(CProfilesManager::Get().GetUserDataItem("passwords.xml")); } -CStdString CPasswordManager::GetLookupPath(const CURL &url) const +std::string CPasswordManager::GetLookupPath(const CURL &url) const { return "smb://" + url.GetHostName() + "/" + url.GetShareName(); } -CStdString CPasswordManager::GetServerLookup(const CStdString &path) const +std::string CPasswordManager::GetServerLookup(const std::string &path) const { CURL url(path); return "smb://" + url.GetHostName() + "/"; diff --git a/xbmc/PasswordManager.h b/xbmc/PasswordManager.h index 5f74bae857..b2db8ef310 100644 --- a/xbmc/PasswordManager.h +++ b/xbmc/PasswordManager.h @@ -19,8 +19,9 @@ * */ -#include "utils/StdString.h" #include <map> +#include <string> +#include <stdint.h> #include "threads/CriticalSection.h" class CURL; @@ -92,11 +93,11 @@ private: void Load(); void Save() const; - CStdString GetLookupPath(const CURL &url) const; - CStdString GetServerLookup(const CStdString &path) const; + std::string GetLookupPath(const CURL &url) const; + std::string GetServerLookup(const std::string &path) const; - std::map<CStdString, CStdString> m_temporaryCache; - std::map<CStdString, CStdString> m_permanentCache; + std::map<std::string, std::string> m_temporaryCache; + std::map<std::string, std::string> m_permanentCache; bool m_loaded; CCriticalSection m_critSection; diff --git a/xbmc/PlayListPlayer.cpp b/xbmc/PlayListPlayer.cpp index 5f5955eeac..c6f210e9fb 100644 --- a/xbmc/PlayListPlayer.cpp +++ b/xbmc/PlayListPlayer.cpp @@ -487,7 +487,7 @@ void CPlayListPlayer::SetShuffle(int iPlaylist, bool bYesNo, bool bNotify /* = f if (bNotify) { - CStdString shuffleStr = StringUtils::Format("%s: %s", g_localizeStrings.Get(191).c_str(), g_localizeStrings.Get(bYesNo ? 593 : 591).c_str()); // Shuffle: All/Off + std::string shuffleStr = StringUtils::Format("%s: %s", g_localizeStrings.Get(191).c_str(), g_localizeStrings.Get(bYesNo ? 593 : 591).c_str()); // Shuffle: All/Off CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(559), shuffleStr); } diff --git a/xbmc/SectionLoader.cpp b/xbmc/SectionLoader.cpp index a4970f565b..9ff9c86c2e 100644 --- a/xbmc/SectionLoader.cpp +++ b/xbmc/SectionLoader.cpp @@ -25,6 +25,7 @@ #include "threads/SingleLock.h" #include "utils/log.h" #include "utils/TimeUtils.h" +#include "utils/StringUtils.h" using namespace std; @@ -44,16 +45,16 @@ CSectionLoader::~CSectionLoader(void) UnloadAll(); } -LibraryLoader *CSectionLoader::LoadDLL(const CStdString &dllname, bool bDelayUnload /*=true*/, bool bLoadSymbols /*=false*/) +LibraryLoader *CSectionLoader::LoadDLL(const std::string &dllname, bool bDelayUnload /*=true*/, bool bLoadSymbols /*=false*/) { CSingleLock lock(g_sectionLoader.m_critSection); - if (!dllname) return NULL; + if (dllname.empty()) return NULL; // check if it's already loaded, and increase the reference count if so for (int i = 0; i < (int)g_sectionLoader.m_vecLoadedDLLs.size(); ++i) { CDll& dll = g_sectionLoader.m_vecLoadedDLLs[i]; - if (dll.m_strDllName.Equals(dllname)) + if (StringUtils::EqualsNoCase(dll.m_strDllName, dllname)) { dll.m_lReferenceCount++; return dll.m_pDll; @@ -76,16 +77,16 @@ LibraryLoader *CSectionLoader::LoadDLL(const CStdString &dllname, bool bDelayUnl return newDLL.m_pDll; } -void CSectionLoader::UnloadDLL(const CStdString &dllname) +void CSectionLoader::UnloadDLL(const std::string &dllname) { CSingleLock lock(g_sectionLoader.m_critSection); - if (!dllname) return; + if (dllname.empty()) return; // check if it's already loaded, and decrease the reference count if so for (int i = 0; i < (int)g_sectionLoader.m_vecLoadedDLLs.size(); ++i) { CDll& dll = g_sectionLoader.m_vecLoadedDLLs[i]; - if (dll.m_strDllName.Equals(dllname)) + if (StringUtils::EqualsNoCase(dll.m_strDllName, dllname)) { dll.m_lReferenceCount--; if (0 == dll.m_lReferenceCount) diff --git a/xbmc/SectionLoader.h b/xbmc/SectionLoader.h index f45ce0f426..487e2612a3 100644 --- a/xbmc/SectionLoader.h +++ b/xbmc/SectionLoader.h @@ -19,7 +19,8 @@ * */ -#include "utils/StdString.h" +#include <string> +#include <vector> #include "threads/CriticalSection.h" #include "utils/GlobalsHandling.h" @@ -32,7 +33,7 @@ public: class CDll { public: - CStdString m_strDllName; + std::string m_strDllName; long m_lReferenceCount; LibraryLoader *m_pDll; unsigned int m_unloadDelayStartTick; @@ -41,8 +42,8 @@ public: CSectionLoader(void); virtual ~CSectionLoader(void); - static LibraryLoader* LoadDLL(const CStdString& strSection, bool bDelayUnload=true, bool bLoadSymbols=false); - static void UnloadDLL(const CStdString& strSection); + static LibraryLoader* LoadDLL(const std::string& strSection, bool bDelayUnload=true, bool bLoadSymbols=false); + static void UnloadDLL(const std::string& strSection); static void UnloadDelayed(); void UnloadAll(); diff --git a/xbmc/Temperature.cpp b/xbmc/Temperature.cpp index c5dfa42569..5362037dfc 100644 --- a/xbmc/Temperature.cpp +++ b/xbmc/Temperature.cpp @@ -23,6 +23,7 @@ #include "Temperature.h" #include "utils/StringUtils.h" #include "utils/Archive.h" +#include <assert.h> CTemperature::CTemperature() { @@ -44,8 +45,8 @@ CTemperature::CTemperature(double value) bool CTemperature::operator >(const CTemperature& right) const { - ASSERT(IsValid()); - ASSERT(right.IsValid()); + assert(IsValid()); + assert(right.IsValid()); if (!IsValid() || !right.IsValid()) return false; @@ -63,8 +64,8 @@ bool CTemperature::operator >=(const CTemperature& right) const bool CTemperature::operator <(const CTemperature& right) const { - ASSERT(IsValid()); - ASSERT(right.IsValid()); + assert(IsValid()); + assert(right.IsValid()); if (!IsValid() || !right.IsValid()) return false; @@ -82,8 +83,8 @@ bool CTemperature::operator <=(const CTemperature& right) const bool CTemperature::operator ==(const CTemperature& right) const { - ASSERT(IsValid()); - ASSERT(right.IsValid()); + assert(IsValid()); + assert(right.IsValid()); if (!IsValid() || !right.IsValid()) return false; @@ -108,8 +109,8 @@ const CTemperature& CTemperature::operator =(const CTemperature& right) const CTemperature& CTemperature::operator +=(const CTemperature& right) { - ASSERT(IsValid()); - ASSERT(right.IsValid()); + assert(IsValid()); + assert(right.IsValid()); m_value+=right.m_value; return *this; @@ -117,8 +118,8 @@ const CTemperature& CTemperature::operator +=(const CTemperature& right) const CTemperature& CTemperature::operator -=(const CTemperature& right) { - ASSERT(IsValid()); - ASSERT(right.IsValid()); + assert(IsValid()); + assert(right.IsValid()); m_value-=right.m_value; return *this; @@ -126,8 +127,8 @@ const CTemperature& CTemperature::operator -=(const CTemperature& right) const CTemperature& CTemperature::operator *=(const CTemperature& right) { - ASSERT(IsValid()); - ASSERT(right.IsValid()); + assert(IsValid()); + assert(right.IsValid()); m_value*=right.m_value; return *this; @@ -135,8 +136,8 @@ const CTemperature& CTemperature::operator *=(const CTemperature& right) const CTemperature& CTemperature::operator /=(const CTemperature& right) { - ASSERT(IsValid()); - ASSERT(right.IsValid()); + assert(IsValid()); + assert(right.IsValid()); m_value/=right.m_value; return *this; @@ -144,8 +145,8 @@ const CTemperature& CTemperature::operator /=(const CTemperature& right) CTemperature CTemperature::operator +(const CTemperature& right) const { - ASSERT(IsValid()); - ASSERT(right.IsValid()); + assert(IsValid()); + assert(right.IsValid()); CTemperature temp(*this); @@ -159,8 +160,8 @@ CTemperature CTemperature::operator +(const CTemperature& right) const CTemperature CTemperature::operator -(const CTemperature& right) const { - ASSERT(IsValid()); - ASSERT(right.IsValid()); + assert(IsValid()); + assert(right.IsValid()); CTemperature temp(*this); if (!IsValid() || !right.IsValid()) @@ -173,8 +174,8 @@ CTemperature CTemperature::operator -(const CTemperature& right) const CTemperature CTemperature::operator *(const CTemperature& right) const { - ASSERT(IsValid()); - ASSERT(right.IsValid()); + assert(IsValid()); + assert(right.IsValid()); CTemperature temp(*this); if (!IsValid() || !right.IsValid()) @@ -186,8 +187,8 @@ CTemperature CTemperature::operator *(const CTemperature& right) const CTemperature CTemperature::operator /(const CTemperature& right) const { - ASSERT(IsValid()); - ASSERT(right.IsValid()); + assert(IsValid()); + assert(right.IsValid()); CTemperature temp(*this); if (!IsValid() || !right.IsValid()) @@ -199,7 +200,7 @@ CTemperature CTemperature::operator /(const CTemperature& right) const CTemperature& CTemperature::operator ++() { - ASSERT(IsValid()); + assert(IsValid()); m_value++; return *this; @@ -207,7 +208,7 @@ CTemperature& CTemperature::operator ++() CTemperature& CTemperature::operator --() { - ASSERT(IsValid()); + assert(IsValid()); m_value--; return *this; @@ -215,7 +216,7 @@ CTemperature& CTemperature::operator --() CTemperature CTemperature::operator ++(int) { - ASSERT(IsValid()); + assert(IsValid()); CTemperature temp(*this); m_value++; @@ -224,7 +225,7 @@ CTemperature CTemperature::operator ++(int) CTemperature CTemperature::operator --(int) { - ASSERT(IsValid()); + assert(IsValid()); CTemperature temp(*this); m_value--; @@ -233,7 +234,7 @@ CTemperature CTemperature::operator --(int) bool CTemperature::operator >(double right) const { - ASSERT(IsValid()); + assert(IsValid()); if (!IsValid()) return false; @@ -248,7 +249,7 @@ bool CTemperature::operator >=(double right) const bool CTemperature::operator <(double right) const { - ASSERT(IsValid()); + assert(IsValid()); if (!IsValid()) return false; @@ -276,7 +277,7 @@ bool CTemperature::operator !=(double right) const const CTemperature& CTemperature::operator +=(double right) { - ASSERT(IsValid()); + assert(IsValid()); m_value+=right; return *this; @@ -284,7 +285,7 @@ const CTemperature& CTemperature::operator +=(double right) const CTemperature& CTemperature::operator -=(double right) { - ASSERT(IsValid()); + assert(IsValid()); m_value-=right; return *this; @@ -292,7 +293,7 @@ const CTemperature& CTemperature::operator -=(double right) const CTemperature& CTemperature::operator *=(double right) { - ASSERT(IsValid()); + assert(IsValid()); m_value*=right; return *this; @@ -300,7 +301,7 @@ const CTemperature& CTemperature::operator *=(double right) const CTemperature& CTemperature::operator /=(double right) { - ASSERT(IsValid()); + assert(IsValid()); m_value/=right; return *this; @@ -308,7 +309,7 @@ const CTemperature& CTemperature::operator /=(double right) CTemperature CTemperature::operator +(double right) const { - ASSERT(IsValid()); + assert(IsValid()); CTemperature temp(*this); temp.m_value+=right; @@ -317,7 +318,7 @@ CTemperature CTemperature::operator +(double right) const CTemperature CTemperature::operator -(double right) const { - ASSERT(IsValid()); + assert(IsValid()); CTemperature temp(*this); temp.m_value-=right; @@ -326,7 +327,7 @@ CTemperature CTemperature::operator -(double right) const CTemperature CTemperature::operator *(double right) const { - ASSERT(IsValid()); + assert(IsValid()); CTemperature temp(*this); temp.m_value*=right; @@ -335,7 +336,7 @@ CTemperature CTemperature::operator *(double right) const CTemperature CTemperature::operator /(double right) const { - ASSERT(IsValid()); + assert(IsValid()); CTemperature temp(*this); temp.m_value/=right; @@ -477,7 +478,7 @@ double CTemperature::ToLocale() const value=ToNewton(); break; default: - ASSERT(false); + assert(false); break; } return value; diff --git a/xbmc/TextureCache.cpp b/xbmc/TextureCache.cpp index d7e55cf2d1..542183b9e1 100644 --- a/xbmc/TextureCache.cpp +++ b/xbmc/TextureCache.cpp @@ -61,7 +61,7 @@ void CTextureCache::Deinitialize() m_database.Close(); } -bool CTextureCache::IsCachedImage(const CStdString &url) const +bool CTextureCache::IsCachedImage(const std::string &url) const { if (url != "-" && !CURL::IsFullPath(url)) return true; @@ -73,16 +73,16 @@ bool CTextureCache::IsCachedImage(const CStdString &url) const return false; } -bool CTextureCache::HasCachedImage(const CStdString &url) +bool CTextureCache::HasCachedImage(const std::string &url) { CTextureDetails details; - CStdString cachedImage(GetCachedImage(url, details)); + std::string cachedImage(GetCachedImage(url, details)); return (!cachedImage.empty() && cachedImage != url); } -CStdString CTextureCache::GetCachedImage(const CStdString &image, CTextureDetails &details, bool trackUsage) +std::string CTextureCache::GetCachedImage(const std::string &image, CTextureDetails &details, bool trackUsage) { - CStdString url = CTextureUtils::UnwrapImageURL(image); + std::string url = CTextureUtils::UnwrapImageURL(image); if (IsCachedImage(url)) return url; @@ -102,16 +102,16 @@ bool CTextureCache::CanCacheImageURL(const CURL &url) return (url.GetUserName().empty() || url.GetUserName() == "music"); } -CStdString CTextureCache::CheckCachedImage(const CStdString &url, bool returnDDS, bool &needsRecaching) +std::string CTextureCache::CheckCachedImage(const std::string &url, bool returnDDS, bool &needsRecaching) { CTextureDetails details; - CStdString path(GetCachedImage(url, details, true)); + std::string path(GetCachedImage(url, details, true)); needsRecaching = !details.hash.empty(); if (!path.empty()) { if (!needsRecaching && returnDDS && !URIUtils::IsInPath(url, "special://skin/")) // TODO: should skin images be .dds'd (currently they're not necessarily writeable) { // check for dds version - CStdString ddsPath = URIUtils::ReplaceExtension(path, ".dds"); + std::string ddsPath = URIUtils::ReplaceExtension(path, ".dds"); if (CFile::Exists(ddsPath)) return ddsPath; if (g_advancedSettings.m_useDDSFanart) @@ -122,10 +122,10 @@ CStdString CTextureCache::CheckCachedImage(const CStdString &url, bool returnDDS return ""; } -void CTextureCache::BackgroundCacheImage(const CStdString &url) +void CTextureCache::BackgroundCacheImage(const std::string &url) { CTextureDetails details; - CStdString path(GetCachedImage(url, details)); + std::string path(GetCachedImage(url, details)); if (!path.empty() && details.hash.empty()) return; // image is already cached and doesn't need to be checked further @@ -133,18 +133,18 @@ void CTextureCache::BackgroundCacheImage(const CStdString &url) AddJob(new CTextureCacheJob(CTextureUtils::UnwrapImageURL(url), details.hash)); } -bool CTextureCache::CacheImage(const CStdString &image, CTextureDetails &details) +bool CTextureCache::CacheImage(const std::string &image, CTextureDetails &details) { - CStdString path = GetCachedImage(image, details); + std::string path = GetCachedImage(image, details); if (path.empty()) // not cached path = CacheImage(image, NULL, &details); return !path.empty(); } -CStdString CTextureCache::CacheImage(const CStdString &image, CBaseTexture **texture, CTextureDetails *details) +std::string CTextureCache::CacheImage(const std::string &image, CBaseTexture **texture, CTextureDetails *details) { - CStdString url = CTextureUtils::UnwrapImageURL(image); + std::string url = CTextureUtils::UnwrapImageURL(image); CSingleLock lock(m_processingSection); if (m_processinglist.find(url) == m_processinglist.end()) { @@ -176,11 +176,11 @@ CStdString CTextureCache::CacheImage(const CStdString &image, CBaseTexture **tex return GetCachedImage(url, *details, true); } -void CTextureCache::ClearCachedImage(const CStdString &url, bool deleteSource /*= false */) +void CTextureCache::ClearCachedImage(const std::string &url, bool deleteSource /*= false */) { // TODO: This can be removed when the texture cache covers everything. - CStdString path = deleteSource ? url : ""; - CStdString cachedFile; + std::string path = deleteSource ? url : ""; + std::string cachedFile; if (ClearCachedTexture(url, cachedFile)) path = GetCachedPath(cachedFile); if (CFile::Exists(path)) @@ -192,7 +192,7 @@ void CTextureCache::ClearCachedImage(const CStdString &url, bool deleteSource /* bool CTextureCache::ClearCachedImage(int id) { - CStdString cachedFile; + std::string cachedFile; if (ClearCachedTexture(id, cachedFile)) { cachedFile = GetCachedPath(cachedFile); @@ -206,13 +206,13 @@ bool CTextureCache::ClearCachedImage(int id) return false; } -bool CTextureCache::GetCachedTexture(const CStdString &url, CTextureDetails &details) +bool CTextureCache::GetCachedTexture(const std::string &url, CTextureDetails &details) { CSingleLock lock(m_databaseSection); return m_database.GetCachedTexture(url, details); } -bool CTextureCache::AddCachedTexture(const CStdString &url, const CTextureDetails &details) +bool CTextureCache::AddCachedTexture(const std::string &url, const CTextureDetails &details) { CSingleLock lock(m_databaseSection); return m_database.AddCachedTexture(url, details); @@ -231,34 +231,34 @@ void CTextureCache::IncrementUseCount(const CTextureDetails &details) } } -bool CTextureCache::SetCachedTextureValid(const CStdString &url, bool updateable) +bool CTextureCache::SetCachedTextureValid(const std::string &url, bool updateable) { CSingleLock lock(m_databaseSection); return m_database.SetCachedTextureValid(url, updateable); } -bool CTextureCache::ClearCachedTexture(const CStdString &url, CStdString &cachedURL) +bool CTextureCache::ClearCachedTexture(const std::string &url, std::string &cachedURL) { CSingleLock lock(m_databaseSection); return m_database.ClearCachedTexture(url, cachedURL); } -bool CTextureCache::ClearCachedTexture(int id, CStdString &cachedURL) +bool CTextureCache::ClearCachedTexture(int id, std::string &cachedURL) { CSingleLock lock(m_databaseSection); return m_database.ClearCachedTexture(id, cachedURL); } -CStdString CTextureCache::GetCacheFile(const CStdString &url) +std::string CTextureCache::GetCacheFile(const std::string &url) { Crc32 crc; crc.ComputeFromLowerCase(url); - CStdString hex = StringUtils::Format("%08x", (unsigned int)crc); - CStdString hash = StringUtils::Format("%c/%s", hex[0], hex.c_str()); + std::string hex = StringUtils::Format("%08x", (unsigned int)crc); + std::string hash = StringUtils::Format("%c/%s", hex[0], hex.c_str()); return hash; } -CStdString CTextureCache::GetCachedPath(const CStdString &file) +std::string CTextureCache::GetCachedPath(const std::string &file) { return URIUtils::AddFileToFolder(CProfilesManager::Get().GetThumbnailsFolder(), file); } @@ -275,7 +275,7 @@ void CTextureCache::OnCachingComplete(bool success, CTextureCacheJob *job) { // remove from our processing list CSingleLock lock(m_processingSection); - std::set<CStdString>::iterator i = m_processinglist.find(job->m_url); + std::set<std::string>::iterator i = m_processinglist.find(job->m_url); if (i != m_processinglist.end()) m_processinglist.erase(i); } @@ -301,7 +301,7 @@ void CTextureCache::OnJobProgress(unsigned int jobID, unsigned int progress, uns { CSingleLock lock(m_processingSection); const CTextureCacheJob *cacheJob = (CTextureCacheJob *)job; - std::set<CStdString>::iterator i = m_processinglist.find(cacheJob->m_url); + std::set<std::string>::iterator i = m_processinglist.find(cacheJob->m_url); if (i == m_processinglist.end()) { m_processinglist.insert(cacheJob->m_url); @@ -314,13 +314,13 @@ void CTextureCache::OnJobProgress(unsigned int jobID, unsigned int progress, uns CJobQueue::OnJobProgress(jobID, progress, total, job); } -bool CTextureCache::Export(const CStdString &image, const CStdString &destination, bool overwrite) +bool CTextureCache::Export(const std::string &image, const std::string &destination, bool overwrite) { CTextureDetails details; - CStdString cachedImage(GetCachedImage(image, details)); + std::string cachedImage(GetCachedImage(image, details)); if (!cachedImage.empty()) { - CStdString dest = destination + CStdString(URIUtils::GetExtension(cachedImage)); + std::string dest = destination + URIUtils::GetExtension(cachedImage); if (overwrite || !CFile::Exists(dest)) { if (CFile::Copy(cachedImage, dest)) @@ -331,10 +331,10 @@ bool CTextureCache::Export(const CStdString &image, const CStdString &destinatio return false; } -bool CTextureCache::Export(const CStdString &image, const CStdString &destination) +bool CTextureCache::Export(const std::string &image, const std::string &destination) { CTextureDetails details; - CStdString cachedImage(GetCachedImage(image, details)); + std::string cachedImage(GetCachedImage(image, details)); if (!cachedImage.empty()) { if (CFile::Copy(cachedImage, destination)) diff --git a/xbmc/TextureCache.h b/xbmc/TextureCache.h index af2e2c8cc1..f35c56c7c9 100644 --- a/xbmc/TextureCache.h +++ b/xbmc/TextureCache.h @@ -21,7 +21,8 @@ #pragma once #include <set> -#include "utils/StdString.h" +#include <string> +#include <vector> #include "utils/JobManager.h" #include "TextureDatabase.h" #include "threads/Event.h" @@ -68,7 +69,7 @@ public: \return cached url of this image \sa GetCachedImage */ - CStdString CheckCachedImage(const CStdString &image, bool returnDDS, bool &needsRecaching); + std::string CheckCachedImage(const std::string &image, bool returnDDS, bool &needsRecaching); /*! \brief Cache image (if required) using a background job @@ -79,7 +80,7 @@ public: \param image url of the image to cache \sa CacheImage */ - void BackgroundCacheImage(const CStdString &image); + void BackgroundCacheImage(const std::string &image); /*! \brief Cache an image to image cache, optionally return the texture @@ -91,7 +92,7 @@ public: \return cached url of this image \sa CTextureCacheJob::CacheTexture */ - CStdString CacheImage(const CStdString &url, CBaseTexture **texture = NULL, CTextureDetails *details = NULL); + std::string CacheImage(const std::string &url, CBaseTexture **texture = NULL, CTextureDetails *details = NULL); /*! \brief Cache an image to image cache if not already cached, returning the image details. \param image url of the image to cache. @@ -99,7 +100,7 @@ public: \return true if the image is in the cache, false otherwise. \sa CTextureCacheJob::CacheTexture */ - bool CacheImage(const CStdString &image, CTextureDetails &details); + bool CacheImage(const std::string &image, CTextureDetails &details); /*! \brief Check whether an image is in the cache Note: If the image url won't normally be cached (eg a skin image) this function will return false. @@ -107,13 +108,13 @@ public: \return true if the image is cached, false otherwise \sa ClearCachedImage */ - bool HasCachedImage(const CStdString &image); + bool HasCachedImage(const std::string &image); /*! \brief clear the cached version of the given image \param image url of the image \sa GetCachedImage */ - void ClearCachedImage(const CStdString &image, bool deleteSource = false); + void ClearCachedImage(const std::string &image, bool deleteSource = false); /*! \brief clear the cached version of the image with given id \param database id of the image @@ -126,13 +127,13 @@ public: \param url location of the image \return a "unique" filename for the associated cache file, excluding extension */ - static CStdString GetCacheFile(const CStdString &url); + static std::string GetCacheFile(const std::string &url); /*! \brief retrieve the full path of the given cached file \param file name of the file \return full path of the cached file */ - static CStdString GetCachedPath(const CStdString &file); + static std::string GetCachedPath(const std::string &file); /*! \brief check whether an image:// URL may be cached \param url the URL to the image @@ -146,7 +147,7 @@ public: \param details the texture details to add \return true if we successfully added to the database, false otherwise. */ - bool AddCachedTexture(const CStdString &image, const CTextureDetails &details); + bool AddCachedTexture(const std::string &image, const CTextureDetails &details); /*! \brief Export a (possibly) cached image to a file \param image url of the original image @@ -154,8 +155,8 @@ public: \param overwrite whether to overwrite the destination if it exists (TODO: Defaults to false) \return true if we successfully exported the file, false otherwise. */ - bool Export(const CStdString &image, const CStdString &destination, bool overwrite); - bool Export(const CStdString &image, const CStdString &destination); // TODO: BACKWARD COMPATIBILITY FOR MUSIC THUMBS + bool Export(const std::string &image, const std::string &destination, bool overwrite); + bool Export(const std::string &image, const std::string &destination); // TODO: BACKWARD COMPATIBILITY FOR MUSIC THUMBS private: // private construction, and no assignements; use the provided singleton methods CTextureCache(); @@ -167,7 +168,7 @@ private: \param image url of the image \return true if this is a cached image, false otherwise. */ - bool IsCachedImage(const CStdString &image) const; + bool IsCachedImage(const std::string &image) const; /*! \brief retrieve the cached version of the given image (if it exists) \param image url of the image @@ -176,7 +177,7 @@ private: \return cached url of this image, empty if none exists \sa ClearCachedImage, CTextureDetails */ - CStdString GetCachedImage(const CStdString &image, CTextureDetails &details, bool trackUsage = false); + std::string GetCachedImage(const std::string &image, CTextureDetails &details, bool trackUsage = false); /*! \brief Get an image from the database Thread-safe wrapper of CTextureDatabase::GetCachedTexture @@ -184,7 +185,7 @@ private: \param details [out] texture details from the database (if available) \return true if we have a cached version of this image, false otherwise. */ - bool GetCachedTexture(const CStdString &url, CTextureDetails &details); + bool GetCachedTexture(const std::string &url, CTextureDetails &details); /*! \brief Clear an image from the database Thread-safe wrapper of CTextureDatabase::ClearCachedTexture @@ -192,8 +193,8 @@ private: \param cacheFile [out] url of the cached original (if available) \return true if we had a cached version of this image, false otherwise. */ - bool ClearCachedTexture(const CStdString &url, CStdString &cacheFile); - bool ClearCachedTexture(int textureID, CStdString &cacheFile); + bool ClearCachedTexture(const std::string &url, std::string &cacheFile); + bool ClearCachedTexture(int textureID, std::string &cacheFile); /*! \brief Increment the use count of a texture Stores locally before calling CTextureDatabase::IncrementUseCount via a CUseCountJob @@ -207,7 +208,7 @@ private: \param updateable whether this image should be checked for updates \return true if successful, false otherwise. */ - bool SetCachedTextureValid(const CStdString &url, bool updateable); + bool SetCachedTextureValid(const std::string &url, bool updateable); virtual void OnJobComplete(unsigned int jobID, bool success, CJob *job); virtual void OnJobProgress(unsigned int jobID, unsigned int progress, unsigned int total, const CJob *job); @@ -222,7 +223,7 @@ private: CCriticalSection m_databaseSection; CTextureDatabase m_database; - std::set<CStdString> m_processinglist; ///< currently processing list to avoid 2 jobs being processed at once + std::set<std::string> m_processinglist; ///< currently processing list to avoid 2 jobs being processed at once CCriticalSection m_processingSection; CEvent m_completeEvent; ///< Set whenever a job has finished std::vector<CTextureDetails> m_useCounts; ///< Use count tracking diff --git a/xbmc/TextureCacheJob.cpp b/xbmc/TextureCacheJob.cpp index fe0904d673..a21614d29c 100644 --- a/xbmc/TextureCacheJob.cpp +++ b/xbmc/TextureCacheJob.cpp @@ -37,7 +37,7 @@ #include "cores/omxplayer/OMXImage.h" #endif -CTextureCacheJob::CTextureCacheJob(const CStdString &url, const CStdString &oldHash) +CTextureCacheJob::CTextureCacheJob(const std::string &url, const std::string &oldHash) { m_url = url; m_oldHash = oldHash; @@ -68,7 +68,7 @@ bool CTextureCacheJob::DoWork() // check whether we need cache the job anyway bool needsRecaching = false; - CStdString path(CTextureCache::Get().CheckCachedImage(m_url, false, needsRecaching)); + std::string path(CTextureCache::Get().CheckCachedImage(m_url, false, needsRecaching)); if (!path.empty() && !needsRecaching) return false; return CacheTexture(); @@ -79,7 +79,7 @@ bool CTextureCacheJob::CacheTexture(CBaseTexture **out_texture) // unwrap the URL as required std::string additional_info; unsigned int width, height; - CStdString image = DecodeImageURL(m_url, width, height, additional_info); + std::string image = DecodeImageURL(m_url, width, height, additional_info); m_details.updateable = additional_info != "music" && UpdateableURL(image); @@ -127,10 +127,10 @@ bool CTextureCacheJob::CacheTexture(CBaseTexture **out_texture) return false; } -CStdString CTextureCacheJob::DecodeImageURL(const CStdString &url, unsigned int &width, unsigned int &height, std::string &additional_info) +std::string CTextureCacheJob::DecodeImageURL(const std::string &url, unsigned int &width, unsigned int &height, std::string &additional_info) { // unwrap the URL as required - CStdString image(url); + std::string image(url); additional_info.clear(); width = height = 0; if (StringUtils::StartsWith(url, "image://")) @@ -154,7 +154,7 @@ CStdString CTextureCacheJob::DecodeImageURL(const CStdString &url, unsigned int return image; } -CBaseTexture *CTextureCacheJob::LoadImage(const CStdString &image, unsigned int width, unsigned int height, const std::string &additional_info, bool requirePixels) +CBaseTexture *CTextureCacheJob::LoadImage(const std::string &image, unsigned int width, unsigned int height, const std::string &additional_info, bool requirePixels) { if (additional_info == "music") { // special case for embedded music images @@ -183,7 +183,7 @@ CBaseTexture *CTextureCacheJob::LoadImage(const CStdString &image, unsigned int return texture; } -bool CTextureCacheJob::UpdateableURL(const CStdString &url) const +bool CTextureCacheJob::UpdateableURL(const std::string &url) const { // we don't constantly check online images if (StringUtils::StartsWith(url, "http://") || @@ -192,7 +192,7 @@ bool CTextureCacheJob::UpdateableURL(const CStdString &url) const return true; } -CStdString CTextureCacheJob::GetImageHash(const CStdString &url) +std::string CTextureCacheJob::GetImageHash(const std::string &url) { struct __stat64 st; if (XFILE::CFile::Stat(url, &st) == 0) @@ -208,7 +208,7 @@ CStdString CTextureCacheJob::GetImageHash(const CStdString &url) return ""; } -CTextureDDSJob::CTextureDDSJob(const CStdString &original) +CTextureDDSJob::CTextureDDSJob(const std::string &original) { m_original = original; } diff --git a/xbmc/TextureCacheJob.h b/xbmc/TextureCacheJob.h index 73f5756412..0515db9a65 100644 --- a/xbmc/TextureCacheJob.h +++ b/xbmc/TextureCacheJob.h @@ -20,7 +20,8 @@ #pragma once -#include "utils/StdString.h" +#include <string> +#include <vector> #include "utils/Job.h" class CBaseTexture; @@ -61,7 +62,7 @@ public: class CTextureCacheJob : public CJob { public: - CTextureCacheJob(const CStdString &url, const CStdString &oldHash = ""); + CTextureCacheJob(const std::string &url, const std::string &oldHash = ""); virtual ~CTextureCacheJob(); virtual const char* GetType() const { return kJobTypeCacheImage; }; @@ -75,8 +76,8 @@ public: */ bool CacheTexture(CBaseTexture **texture = NULL); - CStdString m_url; - CStdString m_oldHash; + std::string m_url; + std::string m_oldHash; CTextureDetails m_details; private: friend class CEdenVideoArtUpdater; @@ -86,7 +87,7 @@ private: \param url location of the image \return a hash string for this image */ - static CStdString GetImageHash(const CStdString &url); + static std::string GetImageHash(const std::string &url); /*! \brief Check whether a given URL represents an image that can be updated We currently don't check http:// and https:// URLs for updates, under the assumption that @@ -95,7 +96,7 @@ private: \param url the url to check \return true if the image given by the URL should be checked for updates, false otehrwise */ - bool UpdateableURL(const CStdString &url) const; + bool UpdateableURL(const std::string &url) const; /*! \brief Decode an image URL to the underlying image, width, height and orientation \param url wrapped URL of the image @@ -104,7 +105,7 @@ private: \param additional_info additional information, such as "flipped" to flip horizontally \return URL of the underlying image file. */ - static CStdString DecodeImageURL(const CStdString &url, unsigned int &width, unsigned int &height, std::string &additional_info); + static std::string DecodeImageURL(const std::string &url, unsigned int &width, unsigned int &height, std::string &additional_info); /*! \brief Load an image at a given target size and orientation. @@ -117,9 +118,9 @@ private: \param additional_info extra info for loading, such as whether to flip horizontally. \return a pointer to a CBaseTexture object, NULL if failed. */ - static CBaseTexture *LoadImage(const CStdString &image, unsigned int width, unsigned int height, const std::string &additional_info, bool requirePixels = false); + static CBaseTexture *LoadImage(const std::string &image, unsigned int width, unsigned int height, const std::string &additional_info, bool requirePixels = false); - CStdString m_cachePath; + std::string m_cachePath; }; /* \brief Job class for creating .dds versions of textures @@ -127,13 +128,13 @@ private: class CTextureDDSJob : public CJob { public: - CTextureDDSJob(const CStdString &original); + CTextureDDSJob(const std::string &original); virtual const char* GetType() const { return kJobTypeDDSCompress; }; virtual bool operator==(const CJob *job) const; virtual bool DoWork(); - CStdString m_original; + std::string m_original; }; /* \brief Job class for storing the use count of textures diff --git a/xbmc/TextureDatabase.cpp b/xbmc/TextureDatabase.cpp index 2af5ec8fc1..0e5b6df827 100644 --- a/xbmc/TextureDatabase.cpp +++ b/xbmc/TextureDatabase.cpp @@ -118,7 +118,7 @@ void CTextureRule::GetAvailableFields(std::vector<std::string> &fieldList) fieldList.push_back(fields[i].string); } -CStdString CTextureUtils::GetWrappedImageURL(const CStdString &image, const CStdString &type, const CStdString &options) +std::string CTextureUtils::GetWrappedImageURL(const std::string &image, const std::string &type, const std::string &options) { if (StringUtils::StartsWith(image, "image://")) return image; // already wrapped @@ -135,12 +135,12 @@ CStdString CTextureUtils::GetWrappedImageURL(const CStdString &image, const CStd return url.Get(); } -CStdString CTextureUtils::GetWrappedThumbURL(const CStdString &image) +std::string CTextureUtils::GetWrappedThumbURL(const std::string &image) { return GetWrappedImageURL(image, "", "size=thumb"); } -CStdString CTextureUtils::UnwrapImageURL(const CStdString &image) +std::string CTextureUtils::UnwrapImageURL(const std::string &image) { if (StringUtils::StartsWith(image, "image://")) { @@ -246,18 +246,18 @@ void CTextureDatabase::UpdateTables(int version) bool CTextureDatabase::IncrementUseCount(const CTextureDetails &details) { - CStdString sql = PrepareSQL("UPDATE sizes SET usecount=usecount+1, lastusetime=CURRENT_TIMESTAMP WHERE idtexture=%u AND width=%u AND height=%u", details.id, details.width, details.height); + std::string sql = PrepareSQL("UPDATE sizes SET usecount=usecount+1, lastusetime=CURRENT_TIMESTAMP WHERE idtexture=%u AND width=%u AND height=%u", details.id, details.width, details.height); return ExecuteQuery(sql); } -bool CTextureDatabase::GetCachedTexture(const CStdString &url, CTextureDetails &details) +bool CTextureDatabase::GetCachedTexture(const std::string &url, CTextureDetails &details) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString sql = PrepareSQL("SELECT id, cachedurl, lasthashcheck, imagehash, width, height FROM texture JOIN sizes ON (texture.id=sizes.idtexture AND sizes.size=1) WHERE url='%s'", url.c_str()); + std::string sql = PrepareSQL("SELECT id, cachedurl, lasthashcheck, imagehash, width, height FROM texture JOIN sizes ON (texture.id=sizes.idtexture AND sizes.size=1) WHERE url='%s'", url.c_str()); m_pDS->query(sql.c_str()); if (!m_pDS->eof()) { // have some information @@ -327,24 +327,24 @@ bool CTextureDatabase::GetTextures(CVariant &items, const Filter &filter) return false; } -bool CTextureDatabase::SetCachedTextureValid(const CStdString &url, bool updateable) +bool CTextureDatabase::SetCachedTextureValid(const std::string &url, bool updateable) { - CStdString date = updateable ? CDateTime::GetCurrentDateTime().GetAsDBDateTime() : ""; - CStdString sql = PrepareSQL("UPDATE texture SET lasthashcheck='%s' WHERE url='%s'", date.c_str(), url.c_str()); + std::string date = updateable ? CDateTime::GetCurrentDateTime().GetAsDBDateTime() : ""; + std::string sql = PrepareSQL("UPDATE texture SET lasthashcheck='%s' WHERE url='%s'", date.c_str(), url.c_str()); return ExecuteQuery(sql); } -bool CTextureDatabase::AddCachedTexture(const CStdString &url, const CTextureDetails &details) +bool CTextureDatabase::AddCachedTexture(const std::string &url, const CTextureDetails &details) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString sql = PrepareSQL("DELETE FROM texture WHERE url='%s'", url.c_str()); + std::string sql = PrepareSQL("DELETE FROM texture WHERE url='%s'", url.c_str()); m_pDS->exec(sql.c_str()); - CStdString date = details.updateable ? CDateTime::GetCurrentDateTime().GetAsDBDateTime() : ""; + std::string date = details.updateable ? CDateTime::GetCurrentDateTime().GetAsDBDateTime() : ""; sql = PrepareSQL("INSERT INTO texture (id, url, cachedurl, imagehash, lasthashcheck) VALUES(NULL, '%s', '%s', '%s', '%s')", url.c_str(), details.file.c_str(), details.hash.c_str(), date.c_str()); m_pDS->exec(sql.c_str()); int textureID = (int)m_pDS->lastinsertid(); @@ -360,20 +360,20 @@ bool CTextureDatabase::AddCachedTexture(const CStdString &url, const CTextureDet return true; } -bool CTextureDatabase::ClearCachedTexture(const CStdString &url, CStdString &cacheFile) +bool CTextureDatabase::ClearCachedTexture(const std::string &url, std::string &cacheFile) { std::string id = GetSingleValue(PrepareSQL("select id from texture where url='%s'", url.c_str())); return !id.empty() ? ClearCachedTexture(strtol(id.c_str(), NULL, 10), cacheFile) : false; } -bool CTextureDatabase::ClearCachedTexture(int id, CStdString &cacheFile) +bool CTextureDatabase::ClearCachedTexture(int id, std::string &cacheFile) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString sql = PrepareSQL("select cachedurl from texture where id=%u", id); + std::string sql = PrepareSQL("select cachedurl from texture where id=%u", id); m_pDS->query(sql.c_str()); if (!m_pDS->eof()) @@ -394,14 +394,14 @@ bool CTextureDatabase::ClearCachedTexture(int id, CStdString &cacheFile) return false; } -bool CTextureDatabase::InvalidateCachedTexture(const CStdString &url) +bool CTextureDatabase::InvalidateCachedTexture(const std::string &url) { - CStdString date = (CDateTime::GetCurrentDateTime() - CDateTimeSpan(2, 0, 0, 0)).GetAsDBDateTime(); - CStdString sql = PrepareSQL("UPDATE texture SET lasthashcheck='%s' WHERE url='%s'", date.c_str(), url.c_str()); + std::string date = (CDateTime::GetCurrentDateTime() - CDateTimeSpan(2, 0, 0, 0)).GetAsDBDateTime(); + std::string sql = PrepareSQL("UPDATE texture SET lasthashcheck='%s' WHERE url='%s'", date.c_str(), url.c_str()); return ExecuteQuery(sql); } -CStdString CTextureDatabase::GetTextureForPath(const CStdString &url, const CStdString &type) +std::string CTextureDatabase::GetTextureForPath(const std::string &url, const std::string &type) { try { @@ -411,12 +411,12 @@ CStdString CTextureDatabase::GetTextureForPath(const CStdString &url, const CStd if (url.empty()) return ""; - CStdString sql = PrepareSQL("select texture from path where url='%s' and type='%s'", url.c_str(), type.c_str()); + std::string sql = PrepareSQL("select texture from path where url='%s' and type='%s'", url.c_str(), type.c_str()); m_pDS->query(sql.c_str()); if (!m_pDS->eof()) { // have some information - CStdString texture = m_pDS->fv(0).get_asString(); + std::string texture = m_pDS->fv(0).get_asString(); m_pDS->close(); return texture; } @@ -429,7 +429,7 @@ CStdString CTextureDatabase::GetTextureForPath(const CStdString &url, const CStd return ""; } -void CTextureDatabase::SetTextureForPath(const CStdString &url, const CStdString &type, const CStdString &texture) +void CTextureDatabase::SetTextureForPath(const std::string &url, const std::string &type, const std::string &texture) { try { @@ -439,7 +439,7 @@ void CTextureDatabase::SetTextureForPath(const CStdString &url, const CStdString if (url.empty()) return; - CStdString sql = PrepareSQL("select id from path where url='%s' and type='%s'", url.c_str(), type.c_str()); + std::string sql = PrepareSQL("select id from path where url='%s' and type='%s'", url.c_str(), type.c_str()); m_pDS->query(sql.c_str()); if (!m_pDS->eof()) { // update @@ -462,14 +462,14 @@ void CTextureDatabase::SetTextureForPath(const CStdString &url, const CStdString return; } -void CTextureDatabase::ClearTextureForPath(const CStdString &url, const CStdString &type) +void CTextureDatabase::ClearTextureForPath(const std::string &url, const std::string &type) { try { if (NULL == m_pDB.get()) return; if (NULL == m_pDS.get()) return; - CStdString sql = PrepareSQL("DELETE FROM path WHERE url='%s' and type='%s'", url.c_str(), type.c_str()); + std::string sql = PrepareSQL("DELETE FROM path WHERE url='%s' and type='%s'", url.c_str(), type.c_str()); m_pDS->exec(sql.c_str()); } catch (...) diff --git a/xbmc/TextureDatabase.h b/xbmc/TextureDatabase.h index 0bb84022ef..35716d253a 100644 --- a/xbmc/TextureDatabase.h +++ b/xbmc/TextureDatabase.h @@ -54,15 +54,15 @@ public: \param options which options we need (eg size=thumb) \return full wrapped URL of the image file */ - static CStdString GetWrappedImageURL(const CStdString &image, const CStdString &type = "", const CStdString &options = ""); - static CStdString GetWrappedThumbURL(const CStdString &image); + static std::string GetWrappedImageURL(const std::string &image, const std::string &type = "", const std::string &options = ""); + static std::string GetWrappedThumbURL(const std::string &image); /*! \brief Unwrap an image://<url_encoded_path> style URL Such urls are used for art over the webserver or other users of the VFS \param image url of the image \return the unwrapped URL, or the original URL if unwrapping is inappropriate. */ - static CStdString UnwrapImageURL(const CStdString &image); + static std::string UnwrapImageURL(const std::string &image); }; class CTextureDatabase : public CDatabase, public IDatabaseQueryRuleFactory @@ -72,11 +72,11 @@ public: virtual ~CTextureDatabase(); virtual bool Open(); - bool GetCachedTexture(const CStdString &originalURL, CTextureDetails &details); - bool AddCachedTexture(const CStdString &originalURL, const CTextureDetails &details); - bool SetCachedTextureValid(const CStdString &originalURL, bool updateable); - bool ClearCachedTexture(const CStdString &originalURL, CStdString &cacheFile); - bool ClearCachedTexture(int textureID, CStdString &cacheFile); + bool GetCachedTexture(const std::string &originalURL, CTextureDetails &details); + bool AddCachedTexture(const std::string &originalURL, const CTextureDetails &details); + bool SetCachedTextureValid(const std::string &originalURL, bool updateable); + bool ClearCachedTexture(const std::string &originalURL, std::string &cacheFile); + bool ClearCachedTexture(int textureID, std::string &cacheFile); bool IncrementUseCount(const CTextureDetails &details); /*! \brief Invalidate a previously cached texture @@ -84,7 +84,7 @@ public: next texture load it will be re-cached. \param url texture path */ - bool InvalidateCachedTexture(const CStdString &originalURL); + bool InvalidateCachedTexture(const std::string &originalURL); /*! \brief Get a texture associated with the given path Used for retrieval of previously discovered images to save @@ -93,7 +93,7 @@ public: \param type type of image to look for \return URL of the texture associated with the given path */ - CStdString GetTextureForPath(const CStdString &url, const CStdString &type); + std::string GetTextureForPath(const std::string &url, const std::string &type); /*! \brief Set a texture associated with the given path Used for setting of previously discovered images to save @@ -104,7 +104,7 @@ public: \param type type of image to associate \param texture URL of the texture to associate with the path */ - void SetTextureForPath(const CStdString &url, const CStdString &type, const CStdString &texture); + void SetTextureForPath(const std::string &url, const std::string &type, const std::string &texture); /*! \brief Clear a texture associated with the given path \param url path that was used to find the texture @@ -112,7 +112,7 @@ public: \param texture URL of the texture to associate with the path \sa GetTextureForPath, SetTextureForPath */ - void ClearTextureForPath(const CStdString &url, const CStdString &type); + void ClearTextureForPath(const std::string &url, const std::string &type); bool GetTextures(CVariant &items, const Filter &filter); @@ -125,7 +125,7 @@ protected: \param url url to hash \return a hash for this url */ - unsigned int GetURLHash(const CStdString &url) const; + unsigned int GetURLHash(const std::string &url) const; virtual void CreateTables(); virtual void CreateAnalytics(); diff --git a/xbmc/ThumbLoader.cpp b/xbmc/ThumbLoader.cpp index 4aa7b2c0ef..9855e198c9 100644 --- a/xbmc/ThumbLoader.cpp +++ b/xbmc/ThumbLoader.cpp @@ -47,18 +47,18 @@ void CThumbLoader::OnLoaderFinish() m_textureDatabase->Close(); } -CStdString CThumbLoader::GetCachedImage(const CFileItem &item, const CStdString &type) +std::string CThumbLoader::GetCachedImage(const CFileItem &item, const std::string &type) { if (!item.GetPath().empty() && m_textureDatabase->Open()) { - CStdString image = m_textureDatabase->GetTextureForPath(item.GetPath(), type); + std::string image = m_textureDatabase->GetTextureForPath(item.GetPath(), type); m_textureDatabase->Close(); return image; } return ""; } -void CThumbLoader::SetCachedImage(const CFileItem &item, const CStdString &type, const CStdString &image) +void CThumbLoader::SetCachedImage(const CFileItem &item, const std::string &type, const std::string &image) { if (!item.GetPath().empty() && m_textureDatabase->Open()) { @@ -99,7 +99,7 @@ bool CProgramThumbLoader::LoadItemLookup(CFileItem *pItem) bool CProgramThumbLoader::FillThumb(CFileItem &item) { // no need to do anything if we already have a thumb set - CStdString thumb = item.GetArt("thumb"); + std::string thumb = item.GetArt("thumb"); if (thumb.empty()) { // see whether we have a cached image for this item @@ -120,7 +120,7 @@ bool CProgramThumbLoader::FillThumb(CFileItem &item) return true; } -CStdString CProgramThumbLoader::GetLocalThumb(const CFileItem &item) +std::string CProgramThumbLoader::GetLocalThumb(const CFileItem &item) { if (item.IsAddonsPath()) return ""; @@ -128,13 +128,13 @@ CStdString CProgramThumbLoader::GetLocalThumb(const CFileItem &item) // look for the thumb if (item.m_bIsFolder) { - CStdString folderThumb = item.GetFolderThumb(); + std::string folderThumb = item.GetFolderThumb(); if (CFile::Exists(folderThumb)) return folderThumb; } else { - CStdString fileThumb(item.GetTBNFile()); + std::string fileThumb(item.GetTBNFile()); if (CFile::Exists(fileThumb)) return fileThumb; } diff --git a/xbmc/ThumbLoader.h b/xbmc/ThumbLoader.h index a5ee38bcba..bc497a43eb 100644 --- a/xbmc/ThumbLoader.h +++ b/xbmc/ThumbLoader.h @@ -20,7 +20,7 @@ */ #include "BackgroundInfoLoader.h" -#include "utils/StdString.h" +#include <string> class CTextureDatabase; @@ -44,14 +44,14 @@ public: \param type the type of image to retrieve \return the image associated with this item */ - virtual CStdString GetCachedImage(const CFileItem &item, const CStdString &type); + virtual std::string GetCachedImage(const CFileItem &item, const std::string &type); /*! \brief Associate an image with the given item in the texture database \param item CFileItem to associate the image with \param type the type of image \param image the URL of the image */ - virtual void SetCachedImage(const CFileItem &item, const CStdString &type, const CStdString &image); + virtual void SetCachedImage(const CFileItem &item, const std::string &type, const std::string &image); protected: CTextureDatabase *m_textureDatabase; @@ -81,5 +81,5 @@ public: \return the local thumb (if it exists) \sa FillThumb */ - static CStdString GetLocalThumb(const CFileItem &item); + static std::string GetLocalThumb(const CFileItem &item); }; diff --git a/xbmc/URL.cpp b/xbmc/URL.cpp index ed4549dd4c..6b13a57ed4 100644 --- a/xbmc/URL.cpp +++ b/xbmc/URL.cpp @@ -19,6 +19,7 @@ */ #include "URL.h" +#include "Application.h" #include "utils/RegExp.h" #include "utils/log.h" #include "utils/URIUtils.h" @@ -29,6 +30,7 @@ #include "filesystem/StackDirectory.h" #include "addons/Addon.h" #include "utils/StringUtils.h" +#include "network/Network.h" #ifndef TARGET_POSIX #include <sys\types.h> #include <sys\stat.h> @@ -679,14 +681,12 @@ std::string CURL::GetRedacted(const std::string& path) bool CURL::IsLocal() const { - return (IsLocalHost() || m_strProtocol.empty()); + return (m_strProtocol.empty() || IsLocalHost()); } bool CURL::IsLocalHost() const { - // localhost is case-insensitive - return (StringUtils::EqualsNoCase(m_strHostName, "localhost") || - m_strHostName == "127.0.0.1"); + return g_application.getNetwork().IsLocalHost(m_strHostName); } bool CURL::IsFileOnly(const std::string &url) diff --git a/xbmc/Util.cpp b/xbmc/Util.cpp index 1760beb010..4bb7fe4df5 100644 --- a/xbmc/Util.cpp +++ b/xbmc/Util.cpp @@ -131,20 +131,20 @@ CUtil::CUtil(void) CUtil::~CUtil(void) {} -CStdString CUtil::GetTitleFromPath(const CStdString& strFileNameAndPath, bool bIsFolder /* = false */) +std::string CUtil::GetTitleFromPath(const std::string& strFileNameAndPath, bool bIsFolder /* = false */) { CURL pathToUrl(strFileNameAndPath); return GetTitleFromPath(pathToUrl, bIsFolder); } -CStdString CUtil::GetTitleFromPath(const CURL& url, bool bIsFolder /* = false */) +std::string CUtil::GetTitleFromPath(const CURL& url, bool bIsFolder /* = false */) { // use above to get the filename - CStdString path(url.Get()); + std::string path(url.Get()); URIUtils::RemoveSlashAtEnd(path); - CStdString strFilename = URIUtils::GetFileName(path); + std::string strFilename = URIUtils::GetFileName(path); - CStdString strHostname = url.GetHostName(); + std::string strHostname = url.GetHostName(); #ifdef HAS_UPNP // UPNP @@ -163,7 +163,7 @@ CStdString CUtil::GetTitleFromPath(const CURL& url, bool bIsFolder /* = false */ // Shoutcast else if (url.IsProtocol("shout")) { - const CStdString strFileNameAndPath = url.Get(); + const std::string strFileNameAndPath = url.Get(); const int genre = strFileNameAndPath.find_first_of('='); if(genre <0) strFilename = g_localizeStrings.Get(260); @@ -349,14 +349,14 @@ void CUtil::GetQualifiedFilename(const std::string &strBasePath, std::string &st size_t pos; while ((pos = strFilename.find("/../")) != std::string::npos) { - CStdString basePath = strFilename.substr(0, pos + 1); + std::string basePath = strFilename.substr(0, pos + 1); strFilename.erase(0, pos + 4); basePath = URIUtils::GetParentPath(basePath); strFilename = URIUtils::AddFileToFolder(basePath, strFilename); } while ((pos = strFilename.find("\\..\\")) != std::string::npos) { - CStdString basePath = strFilename.substr(0, pos + 1); + std::string basePath = strFilename.substr(0, pos + 1); strFilename.erase(0, pos + 4); basePath = URIUtils::GetParentPath(basePath); strFilename = URIUtils::AddFileToFolder(basePath, strFilename); @@ -366,7 +366,7 @@ void CUtil::GetQualifiedFilename(const std::string &strBasePath, std::string &st #ifdef UNIT_TESTING bool CUtil::TestGetQualifiedFilename() { - CStdString file = "../foo"; GetQualifiedFilename("smb://", file); + std::string file = "../foo"; GetQualifiedFilename("smb://", file); if (file != "foo") return false; file = "C:\\foo\\bar"; GetQualifiedFilename("smb://", file); if (file != "C:\\foo\\bar") return false; @@ -379,7 +379,7 @@ bool CUtil::TestGetQualifiedFilename() bool CUtil::TestMakeLegalPath() { - CStdString path; + std::string path; #ifdef TARGET_WINDOWS path = "C:\\foo\\bar"; path = MakeLegalPath(path); if (path != "C:\\foo\\bar") return false; @@ -414,14 +414,14 @@ void CUtil::GetHomePath(std::string& strPath, const std::string& strTarget) if (strPath.find("..") != std::string::npos) { //expand potential relative path to full path - CStdStringW strPathW; + std::wstring strPathW; g_charsetConverter.utf8ToW(strPath, strPathW, false); CWIN32Util::AddExtraLongPathPrefix(strPathW); - const unsigned int bufSize = GetFullPathNameW(strPathW, 0, NULL, NULL); + const unsigned int bufSize = GetFullPathNameW(strPathW.c_str(), 0, NULL, NULL); if (bufSize != 0) { wchar_t * buf = new wchar_t[bufSize]; - if (GetFullPathNameW(strPathW, bufSize, buf, NULL) <= bufSize-1) + if (GetFullPathNameW(strPathW.c_str(), bufSize, buf, NULL) <= bufSize-1) { std::wstring expandedPathW(buf); CWIN32Util::RemoveExtraLongPathPrefix(expandedPathW); @@ -483,7 +483,7 @@ void CUtil::GetHomePath(std::string& strPath, const std::string& strTarget) if (strTarget.empty() && installPath.compare(binInstallPath)) { int pos = strPath.length() - binInstallPath.length(); - CStdString tmp = strPath; + std::string tmp = strPath; tmp.erase(0, pos); if (!tmp.compare(binInstallPath)) { @@ -494,17 +494,17 @@ void CUtil::GetHomePath(std::string& strPath, const std::string& strTarget) #endif } -bool CUtil::IsPVR(const CStdString& strFile) +bool CUtil::IsPVR(const std::string& strFile) { return StringUtils::StartsWithNoCase(strFile, "pvr:"); } -bool CUtil::IsHTSP(const CStdString& strFile) +bool CUtil::IsHTSP(const std::string& strFile) { return StringUtils::StartsWithNoCase(strFile, "htsp:"); } -bool CUtil::IsLiveTV(const CStdString& strFile) +bool CUtil::IsLiveTV(const std::string& strFile) { if (StringUtils::StartsWithNoCase(strFile, "pvr://channels")) return true; @@ -522,18 +522,18 @@ bool CUtil::IsLiveTV(const CStdString& strFile) return false; } -bool CUtil::IsTVRecording(const CStdString& strFile) +bool CUtil::IsTVRecording(const std::string& strFile) { return StringUtils::StartsWithNoCase(strFile, "pvr://recording"); } -bool CUtil::IsPicture(const CStdString& strFile) +bool CUtil::IsPicture(const std::string& strFile) { return URIUtils::HasExtension(strFile, g_advancedSettings.m_pictureExtensions + "|.tbn|.dds"); } -bool CUtil::ExcludeFileOrFolder(const CStdString& strFileOrFolder, const vector<string>& regexps) +bool CUtil::ExcludeFileOrFolder(const std::string& strFileOrFolder, const vector<string>& regexps) { if (strFileOrFolder.empty()) return false; @@ -556,7 +556,7 @@ bool CUtil::ExcludeFileOrFolder(const CStdString& strFileOrFolder, const vector< return false; } -void CUtil::GetFileAndProtocol(const CStdString& strURL, CStdString& strDir) +void CUtil::GetFileAndProtocol(const std::string& strURL, std::string& strDir) { strDir = strURL; if (!URIUtils::IsRemote(strURL)) return ; @@ -566,18 +566,18 @@ void CUtil::GetFileAndProtocol(const CStdString& strURL, CStdString& strDir) strDir = StringUtils::Format("%s://%s", url.GetProtocol().c_str(), url.GetFileName().c_str()); } -int CUtil::GetDVDIfoTitle(const CStdString& strFile) +int CUtil::GetDVDIfoTitle(const std::string& strFile) { - CStdString strFilename = URIUtils::GetFileName(strFile); - if (strFilename.Equals("video_ts.ifo")) return 0; + std::string strFilename = URIUtils::GetFileName(strFile); + if (StringUtils::EqualsNoCase(strFilename, "video_ts.ifo")) return 0; //VTS_[TITLE]_0.IFO return atoi(strFilename.substr(4, 2).c_str()); } -CStdString CUtil::GetFileMD5(const CStdString& strPath) +std::string CUtil::GetFileMD5(const std::string& strPath) { CFile file; - CStdString result; + std::string result; if (file.Open(strPath)) { XBMC::XBMC_MD5 md5; @@ -596,9 +596,9 @@ CStdString CUtil::GetFileMD5(const CStdString& strPath) return result; } -bool CUtil::GetDirectoryName(const CStdString& strFileName, CStdString& strDescription) +bool CUtil::GetDirectoryName(const std::string& strFileName, std::string& strDescription) { - CStdString strFName = URIUtils::GetFileName(strFileName); + std::string strFName = URIUtils::GetFileName(strFileName); strDescription = URIUtils::GetDirectory(strFileName); URIUtils::RemoveSlashAtEnd(strDescription); @@ -647,7 +647,7 @@ void CUtil::GetDVDDriveIcon(const std::string& strPath, std::string& strIcon) void CUtil::RemoveTempFiles() { - CStdString searchPath = CProfilesManager::Get().GetDatabaseFolder(); + std::string searchPath = CProfilesManager::Get().GetDatabaseFolder(); CFileItemList items; if (!XFILE::CDirectory::GetDirectory(searchPath, items, ".tmp", DIR_FLAG_NO_FILE_DIRS)) return; @@ -681,7 +681,7 @@ void CUtil::ClearSubtitles() void CUtil::ClearTempFonts() { - CStdString searchPath = "special://temp/fonts/"; + std::string searchPath = "special://temp/fonts/"; if (!CDirectory::Exists(searchPath)) return; @@ -708,14 +708,14 @@ int64_t CUtil::ToInt64(uint32_t high, uint32_t low) return n; } -CStdString CUtil::GetNextFilename(const CStdString &fn_template, int max) +std::string CUtil::GetNextFilename(const std::string &fn_template, int max) { if (fn_template.find("%03d") == std::string::npos) return ""; - CStdString searchPath = URIUtils::GetDirectory(fn_template); - CStdString mask = URIUtils::GetExtension(fn_template); - CStdString name = StringUtils::Format(fn_template.c_str(), 0); + std::string searchPath = URIUtils::GetDirectory(fn_template); + std::string mask = URIUtils::GetExtension(fn_template); + std::string name = StringUtils::Format(fn_template.c_str(), 0); CFileItemList items; if (!CDirectory::GetDirectory(searchPath, items, mask, DIR_FLAG_NO_FILE_DIRS)) @@ -724,21 +724,21 @@ CStdString CUtil::GetNextFilename(const CStdString &fn_template, int max) items.SetFastLookup(true); for (int i = 0; i <= max; i++) { - CStdString name = StringUtils::Format(fn_template.c_str(), i); + std::string name = StringUtils::Format(fn_template.c_str(), i); if (!items.Get(name)) return name; } return ""; } -CStdString CUtil::GetNextPathname(const CStdString &path_template, int max) +std::string CUtil::GetNextPathname(const std::string &path_template, int max) { if (path_template.find("%04d") == std::string::npos) return ""; for (int i = 0; i <= max; i++) { - CStdString name = StringUtils::Format(path_template.c_str(), i); + std::string name = StringUtils::Format(path_template.c_str(), i); if (!CFile::Exists(name) && !CDirectory::Exists(name)) return name; } @@ -885,7 +885,7 @@ void CUtil::Stat64ToStat64i32(struct _stat64i32 *result, struct __stat64 *stat) } #endif -bool CUtil::CreateDirectoryEx(const CStdString& strPath) +bool CUtil::CreateDirectoryEx(const std::string& strPath) { // Function to create all directories at once instead // of calling CreateDirectory for every subdir. @@ -904,7 +904,7 @@ bool CUtil::CreateDirectoryEx(const CStdString& strPath) vector<string> dirs = URIUtils::SplitPath(strPath); if (dirs.empty()) return false; - CStdString dir(dirs.front()); + std::string dir(dirs.front()); URIUtils::AddSlashAtEnd(dir); for (vector<string>::const_iterator it = dirs.begin() + 1; it != dirs.end(); it ++) { @@ -917,9 +917,9 @@ bool CUtil::CreateDirectoryEx(const CStdString& strPath) return true; } -CStdString CUtil::MakeLegalFileName(const CStdString &strFile, int LegalType) +std::string CUtil::MakeLegalFileName(const std::string &strFile, int LegalType) { - CStdString result = strFile; + std::string result = strFile; StringUtils::Replace(result, '/', '_'); StringUtils::Replace(result, '\\', '_'); @@ -941,7 +941,7 @@ CStdString CUtil::MakeLegalFileName(const CStdString &strFile, int LegalType) } // legalize entire path -CStdString CUtil::MakeLegalPath(const CStdString &strPathAndFile, int LegalType) +std::string CUtil::MakeLegalPath(const std::string &strPathAndFile, int LegalType) { if (URIUtils::IsStack(strPathAndFile)) return MakeLegalPath(CStackDirectory::GetFirstStackedFile(strPathAndFile)); @@ -957,7 +957,7 @@ CStdString CUtil::MakeLegalPath(const CStdString &strPathAndFile, int LegalType) // we just add first token to path and don't legalize it - possible values: // "X:" (local win32), "" (local unix - empty string before '/') or // "protocol://domain" - CStdString dir(dirs.front()); + std::string dir(dirs.front()); URIUtils::AddSlashAtEnd(dir); for (vector<string>::const_iterator it = dirs.begin() + 1; it != dirs.end(); it ++) dir = URIUtils::AddFileToFolder(dir, MakeLegalFileName(*it, LegalType)); @@ -965,9 +965,9 @@ CStdString CUtil::MakeLegalPath(const CStdString &strPathAndFile, int LegalType) return dir; } -CStdString CUtil::ValidatePath(const CStdString &path, bool bFixDoubleSlashes /* = false */) +std::string CUtil::ValidatePath(const std::string &path, bool bFixDoubleSlashes /* = false */) { - CStdString result = path; + std::string result = path; // Don't do any stuff on URLs containing %-characters or protocols that embed // filenames. NOTE: Don't use IsInZip or IsInRar here since it will infinitely @@ -1030,8 +1030,8 @@ bool CUtil::IsUsingTTFSubtitles() #ifdef UNIT_TESTING bool CUtil::TestSplitExec() { - CStdString function; - vector<CStdString> params; + std::string function; + vector<std::string> params; CUtil::SplitExecFunction("ActivateWindow(Video, \"C:\\test\\foo\")", function, params); if (function != "ActivateWindow" || params.size() != 2 || params[0] != "Video" || params[1] != "C:\\test\\foo") return false; @@ -1077,13 +1077,13 @@ void CUtil::SplitExecFunction(const std::string &execString, std::string &functi SplitParams(paramString, parameters); } -void CUtil::SplitParams(const CStdString ¶mString, std::vector<std::string> ¶meters) +void CUtil::SplitParams(const std::string ¶mString, std::vector<std::string> ¶meters) { bool inQuotes = false; bool lastEscaped = false; // only every second character can be escaped int inFunction = 0; size_t whiteSpacePos = 0; - CStdString parameter; + std::string parameter; parameters.clear(); for (size_t pos = 0; pos < paramString.size(); pos++) { @@ -1172,13 +1172,13 @@ void CUtil::SplitParams(const CStdString ¶mString, std::vector<std::string> parameters.push_back(parameter); } -int CUtil::GetMatchingSource(const CStdString& strPath1, VECSOURCES& VECSOURCES, bool& bIsSourceName) +int CUtil::GetMatchingSource(const std::string& strPath1, VECSOURCES& VECSOURCES, bool& bIsSourceName) { if (strPath1.empty()) return -1; // copy as we may change strPath - CStdString strPath = strPath1; + std::string strPath = strPath1; // Check for special protocols CURL checkURL(strPath); @@ -1206,7 +1206,7 @@ int CUtil::GetMatchingSource(const CStdString& strPath1, VECSOURCES& VECSOURCES, for (int i = 0; i < (int)VECSOURCES.size(); ++i) { CMediaSource share = VECSOURCES.at(i); - CStdString strName = share.strName; + std::string strName = share.strName; // special cases for dvds if (URIUtils::IsOnDVD(share.strPath)) @@ -1221,7 +1221,7 @@ int CUtil::GetMatchingSource(const CStdString& strPath1, VECSOURCES& VECSOURCES, if (iPos != std::string::npos && iPos > 1) strName = strName.substr(0, iPos - 1); } - if (strPath.Equals(strName)) + if (StringUtils::EqualsNoCase(strPath, strName)) { bIsSourceName = true; return i; @@ -1234,7 +1234,7 @@ int CUtil::GetMatchingSource(const CStdString& strPath1, VECSOURCES& VECSOURCES, // and ends with a trailing slash so as not to match a substring CURL urlDest(strPath); urlDest.SetOptions(""); - CStdString strDest = urlDest.GetWithoutUserDetails(); + std::string strDest = urlDest.GetWithoutUserDetails(); ForceForwardSlashes(strDest); if (!URIUtils::HasSlashAtEnd(strDest)) strDest += "/"; @@ -1270,7 +1270,7 @@ int CUtil::GetMatchingSource(const CStdString& strPath1, VECSOURCES& VECSOURCES, // and ends with a trailing slash so as not to match a substring CURL urlShare(vecPaths[j]); urlShare.SetOptions(""); - CStdString strShare = urlShare.GetWithoutUserDetails(); + std::string strShare = urlShare.GetWithoutUserDetails(); ForceForwardSlashes(strShare); if (!URIUtils::HasSlashAtEnd(strShare)) strShare += "/"; @@ -1315,7 +1315,7 @@ int CUtil::GetMatchingSource(const CStdString& strPath1, VECSOURCES& VECSOURCES, return iIndex; } -CStdString CUtil::TranslateSpecialSource(const CStdString &strSpecial) +std::string CUtil::TranslateSpecialSource(const std::string &strSpecial) { if (!strSpecial.empty() && strSpecial[0] == '$') { @@ -1346,7 +1346,7 @@ CStdString CUtil::TranslateSpecialSource(const CStdString &strSpecial) return strSpecial; } -CStdString CUtil::MusicPlaylistsLocation() +std::string CUtil::MusicPlaylistsLocation() { vector<string> vec; vec.push_back(URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "music")); @@ -1354,7 +1354,7 @@ CStdString CUtil::MusicPlaylistsLocation() return XFILE::CMultiPathDirectory::ConstructMultiPath(vec); } -CStdString CUtil::VideoPlaylistsLocation() +std::string CUtil::VideoPlaylistsLocation() { vector<string> vec; vec.push_back(URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "video")); @@ -1374,9 +1374,9 @@ void CUtil::DeleteVideoDatabaseDirectoryCache() CUtil::DeleteDirectoryCache("sp-"); // overkill as it will delete music smartplaylists, but as we can't differentiate based on URL... } -void CUtil::DeleteDirectoryCache(const CStdString &prefix) +void CUtil::DeleteDirectoryCache(const std::string &prefix) { - CStdString searchPath = "special://temp/"; + std::string searchPath = "special://temp/"; CFileItemList items; if (!XFILE::CDirectory::GetDirectory(searchPath, items, ".fi", DIR_FLAG_NO_FILE_DIRS)) return; @@ -1385,14 +1385,14 @@ void CUtil::DeleteDirectoryCache(const CStdString &prefix) { if (items[i]->m_bIsFolder) continue; - CStdString fileName = URIUtils::GetFileName(items[i]->GetPath()); + std::string fileName = URIUtils::GetFileName(items[i]->GetPath()); if (StringUtils::StartsWith(fileName, prefix)) XFILE::CFile::Delete(items[i]->GetPath()); } } -void CUtil::GetRecursiveListing(const CStdString& strPath, CFileItemList& items, const CStdString& strMask, unsigned int flags /* = DIR_FLAG_DEFAULTS */) +void CUtil::GetRecursiveListing(const std::string& strPath, CFileItemList& items, const std::string& strMask, unsigned int flags /* = DIR_FLAG_DEFAULTS */) { CFileItemList myItems; CDirectory::GetDirectory(strPath,myItems,strMask,flags); @@ -1405,7 +1405,7 @@ void CUtil::GetRecursiveListing(const CStdString& strPath, CFileItemList& items, } } -void CUtil::GetRecursiveDirsListing(const CStdString& strPath, CFileItemList& item, unsigned int flags /* = DIR_FLAG_DEFAULTS */) +void CUtil::GetRecursiveDirsListing(const std::string& strPath, CFileItemList& item, unsigned int flags /* = DIR_FLAG_DEFAULTS */) { CFileItemList myItems; CDirectory::GetDirectory(strPath,myItems,"",flags); @@ -1419,7 +1419,7 @@ void CUtil::GetRecursiveDirsListing(const CStdString& strPath, CFileItemList& it } } -void CUtil::ForceForwardSlashes(CStdString& strPath) +void CUtil::ForceForwardSlashes(std::string& strPath) { size_t iPos = strPath.rfind('\\'); while (iPos != string::npos) @@ -1429,24 +1429,24 @@ void CUtil::ForceForwardSlashes(CStdString& strPath) } } -double CUtil::AlbumRelevance(const CStdString& strAlbumTemp1, const CStdString& strAlbum1, const CStdString& strArtistTemp1, const CStdString& strArtist1) +double CUtil::AlbumRelevance(const std::string& strAlbumTemp1, const std::string& strAlbum1, const std::string& strArtistTemp1, const std::string& strArtist1) { // case-insensitive fuzzy string comparison on the album and artist for relevance // weighting is identical, both album and artist are 50% of the total relevance // a missing artist means the maximum relevance can only be 0.50 - CStdString strAlbumTemp = strAlbumTemp1; + std::string strAlbumTemp = strAlbumTemp1; StringUtils::ToLower(strAlbumTemp); - CStdString strAlbum = strAlbum1; + std::string strAlbum = strAlbum1; StringUtils::ToLower(strAlbum); - double fAlbumPercentage = fstrcmp(strAlbumTemp, strAlbum, 0.0f); + double fAlbumPercentage = fstrcmp(strAlbumTemp.c_str(), strAlbum.c_str(), 0.0f); double fArtistPercentage = 0.0f; if (!strArtist1.empty()) { - CStdString strArtistTemp = strArtistTemp1; + std::string strArtistTemp = strArtistTemp1; StringUtils::ToLower(strArtistTemp); - CStdString strArtist = strArtist1; + std::string strArtist = strArtist1; StringUtils::ToLower(strArtist); - fArtistPercentage = fstrcmp(strArtistTemp, strArtist, 0.0f); + fArtistPercentage = fstrcmp(strArtistTemp.c_str(), strArtist.c_str(), 0.0f); } double fRelevance = fAlbumPercentage * 0.5f + fArtistPercentage * 0.5f; return fRelevance; @@ -1484,7 +1484,7 @@ bool CUtil::MakeShortenPath(std::string StrInput, std::string& StrOutput, size_t nGreaterDelim = nPos; if ( nPos != std::string::npos ) nPos = StrInput.find_last_of( cDelim, nPos - 1 ); - if ( nPos == CStdString::npos ) break; + if ( nPos == std::string::npos ) break; if ( nGreaterDelim > nPos ) StrInput.replace( nPos + 1, nGreaterDelim - nPos - 1, ".." ); iStrInputSize = StrInput.size(); } @@ -1507,7 +1507,7 @@ bool CUtil::MakeShortenPath(std::string StrInput, std::string& StrOutput, size_t return true; } -bool CUtil::SupportsWriteFileOperations(const CStdString& strPath) +bool CUtil::SupportsWriteFileOperations(const std::string& strPath) { // currently only hd, smb, nfs, afp and dav support delete and rename if (URIUtils::IsHD(strPath)) @@ -1539,7 +1539,7 @@ bool CUtil::SupportsWriteFileOperations(const CStdString& strPath) return false; } -bool CUtil::SupportsReadFileOperations(const CStdString& strPath) +bool CUtil::SupportsReadFileOperations(const std::string& strPath) { if (URIUtils::IsVideoDb(strPath)) return false; @@ -1547,7 +1547,7 @@ bool CUtil::SupportsReadFileOperations(const CStdString& strPath) return true; } -CStdString CUtil::GetDefaultFolderThumb(const CStdString &folderThumb) +std::string CUtil::GetDefaultFolderThumb(const std::string &folderThumb) { if (g_TextureManager.HasTexture(folderThumb)) return folderThumb; @@ -1565,7 +1565,7 @@ void CUtil::GetSkinThemes(vector<std::string>& vecTheme) CFileItemPtr pItem = items[i]; if (!pItem->m_bIsFolder) { - CStdString strExtension = URIUtils::GetExtension(pItem->GetPath()); + std::string strExtension = URIUtils::GetExtension(pItem->GetPath()); if ((strExtension == ".xpr" && !StringUtils::EqualsNoCase(pItem->GetLabel(), "Textures.xpr")) || (strExtension == ".xbt" && !StringUtils::EqualsNoCase(pItem->GetLabel(), "Textures.xbt"))) { @@ -1588,7 +1588,7 @@ void CUtil::InitRandomSeed() } #ifdef TARGET_POSIX -bool CUtil::RunCommandLine(const CStdString& cmdLine, bool waitExit) +bool CUtil::RunCommandLine(const std::string& cmdLine, bool waitExit) { vector<string> args = StringUtils::Split(cmdLine, ","); @@ -1614,9 +1614,6 @@ bool CUtil::RunCommandLine(const CStdString& cmdLine, bool waitExit) return Command(args, waitExit); } -// -// FIXME, this should be merged with the function below. -// bool CUtil::Command(const std::vector<std::string>& arrArgs, bool waitExit) { #ifdef _DEBUG @@ -1658,36 +1655,6 @@ bool CUtil::Command(const std::vector<std::string>& arrArgs, bool waitExit) return (waitExit) ? (WEXITSTATUS(n) == 0) : true; } - -bool CUtil::SudoCommand(const CStdString &strCommand) -{ - CLog::Log(LOGDEBUG, "Executing sudo command: <%s>", strCommand.c_str()); - pid_t child = fork(); - int n = 0; - if (child == 0) - { - close(0); // close stdin to avoid sudo request password - close(1); - close(2); - vector<string> arrArgs = StringUtils::Split(strCommand, " "); - if (arrArgs.size() > 0) - { - char **args = (char **)alloca(sizeof(char *) * (arrArgs.size() + 3)); - memset(args, 0, (sizeof(char *) * (arrArgs.size() + 3))); - args[0] = (char *)"/usr/bin/sudo"; - args[1] = (char *)"-S"; - for (size_t i=0; i<arrArgs.size(); i++) - { - args[i+2] = (char *)arrArgs[i].c_str(); - } - execvp("/usr/bin/sudo", args); - } - } - else - waitpid(child, &n, 0); - - return WEXITSTATUS(n) == 0; -} #endif int CUtil::LookupRomanDigit(char roman_digit) @@ -1803,9 +1770,9 @@ int CUtil::TranslateRomanNumeral(const char* roman_numeral) return decimal; } -CStdString CUtil::ResolveExecutablePath() +std::string CUtil::ResolveExecutablePath() { - CStdString strExecutablePath; + std::string strExecutablePath; #ifdef TARGET_WINDOWS static const size_t bufSize = MAX_PATH * 2; wchar_t* buf = new wchar_t[bufSize]; @@ -1854,9 +1821,9 @@ CStdString CUtil::ResolveExecutablePath() return strExecutablePath; } -CStdString CUtil::GetFrameworksPath(bool forPython) +std::string CUtil::GetFrameworksPath(bool forPython) { - CStdString strFrameworksPath; + std::string strFrameworksPath; #if defined(TARGET_DARWIN) char given_path[2*MAXPATHLEN]; uint32_t path_size =2*MAXPATHLEN; @@ -2145,7 +2112,7 @@ int CUtil::ScanArchiveForSubtitles( const std::string& strArchivePath, const std if (StringUtils::EqualsNoCase(strExt, sub_exts[iPos])) { CURL pathToURL(strArchivePath); - CStdString strSourceUrl; + std::string strSourceUrl; if (URIUtils::HasExtension(strArchivePath, ".rar")) strSourceUrl = URIUtils::CreateArchivePath("rar", pathToURL, strPathInRar).Get(); else @@ -2163,12 +2130,12 @@ int CUtil::ScanArchiveForSubtitles( const std::string& strArchivePath, const std return nSubtitlesAdded; } -void CUtil::GetExternalStreamDetailsFromFilename(const CStdString& strVideo, const CStdString& strStream, ExternalStreamInfo& info) +void CUtil::GetExternalStreamDetailsFromFilename(const std::string& strVideo, const std::string& strStream, ExternalStreamInfo& info) { - CStdString videoBaseName = URIUtils::GetFileName(strVideo); + std::string videoBaseName = URIUtils::GetFileName(strVideo); URIUtils::RemoveExtension(videoBaseName); - CStdString toParse = URIUtils::GetFileName(strStream); + std::string toParse = URIUtils::GetFileName(strStream); URIUtils::RemoveExtension(toParse); // we check left part - if it's same as video base name - strip it @@ -2196,8 +2163,8 @@ void CUtil::GetExternalStreamDetailsFromFilename(const CStdString& strVideo, con { if (info.language.empty()) { - CStdString langTmp(*it); - CStdString langCode; + std::string langTmp(*it); + std::string langCode; // try to recognize language if (g_LangCodeExpander.ConvertToThreeCharCode(langCode, langTmp)) { @@ -2256,7 +2223,8 @@ bool CUtil::FindVobSubPair(const std::vector<std::string>& vecSubtitles, const s if (URIUtils::IsInArchive(vecSubtitles[j])) strSubDirectory = CURL::Decode(strSubDirectory); if (URIUtils::HasExtension(strSubFile, ".sub") && - (URIUtils::ReplaceExtension(strIdxPath,"").Equals(URIUtils::ReplaceExtension(vecSubtitles[j],"")) || + (URIUtils::PathEquals(URIUtils::ReplaceExtension(strIdxPath,""), + URIUtils::ReplaceExtension(vecSubtitles[j],"")) || (strSubDirectory.size() >= 11 && StringUtils::EqualsNoCase(strSubDirectory.substr(6, strSubDirectory.length()-11), URIUtils::ReplaceExtension(strIdxPath,""))))) { @@ -2285,7 +2253,8 @@ bool CUtil::IsVobSub(const std::vector<std::string>& vecSubtitles, const std::st std::string strIdxDirectory; URIUtils::Split(vecSubtitles[j], strIdxDirectory, strIdxFile); if (URIUtils::HasExtension(strIdxFile, ".idx") && - (URIUtils::ReplaceExtension(vecSubtitles[j],"").Equals(URIUtils::ReplaceExtension(strSubPath,"")) || + (URIUtils::PathEquals(URIUtils::ReplaceExtension(vecSubtitles[j],""), + URIUtils::ReplaceExtension(strSubPath,"")) || (strSubDirectory.size() >= 11 && StringUtils::EqualsNoCase(strSubDirectory.substr(6, strSubDirectory.length()-11), URIUtils::ReplaceExtension(vecSubtitles[j],""))))) return true; diff --git a/xbmc/Util.h b/xbmc/Util.h index 76af6da8d3..4144f47bf7 100644 --- a/xbmc/Util.h +++ b/xbmc/Util.h @@ -39,10 +39,10 @@ class CURL; struct sortstringbyname { - bool operator()(const CStdString& strItem1, const CStdString& strItem2) + bool operator()(const std::string& strItem1, const std::string& strItem2) { - CStdString strLine1 = strItem1; - CStdString strLine2 = strItem2; + std::string strLine1 = strItem1; + std::string strLine2 = strItem2; StringUtils::ToLower(strLine1); StringUtils::ToLower(strLine2); return strcmp(strLine1.c_str(), strLine2.c_str()) < 0; @@ -69,27 +69,27 @@ public: std::string& strYear, bool bRemoveExtension = false, bool bCleanChars = true); - static CStdString GetTitleFromPath(const CURL& url, bool bIsFolder = false); - static CStdString GetTitleFromPath(const CStdString& strFileNameAndPath, bool bIsFolder = false); + static std::string GetTitleFromPath(const CURL& url, bool bIsFolder = false); + static std::string GetTitleFromPath(const std::string& strFileNameAndPath, bool bIsFolder = false); static void GetQualifiedFilename(const std::string &strBasePath, std::string &strFilename); static void RunShortcut(const char* szPath); static void GetHomePath(std::string& strPath, const std::string& strTarget = ""); // default target is "KODI_HOME" - static bool IsPVR(const CStdString& strFile); - static bool IsHTSP(const CStdString& strFile); - static bool IsLiveTV(const CStdString& strFile); - static bool IsTVRecording(const CStdString& strFile); - static bool ExcludeFileOrFolder(const CStdString& strFileOrFolder, const std::vector<std::string>& regexps); - static void GetFileAndProtocol(const CStdString& strURL, CStdString& strDir); - static int GetDVDIfoTitle(const CStdString& strPathFile); + static bool IsPVR(const std::string& strFile); + static bool IsHTSP(const std::string& strFile); + static bool IsLiveTV(const std::string& strFile); + static bool IsTVRecording(const std::string& strFile); + static bool ExcludeFileOrFolder(const std::string& strFileOrFolder, const std::vector<std::string>& regexps); + static void GetFileAndProtocol(const std::string& strURL, std::string& strDir); + static int GetDVDIfoTitle(const std::string& strPathFile); - static bool IsPicture(const CStdString& strFile); + static bool IsPicture(const std::string& strFile); /*! \brief retrieve MD5sum of a file \param strPath - path to the file to MD5sum \return md5 sum of the file */ - static CStdString GetFileMD5(const CStdString& strPath); - static bool GetDirectoryName(const CStdString& strFileName, CStdString& strDescription); + static std::string GetFileMD5(const std::string& strPath); + static bool GetDirectoryName(const std::string& strFileName, std::string& strDescription); static void GetDVDDriveIcon(const std::string& strPath, std::string& strIcon); static void RemoveTempFiles(); static void ClearTempFonts(); @@ -97,14 +97,14 @@ public: static void ClearSubtitles(); static void ScanForExternalSubtitles(const std::string& strMovie, std::vector<std::string>& vecSubtitles ); static int ScanArchiveForSubtitles( const std::string& strArchivePath, const std::string& strMovieFileNameNoExt, std::vector<std::string>& vecSubtitles ); - static void GetExternalStreamDetailsFromFilename(const CStdString& strMovie, const CStdString& strSubtitles, ExternalStreamInfo& info); + static void GetExternalStreamDetailsFromFilename(const std::string& strMovie, const std::string& strSubtitles, ExternalStreamInfo& info); static bool FindVobSubPair( const std::vector<std::string>& vecSubtitles, const std::string& strIdxPath, std::string& strSubPath ); static bool IsVobSub(const std::vector<std::string>& vecSubtitles, const std::string& strSubPath); static std::string GetVobSubSubFromIdx(const std::string& vobSubIdx); static std::string GetVobSubIdxFromSub(const std::string& vobSub); static int64_t ToInt64(uint32_t high, uint32_t low); - static CStdString GetNextFilename(const CStdString &fn_template, int max); - static CStdString GetNextPathname(const CStdString &path_template, int max); + static std::string GetNextFilename(const std::string &fn_template, int max); + static std::string GetNextPathname(const std::string &path_template, int max); static void StatToStatI64(struct _stati64 *result, struct stat *stat); static void StatToStat64(struct __stat64 *result, const struct stat *stat); static void Stat64ToStatI64(struct _stati64 *result, struct __stat64 *stat); @@ -113,16 +113,16 @@ public: #ifdef TARGET_WINDOWS static void Stat64ToStat64i32(struct _stat64i32 *result, struct __stat64 *stat); #endif - static bool CreateDirectoryEx(const CStdString& strPath); + static bool CreateDirectoryEx(const std::string& strPath); #ifdef TARGET_WINDOWS - static CStdString MakeLegalFileName(const CStdString &strFile, int LegalType=LEGAL_WIN32_COMPAT); - static CStdString MakeLegalPath(const CStdString &strPath, int LegalType=LEGAL_WIN32_COMPAT); + static std::string MakeLegalFileName(const std::string &strFile, int LegalType=LEGAL_WIN32_COMPAT); + static std::string MakeLegalPath(const std::string &strPath, int LegalType=LEGAL_WIN32_COMPAT); #else - static CStdString MakeLegalFileName(const CStdString &strFile, int LegalType=LEGAL_NONE); - static CStdString MakeLegalPath(const CStdString &strPath, int LegalType=LEGAL_NONE); + static std::string MakeLegalFileName(const std::string &strFile, int LegalType=LEGAL_NONE); + static std::string MakeLegalPath(const std::string &strPath, int LegalType=LEGAL_NONE); #endif - static CStdString ValidatePath(const CStdString &path, bool bFixDoubleSlashes = false); ///< return a validated path, with correct directory separators. + static std::string ValidatePath(const std::string &path, bool bFixDoubleSlashes = false); ///< return a validated path, with correct directory separators. static bool IsUsingTTFSubtitles(); @@ -141,22 +141,22 @@ public: \param paramString the string to break up \param parameters the returned parameters */ - static void SplitParams(const CStdString ¶mString, std::vector<std::string> ¶meters); + static void SplitParams(const std::string ¶mString, std::vector<std::string> ¶meters); static void SplitExecFunction(const std::string &execString, std::string &function, std::vector<std::string> ¶meters); - static int GetMatchingSource(const CStdString& strPath, VECSOURCES& VECSOURCES, bool& bIsSourceName); - static CStdString TranslateSpecialSource(const CStdString &strSpecial); - static void DeleteDirectoryCache(const CStdString &prefix = ""); + static int GetMatchingSource(const std::string& strPath, VECSOURCES& VECSOURCES, bool& bIsSourceName); + static std::string TranslateSpecialSource(const std::string &strSpecial); + static void DeleteDirectoryCache(const std::string &prefix = ""); static void DeleteMusicDatabaseDirectoryCache(); static void DeleteVideoDatabaseDirectoryCache(); - static CStdString MusicPlaylistsLocation(); - static CStdString VideoPlaylistsLocation(); + static std::string MusicPlaylistsLocation(); + static std::string VideoPlaylistsLocation(); static void GetSkinThemes(std::vector<std::string>& vecTheme); - static void GetRecursiveListing(const CStdString& strPath, CFileItemList& items, const CStdString& strMask, unsigned int flags = 0 /* DIR_FLAG_DEFAULTS */); - static void GetRecursiveDirsListing(const CStdString& strPath, CFileItemList& items, unsigned int flags = 0 /* DIR_FLAG_DEFAULTS */); - static void ForceForwardSlashes(CStdString& strPath); + static void GetRecursiveListing(const std::string& strPath, CFileItemList& items, const std::string& strMask, unsigned int flags = 0 /* DIR_FLAG_DEFAULTS */); + static void GetRecursiveDirsListing(const std::string& strPath, CFileItemList& items, unsigned int flags = 0 /* DIR_FLAG_DEFAULTS */); + static void ForceForwardSlashes(std::string& strPath); - static double AlbumRelevance(const CStdString& strAlbumTemp1, const CStdString& strAlbum1, const CStdString& strArtistTemp1, const CStdString& strArtist1); + static double AlbumRelevance(const std::string& strAlbumTemp1, const std::string& strAlbum1, const std::string& strArtistTemp1, const std::string& strArtist1); static bool MakeShortenPath(std::string StrInput, std::string& StrOutput, size_t iTextMaxLength); /*! \brief Checks wether the supplied path supports Write file operations (e.g. Rename, Delete, ...) @@ -164,15 +164,15 @@ public: \return true if Write file operations are supported, false otherwise */ - static bool SupportsWriteFileOperations(const CStdString& strPath); + static bool SupportsWriteFileOperations(const std::string& strPath); /*! \brief Checks wether the supplied path supports Read file operations (e.g. Copy, ...) \param strPath the path to be checked \return true if Read file operations are supported, false otherwise */ - static bool SupportsReadFileOperations(const CStdString& strPath); - static CStdString GetDefaultFolderThumb(const CStdString &folderThumb); + static bool SupportsReadFileOperations(const std::string& strPath); + static std::string GetDefaultFolderThumb(const std::string &folderThumb); #ifdef UNIT_TESTING static bool TestSplitExec(); @@ -190,13 +190,6 @@ public: static int TranslateRomanNumeral(const char* roman_numeral); #ifdef TARGET_POSIX - // this will run the command using sudo in a new process. - // the user that runs xbmc should be allowed to issue the given sudo command. - // in order to allow a user to run sudo without supplying the password you'll need to edit sudoers - // # sudo visudo - // and add a line at the end defining the user and allowed commands - static bool SudoCommand(const CStdString &strCommand); - // // Forks to execute a shell command. // @@ -205,10 +198,10 @@ public: // // Forks to execute an unparsed shell command line. // - static bool RunCommandLine(const CStdString& cmdLine, bool waitExit = false); + static bool RunCommandLine(const std::string& cmdLine, bool waitExit = false); #endif - static CStdString ResolveExecutablePath(); - static CStdString GetFrameworksPath(bool forPython = false); + static std::string ResolveExecutablePath(); + static std::string GetFrameworksPath(bool forPython = false); static bool CanBindPrivileged(); static bool ValidatePort(int port); diff --git a/xbmc/addons/Addon.cpp b/xbmc/addons/Addon.cpp index ddc71c6a69..734364355b 100644 --- a/xbmc/addons/Addon.cpp +++ b/xbmc/addons/Addon.cpp @@ -216,7 +216,7 @@ void AddonProps::Serialize(CVariant &variant) const variant["fanart"] = URIUtils::AddFileToFolder(path, fanart); variant["dependencies"] = CVariant(CVariant::VariantTypeArray); - for (ADDONDEPS::const_iterator it = dependencies.begin(); it != dependencies.end(); it++) + for (ADDONDEPS::const_iterator it = dependencies.begin(); it != dependencies.end(); ++it) { CVariant dep(CVariant::VariantTypeObject); dep["addonid"] = it->first; @@ -229,7 +229,7 @@ void AddonProps::Serialize(CVariant &variant) const else variant["broken"] = broken; variant["extrainfo"] = CVariant(CVariant::VariantTypeArray); - for (InfoMap::const_iterator it = extrainfo.begin(); it != extrainfo.end(); it++) + for (InfoMap::const_iterator it = extrainfo.begin(); it != extrainfo.end(); ++it) { CVariant info(CVariant::VariantTypeObject); info["key"] = it->first; @@ -295,9 +295,9 @@ CAddon::CAddon(const AddonProps &props) } CAddon::CAddon(const CAddon &rhs) - : m_props(rhs.Props()) + : m_props(rhs.Props()), + m_settings(rhs.m_settings) { - m_settings = rhs.m_settings; m_addonXmlDoc = rhs.m_addonXmlDoc; m_settingsLoaded = rhs.m_settingsLoaded; m_userSettingsLoaded = rhs.m_userSettingsLoaded; diff --git a/xbmc/addons/AddonInstaller.cpp b/xbmc/addons/AddonInstaller.cpp index d358a231c4..c61da1bf84 100644 --- a/xbmc/addons/AddonInstaller.cpp +++ b/xbmc/addons/AddonInstaller.cpp @@ -359,9 +359,9 @@ bool CAddonInstaller::CheckDependencies(const AddonPtr &addon, if (!CheckDependencies(dep, preDeps, database)) { database.Close(); + preDeps.push_back(dep->ID()); return false; } - preDeps.push_back(dep->ID()); } } database.Close(); diff --git a/xbmc/addons/AddonManager.cpp b/xbmc/addons/AddonManager.cpp index 90ab02253f..9c93c0d2ab 100644 --- a/xbmc/addons/AddonManager.cpp +++ b/xbmc/addons/AddonManager.cpp @@ -275,7 +275,19 @@ bool CAddonMgr::Init() m_cp_context = m_cpluff->create_context(&status); assert(m_cp_context); status = m_cpluff->register_pcollection(m_cp_context, CSpecialProtocol::TranslatePath("special://home/addons").c_str()); + if (status != CP_OK) + { + CLog::Log(LOGERROR, "ADDONS: Fatal Error, cp_register_pcollection() returned status: %i", status); + return false; + } + status = m_cpluff->register_pcollection(m_cp_context, CSpecialProtocol::TranslatePath("special://xbmc/addons").c_str()); + if (status != CP_OK) + { + CLog::Log(LOGERROR, "ADDONS: Fatal Error, cp_register_pcollection() returned status: %i", status); + return false; + } + status = m_cpluff->register_pcollection(m_cp_context, CSpecialProtocol::TranslatePath("special://xbmcbin/addons").c_str()); if (status != CP_OK) { @@ -391,7 +403,7 @@ bool CAddonMgr::GetAllOutdatedAddons(VECADDONS &addons, bool getLocalVersion /*= { // Ignore duplicates due to add-ons with multiple extension points bool found = false; - for (VECADDONS::const_iterator addonIt = addons.begin(); addonIt != addons.end(); addonIt++) + for (VECADDONS::const_iterator addonIt = addons.begin(); addonIt != addons.end(); ++addonIt) { if ((*addonIt)->ID() == temp[j]->ID()) found = true; diff --git a/xbmc/addons/GUIDialogAddonSettings.cpp b/xbmc/addons/GUIDialogAddonSettings.cpp index 45eda1e3db..41edb263ae 100644 --- a/xbmc/addons/GUIDialogAddonSettings.cpp +++ b/xbmc/addons/GUIDialogAddonSettings.cpp @@ -911,7 +911,7 @@ std::string CGUIDialogAddonSettings::GetAddonNames(const std::string& addonIDsli { std::string retVal; vector<string> addons = StringUtils::Split(addonIDslist, ','); - for (vector<string>::const_iterator it = addons.begin(); it != addons.end() ; it ++) + for (vector<string>::const_iterator it = addons.begin(); it != addons.end() ; ++it) { if (!retVal.empty()) retVal += ", "; diff --git a/xbmc/addons/GUIViewStateAddonBrowser.cpp b/xbmc/addons/GUIViewStateAddonBrowser.cpp index c6497f4ecd..4f42b2e133 100644 --- a/xbmc/addons/GUIViewStateAddonBrowser.cpp +++ b/xbmc/addons/GUIViewStateAddonBrowser.cpp @@ -44,7 +44,7 @@ CGUIViewStateAddonBrowser::CGUIViewStateAddonBrowser(const CFileItemList& items) { AddSortMethod(SortByLabel, SortAttributeIgnoreFolders, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Filename, Size | Foldername, empty AddSortMethod(SortByDate, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Filename, Date | Foldername, Date - SetSortMethod(SortByLabel, SortAttributeIgnoreFolders); + SetSortMethod(SortByLabel); } SetViewAsControl(DEFAULT_VIEW_AUTO); diff --git a/xbmc/addons/GUIWindowAddonBrowser.cpp b/xbmc/addons/GUIWindowAddonBrowser.cpp index 92a4bd892c..8c62d8496b 100644 --- a/xbmc/addons/GUIWindowAddonBrowser.cpp +++ b/xbmc/addons/GUIWindowAddonBrowser.cpp @@ -537,7 +537,7 @@ int CGUIWindowAddonBrowser::SelectAddonID(const vector<ADDON::TYPE> &types, vect if (addonIDs.size() > 0) { - for (vector<string>::const_iterator it = addonIDs.begin(); it != addonIDs.end() ; it++) + for (vector<string>::const_iterator it = addonIDs.begin(); it != addonIDs.end() ; ++it) { CFileItemPtr item = items.Get(*it); if (item) diff --git a/xbmc/addons/Repository.cpp b/xbmc/addons/Repository.cpp index b42d881387..f97aab3110 100644 --- a/xbmc/addons/Repository.cpp +++ b/xbmc/addons/Repository.cpp @@ -96,9 +96,8 @@ CRepository::CRepository(const cp_extension_t *ext) } CRepository::CRepository(const CRepository &rhs) - : CAddon(rhs) + : CAddon(rhs), m_dirs(rhs.m_dirs) { - m_dirs = rhs.m_dirs; } CRepository::~CRepository() diff --git a/xbmc/addons/Scraper.cpp b/xbmc/addons/Scraper.cpp index 4d22ce7a3c..d6855853e6 100644 --- a/xbmc/addons/Scraper.cpp +++ b/xbmc/addons/Scraper.cpp @@ -164,12 +164,12 @@ AddonPtr CScraper::Clone() const } CScraper::CScraper(const CScraper &rhs) - : CAddon(rhs), m_fLoaded(false) + : CAddon(rhs), m_fLoaded(false), + m_language(rhs.m_language), + m_requiressettings(rhs.m_requiressettings), + m_persistence(rhs.m_persistence), + m_pathContent(rhs.m_pathContent) { - m_pathContent = rhs.m_pathContent; - m_persistence = rhs.m_persistence; - m_requiressettings = rhs.m_requiressettings; - m_language = rhs.m_language; } bool CScraper::Supports(const CONTENT_TYPE &content) const @@ -383,7 +383,7 @@ bool CScraper::Load() break; } } - itr++; + ++itr; } } diff --git a/xbmc/addons/Skin.cpp b/xbmc/addons/Skin.cpp index 55377e4d65..351a821663 100644 --- a/xbmc/addons/Skin.cpp +++ b/xbmc/addons/Skin.cpp @@ -202,7 +202,7 @@ int CSkinInfo::GetStartWindow() const { int windowID = CSettings::Get().GetInt("lookandfeel.startupwindow"); assert(m_startupWindows.size()); - for (vector<CStartupWindow>::const_iterator it = m_startupWindows.begin(); it != m_startupWindows.end(); it++) + for (vector<CStartupWindow>::const_iterator it = m_startupWindows.begin(); it != m_startupWindows.end(); ++it) { if (windowID == (*it).m_id) return windowID; @@ -470,7 +470,7 @@ void CSkinInfo::SettingOptionsStartupWindowsFiller(const CSetting *setting, std: const vector<CStartupWindow> &startupWindows = g_SkinInfo->GetStartupWindows(); - for (vector<CStartupWindow>::const_iterator it = startupWindows.begin(); it != startupWindows.end(); it++) + for (vector<CStartupWindow>::const_iterator it = startupWindows.begin(); it != startupWindows.end(); ++it) { string windowName = it->m_name; if (StringUtils::IsNaturalNumber(windowName)) diff --git a/xbmc/addons/Skin.h b/xbmc/addons/Skin.h index 16a073ae20..dd7771a949 100644 --- a/xbmc/addons/Skin.h +++ b/xbmc/addons/Skin.h @@ -38,9 +38,9 @@ public: class CStartupWindow { public: - CStartupWindow(int id, const std::string &name) + CStartupWindow(int id, const std::string &name): + m_id(id), m_name(name) { - m_id = id; m_name = name; }; int m_id; std::string m_name; diff --git a/xbmc/addons/Visualisation.cpp b/xbmc/addons/Visualisation.cpp index 810e5b2ff2..b28289bfae 100644 --- a/xbmc/addons/Visualisation.cpp +++ b/xbmc/addons/Visualisation.cpp @@ -321,7 +321,7 @@ void CVisualisation::ClearBuffers() m_bWantsFreq = false; m_iNumBuffers = 0; - while (m_vecBuffers.size() > 0) + while (!m_vecBuffers.empty()) { CAudioBuffer* pAudioBuffer = m_vecBuffers.front(); delete pAudioBuffer; diff --git a/xbmc/addons/include/xbmc_pvr_dll.h b/xbmc/addons/include/xbmc_pvr_dll.h index 50012b0497..6ef21f3b8e 100644 --- a/xbmc/addons/include/xbmc_pvr_dll.h +++ b/xbmc/addons/include/xbmc_pvr_dll.h @@ -595,6 +595,13 @@ extern "C" time_t GetBufferTimeEnd(); /*! + * Get the hostname of the pvr backend server + * @return hostname as ip address or alias. If backend does not + * utilize a server, return empty string. + */ + const char* GetBackendHostname(); + + /*! * Called by XBMC to assign the function pointers of this add-on to pClient. * @param pClient The struct to assign the function pointers to. */ @@ -674,6 +681,8 @@ extern "C" pClient->GetPlayingTime = GetPlayingTime; pClient->GetBufferTimeStart = GetBufferTimeStart; pClient->GetBufferTimeEnd = GetBufferTimeEnd; + + pClient->GetBackendHostname = GetBackendHostname; }; }; diff --git a/xbmc/addons/include/xbmc_pvr_types.h b/xbmc/addons/include/xbmc_pvr_types.h index b218943534..8d78818e78 100644 --- a/xbmc/addons/include/xbmc_pvr_types.h +++ b/xbmc/addons/include/xbmc_pvr_types.h @@ -75,10 +75,10 @@ struct DemuxPacket; #define PVR_STREAM_MAX_STREAMS 20 /* current PVR API version */ -#define XBMC_PVR_API_VERSION "1.9.2" +#define XBMC_PVR_API_VERSION "1.9.3" /* min. PVR API version */ -#define XBMC_PVR_MIN_API_VERSION "1.9.2" +#define XBMC_PVR_MIN_API_VERSION "1.9.3" #ifdef __cplusplus extern "C" { @@ -399,6 +399,7 @@ extern "C" { time_t (__cdecl* GetPlayingTime)(void); time_t (__cdecl* GetBufferTimeStart)(void); time_t (__cdecl* GetBufferTimeEnd)(void); + const char* (__cdecl* GetBackendHostname)(void); } PVRClient; #ifdef __cplusplus diff --git a/xbmc/android/activity/XBMCApp.cpp b/xbmc/android/activity/XBMCApp.cpp index 5f0ae48a5e..c69ac2603a 100644 --- a/xbmc/android/activity/XBMCApp.cpp +++ b/xbmc/android/activity/XBMCApp.cpp @@ -456,7 +456,7 @@ bool CXBMCApp::StartActivity(const string &package, const string &intent, const newIntent.setPackage(package); startActivity(newIntent); - if (xbmc_jnienv()->ExceptionOccurred()) + if (xbmc_jnienv()->ExceptionCheck()) { CLog::Log(LOGERROR, "CXBMCApp::StartActivity - ExceptionOccurred launching %s", package.c_str()); xbmc_jnienv()->ExceptionClear(); diff --git a/xbmc/android/jni/JNIBase.cpp b/xbmc/android/jni/JNIBase.cpp index 57bfa5ffb5..1a1c88e163 100644 --- a/xbmc/android/jni/JNIBase.cpp +++ b/xbmc/android/jni/JNIBase.cpp @@ -23,15 +23,14 @@ using namespace jni; int CJNIBase::m_sdk_version = -1; -CJNIBase::CJNIBase(std::string classname) +CJNIBase::CJNIBase(std::string classname): + m_className(classname) { - m_className = classname; } -CJNIBase::CJNIBase(const jhobject &object) +CJNIBase::CJNIBase(const jhobject &object): + m_object(object) { - m_className = ""; - m_object = object; m_object.setGlobal(); } diff --git a/xbmc/android/loader/AndroidDyload.cpp b/xbmc/android/loader/AndroidDyload.cpp index 7e36d6fabe..93dc4063d6 100644 --- a/xbmc/android/loader/AndroidDyload.cpp +++ b/xbmc/android/loader/AndroidDyload.cpp @@ -21,7 +21,7 @@ bool CAndroidDyload::IsSystemLib(const string &filename) { { CSingleLock lock(m_libLock); - for ( solibit i = m_libs.begin() ; i != m_libs.end(); i++ ) + for ( solibit i = m_libs.begin() ; i != m_libs.end(); ++i ) { if (i->first == filename) return i->second.system; @@ -95,7 +95,7 @@ void* CAndroidDyload::Find(const string &filename) string CAndroidDyload::Find(void *handle) { CSingleLock lock(m_libLock); - for ( solibit i = m_libs.begin() ; i != m_libs.end(); i++ ) + for ( solibit i = m_libs.begin() ; i != m_libs.end(); ++i ) { if (i->second.handle == handle) return i->first; @@ -106,7 +106,7 @@ string CAndroidDyload::Find(void *handle) void *CAndroidDyload::FindInDeps(const string &filename) { CSingleLock lock(m_depsLock); - for (std::list<recursivelibdep>::iterator k = m_lib.deps.begin(); k != m_lib.deps.end(); k++) + for (std::list<recursivelibdep>::iterator k = m_lib.deps.begin(); k != m_lib.deps.end(); ++k) { if (k->filename == filename) return k->handle; @@ -294,11 +294,11 @@ void* CAndroidDyload::Open_Internal(string filename, bool checkSystem) int CAndroidDyload::Close(void *handle) { CSingleLock lock(m_depsLock); - for (std::list<recursivelib>::iterator i = m_recursivelibs.begin(); i != m_recursivelibs.end(); i++) + for (std::list<recursivelib>::iterator i = m_recursivelibs.begin(); i != m_recursivelibs.end(); ++i) { if (i->handle == handle) { - for (std::list<recursivelibdep>::iterator j = i->deps.begin(); j != i->deps.end(); j++) + for (std::list<recursivelibdep>::iterator j = i->deps.begin(); j != i->deps.end(); ++j) { if (DecRef(j->filename) == 0) { @@ -322,16 +322,16 @@ int CAndroidDyload::Close(void *handle) void CAndroidDyload::Dump() { CSingleLock liblock(m_libLock); - for ( solibit i = m_libs.begin() ; i != m_libs.end(); i++ ) + for ( solibit i = m_libs.begin() ; i != m_libs.end(); ++i ) { CXBMCApp::android_printf("lib: %s. refcount: %i",i->first.c_str(), i->second.refcount); } CSingleLock depslock(m_depsLock); - for (std::list<recursivelib>::iterator i = m_recursivelibs.begin(); i != m_recursivelibs.end(); i++) + for (std::list<recursivelib>::iterator i = m_recursivelibs.begin(); i != m_recursivelibs.end(); ++i) { CXBMCApp::android_printf("xb_dlopen: recursive dep: %s", i->filename.c_str()); - for (std::list<recursivelibdep>::iterator j = i->deps.begin(); j != i->deps.end(); j++) + for (std::list<recursivelibdep>::iterator j = i->deps.begin(); j != i->deps.end(); ++j) { CXBMCApp::android_printf("xb_dlopen: recursive dep: \\-- %s", j->filename.c_str()); } diff --git a/xbmc/cdrip/CDDARipper.h b/xbmc/cdrip/CDDARipper.h index 51cbab420a..a0505dce20 100644 --- a/xbmc/cdrip/CDDARipper.h +++ b/xbmc/cdrip/CDDARipper.h @@ -21,7 +21,7 @@ * */ -#include "utils/StdString.h" +#include <string> #include "utils/JobManager.h" class CFileItem; diff --git a/xbmc/cdrip/EncoderFFmpeg.h b/xbmc/cdrip/EncoderFFmpeg.h index 3cf2d753e7..1702267cee 100644 --- a/xbmc/cdrip/EncoderFFmpeg.h +++ b/xbmc/cdrip/EncoderFFmpeg.h @@ -59,7 +59,6 @@ private: static int64_t avio_seek_callback(void *opaque, int64_t offset, int whence); void SetTag(const std::string &tag, const std::string &value); - unsigned int m_NeededFrames; unsigned int m_NeededBytes; uint8_t *m_Buffer; diff --git a/xbmc/commons/Exception.h b/xbmc/commons/Exception.h index a6be3037ce..649d967530 100644 --- a/xbmc/commons/Exception.h +++ b/xbmc/commons/Exception.h @@ -27,6 +27,7 @@ #include "utils/StringUtils.h" //--------------------------------------------------------- #include "ilog.h" +#include <stdarg.h> #ifdef __GNUC__ // The 'this' pointer counts as a parameter on member methods. diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp index 96bce120f6..b4221663c7 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp @@ -53,6 +53,7 @@ CActiveAEStream::CActiveAEStream(AEAudioFormat *format) m_streamFading = false; m_streamFreeBuffers = 0; m_streamIsBuffering = false; + m_streamIsFlushed = false; m_streamSlave = NULL; m_leftoverBuffer = new uint8_t[m_format.m_frameSize]; m_leftoverBytes = 0; @@ -181,8 +182,7 @@ void CActiveAEStream::RemapBuffer() } // swap sound packets - CSoundPacket *tmp = m_remapBuffer; - tmp = m_currentBuffer->pkt; + CSoundPacket *tmp = m_currentBuffer->pkt; m_currentBuffer->pkt = m_remapBuffer; m_remapBuffer = tmp; } @@ -201,6 +201,8 @@ unsigned int CActiveAEStream::AddData(uint8_t* const *data, unsigned int offset, int sourceFrames = frames; uint8_t* const *buf = data; + m_streamIsFlushed = false; + while(copied < frames) { sourceFrames = frames - copied; @@ -386,10 +388,14 @@ bool CActiveAEStream::IsDrained() void CActiveAEStream::Flush() { - m_currentBuffer = NULL; - m_leftoverBytes = 0; - AE.FlushStream(this); - ResetFreeBuffers(); + if (!m_streamIsFlushed) + { + m_currentBuffer = NULL; + m_leftoverBytes = 0; + AE.FlushStream(this); + ResetFreeBuffers(); + m_streamIsFlushed = true; + } } float CActiveAEStream::GetAmplification() diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.h b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.h index 09fda0fadc..011ad02c02 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.h +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.h @@ -92,6 +92,7 @@ protected: bool m_streamFading; int m_streamFreeBuffers; bool m_streamIsBuffering; + bool m_streamIsFlushed; IAEStream *m_streamSlave; CCriticalSection m_streamLock; uint8_t *m_leftoverBuffer; diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp index d30cbabce7..df50940afc 100644 --- a/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp +++ b/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp @@ -338,8 +338,10 @@ snd_pcm_chmap_t* CAESinkALSA::CopyALSAchmap(snd_pcm_chmap_t* alsaMap) std::string CAESinkALSA::ALSAchmapToString(snd_pcm_chmap_t* alsaMap) { - char buf[64] = { 0 }; - int err = snd_pcm_chmap_print(alsaMap, sizeof(buf), buf); + char buf[128] = { 0 }; + // ALSA bug - buffer overflow by a factor of 2 is possible + // http://mailman.alsa-project.org/pipermail/alsa-devel/2014-December/085815.html + int err = snd_pcm_chmap_print(alsaMap, sizeof(buf) / 2, buf); if (err < 0) return "Error"; return std::string(buf); diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkDARWINIOS.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkDARWINIOS.cpp index 169014e0f4..9e1c7d6aea 100644 --- a/xbmc/cores/AudioEngine/Sinks/AESinkDARWINIOS.cpp +++ b/xbmc/cores/AudioEngine/Sinks/AESinkDARWINIOS.cpp @@ -290,12 +290,11 @@ void CAAudioUnitSink::drain() void CAAudioUnitSink::setCoreAudioBuffersize() { #if !TARGET_IPHONE_SIMULATOR - OSStatus status = noErr; // set the buffer size, this affects the number of samples // that get rendered every time the audio callback is fired. Float32 preferredBufferSize = 512 * m_outputFormat.mChannelsPerFrame / m_outputFormat.mSampleRate; CLog::Log(LOGNOTICE, "%s setting buffer duration to %f", __PRETTY_FUNCTION__, preferredBufferSize); - status = AudioSessionSetProperty(kAudioSessionProperty_PreferredHardwareIOBufferDuration, + OSStatus status = AudioSessionSetProperty(kAudioSessionProperty_PreferredHardwareIOBufferDuration, sizeof(preferredBufferSize), &preferredBufferSize); if (status != noErr) CLog::Log(LOGWARNING, "%s preferredBufferSize couldn't be set (error: %d)", __PRETTY_FUNCTION__, (int)status); diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkPULSE.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkPULSE.cpp index 9ccfb83c5b..dcef42c77b 100644 --- a/xbmc/cores/AudioEngine/Sinks/AESinkPULSE.cpp +++ b/xbmc/cores/AudioEngine/Sinks/AESinkPULSE.cpp @@ -319,7 +319,7 @@ static pa_channel_position_t AEChannelToPAChannel(AEChannel ae_channel) return pa_channel; } -static pa_channel_map AEChannelMapToPAChannel(CAEChannelInfo info) +static pa_channel_map AEChannelMapToPAChannel(const CAEChannelInfo& info) { pa_channel_map map; pa_channel_map_init(&map); diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp index 56dd641c64..858b008cc4 100644 --- a/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp +++ b/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp @@ -110,9 +110,13 @@ struct sampleFormat }; /* Sample formats go from float -> 32 bit int -> 24 bit int (packed in 32) -> -> 24 bit int -> 16 bit int */ +// versions of Kodi before 14.0 had a bug which made S24NE4MSB the first format selected +// this bug worked around some driver bug of some IEC958 devices which report S32 but can't handle it +// correctly. So far I have never seen and WASAPI device using S32 and don't think probing S24 before +// S32 has any negative impact. static const sampleFormat testFormats[] = { {KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 32, 32, AE_FMT_FLOAT}, - {KSDATAFORMAT_SUBTYPE_PCM, 32, 32, AE_FMT_S32NE}, {KSDATAFORMAT_SUBTYPE_PCM, 32, 24, AE_FMT_S24NE4MSB}, + {KSDATAFORMAT_SUBTYPE_PCM, 32, 32, AE_FMT_S32NE}, {KSDATAFORMAT_SUBTYPE_PCM, 24, 24, AE_FMT_S24NE3}, {KSDATAFORMAT_SUBTYPE_PCM, 16, 16, AE_FMT_S16NE} }; @@ -1075,7 +1079,8 @@ bool CAESinkWASAPI::InitializeExclusive(AEAudioFormat &format) else if (AE_IS_RAW(format.m_dataFormat)) //No sense in trying other formats for passthrough. return false; - CLog::Log(LOGERROR, __FUNCTION__": IsFormatSupported failed (%s) - trying to find a compatible format", WASAPIErrToStr(hr)); + if (g_advancedSettings.CanLogComponent(LOGAUDIO)) + CLog::Log(LOGDEBUG, __FUNCTION__": IsFormatSupported failed (%s) - trying to find a compatible format", WASAPIErrToStr(hr)); int closestMatch; unsigned int requestedChannels = wfxex.Format.nChannels; diff --git a/xbmc/cores/AudioEngine/Sinks/osx/CoreAudioHardware.cpp b/xbmc/cores/AudioEngine/Sinks/osx/CoreAudioHardware.cpp index 73659f6ba1..72b28f38df 100644 --- a/xbmc/cores/AudioEngine/Sinks/osx/CoreAudioHardware.cpp +++ b/xbmc/cores/AudioEngine/Sinks/osx/CoreAudioHardware.cpp @@ -64,7 +64,7 @@ void CCoreAudioHardware::ResetAudioDevices() CoreAudioDeviceList list; if (GetOutputDevices(&list)) { - for (CoreAudioDeviceList::iterator it = list.begin(); it != list.end(); it ++) + for (CoreAudioDeviceList::iterator it = list.begin(); it != list.end(); ++it) { CCoreAudioDevice device = *it; @@ -72,7 +72,7 @@ void CCoreAudioHardware::ResetAudioDevices() if (device.GetStreams(&streams)) { CLog::Log(LOGDEBUG, "CCoreAudioHardware::ResetAudioDevices %lu streams for device %s", streams.size(), device.GetName().c_str()); - for (AudioStreamIdList::iterator ait = streams.begin(); ait != streams.end(); ait ++) + for (AudioStreamIdList::iterator ait = streams.begin(); ait != streams.end(); ++ait) ResetStream(*ait); } } @@ -94,13 +94,12 @@ void CCoreAudioHardware::ResetStream(AudioStreamID streamId) StreamFormatList availableFormats; if (stream.GetAvailablePhysicalFormats(&availableFormats)) { - for (StreamFormatList::iterator fmtIt = availableFormats.begin(); fmtIt != availableFormats.end() ; fmtIt ++) + for (StreamFormatList::iterator fmtIt = availableFormats.begin(); fmtIt != availableFormats.end() ; ++fmtIt) { AudioStreamRangedDescription fmtDesc = *fmtIt; if (fmtDesc.mFormat.mFormatID == kAudioFormatLinearPCM) { - AudioStreamBasicDescription newFmt = { 0 }; - newFmt = fmtDesc.mFormat; + AudioStreamBasicDescription newFmt = fmtDesc.mFormat; if (stream.SetPhysicalFormat(&newFmt)) break; diff --git a/xbmc/cores/DllLoader/LibraryLoader.cpp b/xbmc/cores/DllLoader/LibraryLoader.cpp index 10a51f226e..c0405d7c14 100644 --- a/xbmc/cores/DllLoader/LibraryLoader.cpp +++ b/xbmc/cores/DllLoader/LibraryLoader.cpp @@ -23,10 +23,9 @@ #include <stdlib.h> #include "utils/log.h" -LibraryLoader::LibraryLoader(const std::string& libraryFile) +LibraryLoader::LibraryLoader(const std::string& libraryFile): + m_fileName(libraryFile) { - m_fileName = libraryFile; - size_t pos = m_fileName.find_last_of("\\/"); if (pos != std::string::npos) m_path = m_fileName.substr(0, pos); diff --git a/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp b/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp index 68ed4f143f..e9674bcfb2 100644 --- a/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp +++ b/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp @@ -991,7 +991,7 @@ extern "C" CURL url(CSpecialProtocol::TranslatePath(file)); if (url.IsLocal()) { // Make sure the slashes are correct & translate the path - return opendir(CUtil::ValidatePath(url.Get().c_str())); + return opendir(CUtil::ValidatePath(url.Get().c_str()).c_str()); } // locate next free directory diff --git a/xbmc/cores/VideoRenderers/BaseRenderer.cpp b/xbmc/cores/VideoRenderers/BaseRenderer.cpp index 9ce9b98280..751a61bd02 100644 --- a/xbmc/cores/VideoRenderers/BaseRenderer.cpp +++ b/xbmc/cores/VideoRenderers/BaseRenderer.cpp @@ -301,8 +301,8 @@ RESOLUTION CBaseRenderer::GetResolution() const float CBaseRenderer::GetAspectRatio() const { - float width = (float)m_sourceWidth - CMediaSettings::Get().GetCurrentVideoSettings().m_CropLeft - CMediaSettings::Get().GetCurrentVideoSettings().m_CropRight; - float height = (float)m_sourceHeight - CMediaSettings::Get().GetCurrentVideoSettings().m_CropTop - CMediaSettings::Get().GetCurrentVideoSettings().m_CropBottom; + float width = (float)m_sourceWidth; + float height = (float)m_sourceHeight; return m_sourceFrameRatio * width / height * m_sourceHeight / m_sourceWidth; } @@ -614,11 +614,6 @@ void CBaseRenderer::ManageDisplay() break; } - m_sourceRect.x1 += (float)CMediaSettings::Get().GetCurrentVideoSettings().m_CropLeft; - m_sourceRect.y1 += (float)CMediaSettings::Get().GetCurrentVideoSettings().m_CropTop; - m_sourceRect.x2 -= (float)CMediaSettings::Get().GetCurrentVideoSettings().m_CropRight; - m_sourceRect.y2 -= (float)CMediaSettings::Get().GetCurrentVideoSettings().m_CropBottom; - CalcNormalDisplayRect(view.x1, view.y1, view.Width(), view.Height(), GetAspectRatio() * CDisplaySettings::Get().GetPixelRatio(), CDisplaySettings::Get().GetZoomAmount(), CDisplaySettings::Get().GetVerticalShift()); } @@ -719,7 +714,7 @@ void CBaseRenderer::SetViewMode(int viewMode) newHeight = screenHeight; } // now work out the zoom amount so that no zoom is done - CDisplaySettings::Get().SetZoomAmount((m_sourceHeight - CMediaSettings::Get().GetCurrentVideoSettings().m_CropTop - CMediaSettings::Get().GetCurrentVideoSettings().m_CropBottom) / newHeight); + CDisplaySettings::Get().SetZoomAmount(m_sourceHeight / newHeight); } else if (CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode == ViewModeCustom) { diff --git a/xbmc/cores/VideoRenderers/DXVA.cpp b/xbmc/cores/VideoRenderers/DXVA.cpp index 86146d7593..2f38ed0471 100644 --- a/xbmc/cores/VideoRenderers/DXVA.cpp +++ b/xbmc/cores/VideoRenderers/DXVA.cpp @@ -110,9 +110,9 @@ static const pci_device NoDeintProcForProgDevices[] = { { 0 , 0x0000 } }; -static CStdString GUIDToString(const GUID& guid) +static std::string GUIDToString(const GUID& guid) { - CStdString buffer = StringUtils::Format("%08X-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x" + std::string buffer = StringUtils::Format("%08X-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x" , guid.Data1, guid.Data2, guid.Data3 , guid.Data4[0], guid.Data4[1] , guid.Data4[2], guid.Data4[3], guid.Data4[4] @@ -664,6 +664,7 @@ bool CProcessor::Render(CRect src, CRect dst, IDirect3DSurface9* target, IDirect vs.Start = frameIdx + (sampIdx - pastFrames) * 2; vs.End = vs.Start + 2; vs.PlanarAlpha = DXVA2_Fixed32OpaqueAlpha(); + vs.SampleFormat = m_desc.SampleFormat; vs.SampleFormat.SampleFormat = sampleFormat; // Override the sample format when the processor doesn't need to deinterlace or when deinterlacing is forced and flags are missing. diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp index ae7f649805..060dec0979 100644 --- a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp +++ b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp @@ -39,6 +39,7 @@ #include "windowing/WindowingFactory.h" #include "guilib/Texture.h" #include "guilib/LocalizeStrings.h" +#include "guilib/MatrixGLES.h" #include "threads/SingleLock.h" #include "utils/log.h" #include "utils/GLUtils.h" @@ -1383,21 +1384,18 @@ void CLinuxRendererGL::RenderToFBO(int index, int field, bool weave /*= false*/) glPushAttrib(GL_VIEWPORT_BIT); glPushAttrib(GL_SCISSOR_BIT); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - VerifyGLState(); - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - VerifyGLState(); - gluOrtho2D(0, m_sourceWidth, 0, m_sourceHeight); + glMatrixModview.Push(); + glMatrixModview->LoadIdentity(); + glMatrixModview.Load(); + + glMatrixProject.Push(); + glMatrixProject->LoadIdentity(); + glMatrixProject->Ortho2D(0, m_sourceWidth, 0, m_sourceHeight); + glMatrixProject.Load(); + glViewport(0, 0, m_sourceWidth, m_sourceHeight); glScissor (0, 0, m_sourceWidth, m_sourceHeight); - glMatrixMode(GL_MODELVIEW); - VerifyGLState(); - if (!m_pYUVShader->Enable()) { @@ -1444,13 +1442,11 @@ void CLinuxRendererGL::RenderToFBO(int index, int field, bool weave /*= false*/) m_pYUVShader->Disable(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); // pop modelview - glMatrixMode(GL_PROJECTION); - glPopMatrix(); // pop projection + glMatrixModview.PopLoad(); + glMatrixProject.PopLoad(); + glPopAttrib(); // pop scissor glPopAttrib(); // pop viewport - glMatrixMode(GL_MODELVIEW); VerifyGLState(); m_fbo.fbo.EndRender(); @@ -1684,10 +1680,11 @@ bool CLinuxRendererGL::RenderCapture(CRenderCapture* capture) //invert Y axis to get non-inverted image glDisable(GL_BLEND); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glTranslatef(0, capture->GetHeight(), 0); - glScalef(1.0, -1.0f, 1.0f); + + glMatrixModview.Push(); + glMatrixModview->Translatef(0.0f, capture->GetHeight(), 0.0f); + glMatrixModview->Scalef(1.0f, -1.0f, 1.0f); + glMatrixModview.Load(); capture->BeginRender(); @@ -1699,8 +1696,7 @@ bool CLinuxRendererGL::RenderCapture(CRenderCapture* capture) capture->EndRender(); // revert model view matrix - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); + glMatrixModview.PopLoad(); // restore original video rect m_destRect = saveSize; @@ -3291,7 +3287,6 @@ bool CLinuxRendererGL::Supports(ERENDERFEATURE feature) } if (feature == RENDERFEATURE_STRETCH || - feature == RENDERFEATURE_CROP || feature == RENDERFEATURE_ZOOM || feature == RENDERFEATURE_VERTICAL_SHIFT || feature == RENDERFEATURE_PIXEL_RATIO || diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp index 81fe19b063..c2c4a30df0 100644 --- a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp +++ b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp @@ -1081,7 +1081,7 @@ void CLinuxRendererGLES::RenderSinglePass(int index, int field) else if(field == FIELD_BOT) m_pYUVShader->SetField(0); - m_pYUVShader->SetMatrices(g_matrices.GetMatrix(MM_PROJECTION), g_matrices.GetMatrix(MM_MODELVIEW)); + m_pYUVShader->SetMatrices(glMatrixProject.Get(), glMatrixModview.Get()); m_pYUVShader->Enable(); GLubyte idx[4] = {0, 1, 3, 2}; //determines order of triangle strip @@ -1141,8 +1141,6 @@ void CLinuxRendererGLES::RenderSinglePass(int index, int field) glActiveTexture(GL_TEXTURE0); glDisable(m_textureTarget); - g_matrices.MatrixMode(MM_MODELVIEW); - VerifyGLState(); } @@ -1207,19 +1205,15 @@ void CLinuxRendererGLES::RenderMultiPass(int index, int field) //TODO // glPushAttrib(GL_VIEWPORT_BIT); // glPushAttrib(GL_SCISSOR_BIT); - g_matrices.MatrixMode(MM_MODELVIEW); - g_matrices.PushMatrix(); - g_matrices.LoadIdentity(); - VerifyGLState(); + glMatrixModview.Push(); + glMatrixModview->LoadIdentity(); + + glMatrixProject.Push(); + glMatrixProject->LoadIdentity(); + glMatrixProject->Ortho2D(0, m_sourceWidth, 0, m_sourceHeight); - g_matrices.MatrixMode(MM_PROJECTION); - g_matrices.PushMatrix(); - g_matrices.LoadIdentity(); - VerifyGLState(); - g_matrices.Ortho2D(0, m_sourceWidth, 0, m_sourceHeight); CRect viewport(0, 0, m_sourceWidth, m_sourceHeight); g_Windowing.SetViewPort(viewport); - g_matrices.MatrixMode(MM_MODELVIEW); VerifyGLState(); @@ -1265,14 +1259,12 @@ void CLinuxRendererGLES::RenderMultiPass(int index, int field) m_pYUVShader->Disable(); - g_matrices.MatrixMode(MM_MODELVIEW); - g_matrices.PopMatrix(); // pop modelview - g_matrices.MatrixMode(MM_PROJECTION); - g_matrices.PopMatrix(); // pop projection + glMatrixModview.PopLoad(); + glMatrixProject.PopLoad(); + //TODO // glPopAttrib(); // pop scissor // glPopAttrib(); // pop viewport - g_matrices.MatrixMode(MM_MODELVIEW); VerifyGLState(); m_fbo.EndRender(); @@ -1776,17 +1768,17 @@ bool CLinuxRendererGLES::RenderCapture(CRenderCapture* capture) // clear framebuffer and invert Y axis to get non-inverted image glDisable(GL_BLEND); - g_matrices.MatrixMode(MM_MODELVIEW); - g_matrices.PushMatrix(); + glMatrixModview.Push(); // fixme - we know that cvref & eglimg are already flipped in y direction // but somehow this also effects the rendercapture here // therefore we have to skip the flip here or we get upside down // images if (m_renderMethod != RENDER_CVREF) { - g_matrices.Translatef(0.0f, capture->GetHeight(), 0.0f); - g_matrices.Scalef(1.0f, -1.0f, 1.0f); + glMatrixModview->Translatef(0.0f, capture->GetHeight(), 0.0f); + glMatrixModview->Scalef(1.0f, -1.0f, 1.0f); } + glMatrixModview.Load(); capture->BeginRender(); @@ -1806,8 +1798,7 @@ bool CLinuxRendererGLES::RenderCapture(CRenderCapture* capture) capture->EndRender(); // revert model view matrix - g_matrices.MatrixMode(MM_MODELVIEW); - g_matrices.PopMatrix(); + glMatrixModview.PopLoad(); // restore original video rect m_destRect = saveSize; @@ -2826,7 +2817,6 @@ bool CLinuxRendererGLES::Supports(ERENDERFEATURE feature) return false; if (feature == RENDERFEATURE_STRETCH || - feature == RENDERFEATURE_CROP || feature == RENDERFEATURE_ZOOM || feature == RENDERFEATURE_VERTICAL_SHIFT || feature == RENDERFEATURE_PIXEL_RATIO || diff --git a/xbmc/cores/VideoRenderers/OverlayRendererDX.cpp b/xbmc/cores/VideoRenderers/OverlayRendererDX.cpp index 14dc41ca4e..280c12a52e 100644 --- a/xbmc/cores/VideoRenderers/OverlayRendererDX.cpp +++ b/xbmc/cores/VideoRenderers/OverlayRendererDX.cpp @@ -30,6 +30,11 @@ #include "utils/MathUtils.h" #include "RenderManager.h" +#ifndef ASSERT +#include <crtdbg.h> +#define ASSERT(f) _ASSERTE((f)) +#endif + #ifdef HAS_DX using namespace OVERLAY; diff --git a/xbmc/cores/VideoRenderers/OverlayRendererGL.cpp b/xbmc/cores/VideoRenderers/OverlayRendererGL.cpp index 8684567dda..0fe125ace7 100644 --- a/xbmc/cores/VideoRenderers/OverlayRendererGL.cpp +++ b/xbmc/cores/VideoRenderers/OverlayRendererGL.cpp @@ -27,8 +27,8 @@ #include "LinuxRendererGL.h" #elif HAS_GLES == 2 #include "LinuxRendererGLES.h" - #include "guilib/MatrixGLES.h" #endif +#include "guilib/MatrixGLES.h" #include "RenderManager.h" #include "cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayImage.h" #include "cores/dvdplayer/DVDCodecs/Overlay/DVDOverlaySpu.h" @@ -417,6 +417,11 @@ void COverlayGlyphGL::Render(SRenderState& state) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glMatrixModview.Push(); + glMatrixModview->Translatef(state.x, state.y, 0.0f); + glMatrixModview->Scalef(state.width, state.height, 1.0f); + glMatrixModview.Load(); + #ifdef HAS_GL glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); @@ -430,11 +435,6 @@ void COverlayGlyphGL::Render(SRenderState& state) glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glTranslatef(state.x , state.y , 0.0f); - glScalef (state.width, state.height, 1.0f); - VerifyGLState(); glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT); @@ -448,14 +448,7 @@ void COverlayGlyphGL::Render(SRenderState& state) glDrawArrays(GL_QUADS, 0, m_count * 4); glPopClientAttrib(); - glPopMatrix(); #else - g_matrices.MatrixMode(MM_MODELVIEW); - g_matrices.PushMatrix(); - g_matrices.Translatef(state.x, state.y, 0.0f); - g_matrices.Scalef(state.width, state.height, 1.0f); - VerifyGLState(); - g_Windowing.EnableGUIShader(SM_FONTS); GLint posLoc = g_Windowing.GUIShaderGetPos(); @@ -495,9 +488,10 @@ void COverlayGlyphGL::Render(SRenderState& state) g_Windowing.DisableGUIShader(); - g_matrices.PopMatrix(); #endif + glMatrixModview.PopLoad(); + glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); diff --git a/xbmc/cores/VideoRenderers/RenderFeatures.h b/xbmc/cores/VideoRenderers/RenderFeatures.h index 18e621e24c..023c7931a1 100644 --- a/xbmc/cores/VideoRenderers/RenderFeatures.h +++ b/xbmc/cores/VideoRenderers/RenderFeatures.h @@ -31,7 +31,6 @@ enum ERENDERFEATURE RENDERFEATURE_NONLINSTRETCH, RENDERFEATURE_ROTATION, RENDERFEATURE_STRETCH, - RENDERFEATURE_CROP, RENDERFEATURE_ZOOM, RENDERFEATURE_VERTICAL_SHIFT, RENDERFEATURE_PIXEL_RATIO, diff --git a/xbmc/cores/VideoRenderers/WinRenderer.cpp b/xbmc/cores/VideoRenderers/WinRenderer.cpp index e6120ce2fc..7c12f3f8e9 100644 --- a/xbmc/cores/VideoRenderers/WinRenderer.cpp +++ b/xbmc/cores/VideoRenderers/WinRenderer.cpp @@ -1265,7 +1265,6 @@ bool CWinRenderer::Supports(ERENDERFEATURE feature) if (feature == RENDERFEATURE_STRETCH || feature == RENDERFEATURE_NONLINSTRETCH || - feature == RENDERFEATURE_CROP || feature == RENDERFEATURE_ZOOM || feature == RENDERFEATURE_VERTICAL_SHIFT || feature == RENDERFEATURE_PIXEL_RATIO || diff --git a/xbmc/cores/dvdplayer/DVDAudio.cpp b/xbmc/cores/dvdplayer/DVDAudio.cpp index 6514030357..9d7900e6b3 100644 --- a/xbmc/cores/dvdplayer/DVDAudio.cpp +++ b/xbmc/cores/dvdplayer/DVDAudio.cpp @@ -31,66 +31,6 @@ using namespace std; -CPTSOutputQueue::CPTSOutputQueue() -{ - Flush(); -} - -void CPTSOutputQueue::Add(double pts, double delay, double duration, double timestamp) -{ - CSingleLock lock(m_sync); - - // don't accept a re-add, since that would cause time moving back - double last = m_queue.empty() ? m_current.pts : m_queue.back().pts; - if(last == pts) - return; - - TPTSItem item; - item.pts = pts; - item.timestamp = timestamp + delay; - item.duration = duration; - - // first one is applied directly - if(m_queue.empty() && m_current.pts == DVD_NOPTS_VALUE) - m_current = item; - else - m_queue.push(item); - - // call function to make sure the queue - // doesn't grow should nobody call it - Current(timestamp); -} -void CPTSOutputQueue::Flush() -{ - CSingleLock lock(m_sync); - - while( !m_queue.empty() ) m_queue.pop(); - m_current.pts = DVD_NOPTS_VALUE; - m_current.timestamp = 0.0; - m_current.duration = 0.0; -} - -double CPTSOutputQueue::Current(double timestamp) -{ - CSingleLock lock(m_sync); - - if(!m_queue.empty() && m_current.pts == DVD_NOPTS_VALUE) - { - m_current = m_queue.front(); - m_queue.pop(); - } - - while( !m_queue.empty() && timestamp >= m_queue.front().timestamp ) - { - m_current = m_queue.front(); - m_queue.pop(); - } - - if( m_current.timestamp == 0 ) return m_current.pts; - - return m_current.pts + min(m_current.duration, (timestamp - m_current.timestamp)); -} - CDVDAudio::CDVDAudio(volatile bool &bStop) : m_bStop(bStop) { @@ -160,13 +100,16 @@ void CDVDAudio::Destroy() m_iBitsPerSample = 0; m_bPassthrough = false; m_bPaused = true; - m_time.Flush(); + m_playingPts = DVD_NOPTS_VALUE; } unsigned int CDVDAudio::AddPackets(const DVDAudioFrame &audioframe) { CSingleLock lock (m_critSection); + m_playingPts = audioframe.pts - GetDelay(); + m_timeOfPts = CDVDClock::GetAbsoluteClock(); + if(!m_pAudioStream) return 0; @@ -198,11 +141,6 @@ unsigned int CDVDAudio::AddPackets(const DVDAudioFrame &audioframe) lock.Enter(); } while (!m_bStop); - double time_added = DVD_SEC_TO_TIME(m_SecondsPerByte * audioframe.nb_frames * audioframe.framesize); - double delay = GetDelay(); - double timestamp = CDVDClock::GetAbsoluteClock(); - m_time.Add(audioframe.pts, delay - time_added, audioframe.duration, timestamp); - return total - frames; } @@ -246,8 +184,9 @@ float CDVDAudio::GetCurrentAttenuation() void CDVDAudio::Pause() { CSingleLock lock (m_critSection); - if (m_pAudioStream) m_pAudioStream->Pause(); - m_time.Flush(); + if (m_pAudioStream) + m_pAudioStream->Pause(); + m_playingPts = DVD_NOPTS_VALUE; } void CDVDAudio::Resume() @@ -260,7 +199,7 @@ double CDVDAudio::GetDelay() { CSingleLock lock (m_critSection); - double delay = 0.0; + double delay = 0.3; if(m_pAudioStream) delay = m_pAudioStream->GetDelay(); @@ -275,7 +214,7 @@ void CDVDAudio::Flush() { m_pAudioStream->Flush(); } - m_time.Flush(); + m_playingPts = DVD_NOPTS_VALUE; } bool CDVDAudio::IsValidFormat(const DVDAudioFrame &audioframe) @@ -325,14 +264,15 @@ double CDVDAudio::GetCacheTotal() void CDVDAudio::SetPlayingPts(double pts) { - CSingleLock lock (m_critSection); - m_time.Flush(); - double delay = GetDelay(); - double timestamp = CDVDClock::GetAbsoluteClock(); - m_time.Add(pts, delay, 0, timestamp); + CSingleLock lock(m_critSection); + m_playingPts = pts - GetDelay(); + m_timeOfPts = CDVDClock::GetAbsoluteClock(); } double CDVDAudio::GetPlayingPts() { - return m_time.Current(CDVDClock::GetAbsoluteClock()); + if (m_playingPts == DVD_NOPTS_VALUE) + return 0.0; + + return m_playingPts + CDVDClock::GetAbsoluteClock() - m_timeOfPts; } diff --git a/xbmc/cores/dvdplayer/DVDAudio.h b/xbmc/cores/dvdplayer/DVDAudio.h index 629fb3237e..057a40a1f4 100644 --- a/xbmc/cores/dvdplayer/DVDAudio.h +++ b/xbmc/cores/dvdplayer/DVDAudio.h @@ -36,21 +36,6 @@ extern "C" { typedef struct stDVDAudioFrame DVDAudioFrame; -class CPTSOutputQueue -{ -private: - typedef struct {double pts; double timestamp; double duration;} TPTSItem; - TPTSItem m_current; - std::queue<TPTSItem> m_queue; - CCriticalSection m_sync; - -public: - CPTSOutputQueue(); - void Add(double pts, double delay, double duration, double timestamp); - void Flush(); - double Current(double timestamp); -}; - class CSingleLock; class CDVDAudio @@ -82,7 +67,8 @@ public: IAEStream *m_pAudioStream; protected: - CPTSOutputQueue m_time; + double m_playingPts; + double m_timeOfPts; CCriticalSection m_critSection; int m_iBitrate; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp b/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp index 10648c59fc..7fa7cc09ee 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp @@ -206,7 +206,18 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, unsigne // amcodec can handle dvd playback. if (!hint.software && CSettings::Get().GetBool("videoplayer.useamcodec")) { - if ( (pCodec = OpenCodec(new CDVDVideoCodecAmlogic(), hint, options)) ) return pCodec; + switch(hint.codec) + { + case AV_CODEC_ID_MPEG4: + case AV_CODEC_ID_MSMPEG4V2: + case AV_CODEC_ID_MSMPEG4V3: + // Avoid h/w decoder for SD; Those files might use features + // not supported and can easily be soft-decoded + if (hint.width <= 800) + break; + default: + if ( (pCodec = OpenCodec(new CDVDVideoCodecAmlogic(), hint, options)) ) return pCodec; + } } #endif @@ -249,8 +260,19 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, unsigne #if defined(TARGET_ANDROID) if (!hint.software && CSettings::Get().GetBool("videoplayer.usemediacodec")) { - CLog::Log(LOGINFO, "MediaCodec Video Decoder..."); - if ( (pCodec = OpenCodec(new CDVDVideoCodecAndroidMediaCodec(), hint, options)) ) return pCodec; + switch(hint.codec) + { + case AV_CODEC_ID_MPEG4: + case AV_CODEC_ID_MSMPEG4V2: + case AV_CODEC_ID_MSMPEG4V3: + // Avoid h/w decoder for SD; Those files might use features + // not supported and can easily be soft-decoded + if (hint.width <= 800) + break; + default: + CLog::Log(LOGINFO, "MediaCodec Video Decoder..."); + if ( (pCodec = OpenCodec(new CDVDVideoCodecAndroidMediaCodec(), hint, options)) ) return pCodec; + } } #endif @@ -282,19 +304,15 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, unsigne { switch(hint.codec) { - case CODEC_ID_H264: - case CODEC_ID_MPEG4: - case CODEC_ID_MPEG2VIDEO: - case CODEC_ID_VC1: - case CODEC_ID_WMV3: - case CODEC_ID_VP3: - case CODEC_ID_VP6: - case CODEC_ID_VP6F: - case CODEC_ID_VP8: - if ( (pCodec = OpenCodec(new CDVDVideoCodecStageFright(), hint, options)) ) return pCodec; - break; + case AV_CODEC_ID_MPEG4: + case AV_CODEC_ID_MSMPEG4V2: + case AV_CODEC_ID_MSMPEG4V3: + // Avoid h/w decoder for SD; Those files might use features + // not supported and can easily be soft-decoded + if (hint.width <= 800) + break; default: - break; + if ( (pCodec = OpenCodec(new CDVDVideoCodecStageFright(), hint, options)) ) return pCodec; } } #endif diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodec.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodec.cpp index 0c8562ecdc..9b1d6aba0d 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodec.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodec.cpp @@ -51,4 +51,4 @@ void CDVDOverlayCodec::GetAbsoluteTimes(double &starttime, double &stoptime, Dem stoptime = 0; replace = true; } -}
\ No newline at end of file +} diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecCC.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecCC.cpp deleted file mode 100644 index 20f74be2a8..0000000000 --- a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecCC.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#include "DVDOverlayCodecCC.h" -#include "DVDOverlayText.h" -#include "DVDClock.h" - -extern "C" { -#include "libspucc/cc_decoder.h" -} -CDVDOverlayCodecCC::CDVDOverlayCodecCC() : CDVDOverlayCodec("Closed Caption") -{ - m_pCurrentOverlay = NULL; - Reset(); -} - -CDVDOverlayCodecCC::~CDVDOverlayCodecCC() -{ -} -static cc_decoder_t* m_cc_decoder = NULL; -bool CDVDOverlayCodecCC::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options) -{ - Reset(); - cc_decoder_init(); - m_cc_decoder = cc_decoder_open(); - return true; -} - -void CDVDOverlayCodecCC::Dispose() -{ - Flush(); - if (m_cc_decoder) cc_decoder_close(m_cc_decoder); - m_cc_decoder = NULL; -} -/* -int CDVDOverlayCodecCC::DecodeFieldData(uint8_t* pData, int iSize) -{ -} -*/ - -int CDVDOverlayCodecCC::Decode(DemuxPacket *pPacket) -{ - if (!pPacket) - return OC_ERROR; - - uint8_t *pData = pPacket->pData; - int iSize = pPacket->iSize; - - // minimum amount of data is even more for cc - decode_cc(m_cc_decoder, pData, iSize); - - if (iSize >= 2) - { - Flush(); - m_pCurrentOverlay = new CDVDOverlayText(); - - cc_buffer_t* data = &m_cc_decoder->on_buf->channel[0]; - for (int r = 0; r < CC_ROWS; r++) - { - if (data->rows[r].num_chars > 0) - { - char row_text[CC_COLUMNS + 1]; - row_text[0] = 0; - for (int c = 0; c < data->rows[r].num_chars; c++) - { - row_text[c] = data->rows[r].cells[c].c; - } - row_text[data->rows[r].num_chars] = '\n'; - row_text[data->rows[r].num_chars + 1] = 0; - CDVDOverlayText::CElementText* pText = new CDVDOverlayText::CElementText(row_text); - m_pCurrentOverlay->AddElement(pText); - } - } - - return OC_OVERLAY; - - /* - - m_pCurrentOverlay->iPTSStartTime = pts; - m_pCurrentOverlay->iPTSStopTime = 0LL; - - char test[64]; - sprintf(test, "cc data : %" PRId64, pts); - CDVDOverlayText::CElementText* pText = new CDVDOverlayText::CElementText(test); - m_pCurrentOverlay->AddElement(pText); - return OC_OVERLAY;*/ - } - return OC_BUFFER; -} - -void CDVDOverlayCodecCC::Reset() -{ - Flush(); -} - -void CDVDOverlayCodecCC::Flush() -{ - if (m_pCurrentOverlay) - { - // end time is not always known and may be 0. - // In that case the overlay container does not remove the overlay. - // We set it here to be sure - if (m_pCurrentOverlay->iPTSStopTime == 0LL) - { - m_pCurrentOverlay->iPTSStopTime = m_pCurrentOverlay->iPTSStartTime + 1; - } - m_pCurrentOverlay->Release(); - m_pCurrentOverlay = NULL; - } -} - -CDVDOverlay* CDVDOverlayCodecCC::GetOverlay() -{ - CDVDOverlay* overlay = m_pCurrentOverlay; - m_pCurrentOverlay = NULL; - return overlay; - -} diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecTX3G.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecTX3G.cpp index 93dfdb1c3b..a057acc880 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecTX3G.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecTX3G.cpp @@ -27,11 +27,14 @@ #include "settings/Settings.h" #include "utils/log.h" #include "utils/StringUtils.h" +#include "utils/auto_buffer.h" // 3GPP/TX3G (aka MPEG-4 Timed Text) Subtitle support // 3GPP -> 3rd Generation Partnership Program // adapted from https://trac.handbrake.fr/browser/trunk/libhb/dectx3gsub.c; +#define LEN_CHECK(x) do { if((end - pos) < (x)) return OC_ERROR; } while(0) + // NOTE: None of these macros check for buffer overflow #define READ_U8() *pos; pos += 1; #define READ_U16() (pos[0] << 8) | pos[1]; pos += 2; @@ -92,15 +95,12 @@ int CDVDOverlayCodecTX3G::Decode(DemuxPacket *pPacket) if (m_pOverlay) SAFE_RELEASE(m_pOverlay); - uint8_t *data = pPacket->pData; - int size = pPacket->iSize; - m_pOverlay = new CDVDOverlayText(); CDVDOverlayCodec::GetAbsoluteTimes(m_pOverlay->iPTSStartTime, m_pOverlay->iPTSStopTime, pPacket, m_pOverlay->replace); // do not move this. READ_XXXX macros modify pos. - uint8_t *pos = data; - uint8_t *end = pos + size; + uint8_t *pos = pPacket->pData; + uint8_t *end = pPacket->pData + pPacket->iSize; // Parse the packet as a TX3G TextSample. // Look for a single StyleBox ('styl') and @@ -108,18 +108,26 @@ int CDVDOverlayCodecTX3G::Decode(DemuxPacket *pPacket) // Ignore all other box types. // NOTE: Buffer overflows on read are not checked. // ALSO: READ_XXXX/SKIP_XXXX macros will modify pos. + LEN_CHECK(2); uint16_t textLength = READ_U16(); + LEN_CHECK(textLength); uint8_t *text = READ_ARRAY(textLength); int numStyleRecords = 0; // reserve one more style slot for broken encoders - uint8_t *bgnStyle = (uint8_t*)calloc(textLength+1, 1); - uint8_t *endStyle = (uint8_t*)calloc(textLength+1, 1); + + XUTILS::auto_buffer bgnStyle(textLength+1); + XUTILS::auto_buffer endStyle(textLength+1); + + memset(bgnStyle.get(), 0, textLength+1); + memset(endStyle.get(), 0, textLength+1); + int bgnColorIndex = 0, endColorIndex = 0; uint32_t textColorRGBA = m_textColor; while (pos < end) { // Read TextSampleModifierBox + LEN_CHECK(4); uint32_t size = READ_U32(); if (size == 0) size = pos - end; // extends to end of packet @@ -128,6 +136,7 @@ int CDVDOverlayCodecTX3G::Decode(DemuxPacket *pPacket) CLog::Log(LOGDEBUG, "CDVDOverlayCodecTX3G: TextSampleModifierBox has unsupported large size" ); break; } + LEN_CHECK(4); uint32_t type = READ_U32(); if (type == FOURCC("uuid")) { @@ -141,14 +150,17 @@ int CDVDOverlayCodecTX3G::Decode(DemuxPacket *pPacket) if ( numStyleRecords != 0 ) { CLog::Log(LOGDEBUG, "CDVDOverlayCodecTX3G: found additional StyleBoxes on subtitle; skipping" ); + LEN_CHECK(size); SKIP_ARRAY(size); continue; } + LEN_CHECK(2); numStyleRecords = READ_U16(); for (int i = 0; i < numStyleRecords; i++) { StyleRecord curRecord; + LEN_CHECK(12); curRecord.bgnChar = READ_U16(); curRecord.endChar = READ_U16(); curRecord.fontID = READ_U16(); @@ -164,8 +176,8 @@ int CDVDOverlayCodecTX3G::Decode(DemuxPacket *pPacket) if (curRecord.endChar > textLength) curRecord.endChar = textLength; - bgnStyle[curRecord.bgnChar] |= curRecord.faceStyleFlags; - endStyle[curRecord.endChar] |= curRecord.faceStyleFlags; + bgnStyle.get()[curRecord.bgnChar] |= curRecord.faceStyleFlags; + endStyle.get()[curRecord.endChar] |= curRecord.faceStyleFlags; bgnColorIndex = curRecord.bgnChar; endColorIndex = curRecord.endChar; textColorRGBA = curRecord.textColorRGBA; @@ -174,6 +186,7 @@ int CDVDOverlayCodecTX3G::Decode(DemuxPacket *pPacket) else { // Found some other kind of TextSampleModifierBox. Skip it. + LEN_CHECK(size); SKIP_ARRAY(size); } } @@ -192,8 +205,8 @@ int CDVDOverlayCodecTX3G::Decode(DemuxPacket *pPacket) continue; // ...without incrementing 'charIndex' } - uint8_t bgnStyles = bgnStyle[charIndex]; - uint8_t endStyles = endStyle[charIndex]; + uint8_t bgnStyles = bgnStyle.get()[charIndex]; + uint8_t endStyles = endStyle.get()[charIndex]; // [B] or [/B] -> toggle bold on and off // [I] or [/I] -> toggle italics on and off @@ -228,9 +241,6 @@ int CDVDOverlayCodecTX3G::Decode(DemuxPacket *pPacket) charIndex++; } - free(bgnStyle); - free(endStyle); - if (strUTF8.empty()) return OC_BUFFER; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayText.h b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayText.h index 8325315a7e..2df0be7407 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayText.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayText.h @@ -74,15 +74,15 @@ public: else m_text.assign(strText, size); } - CElementText(const std::string& text) : CElement(ELEMENT_TYPE_TEXT) + CElementText(const std::string& text) : CElement(ELEMENT_TYPE_TEXT), + m_text(text) { - m_text = text; } CElementText(CElementText& src) - : CElement(src) + : CElement(src), + m_text(src.m_text) { - m_text = src.m_text; } const std::string& GetText() diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/Makefile.in b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/Makefile.in index 9e9c56fe54..282a6300f1 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/Makefile.in +++ b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/Makefile.in @@ -1,12 +1,12 @@ INCLUDES+=-I@abs_top_srcdir@/xbmc/cores/dvdplayer SRCS = DVDOverlayCodec.cpp -SRCS += DVDOverlayCodecCC.cpp SRCS += DVDOverlayCodecFFmpeg.cpp SRCS += DVDOverlayCodecSSA.cpp SRCS += DVDOverlayCodecText.cpp SRCS += DVDOverlayCodecTX3G.cpp -SRCS += libspucc/cc_decoder.c +SRCS += contrib/cc_decoder.c +SRCS += contrib/cc_decoder708.cpp LIB = Overlay.a diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/libspucc/cc_decoder.c b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/contrib/cc_decoder.c index 62d3fd0fad..0e7f574ec5 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/libspucc/cc_decoder.c +++ b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/contrib/cc_decoder.c @@ -39,42 +39,31 @@ extern "C" { #include "cc_decoder.h" -//#undef LOG_DEBUG - -/* number of text colors specified by EIA-608 standard */ -#define NUM_FG_COL 7 - -#ifndef TARGET_WINDOWS -/* colors specified by the EIA 608 standard */ -enum { WHITE, GREEN, BLUE, CYAN, RED, YELLOW, MAGENTA, BLACK, TRANSPARENT }; -#else /* colors specified by the EIA 608 standard */ enum { WHITE, GREEN, BLUE, CYAN, RED, YELLOW, MAGENTA, BLACK }; -#endif /* --------------------- misc. EIA 608 definitions -------------------*/ #define TRANSP_SPACE 0x19 /* code for transparent space, essentially - arbitrary */ - -#define MAX(a, b) ((a) > (b)? (a) : (b)) + arbitrary */ /* mapping from PAC row code to actual CC row */ -static int rowdata[] = {10, -1, 0, 1, 2, 3, 11, 12, 13, 14, 4, 5, 6, - 7, 8, 9}; +static int rowdata[] = {10, -1, 0, 1, 2, 3, 11, 12, 13, 14, 4, 5, 6, 7, 8, 9}; /* FIXME: do real TM */ /* must be mapped as a music note in the captioning font */ -static char specialchar[] = {0xAE,0xB0,0xBD,0xBF,0x54,0xA2,0xA3,0xB6,0xA0, - TRANSP_SPACE,0xA8,0xA2,0xAA,0xAE,0xB4,0xBB}; +static unsigned char specialchar[] = {0xAE,0xB0,0xBD,0xBF,0x54,0xA2,0xA3,0xB6,0xA0, + TRANSP_SPACE,0xA8,0xA2,0xAA,0xAE,0xB4,0xBB}; /* character translation table - EIA 608 codes are not all the same as ASCII */ -static char chartbl[128]; +static unsigned char chartbl[128]; /* CC codes use odd parity for error detection, since they originally were */ /* transmitted via noisy video signals */ static int parity_table[256]; +static cc_buffer_t* active_ccbuffer(cc_decoder_t* dec); + /*---------------- general utility functions ---------------------*/ static int parity(uint8_t byte) @@ -90,7 +79,6 @@ static int parity(uint8_t byte) return ones & 1; } - static void build_parity_table(void) { uint8_t byte; @@ -102,7 +90,6 @@ static void build_parity_table(void) } } - static int good_parity(uint16_t data) { int ret = parity_table[data & 0xff] && parity_table[(data & 0xff00) >> 8]; @@ -111,7 +98,6 @@ static int good_parity(uint16_t data) return ret; } - static void build_char_table(void) { int i; @@ -130,18 +116,6 @@ static void build_char_table(void) chartbl[0x7e] = 0xB1; chartbl[0x7f] = 0xA4; /* FIXME: this should be a solid block */ } -/* -static int ccbuf_has_displayable(cc_buffer_t *buf) -{ - int i; - int found = 0; - for (i = 0; !found && i < CC_ROWS; i++) { - if (buf->rows[i].num_chars > 0) - found = 1; - } - return found; -} -*/ static void ccbuf_add_char(cc_buffer_t *buf, uint8_t c) { @@ -149,29 +123,18 @@ static void ccbuf_add_char(cc_buffer_t *buf, uint8_t c) int pos = rowbuf->pos; int left_displayable = (pos > 0) && (pos <= rowbuf->num_chars); -#if LOG_DEBUG > 2 - printf("cc_decoder: ccbuf_add_char: %c @ %d/%d\n", c, buf->rowpos, pos); -#endif - - if (pos >= CC_COLUMNS) { - printf("cc_decoder: ccbuf_add_char: row buffer overflow\n"); + if (pos >= CC_COLUMNS) + { return; } - if (pos > rowbuf->num_chars) { - /* fill up to indented position with transparent spaces, if necessary */ - /* ccrow_fill_transp(rowbuf); */ - } - /* midrow PAC attributes are applied only if there is no displayable */ /* character to the immediate left. This makes the implementation rather */ /* complicated, but this is what the EIA-608 standard specifies. :-( */ - if (rowbuf->pac_attr_chg && !rowbuf->attr_chg && !left_displayable) { + if (rowbuf->pac_attr_chg && !rowbuf->attr_chg && !left_displayable) + { rowbuf->attr_chg = 1; rowbuf->cells[pos].attributes = rowbuf->pac_attr; -#ifdef LOG_DEBUG - printf("cc_decoder: ccbuf_add_char: Applying midrow PAC.\n"); -#endif } rowbuf->cells[pos].c = c; @@ -222,10 +185,8 @@ static void ccbuf_tab(cc_buffer_t *buf, int tabsize) { cc_row_t *rowbuf = &buf->rows[buf->rowpos]; rowbuf->pos += tabsize; - if (rowbuf->pos > CC_COLUMNS) { -#ifdef LOG_DEBUG - printf("cc_decoder: ccbuf_tab: row buffer overflow\n"); -#endif + if (rowbuf->pos > CC_COLUMNS) + { rowbuf->pos = CC_COLUMNS; return; } @@ -234,37 +195,88 @@ static void ccbuf_tab(cc_buffer_t *buf, int tabsize) /*----------------- cc_memory_t methods --------------------------------*/ +static void ccrow_der(cc_row_t *row, int pos) +{ + int i; + for (i = pos; i < CC_COLUMNS; i++) + { + row->cells[i].c = ' '; + } +} + static void ccmem_clear(cc_memory_t *buf) { -#ifdef LOG_DEBUG - printf("cc_decoder.c: ccmem_clear: Clearing CC memory\n"); -#endif + int i; memset(buf, 0, sizeof (cc_memory_t)); + for (i = 0; i < CC_ROWS; i++) + { + ccrow_der(&buf->channel[0].rows[i], 0); + ccrow_der(&buf->channel[1].rows[i], 0); + } } - static void ccmem_init(cc_memory_t *buf) { ccmem_clear(buf); } - static void ccmem_exit(cc_memory_t *buf) { /*FIXME: anything to deallocate?*/ } +void ccmem_tobuf(cc_decoder_t *dec) +{ + cc_buffer_t *buf = &dec->on_buf->channel[dec->on_buf->channel_no]; + int empty = 1; + dec->textlen = 0; + int i,j; + for (i = 0; i < CC_ROWS; i++) + { + for (j = 0; j<CC_COLUMNS; j++) + if (buf->rows[i].cells[j].c != ' ') + { + empty = 0; + break; + } + if (!empty) + break; + } + if (empty) + return; // Nothing to write + + for (i = 0; i<CC_ROWS; i++) + { + int empty = 1; + for (j = 0; j<CC_COLUMNS; j++) + if (buf->rows[i].cells[j].c != ' ') + empty = 0; + if (!empty) + { + int f, l; // First,last used char + for (f = 0; f<CC_COLUMNS; f++) + if (buf->rows[i].cells[f].c != ' ') + break; + for (l = CC_COLUMNS-1; l>0; l--) + if (buf->rows[i].cells[f].c != ' ') + break; + for (j = f; j <= l; j++) + dec->text[dec->textlen++] = buf->rows[i].cells[j].c; + dec->text[dec->textlen++] = '\n'; + } + } + dec->text[dec->textlen++] = '\n'; + dec->text[dec->textlen++] = '\0'; + dec->callback(0, dec->userdata); +} + /*----------------- cc_decoder_t methods --------------------------------*/ static void cc_set_channel(cc_decoder_t *dec, int channel) { (*dec->active)->channel_no = channel; -#ifdef LOG_DEBUG - printf("cc_decoder: cc_set_channel: selecting channel %d\n", channel); -#endif } - static cc_buffer_t *active_ccbuffer(cc_decoder_t *dec) { cc_memory_t *mem = *dec->active; @@ -278,9 +290,6 @@ static void cc_swap_buffers(cc_decoder_t *dec) /* hide caption in displayed memory */ /* cc_hide_displayed(dec); */ -#ifdef LOG_DEBUG - printf("cc_decoder: cc_swap_buffers: swapping caption memory\n"); -#endif temp = dec->on_buf; dec->on_buf = dec->off_buf; dec->off_buf = temp; @@ -289,6 +298,27 @@ static void cc_swap_buffers(cc_decoder_t *dec) /* cc_show_displayed(dec); */ } +static void cc_roll_up(cc_decoder_t *dec) +{ + cc_buffer_t *buf = active_ccbuffer(dec); + int i, j; + for (i = buf->rowpos - dec->rollup_rows + 1; i < buf->rowpos; i++) + { + if (i < 0) + continue; + + for (j = 0; j < CC_COLUMNS; j++) + { + buf->rows[i].cells[j] = buf->rows[i + 1].cells[j]; + } + } + for (j = 0; j < CC_COLUMNS; j++) + { + buf->rows[buf->rowpos].cells[j].c = ' '; + } + buf->rows[buf->rowpos].pos = 0; +} + static void cc_decode_standard_char(cc_decoder_t *dec, uint8_t c1, uint8_t c2) { cc_buffer_t *buf = active_ccbuffer(dec); @@ -315,11 +345,13 @@ static void cc_decode_PAC(cc_decoder_t *dec, int channel, buf = active_ccbuffer(dec); row = rowdata[((c1 & 0x07) << 1) | ((c2 & 0x20) >> 5)]; - if (c2 & 0x10) { + if (c2 & 0x10) + { column = ((c2 & 0x0e) >> 1) * 4; /* preamble indentation */ color = WHITE; /* indented lines have white color */ } - else if ((c2 & 0x0e) == 0x0e) { + else if ((c2 & 0x0e) == 0x0e) + { italics = 1; /* italics, they are always white */ color = WHITE; } @@ -327,11 +359,6 @@ static void cc_decode_PAC(cc_decoder_t *dec, int channel, color = (c2 & 0x0e) >> 1; underline = c2 & 0x01; -#ifdef LOG_DEBUG - printf("cc_decoder: cc_decode_PAC: row %d, col %d, ul %d, it %d, clr %d\n", - row, column, underline, italics, color); -#endif - ccbuf_set_cursor(buf, row, column, underline, italics, color); } @@ -342,7 +369,6 @@ static void cc_decode_ext_attribute(cc_decoder_t *dec, int channel, cc_set_channel(dec, channel); } - static void cc_decode_special_char(cc_decoder_t *dec, int channel, uint8_t c1, uint8_t c2) { @@ -350,13 +376,9 @@ static void cc_decode_special_char(cc_decoder_t *dec, int channel, cc_set_channel(dec, channel); buf = active_ccbuffer(dec); -#ifdef LOG_DEBUG - printf("cc_decoder: cc_decode_special_char: Mapping %x to %x\n", c2, specialchar[c2 & 0xf]); -#endif ccbuf_add_char(buf, specialchar[c2 & 0xf]); } - static void cc_decode_midrow_attr(cc_decoder_t *dec, int channel, uint8_t c1, uint8_t c2) { @@ -365,21 +387,18 @@ static void cc_decode_midrow_attr(cc_decoder_t *dec, int channel, cc_set_channel(dec, channel); buf = active_ccbuffer(dec); - if (c2 < 0x2e) { + if (c2 < 0x2e) + { attr.italic = 0; attr.foreground = (c2 & 0xe) >> 1; } - else { + else + { attr.italic = 1; attr.foreground = WHITE; } attr.underline = c2 & 0x1; attr.background = BLACK; -#ifdef LOG_DEBUG - printf("cc_decoder: cc_decode_midrow_attr: attribute %x\n", c2); - printf("cc_decoder: cc_decode_midrow_attr: ul %d, it %d, clr %d\n", - attr.underline, attr.italic, attr.foreground); -#endif ccbuf_apply_attribute(buf, &attr); } @@ -388,39 +407,40 @@ static void cc_decode_midrow_attr(cc_decoder_t *dec, int channel, static void cc_decode_misc_control_code(cc_decoder_t *dec, int channel, uint8_t c1, uint8_t c2) { -#ifdef LOG_DEBUG - printf("cc_decoder: decode_misc: decoding %x %x\n", c1, c2); -#endif - cc_set_channel(dec, channel); + cc_buffer_t *buf; - switch (c2) { /* 0x20 <= c2 <= 0x2f */ - + switch (c2) + { /* 0x20 <= c2 <= 0x2f */ case 0x20: /* RCL */ + dec->style = CC_POPON; + dec->active = &dec->off_buf; break; case 0x21: /* backspace */ -#ifdef LOG_DEBUG - printf("cc_decoder: backspace\n"); -#endif break; case 0x24: /* DER */ + buf = active_ccbuffer(dec); + ccrow_der(&buf->rows[buf->rowpos], buf->rows[buf->rowpos].pos); break; case 0x25: /* RU2 */ - break; - + dec->rollup_rows = 2; case 0x26: /* RU3 */ - break; - + dec->rollup_rows = 3; case 0x27: /* RU4 */ + dec->rollup_rows = 4; + dec->style = CC_ROLLUP; + dec->active = &dec->on_buf; break; case 0x28: /* FON */ break; case 0x29: /* RDC */ + dec->style = CC_PAINTON; + dec->active = &dec->on_buf; break; case 0x2a: /* TR */ @@ -435,6 +455,10 @@ static void cc_decode_misc_control_code(cc_decoder_t *dec, int channel, break; case 0x2d: /* carriage return */ + if (dec->style == CC_ROLLUP) + { + cc_roll_up(dec); + } break; case 0x2e: /* ENM - erase non-displayed memory */ @@ -443,11 +467,16 @@ static void cc_decode_misc_control_code(cc_decoder_t *dec, int channel, case 0x2f: /* EOC - swap displayed and non displayed memory */ cc_swap_buffers(dec); + dec->style = CC_POPON; + dec->active = &dec->off_buf; + ccmem_tobuf(dec); + break; + + default: break; } } - static void cc_decode_tab(cc_decoder_t *dec, int channel, uint8_t c1, uint8_t c2) { @@ -458,58 +487,73 @@ static void cc_decode_tab(cc_decoder_t *dec, int channel, ccbuf_tab(buf, c2 & 0x3); } - static void cc_decode_EIA608(cc_decoder_t *dec, uint16_t data) { uint8_t c1 = data & 0x7f; uint8_t c2 = (data >> 8) & 0x7f; -#if LOG_DEBUG >= 3 - printf("decoding %x %x\n", c1, c2); -#endif + if (c1 & 0x60) + { /* normal character, 0x20 <= c1 <= 0x7f */ + if (dec->style == CC_NOTSET) + return; - if (c1 & 0x60) { /* normal character, 0x20 <= c1 <= 0x7f */ cc_decode_standard_char(dec, c1, c2); + if (dec->style == CC_ROLLUP) + { + ccmem_tobuf(dec); + } } - else if (c1 & 0x10) { /* control code or special character */ + else if (c1 & 0x10) + { /* control code or special character */ /* 0x10 <= c1 <= 0x1f */ int channel = (c1 & 0x08) >> 3; c1 &= ~0x08; /* control sequences are often repeated. In this case, we should */ /* evaluate it only once. */ - if (data != dec->lastcode) { - - if (c2 & 0x40) { /* preamble address code: 0x40 <= c2 <= 0x7f */ - cc_decode_PAC(dec, channel, c1, c2); + if (data != dec->lastcode) + { + if (c2 & 0x40) + { /* preamble address code: 0x40 <= c2 <= 0x7f */ + cc_decode_PAC(dec, channel, c1, c2); } - else { - switch (c1) { - - case 0x10: /* extended background attribute code */ - cc_decode_ext_attribute(dec, channel, c1, c2); - break; - - case 0x11: /* attribute or special character */ - if ((c2 & 0x30) == 0x30) { /* special char: 0x30 <= c2 <= 0x3f */ - cc_decode_special_char(dec, channel, c1, c2); - } - else if (c2 & 0x20) { /* midrow attribute: 0x20 <= c2 <= 0x2f */ - cc_decode_midrow_attr(dec, channel, c1, c2); - } - break; - - case 0x14: /* possibly miscellaneous control code */ - cc_decode_misc_control_code(dec, channel, c1, c2); - break; - - case 0x17: /* possibly misc. control code TAB offset */ - /* 0x21 <= c2 <= 0x23 */ - if (c2 >= 0x21 && c2 <= 0x23) { - cc_decode_tab(dec, channel, c1, c2); - } - break; - } + else + { + switch (c1) + { + case 0x10: /* extended background attribute code */ + cc_decode_ext_attribute(dec, channel, c1, c2); + break; + + case 0x11: /* attribute or special character */ + if (dec->style == CC_NOTSET) + return; + if ((c2 & 0x30) == 0x30) + { /* special char: 0x30 <= c2 <= 0x3f */ + cc_decode_special_char(dec, channel, c1, c2); + if (dec->style == CC_ROLLUP) + { + ccmem_tobuf(dec); + } + } + else if (c2 & 0x20) + { /* midrow attribute: 0x20 <= c2 <= 0x2f */ + cc_decode_midrow_attr(dec, channel, c1, c2); + } + break; + + case 0x14: /* possibly miscellaneous control code */ + cc_decode_misc_control_code(dec, channel, c1, c2); + break; + + case 0x17: /* possibly misc. control code TAB offset */ + /* 0x21 <= c2 <= 0x23 */ + if (c2 >= 0x21 && c2 <= 0x23) + { + cc_decode_tab(dec, channel, c1, c2); + } + break; + } } } } @@ -520,99 +564,34 @@ static void cc_decode_EIA608(cc_decoder_t *dec, uint16_t data) void decode_cc(cc_decoder_t *dec, uint8_t *buffer, uint32_t buf_len) { - /* The first number may denote a channel number. I don't have the - * EIA-708 standard, so it is hard to say. - * From what I could figure out so far, the general format seems to be: - * - * repeat - * - * 0xfe starts 2 byte sequence of unknown purpose. It might denote - * field #2 in line 21 of the VBI. We'll ignore it for the - * time being. - * - * 0xff starts 2 byte EIA-608 sequence, field #1 in line 21 of the VBI. - * Followed by a 3-code triplet that starts either with 0xff or - * 0xfe. In either case, the following triplet needs to be ignored - * for line 21, field 1. - * - * 0x00 is padding, followed by 2 more 0x00. - * - * 0x01 always seems to appear at the beginning, always seems to - * be followed by 0xf8, 8-bit number. - * The lower 7 bits of this 8-bit number seem to denote the - * number of code triplets that follow. - * The most significant bit denotes whether the Line 21 field 1 - * captioning information is at odd or even triplet offsets from this - * beginning triplet. 1 denotes odd offsets, 0 denotes even offsets. - * - * Most captions are encoded with odd offsets, so this is what we - * will assume. - * - * until end of packet - */ - uint8_t *current = buffer; - uint32_t curbytes = 0; - int odd_offset = 1; - - while (curbytes < buf_len) { - int skip = 2; - - uint8_t cc_code = *current++; - curbytes++; + uint32_t i; + for (i = 0; i<buf_len; i += 3) + { - if (buf_len - curbytes < 2) { -#ifdef LOG_DEBUG - fprintf(stderr, "Not enough data for 2-byte CC encoding\n"); -#endif - break; - } - - uint8_t data1 = *current; - uint8_t data2 = *(current + 1); - - switch (cc_code) { - case 0xfe: - /* expect 2 byte encoding (perhaps CC3, CC4?) */ - /* ignore for time being */ - skip = 2; - break; - - case 0xff: - /* expect EIA-608 CC1/CC2 encoding */ - if (good_parity(data1 | (data2 << 8))) { - cc_decode_EIA608(dec, data1 | (data2 << 8)); + unsigned char cc_valid = buffer[i] & 0x04; + unsigned char cc_type = buffer[i] & 0x03; + uint8_t data1 = buffer[i + 1]; + uint8_t data2 = buffer[i + 2]; + + switch (cc_type) + { + case 0: + if (good_parity(data1 | (data2 << 8))) + { + cc_decode_EIA608(dec, data1 | (data2 << 8)); } - skip = 5; - break; - - case 0x00: - /* This seems to be just padding */ - skip = 2; break; - case 0x01: - odd_offset = data2 & 0x80; - if (odd_offset) - skip = 2; - else - skip = 5; + case 1: break; default: -#ifdef LOG_DEBUG - fprintf(stderr, "Unknown CC encoding: %x\n", cc_code); -#endif - skip = 2; break; } - current += skip; - curbytes += skip; } } - - cc_decoder_t *cc_decoder_open() { cc_decoder_t *dec = (cc_decoder_t *) calloc(1, sizeof (cc_decoder_t)); @@ -626,25 +605,16 @@ cc_decoder_t *cc_decoder_open() dec->active = &dec->off_buf; dec->lastcode = 0; - dec->capid = 0; -#ifdef LOG_DEBUG - printf("spucc: cc_decoder_open\n"); -#endif return dec; } - void cc_decoder_close(cc_decoder_t *dec) { ccmem_exit(&dec->buffer[0]); ccmem_exit(&dec->buffer[1]); free(dec); - -#ifdef LOG_DEBUG - printf("spucc: cc_decoder_close\n"); -#endif } diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/libspucc/cc_decoder.h b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/contrib/cc_decoder.h index 8dd9228456..67a9daa362 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/libspucc/cc_decoder.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/contrib/cc_decoder.h @@ -27,33 +27,7 @@ * available at http://sourceforge.net/projects/ccdecoder/. */ -#ifdef TARGET_POSIX -#undef EMULATE_INTTYPES -#else -#define EMULATE_INTTYPES -#endif /* TARGET_POSIX */ - -#ifndef EMULATE_INTTYPES -# include <stdint.h> -#else - typedef signed char int8_t; - typedef signed short int16_t; - typedef signed int int32_t; - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned int uint32_t; - -# ifdef CONFIG_WIN32 - typedef signed __int64 int64_t; - typedef unsigned __int64 uint64_t; -# elif __WORDSIZE == 64 - typedef long int int64_t; - typedef unsigned long int uint64_t; -# else /* other OS */ - typedef signed long long int64_t; - typedef unsigned long long uint64_t; -# endif /* other OS */ -#endif /* EMULATE_INTTYPES */ +#include <stdint.h> #define CC_ROWS 15 #define CC_COLUMNS 32 @@ -67,7 +41,8 @@ typedef struct cc_attribute_s { } cc_attribute_t; /* CC character cell */ -typedef struct cc_char_cell_s { +typedef struct cc_char_cell_s +{ uint8_t c; /* character code, not the same as ASCII */ cc_attribute_t attributes; /* attributes of this character, if changed */ /* here */ @@ -75,7 +50,8 @@ typedef struct cc_char_cell_s { } cc_char_cell_t; /* a single row in the closed captioning memory */ -typedef struct cc_row_s { +typedef struct cc_row_s +{ cc_char_cell_t cells[CC_COLUMNS]; int pos; /* position of the cursor */ int num_chars; /* how many characters in the row are data */ @@ -85,19 +61,30 @@ typedef struct cc_row_s { } cc_row_t; /* closed captioning memory for a single channel */ -typedef struct cc_buffer_s { +typedef struct cc_buffer_s +{ cc_row_t rows[CC_ROWS]; int rowpos; /* row cursor position */ } cc_buffer_t; /* captioning memory for all channels */ -typedef struct cc_memory_s { +typedef struct cc_memory_s +{ cc_buffer_t channel[CC_CHANNELS]; int channel_no; /* currently active channel */ } cc_memory_t; +enum cc_style +{ + CC_NOTSET = 0, + CC_ROLLUP, + CC_PAINTON, + CC_POPON +}; + /* The closed captioning decoder data structure */ -struct cc_decoder_s { +struct cc_decoder_s +{ /* CC decoder buffer - one onscreen, one offscreen */ cc_memory_t buffer[2]; /* onscreen, offscreen buffer ptrs */ @@ -106,42 +93,20 @@ struct cc_decoder_s { /* which buffer is active for receiving data */ cc_memory_t **active; - /* for logging and debugging purposes, captions are assigned increasing */ - /* unique ids. */ - uint32_t capid; - /* the last captioning code seen (control codes are often sent twice in a row, but should be processed only once) */ uint32_t lastcode; -}; -typedef struct cc_decoder_s cc_decoder_t; - -#define NUM_CC_PALETTES 2 -extern char *cc_schemes[NUM_CC_PALETTES + 1]; - -#define CC_FONT_MAX 256 + uint16_t rollup_rows; + enum cc_style style; -typedef struct cc_config_s { - int cc_enabled; /* true if closed captions are enabled */ - char font[CC_FONT_MAX]; /* standard captioning font & size */ - int font_size; - char italic_font[CC_FONT_MAX]; /* italic captioning font & size */ - int center; /* true if captions should be centered */ - /* according to text width */ - int cc_scheme; /* which captioning scheme to use */ - - int config_version; /* the decoder should be updated when this is increased */ -} cc_config_t; + void *userdata; + void(*callback)(int service, void *userdata); + char text[CC_ROWS*CC_COLUMNS + 1]; + int textlen; +}; -typedef struct cc_state_s { - cc_config_t *cc_cfg; - /* the following variables are not controlled by configuration files; they */ - /* are intrinsic to the properties of the configuration options and the */ - /* currently played video */ - int can_cc; /* true if captions can be displayed */ - /* (e.g., font fits on screen) */ -} cc_state_t; +typedef struct cc_decoder_s cc_decoder_t; cc_decoder_t *cc_decoder_open(); void cc_decoder_close(cc_decoder_t *this_obj); diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/contrib/cc_decoder708.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/contrib/cc_decoder708.cpp new file mode 100644 index 0000000000..05dd9db01c --- /dev/null +++ b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/contrib/cc_decoder708.cpp @@ -0,0 +1,1154 @@ +/* + * this is mostly borrowed from ccextractor http://ccextractor.sourceforge.net/ + */ + +#include "cc_decoder708.h" +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +/******************************************************** +256 BYTES IS ENOUGH FOR ALL THE SUPPORTED CHARACTERS IN +EIA-708, SO INTERNALLY WE USE THIS TABLE (FOR CONVENIENCE) + +00-1F -> Characters that are in the G2 group in 20-3F, + except for 06, which is used for the closed captions + sign "CC" which is defined in group G3 as 00. (this + is by the article 33). +20-7F -> Group G0 as is - corresponds to the ASCII code +80-9F -> Characters that are in the G2 group in 60-7F + (there are several blank characters here, that's OK) +A0-FF -> Group G1 as is - non-English characters and symbols +*/ + +unsigned char get_internal_from_G0 (unsigned char g0_char) +{ + return g0_char; +} + +unsigned char get_internal_from_G1 (unsigned char g1_char) +{ + return g1_char; +} + +// TODO: Probably not right +// G2: Extended Control Code Set 1 +unsigned char get_internal_from_G2 (unsigned char g2_char) +{ + // according to the comment a few lines above those lines are indeed wrong + /* + if (g2_char>=0x20 && g2_char<=0x3F) + return g2_char-0x20; + if (g2_char>=0x60 && g2_char<=0x7F) + return g2_char+0x20; + */ + // Rest unmapped, so we return a blank space + return 0x20; +} + +// TODO: Probably not right +// G3: Future Characters and Icon Expansion +unsigned char get_internal_from_G3 (unsigned char g3_char) +{ + if (g3_char==0xa0) // The "CC" (closed captions) sign + return 0x06; + // Rest unmapped, so we return a blank space + return 0x20; +} + +void clearTV (cc708_service_decoder *decoder); + +const char *COMMANDS_C0[32]= +{ + "NUL", // 0 = NUL + NULL, // 1 = Reserved + NULL, // 2 = Reserved + "ETX", // 3 = ETX + NULL, // 4 = Reserved + NULL, // 5 = Reserved + NULL, // 6 = Reserved + NULL, // 7 = Reserved + "BS", // 8 = Backspace + NULL, // 9 = Reserved + NULL, // A = Reserved + NULL, // B = Reserved + "FF", // C = FF + "CR", // D = CR + "HCR", // E = HCR + NULL, // F = Reserved + "EXT1",// 0x10 = EXT1, + NULL, // 0x11 = Reserved + NULL, // 0x12 = Reserved + NULL, // 0x13 = Reserved + NULL, // 0x14 = Reserved + NULL, // 0x15 = Reserved + NULL, // 0x16 = Reserved + NULL, // 0x17 = Reserved + "P16", // 0x18 = P16 + NULL, // 0x19 = Reserved + NULL, // 0x1A = Reserved + NULL, // 0x1B = Reserved + NULL, // 0x1C = Reserved + NULL, // 0x1D = Reserved + NULL, // 0x1E = Reserved + NULL, // 0x1F = Reserved +}; + +struct S_COMMANDS_C1 COMMANDS_C1[32]= +{ + {CW0,"CW0","SetCurrentWindow0", 1}, + {CW1,"CW1","SetCurrentWindow1", 1}, + {CW2,"CW2","SetCurrentWindow2", 1}, + {CW3,"CW3","SetCurrentWindow3", 1}, + {CW4,"CW4","SetCurrentWindow4", 1}, + {CW5,"CW5","SetCurrentWindow5", 1}, + {CW6,"CW6","SetCurrentWindow6", 1}, + {CW7,"CW7","SetCurrentWindow7", 1}, + {CLW,"CLW","ClearWindows", 2}, + {DSW,"DSW","DisplayWindows", 2}, + {HDW,"HDW","HideWindows", 2}, + {TGW,"TGW","ToggleWindows", 2}, + {DLW,"DLW","DeleteWindows", 2}, + {DLY,"DLY","Delay", 2}, + {DLC,"DLC","DelayCancel", 1}, + {RST,"RST","Reset", 1}, + {SPA,"SPA","SetPenAttributes", 3}, + {SPC,"SPC","SetPenColor", 4}, + {SPL,"SPL","SetPenLocation", 3}, + {RSV93,"RSV93","Reserved", 1}, + {RSV94,"RSV94","Reserved", 1}, + {RSV95,"RSV95","Reserved", 1}, + {RSV96,"RSV96","Reserved", 1}, + {SWA,"SWA","SetWindowAttributes", 5}, + {DF0,"DF0","DefineWindow0", 7}, + {DF1,"DF0","DefineWindow1", 7}, + {DF2,"DF0","DefineWindow2", 7}, + {DF3,"DF0","DefineWindow3", 7}, + {DF4,"DF0","DefineWindow4", 7}, + {DF5,"DF0","DefineWindow5", 7}, + {DF6,"DF0","DefineWindow6", 7}, + {DF7,"DF0","DefineWindow7", 7} +}; + +void clear_packet(cc708_service_decoder *decoder) +{ + decoder->parent->m_current_packet_length = 0; +} + +void cc708_service_reset(cc708_service_decoder *decoder) +{ + // There's lots of other stuff that we need to do, such as canceling delays + for (int j=0;j<8;j++) + { + decoder->windows[j].is_defined=0; + decoder->windows[j].visible=0; + decoder->windows[j].memory_reserved=0; + decoder->windows[j].is_empty=1; + memset (decoder->windows[j].commands, 0, + sizeof (decoder->windows[j].commands)); + } + decoder->current_window=-1; + clearTV(decoder); + decoder->inited=1; +} + +void cc708_reset(cc708_service_decoder *decoders) +{ + for (int i = 0; i<CCX_DECODERS_708_MAX_SERVICES; i++) + { + cc708_service_reset (&decoders[i]); + } + // Empty packet buffer + clear_packet(&decoders[0]); + decoders[0].parent->m_last_seq = -1; +} + +int compWindowsPriorities (const void *a, const void *b) +{ + e708Window *w1=*(e708Window **)a; + e708Window *w2=*(e708Window **)b; + return w1->priority-w2->priority; +} + +void clearTV (cc708_service_decoder *decoder) +{ + for (int i=0; i<I708_SCREENGRID_ROWS; i++) + { + memset (decoder->tv.chars[i], ' ', I708_SCREENGRID_COLUMNS); + decoder->tv.chars[i][I708_SCREENGRID_COLUMNS]=0; + } +}; + +void printTVtoBuf (cc708_service_decoder *decoder) +{ + int empty=1; + decoder->textlen = 0; + for (int i=0;i<75;i++) + { + for (int j=0;j<210;j++) + if (decoder->tv.chars[i][j] != ' ') + { + empty=0; + break; + } + if (!empty) + break; + } + if (empty) + return; // Nothing to write + + for (int i=0;i<75;i++) + { + int empty=1; + for (int j=0;j<210;j++) + if (decoder->tv.chars[i][j] != ' ') + empty=0; + if (!empty) + { + int f,l; // First,last used char + for (f=0;f<210;f++) + if (decoder->tv.chars[i][f] != ' ') + break; + for (l=209;l>0;l--) + if (decoder->tv.chars[i][l]!=' ') + break; + for (int j=f;j<=l;j++) + decoder->text[decoder->textlen++] = decoder->tv.chars[i][j]; + decoder->text[decoder->textlen++] = '\r'; + decoder->text[decoder->textlen++] = '\n'; + } + } + decoder->text[decoder->textlen++] = '\r'; + decoder->text[decoder->textlen++] = '\n'; + decoder->text[decoder->textlen++] = '\0'; +} + +void updateScreen (cc708_service_decoder *decoder) +{ + clearTV (decoder); + + // THIS FUNCTION WILL DO THE MAGIC OF ACTUALLY EXPORTING THE DECODER STATUS + // TO SEVERAL FILES + e708Window *wnd[I708_MAX_WINDOWS]; // We'll store here the visible windows that contain anything + int visible=0; + for (int i=0;i<I708_MAX_WINDOWS;i++) + { + if (decoder->windows[i].is_defined && decoder->windows[i].visible && !decoder->windows[i].is_empty) + wnd[visible++]=&decoder->windows[i]; + } + qsort (wnd,visible,sizeof (e708Window *),compWindowsPriorities); + + for (int i=0;i<visible;i++) + { + int top,left; + // For each window we calculate the top,left position depending on the + // anchor + switch (wnd[i]->anchor_point) + { + case anchorpoint_top_left: + top=wnd[i]->anchor_vertical; + left=wnd[i]->anchor_horizontal; + break; + case anchorpoint_top_center: + top=wnd[i]->anchor_vertical; + left=wnd[i]->anchor_horizontal - wnd[i]->col_count/2; + break; + case anchorpoint_top_right: + top=wnd[i]->anchor_vertical; + left=wnd[i]->anchor_horizontal - wnd[i]->col_count; + break; + case anchorpoint_middle_left: + top=wnd[i]->anchor_vertical - wnd[i]->row_count/2; + left=wnd[i]->anchor_horizontal; + break; + case anchorpoint_middle_center: + top=wnd[i]->anchor_vertical - wnd[i]->row_count/2; + left=wnd[i]->anchor_horizontal - wnd[i]->col_count/2; + break; + case anchorpoint_middle_right: + top=wnd[i]->anchor_vertical - wnd[i]->row_count/2; + left=wnd[i]->anchor_horizontal - wnd[i]->col_count; + break; + case anchorpoint_bottom_left: + top=wnd[i]->anchor_vertical - wnd[i]->row_count; + left=wnd[i]->anchor_horizontal; + break; + case anchorpoint_bottom_center: + top=wnd[i]->anchor_vertical - wnd[i]->row_count; + left=wnd[i]->anchor_horizontal - wnd[i]->col_count/2; + break; + case anchorpoint_bottom_right: + top=wnd[i]->anchor_vertical - wnd[i]->row_count; + left=wnd[i]->anchor_horizontal - wnd[i]->col_count; + break; + default: // Shouldn't happen, but skip the window just in case + continue; + } + if (top<0) + top=0; + if (left<0) + left=0; + int copyrows=top + wnd[i]->row_count >= I708_SCREENGRID_ROWS ? + I708_SCREENGRID_ROWS - top : wnd[i]->row_count; + int copycols=left + wnd[i]->col_count >= I708_SCREENGRID_COLUMNS ? + I708_SCREENGRID_COLUMNS - left : wnd[i]->col_count; + for (int j=0;j<copyrows;j++) + { + memcpy (decoder->tv.chars[top+j],wnd[i]->rows[j],copycols); + } + } + printTVtoBuf(decoder); + decoder->callback(decoder->service, decoder->userdata); +} + +void rollupWindow(cc708_service_decoder *decoder, int window) +{ + for (int row=0; row<decoder->windows[window].row_count - 1; row++) + { + memcpy(decoder->windows[window].rows[row], decoder->windows[window].rows[row+1], decoder->windows[window].col_count); + } + memset(decoder->windows[window].rows[decoder->windows[window].row_count-1], ' ', decoder->windows[window].col_count); +} + +/* This function handles future codes. While by definition we can't do any work on them, we must return +how many bytes would be consumed if these codes were supported, as defined in the specs. +Note: EXT1 not included */ +// C2: Extended Miscellaneous Control Codes +// TODO: This code is completely untested due to lack of samples. Just following specs! +int handle_708_C2 (cc708_service_decoder *decoder, unsigned char *data, int data_length) +{ + if (data[0]<=0x07) // 00-07... + return 1; // ... Single-byte control bytes (0 additional bytes) + else if (data[0]<=0x0f) // 08-0F ... + return 2; // ..two-byte control codes (1 additional byte) + else if (data[0]<=0x17) // 10-17 ... + return 3; // ..three-byte control codes (2 additional bytes) + return 4; // 18-1F => four-byte control codes (3 additional bytes) +} + +int handle_708_C3 (cc708_service_decoder *decoder, unsigned char *data, int data_length) +{ + if (data[0]<0x80 || data[0]>0x9F) + ;//ccx_common_logging.fatal_ftn (CCX_COMMON_EXIT_BUG_BUG, "Entry in handle_708_C3 with an out of range value."); + if (data[0]<=0x87) // 80-87... + return 5; // ... Five-byte control bytes (4 additional bytes) + else if (data[0]<=0x8F) // 88-8F ... + return 6; // ..Six-byte control codes (5 additional byte) + // If here, then 90-9F ... + + // These are variable length commands, that can even span several segments + // (they allow even downloading fonts or graphics). + // TODO: Implemen if a sample ever appears + return 0; // Unreachable, but otherwise there's compilers warnings +} + +// This function handles extended codes (EXT1 + code), from the extended sets +// G2 (20-7F) => Mostly unmapped, except for a few characters. +// G3 (A0-FF) => A0 is the CC symbol, everything else reserved for future expansion in EIA708-B +// C2 (00-1F) => Reserved for future extended misc. control and captions command codes +// TODO: This code is completely untested due to lack of samples. Just following specs! +// Returns number of used bytes, usually 1 (since EXT1 is not counted). +int handle_708_extended_char (cc708_service_decoder *decoder, unsigned char *data, int data_length) +{ + int used; + unsigned char c=0x20; // Default to space + unsigned char code=data[0]; + if (/* data[i]>=0x00 && */ code<=0x1F) // Comment to silence warning + { + used=handle_708_C2 (decoder, data, data_length); + } + // Group G2 - Extended Miscellaneous Characters + else if (code>=0x20 && code<=0x7F) + { + c=get_internal_from_G2 (code); + used=1; + process_character (decoder, c); + } + // Group C3 + else if (code>=0x80 && code<=0x9F) + { + used=handle_708_C3 (decoder, data, data_length); + // TODO: Something + } + // Group G3 + else + { + c=get_internal_from_G3 (code); + used=1; + process_character (decoder, c); + } + return used; +} + +void process_cr (cc708_service_decoder *decoder) +{ + switch (decoder->windows[decoder->current_window].attribs.print_dir) + { + case pd_left_to_right: + decoder->windows[decoder->current_window].pen_column=0; + if (decoder->windows[decoder->current_window].pen_row+1 < decoder->windows[decoder->current_window].row_count) + decoder->windows[decoder->current_window].pen_row++; + break; + case pd_right_to_left: + decoder->windows[decoder->current_window].pen_column=decoder->windows[decoder->current_window].col_count; + if (decoder->windows[decoder->current_window].pen_row+1 < decoder->windows[decoder->current_window].row_count) + decoder->windows[decoder->current_window].pen_row++; + break; + case pd_top_to_bottom: + decoder->windows[decoder->current_window].pen_row=0; + if (decoder->windows[decoder->current_window].pen_column+1 < decoder->windows[decoder->current_window].col_count) + decoder->windows[decoder->current_window].pen_column++; + break; + case pd_bottom_to_top: + decoder->windows[decoder->current_window].pen_row=decoder->windows[decoder->current_window].row_count; + if (decoder->windows[decoder->current_window].pen_column+1 < decoder->windows[decoder->current_window].col_count) + decoder->windows[decoder->current_window].pen_column++; + break; + } + + if (decoder->windows[decoder->current_window].anchor_point == anchorpoint_bottom_left || + decoder->windows[decoder->current_window].anchor_point == anchorpoint_bottom_center) + { + rollupWindow(decoder, decoder->current_window); + updateScreen(decoder); + } +} + +int handle_708_C0 (cc708_service_decoder *decoder, unsigned char *data, int data_length) +{ + const char *name=COMMANDS_C0[data[0]]; + if (name==NULL) + name="Reserved"; + int len=-1; + // These commands have a known length even if they are reserved. + if (/* data[0]>=0x00 && */ data[0]<=0xF) // Comment to silence warning + { + switch (data[0]) + { + case 0x0d: //CR + process_cr (decoder); + break; + case 0x0e: // HCR (Horizontal Carriage Return) + // TODO: Process HDR + break; + case 0x0c: // FF (Form Feed) + // TODO: Process FF + break; + } + len=1; + } + else if (data[0]>=0x10 && data[0]<=0x17) + { + // Note that 0x10 is actually EXT1 and is dealt with somewhere else. Rest is undefined as per + // CEA-708-D + len=2; + } + else if (data[0]>=0x18 && data[0]<=0x1F) + { + // Only PE16 is defined. + if (data[0]==0x18) // PE16 + { + ; // TODO: Handle PE16 + } + len=3; + } + if (len==-1) + { + return -1; + } + if (len>data_length) + { + return -1; + } + // TODO: Do something useful eventually + return len; +} + + +void process_character (cc708_service_decoder *decoder, unsigned char internal_char) +{ + if (decoder->current_window==-1 || + !decoder->windows[decoder->current_window].is_defined) // Writing to a non existing window, skipping + return; + switch (internal_char) + { + default: + decoder->windows[decoder->current_window].is_empty=0; + decoder->windows[decoder->current_window]. + rows[decoder->windows[decoder->current_window].pen_row] + [decoder->windows[decoder->current_window].pen_column]=internal_char; + /* Not positive this interpretation is correct. Word wrapping is optional, so + let's assume we don't need to autoscroll */ + switch (decoder->windows[decoder->current_window].attribs.print_dir) + { + case pd_left_to_right: + if (decoder->windows[decoder->current_window].pen_column+1 < decoder->windows[decoder->current_window].col_count) + decoder->windows[decoder->current_window].pen_column++; + break; + case pd_right_to_left: + if (decoder->windows->pen_column>0) + decoder->windows[decoder->current_window].pen_column--; + break; + case pd_top_to_bottom: + if (decoder->windows[decoder->current_window].pen_row+1 < decoder->windows[decoder->current_window].row_count) + decoder->windows[decoder->current_window].pen_row++; + break; + case pd_bottom_to_top: + if (decoder->windows[decoder->current_window].pen_row>0) + decoder->windows[decoder->current_window].pen_row--; + break; + } + break; + } +} + +// G0 - Code Set - ASCII printable characters +int handle_708_G0 (cc708_service_decoder *decoder, unsigned char *data, int data_length) +{ + // TODO: Substitution of the music note character for the ASCII DEL character + unsigned char c=get_internal_from_G0 (data[0]); + process_character (decoder, c); + return 1; +} + +// G1 Code Set - ISO 8859-1 LATIN-1 Character Set +int handle_708_G1 (cc708_service_decoder *decoder, unsigned char *data, int data_length) +{ + unsigned char c=get_internal_from_G1 (data[0]); + process_character (decoder, c); + return 1; +} + +/*------------------------------------------------------- + WINDOW COMMANDS + ------------------------------------------------------- */ +void handle_708_CWx_SetCurrentWindow (cc708_service_decoder *decoder, int new_window) +{ + if (decoder->windows[new_window].is_defined) + decoder->current_window=new_window; +} + +void clearWindowText(e708Window *window) +{ + for (int i = 0; i<I708_MAX_ROWS; i++) + { + memset(window->rows[i], ' ', I708_MAX_COLUMNS); + window->rows[i][I708_MAX_COLUMNS] = 0; + } + memset(window->rows[I708_MAX_ROWS], 0, I708_MAX_COLUMNS + 1); + window->is_empty = 1; + +} + +void clearWindow (cc708_service_decoder *decoder, int window) +{ + if (decoder->windows[window].is_defined) + clearWindowText(&decoder->windows[window]); +} + +void handle_708_CLW_ClearWindows (cc708_service_decoder *decoder, int windows_bitmap) +{ + if (windows_bitmap==0) + ;//ccx_common_logging.debug_ftn(CCX_DMT_708, "None\n"); + else + { + for (int i=0; i<8; i++) + { + if (windows_bitmap & 1) + { + clearWindow (decoder, i); + } + windows_bitmap>>=1; + } + } +} + +void handle_708_DSW_DisplayWindows (cc708_service_decoder *decoder, int windows_bitmap) +{ + if (windows_bitmap==0) + ;//ccx_common_logging.debug_ftn(CCX_DMT_708, "None\n"); + else + { + int changes=0; + for (int i=0; i<8; i++) + { + if (windows_bitmap & 1) + { + if (!decoder->windows[i].visible) + { + changes=1; + decoder->windows[i].visible=1; + } + } + windows_bitmap>>=1; + } + if (changes) + updateScreen (decoder); + } +} + +void handle_708_HDW_HideWindows (cc708_service_decoder *decoder, int windows_bitmap) +{ + if (windows_bitmap==0) + ;//ccx_common_logging.debug_ftn(CCX_DMT_708, "None\n"); + else + { + int changes=0; + for (int i=0; i<8; i++) + { + if (windows_bitmap & 1) + { + if (decoder->windows[i].is_defined && decoder->windows[i].visible && !decoder->windows[i].is_empty) + { + changes=1; + decoder->windows[i].visible=0; + } + // TODO: Actually Hide Window + } + windows_bitmap>>=1; + } + if (changes) + updateScreen (decoder); + } +} + +void handle_708_TGW_ToggleWindows (cc708_service_decoder *decoder, int windows_bitmap) +{ + if (windows_bitmap==0) + ;//ccx_common_logging.debug_ftn(CCX_DMT_708, "None\n"); + else + { + for (int i=0; i<8; i++) + { + if (windows_bitmap & 1) + { + decoder->windows[i].visible=!decoder->windows[i].visible; + } + windows_bitmap>>=1; + } + updateScreen(decoder); + } +} + +void handle_708_DFx_DefineWindow (cc708_service_decoder *decoder, int window, unsigned char *data) +{ + if (decoder->windows[window].is_defined && + memcmp (decoder->windows[window].commands, data+1, 6)==0) + { + return; + } + decoder->windows[window].number=window; + int priority = (data[1] ) & 0x7; + int col_lock = (data[1]>>3) & 0x1; + int row_lock = (data[1]>>4) & 0x1; + int visible = (data[1]>>5) & 0x1; + int anchor_vertical = data[2] & 0x7f; + int relative_pos = (data[2]>>7); + int anchor_horizontal = data[3]; + int row_count = data[4] & 0xf; + int anchor_point = data[4]>>4; + int col_count = data[5] & 0x3f; + int pen_style = data[6] & 0x7; + int win_style = (data[6]>>3) & 0x7; + col_count++; // These increments seems to be needed but no documentation + row_count++; // backs it up + + if (anchor_vertical > I708_SCREENGRID_ROWS) + anchor_vertical = I708_SCREENGRID_ROWS; + + decoder->windows[window].priority=priority; + decoder->windows[window].col_lock=col_lock; + decoder->windows[window].row_lock=row_lock; + decoder->windows[window].visible=visible; + decoder->windows[window].anchor_vertical=anchor_vertical; + decoder->windows[window].relative_pos=relative_pos; + decoder->windows[window].anchor_horizontal=anchor_horizontal; + decoder->windows[window].row_count=row_count; + decoder->windows[window].anchor_point=anchor_point; + decoder->windows[window].col_count=col_count; + decoder->windows[window].pen_style=pen_style; + decoder->windows[window].win_style=win_style; + if (!decoder->windows[window].is_defined) + { + // If the window is being created, all character positions in the window + // are set to the fill color... + // TODO: COLORS + // ...and the pen location is set to (0,0) + decoder->windows[window].pen_column=0; + decoder->windows[window].pen_row=0; + if (!decoder->windows[window].memory_reserved) + { + for (int i=0;i<=I708_MAX_ROWS;i++) + { + decoder->windows[window].rows[i]=(unsigned char *) malloc (I708_MAX_COLUMNS+1); + if (decoder->windows[window].rows[i]==NULL) // Great + { + decoder->windows[window].is_defined=0; + decoder->current_window=-1; + for (int j=0;j<i;j++) + free (decoder->windows[window].rows[j]); + return; // TODO: Warn somehow + } + } + decoder->windows[window].memory_reserved=1; + } + decoder->windows[window].is_defined=1; + memset(&decoder->windows[window].attribs, 0, sizeof(e708Window_attribs)); + clearWindowText (&decoder->windows[window]); + } + + // ...also makes the defined windows the current window (setCurrentWindow) + handle_708_CWx_SetCurrentWindow (decoder, window); + memcpy (decoder->windows[window].commands, data+1, 6); +} + +void handle_708_SWA_SetWindowAttributes (cc708_service_decoder *decoder, unsigned char *data) +{ + int fill_color = (data[1] ) & 0x3f; + int fill_opacity = (data[1]>>6) & 0x03; + int border_color = (data[2] ) & 0x3f; + int border_type01 = (data[2]>>6) & 0x03; + int justify = (data[3] ) & 0x03; + int scroll_dir = (data[3]>>2) & 0x03; + int print_dir = (data[3]>>4) & 0x03; + int word_wrap = (data[3]>>6) & 0x01; + int border_type = (data[3]>>5) | border_type01; + int display_eff = (data[4] ) & 0x03; + int effect_dir = (data[4]>>2) & 0x03; + int effect_speed = (data[4]>>4) & 0x0f; + if (decoder->current_window==-1) + { + // Can't do anything yet - we need a window to be defined first. + return; + } + decoder->windows[decoder->current_window].attribs.fill_color=fill_color; + decoder->windows[decoder->current_window].attribs.fill_opacity=fill_opacity; + decoder->windows[decoder->current_window].attribs.border_color=border_color; + decoder->windows[decoder->current_window].attribs.border_type01=border_type01; + decoder->windows[decoder->current_window].attribs.justify=justify; + decoder->windows[decoder->current_window].attribs.scroll_dir=scroll_dir; + decoder->windows[decoder->current_window].attribs.print_dir=print_dir; + decoder->windows[decoder->current_window].attribs.word_wrap=word_wrap; + decoder->windows[decoder->current_window].attribs.border_type=border_type; + decoder->windows[decoder->current_window].attribs.display_eff=display_eff; + decoder->windows[decoder->current_window].attribs.effect_dir=effect_dir; + decoder->windows[decoder->current_window].attribs.effect_speed=effect_speed; + +} + +void deleteWindow (cc708_service_decoder *decoder, int window) +{ + if (window==decoder->current_window) + { + // If the current window is deleted, then the decoder's current window ID + // is unknown and must be reinitialized with either the SetCurrentWindow + // or DefineWindow command. + decoder->current_window=-1; + } + // TODO: Do the actual deletion (remove from display if needed, etc), mark as + // not defined, etc + if (decoder->windows[window].is_defined) + { + clearWindowText(&decoder->windows[window]); + } + decoder->windows[window].is_defined=0; +} + +void handle_708_DLW_DeleteWindows (cc708_service_decoder *decoder, int windows_bitmap) +{ + int changes=0; + if (windows_bitmap==0) + ; //ccx_common_logging.debug_ftn(CCX_DMT_708, "None\n"); + else + { + for (int i=0; i<8; i++) + { + if (windows_bitmap & 1) + { + if (decoder->windows[i].is_defined && decoder->windows[i].visible && !decoder->windows[i].is_empty) + changes=1; + deleteWindow (decoder, i); + } + windows_bitmap>>=1; + } + } + if (changes) + updateScreen (decoder); + +} + +/*------------------------------------------------------- + WINDOW COMMANDS + ------------------------------------------------------- */ +void handle_708_SPA_SetPenAttributes (cc708_service_decoder *decoder, unsigned char *data) +{ + int pen_size = (data[1] ) & 0x3; + int offset = (data[1]>>2) & 0x3; + int text_tag = (data[1]>>4) & 0xf; + int font_tag = (data[2] ) & 0x7; + int edge_type = (data[2]>>3) & 0x7; + int underline = (data[2]>>4) & 0x1; + int italic = (data[2]>>5) & 0x1; + if (decoder->current_window==-1) + { + // Can't do anything yet - we need a window to be defined first. + return; + } + decoder->windows[decoder->current_window].pen.pen_size=pen_size; + decoder->windows[decoder->current_window].pen.offset=offset; + decoder->windows[decoder->current_window].pen.text_tag=text_tag; + decoder->windows[decoder->current_window].pen.font_tag=font_tag; + decoder->windows[decoder->current_window].pen.edge_type=edge_type; + decoder->windows[decoder->current_window].pen.underline=underline; + decoder->windows[decoder->current_window].pen.italic=italic; +} + +void handle_708_SPC_SetPenColor (cc708_service_decoder *decoder, unsigned char *data) +{ + int fg_color = (data[1] ) & 0x3f; + int fg_opacity = (data[1]>>6) & 0x03; + int bg_color = (data[2] ) & 0x3f; + int bg_opacity = (data[2]>>6) & 0x03; + int edge_color = (data[3]>>6) & 0x3f; + if (decoder->current_window==-1) + { + // Can't do anything yet - we need a window to be defined first. + return; + } + + decoder->windows[decoder->current_window].pen_color.fg_color=fg_color; + decoder->windows[decoder->current_window].pen_color.fg_opacity=fg_opacity; + decoder->windows[decoder->current_window].pen_color.bg_color=bg_color; + decoder->windows[decoder->current_window].pen_color.bg_opacity=bg_opacity; + decoder->windows[decoder->current_window].pen_color.edge_color=edge_color; +} + + +void handle_708_SPL_SetPenLocation (cc708_service_decoder *decoder, unsigned char *data) +{ + int row = data[1] & 0x0f; + int col = data[2] & 0x3f; + if (decoder->current_window==-1) + { + // Can't do anything yet - we need a window to be defined first. + return; + } + decoder->windows[decoder->current_window].pen_row=row; + decoder->windows[decoder->current_window].pen_column=col; +} + + +/*------------------------------------------------------- + SYNCHRONIZATION COMMANDS + ------------------------------------------------------- */ +void handle_708_DLY_Delay (cc708_service_decoder *decoder, int tenths_of_sec) +{ + // TODO: Probably ask for the current FTS and wait for this time before resuming - + // not sure it's worth it though +} + +void handle_708_DLC_DelayCancel (cc708_service_decoder *decoder) +{ + // TODO: See above +} + +// C1 Code Set - Captioning Commands Control Codes +int handle_708_C1 (cc708_service_decoder *decoder, unsigned char *data, int data_length) +{ + struct S_COMMANDS_C1 com=COMMANDS_C1[data[0]-0x80]; + if (com.length>data_length) + { + return -1; + } + switch (com.code) + { + case CW0: /* SetCurrentWindow */ + case CW1: + case CW2: + case CW3: + case CW4: + case CW5: + case CW6: + case CW7: + handle_708_CWx_SetCurrentWindow (decoder, com.code-CW0); /* Window 0 to 7 */ + break; + case CLW: + handle_708_CLW_ClearWindows (decoder, data[1]); + break; + case DSW: + handle_708_DSW_DisplayWindows (decoder, data[1]); + break; + case HDW: + handle_708_HDW_HideWindows (decoder, data[1]); + break; + case TGW: + handle_708_TGW_ToggleWindows (decoder, data[1]); + break; + case DLW: + handle_708_DLW_DeleteWindows (decoder, data[1]); + break; + case DLY: + handle_708_DLY_Delay (decoder, data[1]); + break; + case DLC: + handle_708_DLC_DelayCancel (decoder); + break; + case RST: + cc708_service_reset(decoder); + break; + case SPA: + handle_708_SPA_SetPenAttributes (decoder, data); + break; + case SPC: + handle_708_SPC_SetPenColor (decoder, data); + break; + case SPL: + handle_708_SPL_SetPenLocation (decoder, data); + break; + case RSV93: + case RSV94: + case RSV95: + case RSV96: + break; + case SWA: + handle_708_SWA_SetWindowAttributes (decoder, data); + break; + case DF0: + case DF1: + case DF2: + case DF3: + case DF4: + case DF5: + case DF6: + case DF7: + handle_708_DFx_DefineWindow (decoder, com.code-DF0, data); /* Window 0 to 7 */ + break; + default: + break; + } + + return com.length; +} + + +void process_service_block (cc708_service_decoder *decoder, unsigned char *data, int data_length) +{ + int i=0; + while (i<data_length) + { + int used=-1; + if (data[i]!=EXT1) + { + // Group C0 + if (/* data[i]>=0x00 && */ data[i]<=0x1F) // Comment to silence warning + { + used=handle_708_C0 (decoder,data+i,data_length-i); + } + // Group G0 + else if (data[i]>=0x20 && data[i]<=0x7F) + { + used=handle_708_G0 (decoder,data+i,data_length-i); + } + // Group C1 + else if (data[i]>=0x80 && data[i]<=0x9F) + { + used=handle_708_C1 (decoder,data+i,data_length-i); + } + // Group C2 + else + used=handle_708_G1 (decoder,data+i,data_length-i); + if (used==-1) + { + // TODO: Not sure if a local reset is going to be helpful here. + cc708_service_reset (decoder); + return; + } + } + else // Use extended set + { + used=handle_708_extended_char (decoder, data+i+1,data_length-1); + used++; // Since we had EXT1 + } + i+=used; + } + + // update rollup windows + int update = 0; + for (int i = 0; i<I708_MAX_WINDOWS; i++) + { + if (decoder->windows[i].is_defined && decoder->windows[i].visible && + (decoder->windows[i].anchor_point == anchorpoint_bottom_left || + decoder->windows[i].anchor_point == anchorpoint_bottom_center)) + { + update++; + break; + } + } + if (update) + { + updateScreen(decoder); + } +} + +void process_current_packet (cc708_service_decoder *decoders) +{ + int seq = (decoders[0].parent->m_current_packet[0] & 0xC0) >> 6; // Two most significants bits + int len = decoders[0].parent->m_current_packet[0] & 0x3F; // 6 least significants bits + if (decoders[0].parent->m_current_packet_length == 0) + return; + + if (len==0) // This is well defined in EIA-708; no magic. + len=128; + else + len=len*2; + // Note that len here is the length including the header + if (decoders[0].parent->m_current_packet_length != len) // Is this possible? + { + cc708_reset(decoders); + return; + } + int last_seq = decoders[0].parent->m_last_seq; + if ((last_seq != -1) && ((last_seq+1)%4 != seq)) + { + cc708_reset(decoders); + return; + } + decoders[0].parent->m_last_seq = seq; + + unsigned char *pos = decoders[0].parent->m_current_packet + 1; + + while (pos < decoders[0].parent->m_current_packet + len) + { + int service_number=(pos[0] & 0xE0)>>5; // 3 more significant bits + int block_length = (pos[0] & 0x1F); // 5 less significant bits + + if (service_number==7) // There is an extended header + { + pos++; + service_number=(pos[0] & 0x3F); // 6 more significant bits + if (service_number<7) + { + } + pos = decoders[0].parent->m_current_packet + len; + break; + } + + pos++; // Move to service data + if (service_number==0 && block_length!=0) // Illegal, but specs say what to do... + { + pos = decoders[0].parent->m_current_packet + len; // Move to end + break; + } + + if (service_number>0 && decoders[service_number].inited) + process_service_block (&decoders[service_number], pos, block_length); + + pos+=block_length; // Skip data + } + + clear_packet(&decoders[0]); + + if (pos != decoders[0].parent->m_current_packet + len) // For some reason we didn't parse the whole packet + { + cc708_reset(decoders); + } + + if (len<128 && *pos) // Null header is mandatory if there is room + { + ;//ccx_common_logging.debug_ftn(CCX_DMT_708, "Warning: Null header expected but not found.\n"); + } +} + +void decode_708 (const unsigned char *data, int datalength, cc708_service_decoder* decoders) +{ + /* Note: The data has this format: + 1 byte for cc_valid and cc_type + 2 bytes for the actual data */ + for (int i=0; i<datalength; i+=3) + { + unsigned char cc_valid=data[i] & 0x04; + unsigned char cc_type=data[i] & 0x03; + + switch (cc_type) + { + case 0: + // only use 608 as fallback + if (!decoders[0].parent->m_seen708) + decode_cc(decoders[0].parent->m_cc608decoder, (uint8_t*)data+i, 3); + break; + case 2: + if (cc_valid==0) // This ends the previous packet + process_current_packet(decoders); + else + { + if (decoders[0].parent->m_current_packet_length < 254) + { + decoders[0].parent->m_current_packet[decoders[0].parent->m_current_packet_length++]=data[i+1]; + decoders[0].parent->m_current_packet[decoders[0].parent->m_current_packet_length++]=data[i+2]; + } + } + break; + case 3: + process_current_packet(decoders); + if (cc_valid) + { + if (decoders[0].parent->m_current_packet_length < 128) + { + decoders[0].parent->m_current_packet[decoders[0].parent->m_current_packet_length++]=data[i+1]; + decoders[0].parent->m_current_packet[decoders[0].parent->m_current_packet_length++]=data[i+2]; + } + } + break; + default: + break; + } + } +} + +void ccx_decoders_708_init(cc708_service_decoder *decoders, void (*handler)(int service, void *userdata), void *userdata, CDecoderCC708 *parent) +{ + for (int i = 0; i<CCX_DECODERS_708_MAX_SERVICES; i++) + { + cc708_service_reset (&decoders[i]); + decoders[i].srt_counter=0; + decoders[i].service = i; + decoders[i].callback = handler; + decoders[i].userdata = userdata; + decoders[i].parent = parent; + } + decoders[0].parent->m_cc608decoder->callback = handler; + decoders[0].parent->m_cc608decoder->userdata = userdata; + + decoders[0].parent->m_current_packet_length = 0; + decoders[0].parent->m_last_seq = -1; + decoders[0].parent->m_seen708 = false; + decoders[0].parent->m_seen608 = false; +} + +//----------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------- + +CDecoderCC708::CDecoderCC708() +{ + m_inited = false; + cc_decoder_init(); +} + +CDecoderCC708::~CDecoderCC708() +{ + delete [] m_cc708decoders; + cc_decoder_close(m_cc608decoder); +} + +void CDecoderCC708::Init(void (*handler)(int service, void *userdata), void *userdata) +{ + m_cc608decoder = cc_decoder_open(); + m_cc708decoders = new cc708_service_decoder[8]; + ccx_decoders_708_init(m_cc708decoders, handler, userdata, this); +} + +void CDecoderCC708::Decode(const unsigned char *data, int datalength) +{ + decode_708(data, datalength, m_cc708decoders); +} diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/contrib/cc_decoder708.h b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/contrib/cc_decoder708.h new file mode 100644 index 0000000000..0640f9f9d1 --- /dev/null +++ b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/contrib/cc_decoder708.h @@ -0,0 +1,304 @@ +#pragma once + +#include <sys/stat.h> + +extern "C"{ +#include "cc_decoder.h" +} + +#define MAX_708_PACKET_LENGTH 128 +#define CCX_DECODERS_708_MAX_SERVICES 8 +#define I708_MAX_ROWS 15 +#define I708_MAX_COLUMNS 42 +#define I708_SCREENGRID_ROWS 75 +#define I708_SCREENGRID_COLUMNS 210 +#define I708_MAX_WINDOWS 8 + +enum COMMANDS_C0_CODES +{ + NUL=0, + ETX=3, + BS=8, + FF=0xC, + CR=0xD, + HCR=0xE, + EXT1=0x10, + P16=0x18 +}; + +enum COMMANDS_C1_CODES +{ + CW0=0x80, + CW1=0x81, + CW2=0x82, + CW3=0x83, + CW4=0x84, + CW5=0x85, + CW6=0x86, + CW7=0x87, + CLW=0x88, + DSW=0x89, + HDW=0x8A, + TGW=0x8B, + DLW=0x8C, + DLY=0x8D, + DLC=0x8E, + RST=0x8F, + SPA=0x90, + SPC=0x91, + SPL=0x92, + RSV93=0x93, + RSV94=0x94, + RSV95=0x95, + RSV96=0x96, + SWA=0x97, + DF0=0x98, + DF1=0x99, + DF2=0x9A, + DF3=0x9B, + DF4=0x9C, + DF5=0x9D, + DF6=0x9E, + DF7=0x9F +}; + +struct S_COMMANDS_C1 +{ + int code; + const char *name; + const char *description; + int length; +}; + + +enum eWindowsAttribJustify +{ + left=0, + right=1, + center=2, + full=3 +}; + +enum eWindowsAttribPrintDirection +{ + pd_left_to_right=0, + pd_right_to_left=1, + pd_top_to_bottom=2, + pd_bottom_to_top=3 +}; + +enum eWindowsAttribScrollDirection +{ + sd_left_to_right=0, + sd_right_to_left=1, + sd_top_to_bottom=2, + sd_bottom_to_top=3 +}; + +enum eWindowsAttribScrollDisplayEffect +{ + snap=0, + fade=1, + wipe=2 +}; + +enum eWindowsAttribEffectDirection +{ + left_to_right=0, + right_to_left=1, + top_to_bottom=2, + bottom_to_top=3 +}; + +enum eWindowsAttribFillOpacity +{ + solid=0, + flash=1, + traslucent=2, + transparent=3 +}; + +enum eWindowsAttribBorderType +{ + none=0, + raised=1, + depressed=2, + uniform=3, + shadow_left=4, + shadow_right=5 +}; + +enum ePenAttribSize +{ + pensize_small=0, + pensize_standard=1, + pensize_large=2 +}; + +enum ePenAttribFontStyle +{ + fontstyle_default_or_undefined=0, + monospaced_with_serifs=1, + proportionally_spaced_with_serifs=2, + monospaced_without_serifs=3, + proportionally_spaced_without_serifs=4, + casual_font_type=5, + cursive_font_type=6, + small_capitals=7 +}; + +enum ePanAttribTextTag +{ + texttag_dialog=0, + texttag_source_or_speaker_id=1, + texttag_electronic_voice=2, + texttag_foreign_language=3, + texttag_voiceover=4, + texttag_audible_translation=5, + texttag_subtitle_translation=6, + texttag_voice_quality_description=7, + texttag_song_lyrics=8, + texttag_sound_effect_description=9, + texttag_musical_score_description=10, + texttag_expletitive=11, + texttag_undefined_12=12, + texttag_undefined_13=13, + texttag_undefined_14=14, + texttag_not_to_be_displayed=15 +}; + +enum ePanAttribOffset +{ + offset_subscript=0, + offset_normal=1, + offset_superscript=2 +}; + +enum ePanAttribEdgeType +{ + edgetype_none=0, + edgetype_raised=1, + edgetype_depressed=2, + edgetype_uniform=3, + edgetype_left_drop_shadow=4, + edgetype_right_drop_shadow=5 +}; + +enum eAnchorPoints +{ + anchorpoint_top_left = 0, + anchorpoint_top_center = 1, + anchorpoint_top_right =2, + anchorpoint_middle_left = 3, + anchorpoint_middle_center = 4, + anchorpoint_middle_right = 5, + anchorpoint_bottom_left = 6, + anchorpoint_bottom_center = 7, + anchorpoint_bottom_right = 8 +}; + +typedef struct e708Pen_color +{ + int fg_color; + int fg_opacity; + int bg_color; + int bg_opacity; + int edge_color; +} e708Pen_color; + +typedef struct e708Pen_attribs +{ + int pen_size; + int offset; + int text_tag; + int font_tag; + int edge_type; + int underline; + int italic; +} e708Pen_attribs; + +typedef struct e708Window_attribs +{ + int fill_color; + int fill_opacity; + int border_color; + int border_type01; + int justify; + int scroll_dir; + int print_dir; + int word_wrap; + int border_type; + int display_eff; + int effect_dir; + int effect_speed; +} e708Window_attribs; + +typedef struct e708Window +{ + int is_defined; + int number; // Handy, in case we only have a pointer to the window + int priority; + int col_lock; + int row_lock; + int visible; + int anchor_vertical; + int relative_pos; + int anchor_horizontal; + int row_count; + int anchor_point; + int col_count; + int pen_style; + int win_style; + unsigned char commands[6]; // Commands used to create this window + e708Window_attribs attribs; + e708Pen_attribs pen; + e708Pen_color pen_color; + int pen_row; + int pen_column; + unsigned char *rows[I708_MAX_ROWS+1]; // Max is 15, but we define an extra one for convenience + int memory_reserved; + int is_empty; +} e708Window; + +typedef struct tvscreen +{ + unsigned char chars[I708_SCREENGRID_ROWS][I708_SCREENGRID_COLUMNS+1]; +} +tvscreen; + +class CDecoderCC708; +typedef struct cc708_service_decoder +{ + e708Window windows[I708_MAX_WINDOWS]; + int current_window; + int inited; + int service; + tvscreen tv; + int is_empty_tv; + int srt_counter; + void *userdata; + void (*callback)(int service, void *userdata); + char text[I708_SCREENGRID_ROWS*I708_SCREENGRID_COLUMNS+1]; + int textlen; + CDecoderCC708 *parent; +} +cc708_service_decoder; + +void process_character (cc708_service_decoder *decoder, unsigned char internal_char); + +class CDecoderCC708 +{ +public: + CDecoderCC708(); + virtual ~CDecoderCC708(); + void Init(void (*handler)(int service, void *userdata), void *userdata); + void Decode(const unsigned char *data, int datalength); + bool m_inited; + cc708_service_decoder* m_cc708decoders; + cc_decoder_t *m_cc608decoder; + unsigned char m_current_packet[MAX_708_PACKET_LENGTH]; // Length according to EIA-708B, part 5 + int m_current_packet_length; + int m_last_seq; + bool m_seen708; + bool m_seen608; +}; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/AMLCodec.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/AMLCodec.cpp index a45be9899b..d7c7ad8090 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/AMLCodec.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/AMLCodec.cpp @@ -33,6 +33,7 @@ #include "utils/AMLUtils.h" #include "utils/log.h" #include "utils/StringUtils.h" +#include "utils/SysfsUtils.h" #include "utils/TimeUtils.h" #if defined(TARGET_ANDROID) @@ -468,6 +469,9 @@ static vformat_t codecid_to_vformat(enum AVCodecID id) case AV_CODEC_ID_CAVS: format = VFORMAT_AVS; break; + case AV_CODEC_ID_HEVC: + format = VFORMAT_HEVC; + break; default: format = VFORMAT_UNSUPPORT; @@ -577,6 +581,10 @@ static vdec_type_t codec_tag_to_vdec_type(unsigned int codec_tag) // avs dec_type = VIDEO_DEC_FORMAT_AVS; break; + case AV_CODEC_ID_HEVC: + // h265 + dec_type = VIDEO_DEC_FORMAT_HEVC; + break; default: dec_type = VIDEO_DEC_FORMAT_UNKNOW; break; @@ -933,9 +941,7 @@ static int h264_add_header(unsigned char *buf, int size, am_packet_t *pkt) static int h264_write_header(am_private_t *para, am_packet_t *pkt) { // CLog::Log(LOGDEBUG, "h264_write_header"); - int ret = -1; - - ret = h264_add_header(para->extradata, para->extrasize, pkt); + int ret = h264_add_header(para->extradata, para->extrasize, pkt); if (ret == PLAYER_SUCCESS) { //if (ctx->vcodec) { if (1) { @@ -951,6 +957,28 @@ static int h264_write_header(am_private_t *para, am_packet_t *pkt) return ret; } +static int hevc_add_header(unsigned char *buf, int size, am_packet_t *pkt) +{ + memcpy(pkt->hdr->data, buf, size); + pkt->hdr->size = size; + return PLAYER_SUCCESS; +} + +static int hevc_write_header(am_private_t *para, am_packet_t *pkt) +{ + int ret = -1; + + if (para->extradata) { + ret = hevc_add_header(para->extradata, para->extrasize, pkt); + } + if (ret == PLAYER_SUCCESS) { + pkt->codec = ¶->vcodec; + pkt->newflag = 1; + ret = write_av_packet(para, pkt); + } + return ret; +} + static int wmv3_write_header(am_private_t *para, am_packet_t *pkt) { CLog::Log(LOGDEBUG, "wmv3_write_header"); @@ -1125,6 +1153,11 @@ int pre_header_feeding(am_private_t *para, am_packet_t *pkt) if (ret != PLAYER_SUCCESS) { return ret; } + } else if (VFORMAT_HEVC == para->video_format) { + ret = hevc_write_header(para, pkt); + if (ret != PLAYER_SUCCESS) { + return ret; + } } if (pkt->hdr) { @@ -1581,16 +1614,11 @@ bool CAMLCodec::OpenDecoder(CDVDStreamInfo &hints) am_private->gcodec.param = (void*)(EXTERNAL_PTS | SYNC_OUTSIDE); break; case VFORMAT_H264_4K2K: - if (aml_get_device_type() == AML_DEVICE_TYPE_M8) { - am_private->gcodec.format = VIDEO_DEC_FORMAT_H264_4K2K; - am_private->gcodec.param = (void*)EXTERNAL_PTS; - // h264 in an avi file - if (m_hints.ptsinvalid) - am_private->gcodec.param = (void*)(EXTERNAL_PTS | SYNC_OUTSIDE); - } else { - CLog::Log(LOGDEBUG, "CAMLCodec::OpenDecoder codec init failed, 4K supported only on Meson8."); - return false; - } + am_private->gcodec.format = VIDEO_DEC_FORMAT_H264_4K2K; + am_private->gcodec.param = (void*)EXTERNAL_PTS; + // h264 in an avi file + if (m_hints.ptsinvalid) + am_private->gcodec.param = (void*)(EXTERNAL_PTS | SYNC_OUTSIDE); break; case VFORMAT_REAL: am_private->stream_type = AM_STREAM_RM; @@ -1620,6 +1648,12 @@ bool CAMLCodec::OpenDecoder(CDVDStreamInfo &hints) if (m_hints.ptsinvalid) am_private->gcodec.param = (void*)EXTERNAL_PTS; break; + case VFORMAT_HEVC: + am_private->gcodec.format = VIDEO_DEC_FORMAT_HEVC; + am_private->gcodec.param = (void*)EXTERNAL_PTS; + if (m_hints.ptsinvalid) + am_private->gcodec.param = (void*)(EXTERNAL_PTS | SYNC_OUTSIDE); + break; } am_private->gcodec.param = (void *)((unsigned int)am_private->gcodec.param | (am_private->video_rotation_degree << 16)); @@ -1643,7 +1677,7 @@ bool CAMLCodec::OpenDecoder(CDVDStreamInfo &hints) m_dll->codec_set_cntl_avthresh(&am_private->vcodec, AV_SYNC_THRESH); m_dll->codec_set_cntl_syncthresh(&am_private->vcodec, 0); // disable tsync, we are playing video disconnected from audio. - aml_set_sysfs_int("/sys/class/tsync/enable", 0); + SysfsUtils::SetInt("/sys/class/tsync/enable", 0); am_private->am_pkt.codec = &am_private->vcodec; pre_header_feeding(am_private, &am_private->am_pkt); @@ -1654,21 +1688,28 @@ bool CAMLCodec::OpenDecoder(CDVDStreamInfo &hints) g_renderManager.RegisterRenderFeaturesCallBack((const void*)this, RenderFeaturesCallBack); m_display_rect = CRect(0, 0, CDisplaySettings::Get().GetCurrentResolutionInfo().iWidth, CDisplaySettings::Get().GetCurrentResolutionInfo().iHeight); - char mode[256] = {0}; - aml_get_sysfs_str("/sys/class/display/mode", mode, 255); - RESOLUTION_INFO res; - if (aml_mode_to_resolution(mode, &res)) - m_display_rect = CRect(0, 0, res.iScreenWidth, res.iScreenHeight); + + std::string strScaler; + SysfsUtils::GetString("/sys/class/ppmgr/ppscaler", strScaler); + if (strScaler.find("enabled") != std::string::npos) // Scaler not enabled, use screen size + { + CLog::Log(LOGDEBUG, "ppscaler not enabled"); + std::string mode; + SysfsUtils::GetString("/sys/class/display/mode", mode); + RESOLUTION_INFO res; + if (aml_mode_to_resolution(mode.c_str(), &res)) + m_display_rect = CRect(0, 0, res.iScreenWidth, res.iScreenHeight); + } /* // if display is set to 1080xxx, then disable deinterlacer for HD content // else bandwidth usage is too heavy and it will slow down video decoder. char display_mode[256] = {0}; - aml_get_sysfs_str("/sys/class/display/mode", display_mode, 255); + SysfsUtils::GetString("/sys/class/display/mode", display_mode, 255); if (strstr(display_mode,"1080")) - aml_set_sysfs_int("/sys/module/di/parameters/bypass_all", 1); + SysfsUtils::SetInt("/sys/module/di/parameters/bypass_all", 1); else - aml_set_sysfs_int("/sys/module/di/parameters/bypass_all", 0); + SysfsUtils::SetInt("/sys/module/di/parameters/bypass_all", 0); */ m_opened = true; @@ -1701,7 +1742,7 @@ void CAMLCodec::CloseDecoder() free(am_private->extradata); am_private->extradata = NULL; // return tsync to default so external apps work - aml_set_sysfs_int("/sys/class/tsync/enable", 1); + SysfsUtils::SetInt("/sys/class/tsync/enable", 1); ShowMainVideo(false); } @@ -1714,8 +1755,9 @@ void CAMLCodec::Reset() return; // set the system blackout_policy to leave the last frame showing - int blackout_policy = aml_get_sysfs_int("/sys/class/video/blackout_policy"); - aml_set_sysfs_int("/sys/class/video/blackout_policy", 0); + int blackout_policy; + SysfsUtils::GetInt("/sys/class/video/blackout_policy", blackout_policy); + SysfsUtils::SetInt("/sys/class/video/blackout_policy", 0); // restore the speed (some amcodec versions require this) if (m_speed != DVD_PLAYSPEED_NORMAL) @@ -1735,7 +1777,7 @@ void CAMLCodec::Reset() pre_header_feeding(am_private, &am_private->am_pkt); // restore the saved system blackout_policy value - aml_set_sysfs_int("/sys/class/video/blackout_policy", blackout_policy); + SysfsUtils::SetInt("/sys/class/video/blackout_policy", blackout_policy); // reset some interal vars m_1st_pts = 0; @@ -2058,7 +2100,7 @@ void CAMLCodec::ShowMainVideo(const bool show) if (saved_disable_video == disable_video) return; - aml_set_sysfs_int("/sys/class/video/disable_video", disable_video); + SysfsUtils::SetInt("/sys/class/video/disable_video", disable_video); saved_disable_video = disable_video; } @@ -2067,7 +2109,7 @@ void CAMLCodec::SetVideoZoom(const float zoom) // input zoom range is 0.5 to 2.0 with a default of 1.0. // output zoom range is 2 to 300 with default of 100. // we limit that to a range of 50 to 200 with default of 100. - aml_set_sysfs_int("/sys/class/video/zoom", (int)(100 * zoom)); + SysfsUtils::SetInt("/sys/class/video/zoom", (int)(100 * zoom)); } void CAMLCodec::SetVideoContrast(const int contrast) @@ -2075,19 +2117,19 @@ void CAMLCodec::SetVideoContrast(const int contrast) // input contrast range is 0 to 100 with default of 50. // output contrast range is -255 to 255 with default of 0. int aml_contrast = (255 * (contrast - 50)) / 50; - aml_set_sysfs_int("/sys/class/video/contrast", aml_contrast); + SysfsUtils::SetInt("/sys/class/video/contrast", aml_contrast); } void CAMLCodec::SetVideoBrightness(const int brightness) { // input brightness range is 0 to 100 with default of 50. // output brightness range is -127 to 127 with default of 0. int aml_brightness = (127 * (brightness - 50)) / 50; - aml_set_sysfs_int("/sys/class/video/brightness", aml_brightness); + SysfsUtils::SetInt("/sys/class/video/brightness", aml_brightness); } void CAMLCodec::SetVideoSaturation(const int saturation) { // output saturation range is -127 to 127 with default of 127. - aml_set_sysfs_int("/sys/class/video/saturation", saturation); + SysfsUtils::SetInt("/sys/class/video/saturation", saturation); } void CAMLCodec::GetRenderFeatures(Features &renderFeatures) @@ -2103,7 +2145,7 @@ void CAMLCodec::GetRenderFeatures(Features &renderFeatures) void CAMLCodec::SetVideo3dMode(const int mode3d) { CLog::Log(LOGDEBUG, "CAMLCodec::SetVideo3dMode:mode3d(0x%x)", mode3d); - aml_set_sysfs_int("/sys/class/ppmgr/ppmgr_3d_mode", mode3d); + SysfsUtils::SetInt("/sys/class/ppmgr/ppmgr_3d_mode", mode3d); } std::string CAMLCodec::GetStereoMode() @@ -2306,9 +2348,9 @@ void CAMLCodec::SetVideoRect(const CRect &SrcRect, const CRect &DestRect) char video_axis[256] = {}; sprintf(video_axis, "%d %d %d %d", (int)dst_rect.x1, (int)dst_rect.y1, (int)dst_rect.x2, (int)dst_rect.y2); - aml_set_sysfs_str("/sys/class/video/axis", video_axis); + SysfsUtils::SetString("/sys/class/video/axis", video_axis); // make sure we are in 'full stretch' so we can stretch - aml_set_sysfs_int("/sys/class/video/screen_mode", 1); + SysfsUtils::SetInt("/sys/class/video/screen_mode", 1); // we only get called once gui has changed to something // that would show video playback, so show it. diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAmlogic.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAmlogic.cpp index 24c1ab911c..4f3758f6a9 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAmlogic.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAmlogic.cpp @@ -24,6 +24,7 @@ #include "DVDClock.h" #include "DVDStreamInfo.h" #include "AMLCodec.h" +#include "utils/AMLUtils.h" #include "utils/BitstreamConverter.h" #include "utils/log.h" @@ -83,6 +84,11 @@ bool CDVDVideoCodecAmlogic::Open(CDVDStreamInfo &hints, CDVDCodecOptions &option m_pFormatName = "am-mpeg2"; break; case AV_CODEC_ID_H264: + if ((aml_get_device_type() != AML_DEVICE_TYPE_M8 && aml_get_device_type() != AML_DEVICE_TYPE_M8M2) && ((m_hints.width > 1920) || (m_hints.height > 1088))) + { + // 4K is supported only on Amlogic S802/S812 chip + return false; + } m_pFormatName = "am-h264"; // convert h264-avcC to h264-annex-b as h264-avcC // under streamers can have issues when seeking. @@ -131,6 +137,26 @@ bool CDVDVideoCodecAmlogic::Open(CDVDStreamInfo &hints, CDVDCodecOptions &option case AV_CODEC_ID_CAVS: m_pFormatName = "am-avs"; break; + case AV_CODEC_ID_HEVC: + if ((aml_get_device_type() == AML_DEVICE_TYPE_M8B) || (aml_get_device_type() == AML_DEVICE_TYPE_M8M2)) { + if ((aml_get_device_type() == AML_DEVICE_TYPE_M8B) && ((m_hints.width > 1920) || (m_hints.height > 1088))) + { + // 4K HEVC is supported only on Amlogic S812 chip + return false; + } + } else { + // HEVC supported only on S805 and S812. + return false; + } + m_pFormatName = "am-h265"; + m_bitstream = new CBitstreamConverter(); + m_bitstream->Open(m_hints.codec, (uint8_t*)m_hints.extradata, m_hints.extrasize, true); + // make sure we do not leak the existing m_hints.extradata + free(m_hints.extradata); + m_hints.extrasize = m_bitstream->GetExtraSize(); + m_hints.extradata = malloc(m_hints.extrasize); + memcpy(m_hints.extradata, m_bitstream->GetExtraData(), m_hints.extrasize); + break; default: CLog::Log(LOGDEBUG, "%s: Unknown hints.codec(%d", __MODULE_NAME__, m_hints.codec); return false; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp index cc3c7b9a3d..40a36f6bb2 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp @@ -221,10 +221,10 @@ void CDVDMediaCodecInfo::ReleaseOutputBuffer(bool render) m_codec->releaseOutputBuffer(m_index, render); m_isReleased = true; - if (xbmc_jnienv()->ExceptionOccurred()) + if (xbmc_jnienv()->ExceptionCheck()) { CLog::Log(LOGERROR, "CDVDMediaCodecInfo::ReleaseOutputBuffer " - "ExceptionOccurred render(%d)", render); + "ExceptionCheck render(%d)", render); xbmc_jnienv()->ExceptionDescribe(); xbmc_jnienv()->ExceptionClear(); } @@ -275,17 +275,17 @@ void CDVDMediaCodecInfo::UpdateTexImage() m_frameready->WaitMSec(50); m_surfacetexture->updateTexImage(); - if (xbmc_jnienv()->ExceptionOccurred()) + if (xbmc_jnienv()->ExceptionCheck()) { - CLog::Log(LOGERROR, "CDVDMediaCodecInfo::UpdateTexImage updateTexImage:ExceptionOccurred"); + CLog::Log(LOGERROR, "CDVDMediaCodecInfo::UpdateTexImage updateTexImage:ExceptionCheck"); xbmc_jnienv()->ExceptionDescribe(); xbmc_jnienv()->ExceptionClear(); } m_timestamp = m_surfacetexture->getTimestamp(); - if (xbmc_jnienv()->ExceptionOccurred()) + if (xbmc_jnienv()->ExceptionCheck()) { - CLog::Log(LOGERROR, "CDVDMediaCodecInfo::UpdateTexImage getTimestamp:ExceptionOccurred"); + CLog::Log(LOGERROR, "CDVDMediaCodecInfo::UpdateTexImage getTimestamp:ExceptionCheck"); xbmc_jnienv()->ExceptionDescribe(); xbmc_jnienv()->ExceptionClear(); } @@ -364,6 +364,21 @@ bool CDVDVideoCodecAndroidMediaCodec::Open(CDVDStreamInfo &hints, CDVDCodecOptio } } break; + case AV_CODEC_ID_HEVC: + m_mime = "video/hevc"; + m_formatname = "amc-h265"; + // check for hevc-hvcC and convert to h265-annex-b + if (m_hints.extradata && *(uint8_t*)m_hints.extradata == 1) + { + m_bitstream = new CBitstreamConverter; + if (!m_bitstream->Open(m_hints.codec, (uint8_t*)m_hints.extradata, m_hints.extrasize, true)) + { + CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Open CBitstreamConverter Open failed"); + SAFE_DELETE(m_bitstream); + return false; + } + } + break; case AV_CODEC_ID_VC1: case AV_CODEC_ID_WMV3: m_mime = "video/wvc1"; @@ -391,7 +406,7 @@ bool CDVDVideoCodecAndroidMediaCodec::Open(CDVDStreamInfo &hints, CDVDCodecOptio continue; CJNIMediaCodecInfoCodecCapabilities codec_caps = codec_info.getCapabilitiesForType(m_mime); - if (xbmc_jnienv()->ExceptionOccurred()) + if (xbmc_jnienv()->ExceptionCheck()) { // Unsupported type? xbmc_jnienv()->ExceptionClear(); @@ -409,9 +424,9 @@ bool CDVDVideoCodecAndroidMediaCodec::Open(CDVDStreamInfo &hints, CDVDCodecOptio m_codec = boost::shared_ptr<CJNIMediaCodec>(new CJNIMediaCodec(CJNIMediaCodec::createByCodecName(m_codecname))); // clear any jni exceptions, jni gets upset if we do not. - if (xbmc_jnienv()->ExceptionOccurred()) + if (xbmc_jnienv()->ExceptionCheck()) { - CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Open ExceptionOccurred"); + CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Open ExceptionCheck"); xbmc_jnienv()->ExceptionClear(); m_codec.reset(); continue; @@ -560,9 +575,9 @@ int CDVDVideoCodecAndroidMediaCodec::Decode(uint8_t *pData, int iSize, double dt // try to fetch an input buffer int64_t timeout_us = 5000; int index = m_codec->dequeueInputBuffer(timeout_us); - if (xbmc_jnienv()->ExceptionOccurred()) + if (xbmc_jnienv()->ExceptionCheck()) { - CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Decode ExceptionOccurred"); + CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Decode ExceptionCheck"); xbmc_jnienv()->ExceptionDescribe(); xbmc_jnienv()->ExceptionClear(); return VC_ERROR; @@ -573,7 +588,16 @@ int CDVDVideoCodecAndroidMediaCodec::Decode(uint8_t *pData, int iSize, double dt // m_codec->start() but the internal refs are not // setup until much later on some devices. if (m_input.empty()) + { m_input = m_codec->getInputBuffers(); + if (xbmc_jnienv()->ExceptionCheck()) + { + CLog::Log(LOGERROR, "CDVDMediaCodecInfo::getInputBuffers " + "ExceptionCheck"); + xbmc_jnienv()->ExceptionDescribe(); + xbmc_jnienv()->ExceptionClear(); + } + } // we have an input buffer, fill it. int size = m_input[index].capacity(); @@ -611,9 +635,9 @@ int CDVDVideoCodecAndroidMediaCodec::Decode(uint8_t *pData, int iSize, double dt int offset = 0; m_codec->queueInputBuffer(index, offset, demux_pkt.iSize, presentationTimeUs, flags); // clear any jni exceptions, jni gets upset if we do not. - if (xbmc_jnienv()->ExceptionOccurred()) + if (xbmc_jnienv()->ExceptionCheck()) { - CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Decode ExceptionOccurred"); + CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Decode ExceptionCheck"); xbmc_jnienv()->ExceptionClear(); } } @@ -644,9 +668,9 @@ void CDVDVideoCodecAndroidMediaCodec::Reset() // now we can flush the actual MediaCodec object m_codec->flush(); - if (xbmc_jnienv()->ExceptionOccurred()) + if (xbmc_jnienv()->ExceptionCheck()) { - CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Reset ExceptionOccurred"); + CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Reset ExceptionCheck"); xbmc_jnienv()->ExceptionClear(); } @@ -777,9 +801,9 @@ bool CDVDVideoCodecAndroidMediaCodec::ConfigureMediaCodec(void) m_codec->configure(mediaformat, *m_surface, crypto, flags); } // always, check/clear jni exceptions. - if (xbmc_jnienv()->ExceptionOccurred()) + if (xbmc_jnienv()->ExceptionCheck()) { - CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::ExceptionOccurred: configure"); + CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::ExceptionCheck: configure"); xbmc_jnienv()->ExceptionClear(); return false; } @@ -787,9 +811,9 @@ bool CDVDVideoCodecAndroidMediaCodec::ConfigureMediaCodec(void) m_codec->start(); // always, check/clear jni exceptions. - if (xbmc_jnienv()->ExceptionOccurred()) + if (xbmc_jnienv()->ExceptionCheck()) { - CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::ExceptionOccurred: start"); + CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::ExceptionCheck: start"); xbmc_jnienv()->ExceptionClear(); return false; } @@ -808,9 +832,9 @@ int CDVDVideoCodecAndroidMediaCodec::GetOutputPicture(void) int64_t timeout_us = 50000; CJNIMediaCodecBufferInfo bufferInfo; int index = m_codec->dequeueOutputBuffer(bufferInfo, timeout_us); - if (xbmc_jnienv()->ExceptionOccurred()) + if (xbmc_jnienv()->ExceptionCheck()) { - CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::GetOutputPicture ExceptionOccurred"); + CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::GetOutputPicture ExceptionCheck; dequeueOutputBuffer"); xbmc_jnienv()->ExceptionDescribe(); xbmc_jnienv()->ExceptionClear(); return 0; @@ -820,8 +844,13 @@ int CDVDVideoCodecAndroidMediaCodec::GetOutputPicture(void) if (m_drop) { m_codec->releaseOutputBuffer(index, false); - if (xbmc_jnienv()->ExceptionOccurred()) + if (xbmc_jnienv()->ExceptionCheck()) + { + CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::GetOutputPicture ExceptionCheck: releaseOutputBuffer"); + xbmc_jnienv()->ExceptionDescribe(); xbmc_jnienv()->ExceptionClear(); + return 0; + } return 0; } @@ -831,6 +860,13 @@ int CDVDVideoCodecAndroidMediaCodec::GetOutputPicture(void) if (m_output.empty()) { m_output = m_codec->getOutputBuffers(); + if (xbmc_jnienv()->ExceptionCheck()) + { + CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::GetOutputPicture ExceptionCheck: getOutputBuffers"); + xbmc_jnienv()->ExceptionDescribe(); + xbmc_jnienv()->ExceptionClear(); + return 0; + } FlushInternal(); } @@ -845,8 +881,13 @@ int CDVDVideoCodecAndroidMediaCodec::GetOutputPicture(void) { CLog::Log(LOGDEBUG, "CDVDVideoCodecAndroidMediaCodec:: BUFFER_FLAG_END_OF_STREAM"); m_codec->releaseOutputBuffer(index, false); - if (xbmc_jnienv()->ExceptionOccurred()) + if (xbmc_jnienv()->ExceptionCheck()) + { + CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::GetOutputPicture ExceptionCheck: releaseOutputBuffer"); + xbmc_jnienv()->ExceptionDescribe(); xbmc_jnienv()->ExceptionClear(); + return 0; + } return 0; } @@ -893,6 +934,12 @@ int CDVDVideoCodecAndroidMediaCodec::GetOutputPicture(void) } } m_codec->releaseOutputBuffer(index, false); + if (xbmc_jnienv()->ExceptionCheck()) + { + CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::GetOutputPicture ExceptionCheck: releaseOutputBuffer"); + xbmc_jnienv()->ExceptionDescribe(); + xbmc_jnienv()->ExceptionClear(); + } } int64_t pts= bufferInfo.presentationTimeUs(); @@ -906,7 +953,7 @@ int CDVDVideoCodecAndroidMediaCodec::GetOutputPicture(void) "index(%d), pts(%f)", index, m_videobuffer.pts); */ // always, check/clear jni exceptions. - if (xbmc_jnienv()->ExceptionOccurred()) + if (xbmc_jnienv()->ExceptionCheck()) xbmc_jnienv()->ExceptionClear(); rtn = 1; @@ -914,11 +961,23 @@ int CDVDVideoCodecAndroidMediaCodec::GetOutputPicture(void) else if (index == CJNIMediaCodec::INFO_OUTPUT_BUFFERS_CHANGED) { m_output = m_codec->getOutputBuffers(); + if (xbmc_jnienv()->ExceptionCheck()) + { + CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::GetOutputPicture(INFO_OUTPUT_BUFFERS_CHANGED) ExceptionCheck: getOutputBuffers"); + xbmc_jnienv()->ExceptionDescribe(); + xbmc_jnienv()->ExceptionClear(); + } FlushInternal(); } else if (index == CJNIMediaCodec::INFO_OUTPUT_FORMAT_CHANGED) { CJNIMediaFormat mediaformat = m_codec->getOutputFormat(); + if (xbmc_jnienv()->ExceptionCheck()) + { + CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::GetOutputPicture(INFO_OUTPUT_FORMAT_CHANGED) ExceptionCheck: getOutputBuffers"); + xbmc_jnienv()->ExceptionDescribe(); + xbmc_jnienv()->ExceptionClear(); + } ConfigureOutputFormat(&mediaformat); } else if (index == CJNIMediaCodec::INFO_TRY_AGAIN_LATER) @@ -1131,7 +1190,7 @@ void CDVDVideoCodecAndroidMediaCodec::ConfigureOutputFormat(CJNIMediaFormat* med } // clear any jni exceptions - if (xbmc_jnienv()->ExceptionOccurred()) + if (xbmc_jnienv()->ExceptionCheck()) xbmc_jnienv()->ExceptionClear(); } diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecStageFright.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecStageFright.cpp index b05ef561dc..4bd4609a3b 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecStageFright.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecStageFright.cpp @@ -85,6 +85,18 @@ bool CDVDVideoCodecStageFright::Open(CDVDStreamInfo &hints, CDVDCodecOptions &op m_convert_bitstream = m_converter->Open(hints.codec, (uint8_t *)hints.extradata, hints.extrasize, true); break; + case AV_CODEC_ID_HEVC: + m_pFormatName = "stf-h265"; + if (hints.extrasize < 22 || hints.extradata == NULL) + { + CLog::Log(LOGNOTICE, + "%s::%s - hvcC data too small or missing", CLASSNAME, __func__); + return false; + } + m_converter = new CBitstreamConverter(); + m_convert_bitstream = m_converter->Open(hints.codec, (uint8_t *)hints.extradata, hints.extrasize, true); + + break; case CODEC_ID_MPEG2VIDEO: m_pFormatName = "stf-mpeg2"; break; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp index 5e489dcd20..71eea96b5f 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp @@ -22,9 +22,9 @@ #include "utils/log.h" #include "cores/FFmpeg.h" -CDVDVideoPPFFmpeg::CDVDVideoPPFFmpeg(const std::string& mType) +CDVDVideoPPFFmpeg::CDVDVideoPPFFmpeg(const std::string& mType): + m_sType(mType) { - m_sType = mType; m_pMode = m_pContext = NULL; m_pSource = m_pTarget = NULL; m_iInitWidth = m_iInitHeight = 0; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/MMALCodec.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/MMALCodec.h index b4aa571018..b1b7c90ab4 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/MMALCodec.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/MMALCodec.h @@ -36,7 +36,7 @@ #include <queue> #include <semaphore.h> #include <boost/shared_ptr.hpp> -#include "utils/StdString.h" +#include <string> #include "guilib/Geometry.h" #include "rendering/RenderSystem.h" #include "cores/VideoRenderers/BaseRenderer.h" @@ -128,7 +128,7 @@ protected: std::vector<CMMALVideoBuffer*> m_output_buffers; // initialize mmal and get decoder component - bool Initialize( const CStdString &decoder_name); + bool Initialize( const std::string &decoder_name); void PortSettingsChanged(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer); bool SendCodecConfigData(); diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/OpenMaxVideo.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/OpenMaxVideo.cpp index d5b562b576..bd09077630 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/OpenMaxVideo.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/OpenMaxVideo.cpp @@ -268,7 +268,7 @@ void COpenMaxVideo::SetDropState(bool bDrop) // blow all video frames pthread_mutex_lock(&m_omx_queue_mutex); - while (m_omx_output_ready.size() > 0) + while (!m_omx_output_ready.empty()) { m_dts_queue.pop(); OMX_BUFFERHEADERTYPE *omx_buffer = m_omx_output_ready.front()->omx_buffer; @@ -664,9 +664,7 @@ OMX_ERRORTYPE COpenMaxVideo::AllocOMXInputBuffers(void) } OMX_ERRORTYPE COpenMaxVideo::FreeOMXInputBuffers(bool wait) { - OMX_ERRORTYPE omx_err = OMX_ErrorNone; - - omx_err = OMX_SendCommand(m_omx_decoder, OMX_CommandFlush, m_omx_input_port, 0); + OMX_ERRORTYPE omx_err = OMX_SendCommand(m_omx_decoder, OMX_CommandFlush, m_omx_input_port, 0); if (omx_err) CLog::Log(LOGERROR, "%s::%s - OMX_CommandFlush failed with omx_err(0x%x)\n", CLASSNAME, __func__, omx_err); diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp index 369bbde5a5..4be8f39c4d 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp @@ -150,9 +150,12 @@ bool CVAAPIContext::CreateContext() CLog::Log(LOGDEBUG, "VAAPI - driver in use: %s", vaQueryVendorString(m_display)); QueryCaps(); - if (!m_profileCount || !m_attributeCount) + if (!m_profileCount) return false; + if (!m_attributeCount) + CLog::Log(LOGWARNING, "VAAPI - driver did not return anything from vlVaQueryDisplayAttributes"); + return true; } @@ -240,7 +243,7 @@ bool CVAAPIContext::CheckSuccess(VAStatus status) { if (status != VA_STATUS_SUCCESS) { - CLog::Log(LOGERROR, "VAAPI error: %s", vaErrorStr(status)); + CLog::Log(LOGERROR, "VAAPI::%s error: %s", __FUNCTION__, vaErrorStr(status)); return false; } return true; @@ -593,7 +596,9 @@ bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat fmt, unsigned else m_vaapiConfig.maxReferences = 2; - m_vaapiConfig.maxReferences += surfaces; + // add an extra surface for safety, some faulty material + // make ffmpeg require more buffers + m_vaapiConfig.maxReferences += surfaces + 1; if (!ConfigVAAPI()) { @@ -940,7 +945,7 @@ bool CDecoder::CheckSuccess(VAStatus status) { if (status != VA_STATUS_SUCCESS) { - CLog::Log(LOGERROR, "VAAPI - error: %s", vaErrorStr(status)); + CLog::Log(LOGERROR, "VAAPI::%s - error: %s", __FUNCTION__, vaErrorStr(status)); m_ErrorCount++; if(m_DisplayState == VAAPI_OPEN) @@ -2306,7 +2311,7 @@ bool COutput::CheckSuccess(VAStatus status) { if (status != VA_STATUS_SUCCESS) { - CLog::Log(LOGERROR, "VAAPI - Error: %s(%d)", vaErrorStr(status), status); + CLog::Log(LOGERROR, "VAAPI::%s - Error: %s(%d)", __FUNCTION__, vaErrorStr(status), status); m_vaError = true; return false; } @@ -2477,6 +2482,9 @@ bool CVppPostproc::PreInit(CVaapiConfig &config, SDiMethods *methods) // create config if (!CheckSuccess(vaCreateConfig(m_config.dpy, VAProfileNone, VAEntrypointVideoProc, NULL, 0, &m_configId))) { + if (g_advancedSettings.CanLogComponent(LOGVIDEO)) + CLog::Log(LOGDEBUG, "CVppPostproc::PreInit - VPP init failed"); + return false; } @@ -2491,6 +2499,9 @@ bool CVppPostproc::PreInit(CVaapiConfig &config, SDiMethods *methods) nb_surfaces, NULL, 0))) { + if (g_advancedSettings.CanLogComponent(LOGVIDEO)) + CLog::Log(LOGDEBUG, "CVppPostproc::PreInit - VPP init failed"); + return false; } for (int i=0; i<nb_surfaces; i++) @@ -2509,6 +2520,9 @@ bool CVppPostproc::PreInit(CVaapiConfig &config, SDiMethods *methods) &m_contextId))) { m_contextId = VA_INVALID_ID; + if (g_advancedSettings.CanLogComponent(LOGVIDEO)) + CLog::Log(LOGDEBUG, "CVppPostproc::PreInit - VPP init failed"); + return false; } @@ -2519,6 +2533,9 @@ bool CVppPostproc::PreInit(CVaapiConfig &config, SDiMethods *methods) if (!CheckSuccess(vaQueryVideoProcFilters(m_config.dpy, m_contextId, filters, &numFilters))) { + if (g_advancedSettings.CanLogComponent(LOGVIDEO)) + CLog::Log(LOGDEBUG, "CVppPostproc::PreInit - VPP init failed"); + return false; } @@ -2528,6 +2545,9 @@ bool CVppPostproc::PreInit(CVaapiConfig &config, SDiMethods *methods) deinterlacingCaps, &numDeinterlacingCaps))) { + if (g_advancedSettings.CanLogComponent(LOGVIDEO)) + CLog::Log(LOGDEBUG, "CVppPostproc::PreInit - VPP init failed"); + return false; } @@ -2912,7 +2932,7 @@ bool CVppPostproc::CheckSuccess(VAStatus status) { if (status != VA_STATUS_SUCCESS) { - CLog::Log(LOGERROR, "VAAPI - Error: %s(%d)", vaErrorStr(status), status); + CLog::Log(LOGERROR, "VAAPI::%s - Error: %s(%d)", __FUNCTION__, vaErrorStr(status), status); return false; } return true; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp index 1871eb8c80..b9cda6a2a3 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp @@ -1683,8 +1683,7 @@ void CMixer::CreateVdpauMixer() &m_config.surfaceHeight, &m_config.vdpChromaType}; - VdpStatus vdp_st = VDP_STATUS_ERROR; - vdp_st = m_config.context->GetProcs().vdp_video_mixer_create(m_config.context->GetDevice(), + VdpStatus vdp_st = m_config.context->GetProcs().vdp_video_mixer_create(m_config.context->GetDevice(), m_config.context->GetFeatureCount(), m_config.context->GetFeatures(), ARSIZE(parameters), @@ -1902,8 +1901,11 @@ void CMixer::SetColor() else { vdp_st = m_config.context->GetProcs().vdp_generate_csc_matrix(&m_Procamp, colorStandard, &m_CSCMatrix); - void const * pm_CSCMatix[] = { &m_CSCMatrix }; - vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix); + if(vdp_st != VDP_STATUS_ERROR) + { + void const * pm_CSCMatix[] = { &m_CSCMatrix }; + vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix); + } } CheckStatus(vdp_st, __LINE__); diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideo.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideo.cpp index 0f2cab0fda..019bc7aab4 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideo.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideo.cpp @@ -415,6 +415,11 @@ bool CStageFrightVideo::Open(CDVDStreamInfo &hints) const char* mimetype; switch (hints.codec) { + case AV_CODEC_ID_HEVC: + if (p->m_g_advancedSettings->m_stagefrightConfig.useHEVCcodec == 0) + return false; + mimetype = "video/hevc"; + break; case CODEC_ID_H264: if (p->m_g_advancedSettings->m_stagefrightConfig.useAVCcodec == 0) return false; diff --git a/xbmc/cores/dvdplayer/DVDDemuxSPU.cpp b/xbmc/cores/dvdplayer/DVDDemuxSPU.cpp index bd1e1042f9..b0a67252b2 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxSPU.cpp +++ b/xbmc/cores/dvdplayer/DVDDemuxSPU.cpp @@ -410,6 +410,7 @@ CDVDOverlaySpu* CDVDDemuxSPU::ParseRLE(CDVDOverlaySpu* pSPU, uint8_t* pUnparsedD { /* We have a boo boo ! */ CLog::Log(LOGERROR, "ParseRLE: unknown RLE code 0x%.4x", i_code); + pSPU->Release(); return NULL; } } @@ -421,6 +422,7 @@ CDVDOverlaySpu* CDVDDemuxSPU::ParseRLE(CDVDOverlaySpu* pSPU, uint8_t* pUnparsedD { CLog::Log(LOGERROR, "ParseRLE: out of bounds, %i at (%i,%i) is out of %ix%i", i_code >> 2, i_x, i_y, i_width, i_height ); + pSPU->Release(); return NULL; } @@ -441,6 +443,7 @@ CDVDOverlaySpu* CDVDDemuxSPU::ParseRLE(CDVDOverlaySpu* pSPU, uint8_t* pUnparsedD if ((uint8_t *)p_dest >= pSPU->result + sizeof(pSPU->result)) { CLog::Log(LOGERROR, "ParseRLE: Overrunning our data range. Need %li bytes", (long)((uint8_t *)p_dest - pSPU->result)); + pSPU->Release(); return NULL; } *p_dest++ = i_code; @@ -450,6 +453,7 @@ CDVDOverlaySpu* CDVDDemuxSPU::ParseRLE(CDVDOverlaySpu* pSPU, uint8_t* pUnparsedD if ( i_x > i_width ) { CLog::Log(LOGERROR, "ParseRLE: i_x overflowed, %i > %i", i_x, i_width ); + pSPU->Release(); return NULL; } @@ -478,12 +482,14 @@ CDVDOverlaySpu* CDVDDemuxSPU::ParseRLE(CDVDOverlaySpu* pSPU, uint8_t* pUnparsedD if ((uint8_t *)p_dest >= pSPU->result + sizeof(pSPU->result)) { CLog::Log(LOGERROR, "ParseRLE: Overrunning our data range. Need %li bytes", (long)((uint8_t *)p_dest - pSPU->result)); + pSPU->Release(); return NULL; } *p_dest++ = i_width << 2; i_y++; } + pSPU->Release(); return NULL; } diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemux.h b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemux.h index 40c16c0360..d69991ea5b 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemux.h +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemux.h @@ -47,7 +47,7 @@ enum AVDiscard; enum StreamType { - STREAM_NONE, // if unknown + STREAM_NONE = 0,// if unknown STREAM_AUDIO, // audio stream STREAM_VIDEO, // video stream STREAM_DATA, // data stream @@ -60,7 +60,8 @@ enum StreamSource { STREAM_SOURCE_DEMUX = 0x100, STREAM_SOURCE_NAV = 0x200, STREAM_SOURCE_DEMUX_SUB = 0x300, - STREAM_SOURCE_TEXT = 0x400 + STREAM_SOURCE_TEXT = 0x400, + STREAM_SOURCE_VIDEOMUX = 0x500 }; #define STREAM_SOURCE_MASK(a) ((a) & 0xf00) @@ -130,14 +131,16 @@ public: int orig_type; // type of original source enum EFlags - { FLAG_NONE = 0x0000 - , FLAG_DEFAULT = 0x0001 - , FLAG_DUB = 0x0002 - , FLAG_ORIGINAL = 0x0004 - , FLAG_COMMENT = 0x0008 - , FLAG_LYRICS = 0x0010 - , FLAG_KARAOKE = 0x0020 - , FLAG_FORCED = 0x0040 + { FLAG_NONE = 0x0000 + , FLAG_DEFAULT = 0x0001 + , FLAG_DUB = 0x0002 + , FLAG_ORIGINAL = 0x0004 + , FLAG_COMMENT = 0x0008 + , FLAG_LYRICS = 0x0010 + , FLAG_KARAOKE = 0x0020 + , FLAG_FORCED = 0x0040 + , FLAG_HEARING_IMPAIRED = 0x0080 + , FLAG_VISUAL_IMPAIRED = 0x0100 } flags; }; diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxCC.cpp b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxCC.cpp new file mode 100644 index 0000000000..f51032a6af --- /dev/null +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxCC.cpp @@ -0,0 +1,401 @@ +/* + * Copyright (C) 2005-2014 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "DVDDemuxUtils.h" +#include "DVDClock.h" +#include "DVDDemuxCC.h" +#include "cores/dvdplayer/DVDCodecs/Overlay/contrib/cc_decoder708.h" +#include "utils/log.h" + +class CBitstream +{ +public: + CBitstream(uint8_t *data, int bits) + { + m_data = data; + m_offset = 0; + m_len = bits; + m_error = false; + } + unsigned int readBits(int num) + { + int r = 0; + while (num > 0) + { + if (m_offset >= m_len) + { + m_error = true; + return 0; + } + num--; + if (m_data[m_offset / 8] & (1 << (7 - (m_offset & 7)))) + r |= 1 << num; + m_offset++; + } + return r; + } + unsigned int readGolombUE(int maxbits = 32) + { + int lzb = -1; + int bits = 0; + for (int b = 0; !b; lzb++, bits++) + { + if (bits > maxbits) + return 0; + b = readBits(1); + } + return (1 << lzb) - 1 + readBits(lzb); + } + +private: + uint8_t *m_data; + int m_offset; + int m_len; + bool m_error; +}; + +class CCaptionBlock +{ +public: + CCaptionBlock(int size) + { + m_data = (uint8_t*)malloc(size); + m_size = size; + } + virtual ~CCaptionBlock() + { + free(m_data); + } + double m_pts; + uint8_t *m_data; + int m_size; +}; + +bool reorder_sort (CCaptionBlock *lhs, CCaptionBlock *rhs) +{ + return (lhs->m_pts > rhs->m_pts); +} + +CDVDDemuxCC::CDVDDemuxCC(AVCodecID codec) +{ + m_hasData = false; + m_ccDecoder = NULL; + m_codec = codec; +} + +CDVDDemuxCC::~CDVDDemuxCC() +{ + Dispose(); +} + +CDemuxStream* CDVDDemuxCC::GetStream(int iStreamId) +{ + return &m_streams[iStreamId]; +} + +int CDVDDemuxCC::GetNrOfStreams() +{ + return m_streams.size(); +} + +DemuxPacket* CDVDDemuxCC::Read(DemuxPacket *pSrcPacket) +{ + DemuxPacket *pPacket = NULL; + uint32_t startcode = 0xffffffff; + int picType = 0; + int p = 0; + int len; + + if (!pSrcPacket) + { + pPacket = Decode(); + return pPacket; + } + if (pSrcPacket->pts == DVD_NOPTS_VALUE) + { + return pPacket; + } + + while (!m_ccTempBuffer.empty()) + { + m_ccReorderBuffer.push_back(m_ccTempBuffer.back()); + m_ccTempBuffer.pop_back(); + } + + while ((len = pSrcPacket->iSize - p) > 3) + { + if ((startcode & 0xffffff00) == 0x00000100) + { + if (m_codec == AV_CODEC_ID_MPEG2VIDEO) + { + int scode = startcode & 0xFF; + if (scode == 0x00) + { + if (len > 4) + { + uint8_t *buf = pSrcPacket->pData + p; + picType = (buf[1] & 0x38) >> 3; + } + } + else if (scode == 0xb2) // user data + { + uint8_t *buf = pSrcPacket->pData + p; + if (len >= 6 && + buf[0] == 'G' && buf[1] == 'A' && buf[2] == '9' && buf[3] == '4' && + buf[4] == 3 && (buf[5] & 0x40)) + { + int cc_count = buf[5] & 0x1f; + if (cc_count > 0 && len >= 7 + cc_count * 3) + { + CCaptionBlock *cc = new CCaptionBlock(cc_count * 3); + memcpy(cc->m_data, buf + 7, cc_count * 3); + cc->m_pts = pSrcPacket->pts; + if (picType == 1 || picType == 2) + m_ccTempBuffer.push_back(cc); + else + m_ccReorderBuffer.push_back(cc); + } + } + else if (len >= 6 && + buf[0] == 'C' && buf[1] == 'C' && buf[2] == 1) + { + int oddidx = (buf[4] & 0x80) ? 0 : 1; + int cc_count = (buf[4] & 0x3e) >> 1; + int extrafield = buf[4] & 0x01; + if (extrafield) + cc_count++; + + if (cc_count > 0 && len >= 5 + cc_count * 3 * 2) + { + CCaptionBlock *cc = new CCaptionBlock(cc_count * 3); + uint8_t *src = buf + 5; + uint8_t *dst = cc->m_data; + + for (int i = 0; i < cc_count; i++) + { + for (int j = 0; j < 2; j++) + { + if (i == cc_count - 1 && extrafield && j == 1) + break; + + if ((oddidx == j) && (src[0] == 0xFF)) + { + dst[0] = 0x04; + dst[1] = src[1]; + dst[2] = src[2]; + dst += 3; + } + src += 3; + } + } + cc->m_pts = pSrcPacket->pts; + m_ccReorderBuffer.push_back(cc); + picType = 1; + } + } + } + } + else if (m_codec == AV_CODEC_ID_H264) + { + int scode = startcode & 0x9F; + // slice data comes after SEI + if (scode >= 1 && scode <= 5) + { + uint8_t *buf = pSrcPacket->pData + p; + CBitstream bs(buf, len * 8); + bs.readGolombUE(); + int sliceType = bs.readGolombUE(); + if (sliceType == 2 || sliceType == 7) // I slice + picType = 1; + else if (sliceType == 0 || sliceType == 5) // P slice + picType = 2; + if (picType == 0) + { + while (!m_ccTempBuffer.empty()) + { + m_ccReorderBuffer.push_back(m_ccTempBuffer.back()); + m_ccTempBuffer.pop_back(); + } + } + } + if (scode == 0x06) // SEI + { + uint8_t *buf = pSrcPacket->pData + p; + if (len >= 12 && + buf[3] == 0 && buf[4] == 49 && + buf[5] == 'G' && buf[6] == 'A' && buf[7] == '9' && buf[8] == '4' && buf[9] == 3) + { + uint8_t *userdata = buf + 10; + int cc_count = userdata[0] & 0x1f; + if (len >= cc_count * 3 + 10) + { + CCaptionBlock *cc = new CCaptionBlock(cc_count * 3); + memcpy(cc->m_data, userdata + 2, cc_count * 3); + cc->m_pts = pSrcPacket->pts; + m_ccTempBuffer.push_back(cc); + } + } + } + } + } + startcode = startcode << 8 | pSrcPacket->pData[p++]; + } + + if ((picType == 1 || picType == 2) && !m_ccReorderBuffer.empty()) + { + if (!m_ccDecoder) + { + if (!OpenDecoder()) + return NULL; + } + std::sort(m_ccReorderBuffer.begin(), m_ccReorderBuffer.end(), reorder_sort); + pPacket = Decode(); + } + return pPacket; +} + +void CDVDDemuxCC::Handler(int service, void *userdata) +{ + CDVDDemuxCC *ctx = (CDVDDemuxCC*)userdata; + + unsigned int idx; + + // switch back from 608 fallback if we got 708 + if (ctx->m_ccDecoder->m_seen608 && ctx->m_ccDecoder->m_seen708) + { + for (idx = 0; idx < ctx->m_streamdata.size(); idx++) + { + if (ctx->m_streamdata[idx].service == 0) + break; + } + if (idx < ctx->m_streamdata.size()) + { + ctx->m_streamdata.erase(ctx->m_streamdata.begin() + idx); + ctx->m_ccDecoder->m_seen608 = false; + } + if (service == 0) + return; + } + + for (idx = 0; idx < ctx->m_streamdata.size(); idx++) + { + if (ctx->m_streamdata[idx].service == service) + break; + } + if (idx >= ctx->m_streamdata.size()) + { + CDemuxStreamSubtitle stream; + strcpy(stream.language, "cc"); + stream.codec = AV_CODEC_ID_TEXT; + stream.iPhysicalId = service; + stream.iId = idx; + ctx->m_streams.push_back(stream); + + streamdata data; + data.streamIdx = idx; + data.service = service; + ctx->m_streamdata.push_back(data); + + if (service == 0) + ctx->m_ccDecoder->m_seen608 = true; + else + ctx->m_ccDecoder->m_seen708 = true; + } + + ctx->m_streamdata[idx].pts = ctx->m_curPts; + ctx->m_streamdata[idx].hasData = true; + ctx->m_hasData = true; +} + +bool CDVDDemuxCC::OpenDecoder() +{ + m_ccDecoder = new CDecoderCC708(); + m_ccDecoder->Init(Handler, this); + return true; +} + +void CDVDDemuxCC::Dispose() +{ + m_streams.clear(); + m_streamdata.clear(); + delete m_ccDecoder; + m_ccDecoder = NULL; + + while (!m_ccReorderBuffer.empty()) + { + delete m_ccReorderBuffer.back(); + m_ccReorderBuffer.pop_back(); + } + while (!m_ccTempBuffer.empty()) + { + delete m_ccTempBuffer.back(); + m_ccTempBuffer.pop_back(); + } +} + +DemuxPacket* CDVDDemuxCC::Decode() +{ + DemuxPacket *pPacket = NULL; + + while(!m_hasData && !m_ccReorderBuffer.empty()) + { + CCaptionBlock *cc = m_ccReorderBuffer.back(); + m_ccReorderBuffer.pop_back(); + m_curPts = cc->m_pts; + m_ccDecoder->Decode(cc->m_data, cc->m_size); + delete cc; + } + + if (m_hasData) + { + for (unsigned int i=0; i<m_streamdata.size(); i++) + { + if (m_streamdata[i].hasData) + { + int service = m_streamdata[i].service; + + char *data; + int len; + if (service == 0) + { + data = m_ccDecoder->m_cc608decoder->text; + len = m_ccDecoder->m_cc608decoder->textlen; + } + else + { + data = m_ccDecoder->m_cc708decoders[service].text; + len = m_ccDecoder->m_cc708decoders[service].textlen; + } + + pPacket = CDVDDemuxUtils::AllocateDemuxPacket(len); + pPacket->iSize = len; + memcpy(pPacket->pData, data, pPacket->iSize); + + pPacket->iStreamId = i; + pPacket->pts = m_streamdata[i].pts; + pPacket->duration = 0; + m_streamdata[i].hasData = false; + break; + } + m_hasData = false; + } + } + return pPacket; +} diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxCC.h b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxCC.h new file mode 100644 index 0000000000..ae78298c45 --- /dev/null +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxCC.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2005-2014 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#pragma once +#include "DVDDemux.h" +#include <vector> + +class CCaptionBlock; +class CDecoderCC708; + +class CDVDDemuxCC : public CDVDDemux +{ +public: + CDVDDemuxCC(AVCodecID codec); + virtual ~CDVDDemuxCC(); + + virtual void Reset() {}; + virtual void Abort() {}; + virtual void Flush() {}; + virtual DemuxPacket* Read() { return NULL; }; + virtual bool SeekTime(int time, bool backwords = false, double* startpts = NULL) {return true;}; + virtual void SetSpeed(int iSpeed) {}; + virtual int GetStreamLength() {return 0;}; + virtual CDemuxStream* GetStream(int iStreamId); + virtual int GetNrOfStreams(); + virtual std::string GetFileName() {return "";}; + + DemuxPacket* Read(DemuxPacket *packet); + static void Handler(int service, void *userdata); + +protected: + bool OpenDecoder(); + void Dispose(); + DemuxPacket* Decode(); + + struct streamdata + { + int streamIdx; + int service; + bool hasData ; + double pts; + }; + std::vector<streamdata> m_streamdata; + std::vector<CDemuxStreamSubtitle> m_streams; + bool m_hasData; + double m_curPts; + std::vector<CCaptionBlock*> m_ccReorderBuffer; + std::vector<CCaptionBlock*> m_ccTempBuffer; + CDecoderCC708 *m_ccDecoder; + AVCodecID m_codec; +}; diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp index f3da82e219..3bf1b45065 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp @@ -217,13 +217,14 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput, bool streaminfo, bool filein if( m_pInput->GetContent().length() > 0 ) { std::string content = m_pInput->GetContent(); + StringUtils::ToLower(content); /* check if we can get a hint from content */ if ( content.compare("video/x-vobsub") == 0 ) iformat = av_find_input_format("mpeg"); else if( content.compare("video/x-dvd-mpeg") == 0 ) iformat = av_find_input_format("mpeg"); - else if( content.compare("video/x-mpegts") == 0 ) + else if( content.compare("video/mp2t") == 0 ) iformat = av_find_input_format("mpegts"); else if( content.compare("multipart/x-mixed-replace") == 0 ) iformat = av_find_input_format("mjpeg"); @@ -305,8 +306,10 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput, bool streaminfo, bool filein pd.buf = probe_buffer; pd.filename = strFile.c_str(); + // av_probe_input_buffer might have changed the buffer_size beyond our allocated amount + int buffer_size = std::min((int) FFMPEG_FILE_BUFFER_SIZE, m_ioContext->buffer_size); // read data using avformat's buffers - pd.buf_size = avio_read(m_ioContext, pd.buf, m_ioContext->max_packet_size ? m_ioContext->max_packet_size : m_ioContext->buffer_size); + pd.buf_size = avio_read(m_ioContext, pd.buf, m_ioContext->max_packet_size ? m_ioContext->max_packet_size : buffer_size); if (pd.buf_size <= 0) { CLog::Log(LOGERROR, "%s - error reading from input stream, %s", __FUNCTION__, CURL::GetRedacted(strFile).c_str()); @@ -429,7 +432,7 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput, bool streaminfo, bool filein m_checkvideo = true; skipCreateStreams = true; } - else if (iformat && (strcmp(iformat->name, "mpegts") != 0)) + else if (!iformat || (strcmp(iformat->name, "mpegts") != 0)) { m_streaminfo = true; } @@ -641,8 +644,8 @@ double CDVDDemuxFFmpeg::ConvertTimestamp(int64_t pts, int den, int num) double starttime = 0.0f; // for dvd's we need the original time - if(dynamic_cast<CDVDInputStream::IMenus*>(m_pInput)) - starttime = dynamic_cast<CDVDInputStream::IMenus*>(m_pInput)->GetTimeStampCorrection() / DVD_TIME_BASE; + if(CDVDInputStream::IMenus* menu = dynamic_cast<CDVDInputStream::IMenus*>(m_pInput)) + starttime = menu->GetTimeStampCorrection() / DVD_TIME_BASE; else if (m_pFormatContext->start_time != (int64_t)AV_NOPTS_VALUE) starttime = (double)m_pFormatContext->start_time / AV_TIME_BASE; @@ -1605,8 +1608,9 @@ void CDVDDemuxFFmpeg::ParsePacket(AVPacket *pkt) // Force thread count to 1 since the h264 decoder will not extract // SPS and PPS to extradata during multi-threaded decoding av_dict_set(&thread_opt, "threads", "1", 0); - avcodec_open2(st->codec, codec, &thread_opt); - + int res = avcodec_open2(st->codec, codec, &thread_opt); + if(res < 0) + CLog::Log(LOGERROR, "CDVDDemuxFFmpeg::ParsePacket() unable to open codec %d", res); av_dict_free(&thread_opt); } @@ -1705,7 +1709,7 @@ void CDVDDemuxFFmpeg::GetL16Parameters(int &channels, int &samplerate) if (content.compare(pos, 9, "channels=", 9) == 0) { pos += 9; // move position to char after 'channels=' - int len = content.find(';', pos); + size_t len = content.find(';', pos); if (len != std::string::npos) len -= pos; std::string no_channels(content, pos, len); @@ -1723,7 +1727,7 @@ void CDVDDemuxFFmpeg::GetL16Parameters(int &channels, int &samplerate) else if (content.compare(pos, 5, "rate=", 5) == 0) { pos += 5; // move position to char after 'rate=' - int len = content.find(';', pos); + size_t len = content.find(';', pos); if (len != std::string::npos) len -= pos; std::string rate(content, pos, len); @@ -1742,4 +1746,4 @@ void CDVDDemuxFFmpeg::GetL16Parameters(int &channels, int &samplerate) } } } -}
\ No newline at end of file +} diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/Makefile.in b/xbmc/cores/dvdplayer/DVDDemuxers/Makefile.in index 658c451ee2..98493fe075 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxers/Makefile.in +++ b/xbmc/cores/dvdplayer/DVDDemuxers/Makefile.in @@ -9,6 +9,7 @@ SRCS += DVDDemuxPVRClient.cpp SRCS += DVDDemuxShoutcast.cpp SRCS += DVDDemuxUtils.cpp SRCS += DVDDemuxVobsub.cpp +SRCS += DVDDemuxCC.cpp SRCS += DVDFactoryDemuxer.cpp LIB = DVDDemuxers.a diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.cpp b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.cpp index 31d95723d7..6056e51c8b 100644 --- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.cpp +++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.cpp @@ -200,7 +200,11 @@ CDVDInputStreamBluray::CDVDInputStreamBluray(IDVDPlayer* player) : m_player = player; m_navmode = false; m_hold = HOLD_NONE; + m_angle = 0; memset(&m_event, 0, sizeof(m_event)); +#ifdef HAVE_LIBBLURAY_BDJ + memset(&m_argb, 0, sizeof(m_argb)); +#endif } CDVDInputStreamBluray::~CDVDInputStreamBluray() @@ -239,7 +243,7 @@ BLURAY_TITLE_INFO* CDVDInputStreamBluray::GetTitleLongest() BLURAY_TITLE_INFO* CDVDInputStreamBluray::GetTitleFile(const std::string& filename) { unsigned int playlist; - if(sscanf(filename.c_str(), "%05d.mpls", &playlist) != 1) + if(sscanf(filename.c_str(), "%05u.mpls", &playlist) != 1) { CLog::Log(LOGERROR, "get_playlist_title - unsupported playlist file selected %s", filename.c_str()); return NULL; @@ -804,7 +808,7 @@ void CDVDInputStreamBluray::OverlayCallback(const BD_OVERLAY * const ov) } const BD_PG_RLE_ELEM *rlep = ov->img; - uint8_t *img = (uint8_t*) malloc(ov->w * ov->h); + uint8_t *img = (uint8_t*) malloc((size_t)ov->w * (size_t)ov->h); if (!img) return; unsigned pixels = ov->w * ov->h; diff --git a/xbmc/cores/dvdplayer/DVDPlayer.cpp b/xbmc/cores/dvdplayer/DVDPlayer.cpp index aae59dcbbf..748a4771a8 100644 --- a/xbmc/cores/dvdplayer/DVDPlayer.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayer.cpp @@ -33,7 +33,6 @@ #include "DVDDemuxers/DVDDemuxVobsub.h" #include "DVDDemuxers/DVDFactoryDemuxer.h" #include "DVDDemuxers/DVDDemuxFFmpeg.h" - #include "DVDCodecs/DVDCodecs.h" #include "DVDCodecs/DVDFactoryCodec.h" @@ -53,6 +52,8 @@ #include "filesystem/File.h" #include "pictures/Picture.h" #include "libswscale/swscale.h" + +#include "DVDDemuxers/DVDDemuxCC.h" #ifdef HAS_VIDEO_PLAYBACK #include "cores/VideoRenderers/RenderManager.h" #endif @@ -200,6 +201,14 @@ static bool PredicateAudioPriority(const SelectionStream& lh, const SelectionStr std::string audio_language = g_langInfo.GetAudioLanguage(); PREDICATE_RETURN(g_LangCodeExpander.CompareLangCodes(audio_language, lh.language) , g_LangCodeExpander.CompareLangCodes(audio_language, rh.language)); + + bool hearingimp = CSettings::Get().GetBool("accessibility.audiohearing"); + PREDICATE_RETURN(!hearingimp ? !(lh.flags & CDemuxStream::FLAG_HEARING_IMPAIRED) : lh.flags & CDemuxStream::FLAG_HEARING_IMPAIRED + , !hearingimp ? !(rh.flags & CDemuxStream::FLAG_HEARING_IMPAIRED) : rh.flags & CDemuxStream::FLAG_HEARING_IMPAIRED); + + bool visualimp = CSettings::Get().GetBool("accessibility.audiovisual"); + PREDICATE_RETURN(!visualimp ? !(lh.flags & CDemuxStream::FLAG_VISUAL_IMPAIRED) : lh.flags & CDemuxStream::FLAG_VISUAL_IMPAIRED + , !visualimp ? !(rh.flags & CDemuxStream::FLAG_VISUAL_IMPAIRED) : rh.flags & CDemuxStream::FLAG_VISUAL_IMPAIRED); } PREDICATE_RETURN(lh.flags & CDemuxStream::FLAG_DEFAULT @@ -277,6 +286,10 @@ public: { PREDICATE_RETURN(g_LangCodeExpander.CompareLangCodes(subtitle_language, lh.language) , g_LangCodeExpander.CompareLangCodes(subtitle_language, rh.language)); + + bool hearingimp = CSettings::Get().GetBool("accessibility.subhearing"); + PREDICATE_RETURN(!hearingimp ? !(lh.flags & CDemuxStream::FLAG_HEARING_IMPAIRED) : lh.flags & CDemuxStream::FLAG_HEARING_IMPAIRED + , !hearingimp ? !(rh.flags & CDemuxStream::FLAG_HEARING_IMPAIRED) : rh.flags & CDemuxStream::FLAG_HEARING_IMPAIRED); } PREDICATE_RETURN(lh.flags & CDemuxStream::FLAG_DEFAULT @@ -445,9 +458,10 @@ void CSelectionStreams::Update(CDVDInputStream* input, CDVDDemux* demuxer, std:: int source; if(input) /* hack to know this is sub decoder */ source = Source(STREAM_SOURCE_DEMUX, filename); - else + else if (!filename2.empty()) source = Source(STREAM_SOURCE_DEMUX_SUB, filename); - + else + source = Source(STREAM_SOURCE_VIDEOMUX, filename); for(int i=0;i<count;i++) { @@ -492,6 +506,22 @@ void CSelectionStreams::Update(CDVDInputStream* input, CDVDDemux* demuxer, std:: g_dataCacheCore.SignalVideoInfoChange(); } +int CSelectionStreams::CountSource(StreamType type, StreamSource source) const +{ + CSingleLock lock(m_section); + int count = 0; + for(size_t i=0;i<m_Streams.size();i++) + { + if(type && m_Streams[i].type != type) + continue; + if (source && m_Streams[i].source != source) + continue; + count++; + continue; + } + return count; +} + void CDVDPlayer::CreatePlayers() { #ifdef HAS_OMXPLAYER @@ -546,6 +576,7 @@ CDVDPlayer::CDVDPlayer(IPlayerCallback& callback) m_players_created = false; m_pDemuxer = NULL; m_pSubtitleDemuxer = NULL; + m_pCCDemuxer = NULL; m_pInputStream = NULL; m_dvd.Clear(); @@ -846,6 +877,7 @@ void CDVDPlayer::OpenDefaultStreams(bool reset) PredicateSubtitlePriority psp(as.language); streams = m_SelectionStreams.Get(STREAM_SUBTITLE, psp); valid = false; + CloseStream(m_CurrentSubtitle, false); for(SelectionStreams::iterator it = streams.begin(); it != streams.end() && !valid; ++it) { if(OpenStream(m_CurrentSubtitle, it->id, it->source)) @@ -858,7 +890,7 @@ void CDVDPlayer::OpenDefaultStreams(bool reset) } } if(!valid) - CloseStream(m_CurrentSubtitle, true); + CloseStream(m_CurrentSubtitle, false); if (!dynamic_cast<CDVDInputStreamNavigator*>(m_pInputStream) || m_PlayerOptions.state.size() == 0) SetSubtitleVisibleInternal(visible); // only set subtitle visibility if state not stored by dvd navigator, because navigator will restore it (if visible) @@ -872,7 +904,7 @@ void CDVDPlayer::OpenDefaultStreams(bool reset) valid = true; } if(!valid) - CloseStream(m_CurrentTeletext, true); + CloseStream(m_CurrentTeletext, false); } bool CDVDPlayer::ReadPacket(DemuxPacket*& packet, CDemuxStream*& stream) @@ -995,6 +1027,15 @@ bool CDVDPlayer::IsValidStream(CCurrentStream& stream) return true; } + if (source == STREAM_SOURCE_VIDEOMUX) + { + CDemuxStream* st = m_pCCDemuxer->GetStream(stream.id); + if (st == NULL || st->disabled) + return false; + if (st->type != stream.type) + return false; + return true; + } return false; } @@ -1397,6 +1438,34 @@ void CDVDPlayer::Process() CheckBetterStream(m_CurrentSubtitle, pStream); CheckBetterStream(m_CurrentTeletext, pStream); + // demux video stream + if (CSettings::Get().GetBool("subtitles.parsecaptions") && CheckIsCurrent(m_CurrentVideo, pStream, pPacket)) + { + if (m_pCCDemuxer) + { + bool first = true; + while(!m_bAbortRequest) + { + DemuxPacket *pkt = m_pCCDemuxer->Read(first ? pPacket : NULL); + if (!pkt) + break; + + first = false; + if (m_pCCDemuxer->GetNrOfStreams() != m_SelectionStreams.CountSource(STREAM_SUBTITLE, STREAM_SOURCE_VIDEOMUX)) + { + m_SelectionStreams.Clear(STREAM_SUBTITLE, STREAM_SOURCE_VIDEOMUX); + m_SelectionStreams.Update(NULL, m_pCCDemuxer, ""); + OpenDefaultStreams(false); + } + CDemuxStream *pSubStream = m_pCCDemuxer->GetStream(pkt->iStreamId); + if (pSubStream && m_CurrentSubtitle.id == pkt->iStreamId && m_CurrentSubtitle.source == STREAM_SOURCE_VIDEOMUX) + ProcessSubData(pSubStream, pkt); + else + CDVDDemuxUtils::FreeDemuxPacket(pkt); + } + } + } + // process the packet ProcessPacket(pStream, pPacket); @@ -2148,6 +2217,7 @@ void CDVDPlayer::OnExit() // destroy objects SAFE_DELETE(m_pDemuxer); SAFE_DELETE(m_pSubtitleDemuxer); + SAFE_DELETE(m_pCCDemuxer); SAFE_DELETE(m_pInputStream); // clean up all selection streams @@ -2827,10 +2897,10 @@ void CDVDPlayer::GetGeneralInfo(std::string& strGeneralInfo) if( apts != DVD_NOPTS_VALUE && vpts != DVD_NOPTS_VALUE ) dDiff = (apts - vpts) / DVD_TIME_BASE; - CStdString strEDL; + std::string strEDL; strEDL += StringUtils::Format(", edl:%s", m_Edl.GetInfo().c_str()); - CStdString strBuf; + std::string strBuf; CSingleLock lock(m_StateSection); if(m_StateInput.cache_bytes >= 0) { @@ -3096,8 +3166,8 @@ bool CDVDPlayer::OpenStream(CCurrentStream& current, int iStream, int source, bo if(pts == DVD_NOPTS_VALUE) pts = 0; pts += m_offset_pts; - m_pSubtitleDemuxer->SeekTime((int)(1000.0 * pts / (double)DVD_TIME_BASE)); - + if (!m_pSubtitleDemuxer->SeekTime((int)(1000.0 * pts / (double)DVD_TIME_BASE))) + CLog::Log(LOGDEBUG, "%s - failed to start subtitle demuxing from: %f", __FUNCTION__, pts); stream = m_pSubtitleDemuxer->GetStream(iStream); if(!stream || stream->disabled) return false; @@ -3131,6 +3201,17 @@ bool CDVDPlayer::OpenStream(CCurrentStream& current, int iStream, int source, bo if(m_pInputStream && m_pInputStream->IsStreamType(DVDSTREAM_TYPE_DVD)) hint.filename = "dvd"; } + else if(STREAM_SOURCE_MASK(source) == STREAM_SOURCE_VIDEOMUX) + { + if(!m_pCCDemuxer) + return false; + + stream = m_pCCDemuxer->GetStream(iStream); + if(!stream || stream->disabled) + return false; + + hint.Assign(*stream, false); + } bool res; switch(current.type) @@ -3191,6 +3272,9 @@ bool CDVDPlayer::OpenStreamPlayer(CCurrentStream& current, CDVDStreamInfo& hint, if(current.id < 0 || current.hint != hint) { + if (hint.codec == AV_CODEC_ID_MPEG2VIDEO || hint.codec == AV_CODEC_ID_H264) + SAFE_DELETE(m_pCCDemuxer); + if (!player->OpenStream( hint )) return false; } @@ -3243,6 +3327,13 @@ bool CDVDPlayer::OpenVideoStream(CDVDStreamInfo& hint, bool reset) m_HasVideo = true; + // open CC demuxer if video is mpeg2 + if ((hint.codec == AV_CODEC_ID_MPEG2VIDEO || hint.codec == AV_CODEC_ID_H264) && !m_pCCDemuxer) + { + m_pCCDemuxer = new CDVDDemuxCC(hint.codec); + m_SelectionStreams.Clear(STREAM_NONE, STREAM_SOURCE_VIDEOMUX); + } + /* we are potentially going to be waiting on this */ m_dvdPlayerVideo->SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1); diff --git a/xbmc/cores/dvdplayer/DVDPlayer.h b/xbmc/cores/dvdplayer/DVDPlayer.h index ef64076eff..cc62f6f410 100644 --- a/xbmc/cores/dvdplayer/DVDPlayer.h +++ b/xbmc/cores/dvdplayer/DVDPlayer.h @@ -92,6 +92,7 @@ class CDVDDemux; class CDemuxStreamVideo; class CDemuxStreamAudio; class CStreamInfo; +class CDVDDemuxCC; namespace PVR { @@ -188,6 +189,7 @@ public: int IndexOf (StreamType type, int source, int id) const; int IndexOf (StreamType type, CDVDPlayer& p) const; int Count (StreamType type) const { return IndexOf(type, STREAM_SOURCE_NONE, -1) + 1; } + int CountSource(StreamType type, StreamSource source) const; SelectionStream& Get (StreamType type, int index); bool Get (StreamType type, CDemuxStream::EFlags flag, SelectionStream& out); @@ -428,6 +430,7 @@ protected: CDVDInputStream* m_pInputStream; // input stream for current playing file CDVDDemux* m_pDemuxer; // demuxer for current playing file CDVDDemux* m_pSubtitleDemuxer; + CDVDDemuxCC* m_pCCDemuxer; struct SDVDInfo { diff --git a/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp b/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp index f567518c4f..baadbccbad 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp @@ -186,7 +186,7 @@ void CDVDPlayerAudio::OpenStream( CDVDStreamInfo &hints, CDVDAudioCodec* codec ) m_synctype = SYNC_DISCON; m_setsynctype = SYNC_DISCON; if (CSettings::Get().GetBool("videoplayer.usedisplayasclock")) - m_setsynctype = CSettings::Get().GetInt("videoplayer.synctype"); + m_setsynctype = SYNC_RESAMPLE; m_prevsynctype = -1; m_error = 0; @@ -428,12 +428,11 @@ int CDVDPlayerAudio::DecodeFrame(DVDAudioFrame &audioframe) if (speed == DVD_PLAYSPEED_NORMAL) { m_dvdAudio.Resume(); + m_syncclock = true; } else { - m_syncclock = true; - if (speed != DVD_PLAYSPEED_PAUSE) - m_dvdAudio.Flush(); + m_dvdAudio.Flush(); m_dvdAudio.Pause(); } m_speed = speed; @@ -562,9 +561,9 @@ void CDVDPlayerAudio::Process() } // Zero out the frame data if we are supposed to silence the audio - if (m_silence) + if (m_silence || m_syncclock) { - int size = audioframe.nb_frames * audioframe.framesize * audioframe.channel_count / audioframe.planes; + int size = audioframe.nb_frames * audioframe.framesize / audioframe.planes; for (unsigned int i=0; i<audioframe.planes; i++) memset(audioframe.data[i], 0, size); } @@ -639,21 +638,19 @@ void CDVDPlayerAudio::HandleSyncError(double duration) double absolute; double clock = m_pClock->GetClock(absolute); double error = m_dvdAudio.GetPlayingPts() - clock; - EMasterClock master = m_pClock->GetMaster(); - if( (fabs(error) > DVD_MSEC_TO_TIME(100) || m_syncclock) - && (master == MASTER_CLOCK_AUDIO - || master == MASTER_CLOCK_AUDIO_VIDEOREF) ) - { - m_pClock->Update(clock+error, absolute, 0.0, "CDVDPlayerAudio::HandleSyncError1"); - m_errors.Flush(); - m_error = 0; - m_syncclock = false; + m_errors.Add(error); + if (fabs(error) > DVD_MSEC_TO_TIME(100)) + { + m_syncclock = true; return; } - - m_errors.Add(error); + else if (m_syncclock && fabs(error) < DVD_MSEC_TO_TIME(50)) + { + m_syncclock = false; + m_errors.Flush(); + } //check if measured error for 2 seconds if (m_errors.Get(m_error)) @@ -707,7 +704,27 @@ void CDVDPlayerAudio::HandleSyncError(double duration) bool CDVDPlayerAudio::OutputPacket(DVDAudioFrame &audioframe) { - if (m_synctype == SYNC_DISCON) + if (m_syncclock) + { + double absolute; + double clock = m_pClock->GetClock(absolute); + double error = m_dvdAudio.GetPlayingPts() - clock; + m_dvdAudio.SetResampleRatio(1.0); + if (error > 0) + { + int dups = std::min(DVD_MSEC_TO_TIME(100), error) / audioframe.duration; + for (int i = 0; i < dups; i++) + { + m_dvdAudio.AddPackets(audioframe); + } + m_dvdAudio.AddPackets(audioframe); + } + else + { + m_dvdAudio.SetPlayingPts(m_audioClock); + } + } + else if (m_synctype == SYNC_DISCON) { m_dvdAudio.AddPackets(audioframe); } diff --git a/xbmc/cores/dvdplayer/DVDPlayerAudio.h b/xbmc/cores/dvdplayer/DVDPlayerAudio.h index e8b2ab6086..5db89f6683 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerAudio.h +++ b/xbmc/cores/dvdplayer/DVDPlayerAudio.h @@ -134,7 +134,6 @@ public: // holds stream information for current playing stream CDVDStreamInfo m_streaminfo; - CPTSOutputQueue m_ptsOutput; CPTSInputQueue m_ptsInput; double GetCurrentPts() { CSingleLock lock(m_info_section); return m_info.pts; } diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp index f030e37282..b58a4ed917 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp @@ -36,7 +36,6 @@ #include "DVDDemuxers/DVDDemuxUtils.h" #include "DVDOverlayRenderer.h" #include "DVDCodecs/DVDCodecs.h" -#include "DVDCodecs/Overlay/DVDOverlayCodecCC.h" #include "DVDCodecs/Overlay/DVDOverlaySSA.h" #include "guilib/GraphicContext.h" #include <sstream> @@ -132,7 +131,6 @@ CDVDPlayerVideo::CDVDPlayerVideo( CDVDClock* pClock m_pOverlayContainer = pOverlayContainer; m_pTempOverlayPicture = NULL; m_pVideoCodec = NULL; - m_pOverlayCodecCC = NULL; m_speed = DVD_PLAYSPEED_NORMAL; m_bRenderSubs = false; @@ -766,65 +764,9 @@ void CDVDPlayerVideo::Process() void CDVDPlayerVideo::OnExit() { - if (m_pOverlayCodecCC) - { - m_pOverlayCodecCC->Dispose(); - m_pOverlayCodecCC = NULL; - } - CLog::Log(LOGNOTICE, "thread end: video_thread"); } -void CDVDPlayerVideo::ProcessVideoUserData(DVDVideoUserData* pVideoUserData, double pts) -{ - // check userdata type - uint8_t* data = pVideoUserData->data; - int size = pVideoUserData->size; - - if (size >= 2) - { - if (data[0] == 'C' && data[1] == 'C') - { - data += 2; - size -= 2; - - // closed captioning - if (!m_pOverlayCodecCC) - { - m_pOverlayCodecCC = new CDVDOverlayCodecCC(); - CDVDCodecOptions options; - CDVDStreamInfo info; - if (!m_pOverlayCodecCC->Open(info, options)) - { - delete m_pOverlayCodecCC; - m_pOverlayCodecCC = NULL; - } - } - - if (m_pOverlayCodecCC) - { - DemuxPacket packet; - packet.pData = data; - packet.iSize = size; - packet.pts = DVD_NOPTS_VALUE; - packet.dts = DVD_NOPTS_VALUE; - m_pOverlayCodecCC->Decode(&packet); - - CDVDOverlay* overlay; - while((overlay = m_pOverlayCodecCC->GetOverlay()) != NULL) - { - overlay->iPTSStartTime += pts; - if(overlay->iPTSStopTime != 0.0) - overlay->iPTSStopTime += pts; - - m_pOverlayContainer->Add(overlay); - overlay->Release(); - } - } - } - } -} - void CDVDPlayerVideo::SetSpeed(int speed) { if(m_messageQueue.IsInited()) @@ -1217,8 +1159,6 @@ int CDVDPlayerVideo::OutputPicture(const DVDVideoPicture* src, double pts) mDisplayField = FS_BOT; } - AutoCrop(pPicture); - int buffer = g_renderManager.WaitForBuffer(m_bStop, std::max(DVD_TIME_TO_MSEC(iSleepTime) + 500, 1)); if (buffer < 0) return EOS_DROPPED; @@ -1247,182 +1187,6 @@ int CDVDPlayerVideo::OutputPicture(const DVDVideoPicture* src, double pts) #endif } -void CDVDPlayerVideo::AutoCrop(DVDVideoPicture *pPicture) -{ - if ((pPicture->format == RENDER_FMT_YUV420P) || - (pPicture->format == RENDER_FMT_NV12) || - (pPicture->format == RENDER_FMT_YUYV422) || - (pPicture->format == RENDER_FMT_UYVY422)) - { - RECT crop; - - if (CMediaSettings::Get().GetCurrentVideoSettings().m_Crop) - AutoCrop(pPicture, crop); - else - { // reset to defaults - crop.left = 0; - crop.right = 0; - crop.top = 0; - crop.bottom = 0; - } - - m_crop.x1 += ((float)crop.left - m_crop.x1) * 0.1; - m_crop.x2 += ((float)crop.right - m_crop.x2) * 0.1; - m_crop.y1 += ((float)crop.top - m_crop.y1) * 0.1; - m_crop.y2 += ((float)crop.bottom - m_crop.y2) * 0.1; - - crop.left = MathUtils::round_int(m_crop.x1); - crop.right = MathUtils::round_int(m_crop.x2); - crop.top = MathUtils::round_int(m_crop.y1); - crop.bottom = MathUtils::round_int(m_crop.y2); - - //compare with hysteresis -# define HYST(n, o) ((n) > (o) || (n) + 1 < (o)) - if(HYST(CMediaSettings::Get().GetCurrentVideoSettings().m_CropLeft , crop.left) - || HYST(CMediaSettings::Get().GetCurrentVideoSettings().m_CropRight , crop.right) - || HYST(CMediaSettings::Get().GetCurrentVideoSettings().m_CropTop , crop.top) - || HYST(CMediaSettings::Get().GetCurrentVideoSettings().m_CropBottom, crop.bottom)) - { - CMediaSettings::Get().GetCurrentVideoSettings().m_CropLeft = crop.left; - CMediaSettings::Get().GetCurrentVideoSettings().m_CropRight = crop.right; - CMediaSettings::Get().GetCurrentVideoSettings().m_CropTop = crop.top; - CMediaSettings::Get().GetCurrentVideoSettings().m_CropBottom = crop.bottom; - g_renderManager.SetViewMode(CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode); - } -# undef HYST - } -} - -void CDVDPlayerVideo::AutoCrop(DVDVideoPicture *pPicture, RECT &crop) -{ - crop.left = CMediaSettings::Get().GetCurrentVideoSettings().m_CropLeft; - crop.right = CMediaSettings::Get().GetCurrentVideoSettings().m_CropRight; - crop.top = CMediaSettings::Get().GetCurrentVideoSettings().m_CropTop; - crop.bottom = CMediaSettings::Get().GetCurrentVideoSettings().m_CropBottom; - - int black = 16; // what is black in the image - int level = 8; // how high above this should we detect - int multi = 4; // what multiple of last line should failing line be to accept - uint8_t *s; - int last, detect, black2; - - // top and bottom levels - black2 = black * pPicture->iWidth; - detect = level * pPicture->iWidth + black2; - - //YV12 and NV12 have planar Y plane - //YUY2 and UYVY have Y packed with U and V - int xspacing = 1; - int xstart = 0; - if (pPicture->format == RENDER_FMT_YUYV422) - xspacing = 2; - else if (pPicture->format == RENDER_FMT_UYVY422) - { - xspacing = 2; - xstart = 1; - } - - // Crop top - s = pPicture->data[0]; - last = black2; - for (unsigned int y = 0; y < pPicture->iHeight/2; y++) - { - int total = 0; - for (unsigned int x = xstart; x < pPicture->iWidth * xspacing; x += xspacing) - total += s[x]; - s += pPicture->iLineSize[0]; - - if (total > detect) - { - if (total - black2 > (last - black2) * multi) - crop.top = y; - break; - } - last = total; - } - - // Crop bottom - s = pPicture->data[0] + (pPicture->iHeight-1) * pPicture->iLineSize[0]; - last = black2; - for (unsigned int y = (int)pPicture->iHeight; y > pPicture->iHeight/2; y--) - { - int total = 0; - for (unsigned int x = xstart; x < pPicture->iWidth * xspacing; x += xspacing) - total += s[x]; - s -= pPicture->iLineSize[0]; - - if (total > detect) - { - if (total - black2 > (last - black2) * multi) - crop.bottom = pPicture->iHeight - y; - break; - } - last = total; - } - - // left and right levels - black2 = black * pPicture->iHeight; - detect = level * pPicture->iHeight + black2; - - - // Crop left - s = pPicture->data[0]; - last = black2; - for (unsigned int x = xstart; x < pPicture->iWidth/2*xspacing; x += xspacing) - { - int total = 0; - for (unsigned int y = 0; y < pPicture->iHeight; y++) - total += s[y * pPicture->iLineSize[0]]; - s++; - if (total > detect) - { - if (total - black2 > (last - black2) * multi) - crop.left = x / xspacing; - break; - } - last = total; - } - - // Crop right - s = pPicture->data[0] + (pPicture->iWidth-1); - last = black2; - for (unsigned int x = (int)pPicture->iWidth*xspacing-1; x > pPicture->iWidth/2*xspacing; x -= xspacing) - { - int total = 0; - for (unsigned int y = 0; y < pPicture->iHeight; y++) - total += s[y * pPicture->iLineSize[0]]; - s--; - - if (total > detect) - { - if (total - black2 > (last - black2) * multi) - crop.right = pPicture->iWidth - (x / xspacing); - break; - } - last = total; - } - - // We always crop equally on each side to get zoom - // effect intead of moving the image. Aslong as the - // max crop isn't much larger than the min crop - // use that. - int min, max; - - min = std::min(crop.left, crop.right); - max = std::max(crop.left, crop.right); - if(10 * (max - min) / pPicture->iWidth < 1) - crop.left = crop.right = max; - else - crop.left = crop.right = min; - - min = std::min(crop.top, crop.bottom); - max = std::max(crop.top, crop.bottom); - if(10 * (max - min) / pPicture->iHeight < 1) - crop.top = crop.bottom = max; - else - crop.top = crop.bottom = min; -} - std::string CDVDPlayerVideo::GetPlayerInfo() { std::ostringstream s; diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.h b/xbmc/cores/dvdplayer/DVDPlayerVideo.h index 489ebfc95a..ead6f70798 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerVideo.h +++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.h @@ -33,7 +33,6 @@ #endif class CDemuxStreamVideo; -class CDVDOverlayCodecCC; #define VIDEO_PICTURE_QUEUE_SIZE 1 @@ -132,7 +131,6 @@ protected: #ifdef HAS_VIDEO_PLAYBACK void ProcessOverlays(DVDVideoPicture* pSource, double pts); #endif - void ProcessVideoUserData(DVDVideoUserData* pVideoUserData, double pts); void OpenStream(CDVDStreamInfo &hint, CDVDVideoCodec* codec); CDVDMessageQueue m_messageQueue; @@ -196,7 +194,6 @@ protected: // classes CDVDStreamInfo m_hints; CDVDVideoCodec* m_pVideoCodec; - CDVDOverlayCodecCC* m_pOverlayCodecCC; DVDVideoPicture* m_pTempOverlayPicture; diff --git a/xbmc/cores/dvdplayer/DVDSubtitles/DVDSubtitleParser.h b/xbmc/cores/dvdplayer/DVDSubtitles/DVDSubtitleParser.h index 4634fbd829..6cc686ff25 100644 --- a/xbmc/cores/dvdplayer/DVDSubtitles/DVDSubtitleParser.h +++ b/xbmc/cores/dvdplayer/DVDSubtitles/DVDSubtitleParser.h @@ -25,6 +25,7 @@ #include "DVDSubtitleLineCollection.h" #include <string> +#include <stdio.h> class CDVDStreamInfo; diff --git a/xbmc/cores/dvdplayer/Edl.cpp b/xbmc/cores/dvdplayer/Edl.cpp index 774aba6b26..6c3b8aa426 100644 --- a/xbmc/cores/dvdplayer/Edl.cpp +++ b/xbmc/cores/dvdplayer/Edl.cpp @@ -375,7 +375,7 @@ bool CEdl::ReadComskip(const std::string& strMovie, const float fFramesPerSecond else fFrameRate /= 100; // Reduce by factor of 100 to get fps. - comskipFile.ReadString(szBuffer, 1023); // Line 2. Ignore "-------------" + (void)comskipFile.ReadString(szBuffer, 1023); // Line 2. Ignore "-------------" bool bValid = true; int iLine = 2; diff --git a/xbmc/cores/paplayer/DVDPlayerCodec.cpp b/xbmc/cores/paplayer/DVDPlayerCodec.cpp index fd7716ba6b..f5dc2f2d68 100644 --- a/xbmc/cores/paplayer/DVDPlayerCodec.cpp +++ b/xbmc/cores/paplayer/DVDPlayerCodec.cpp @@ -45,7 +45,6 @@ DVDPlayerCodec::DVDPlayerCodec() m_audioPos = 0; m_pPacket = NULL; m_nDecodedLen = 0; - m_strFileName = ""; m_bInited = false; m_pResampler = NULL; m_needConvert = false; diff --git a/xbmc/cores/paplayer/ICodec.h b/xbmc/cores/paplayer/ICodec.h index e5755bb094..23a69533ab 100644 --- a/xbmc/cores/paplayer/ICodec.h +++ b/xbmc/cores/paplayer/ICodec.h @@ -44,7 +44,6 @@ public: m_DataFormat = AE_FMT_INVALID; m_Channels = 0; m_Bitrate = 0; - m_CodecName = ""; }; virtual ~ICodec() {}; diff --git a/xbmc/cores/paplayer/OGGcodec.cpp b/xbmc/cores/paplayer/OGGcodec.cpp index bccd28c98c..a2e9599d1a 100644 --- a/xbmc/cores/paplayer/OGGcodec.cpp +++ b/xbmc/cores/paplayer/OGGcodec.cpp @@ -92,7 +92,10 @@ bool OGGCodec::Init(const std::string &strFile1, unsigned int filecache) if (iStreams>1) { if (m_CurrentStream > iStreams) + { + DeInit(); return false; + } } // Calculate the offset in secs where the bitstream starts @@ -104,6 +107,7 @@ bool OGGCodec::Init(const std::string &strFile1, unsigned int filecache) if (!pInfo) { CLog::Log(LOGERROR, "OGGCodec: Can't get stream info from %s", strFile1.c_str()); + DeInit(); return false; } @@ -122,6 +126,7 @@ bool OGGCodec::Init(const std::string &strFile1, unsigned int filecache) if (m_SampleRate==0 || m_Channels==0 || m_BitsPerSample==0 || m_TotalTime==0) { CLog::Log(LOGERROR, "OGGCodec: incomplete stream info from %s, SampleRate=%i, Channels=%i, BitsPerSample=%i, TotalTime=%" PRIu64, strFile1.c_str(), m_SampleRate, m_Channels, m_BitsPerSample, m_TotalTime); + DeInit(); return false; } @@ -139,10 +144,13 @@ bool OGGCodec::Init(const std::string &strFile1, unsigned int filecache) if (m_dll.ov_time_seek(&m_VorbisFile, m_TimeOffset)!=0) { CLog::Log(LOGERROR, "OGGCodec: Can't seek to the bitstream start time (%s)", strFile1.c_str()); + DeInit(); return false; } } + m_inited = true; + return true; } diff --git a/xbmc/cores/playercorefactory/PlayerCoreConfig.h b/xbmc/cores/playercorefactory/PlayerCoreConfig.h index 696a26c170..a13fe3a289 100644 --- a/xbmc/cores/playercorefactory/PlayerCoreConfig.h +++ b/xbmc/cores/playercorefactory/PlayerCoreConfig.h @@ -35,10 +35,10 @@ class CPlayerCoreConfig friend class CPlayerCoreFactory; public: - CPlayerCoreConfig(std::string name, const EPLAYERCORES eCore, const TiXmlElement* pConfig, const std::string& id = "") + CPlayerCoreConfig(std::string name, const EPLAYERCORES eCore, const TiXmlElement* pConfig, const std::string& id = ""): + m_name(name), + m_id(id) { - m_name = name; - m_id = id; m_eCore = eCore; m_bPlaysAudio = false; m_bPlaysVideo = false; diff --git a/xbmc/dbwrappers/Database.cpp b/xbmc/dbwrappers/Database.cpp index 0044e64e23..a3dbd2eed9 100644 --- a/xbmc/dbwrappers/Database.cpp +++ b/xbmc/dbwrappers/Database.cpp @@ -329,7 +329,7 @@ void CDatabase::InitSettings(DatabaseSettings &dbSettings) m_sqlite = true; #ifdef HAS_MYSQL - if ( dbSettings.type.Equals("mysql") ) + if (dbSettings.type == "mysql") { // check we have all information before we cancel the fallback if ( ! (dbSettings.host.empty() || @@ -340,7 +340,7 @@ void CDatabase::InitSettings(DatabaseSettings &dbSettings) } else #else - if ( dbSettings.type.Equals("mysql") ) + if (dbSettings.type == "mysql") CLog::Log(LOGERROR, "MySQL library requested but MySQL support is not compiled in. Falling back to sqlite3."); #endif { @@ -424,12 +424,12 @@ bool CDatabase::Update(const DatabaseSettings &settings) bool CDatabase::Connect(const std::string &dbName, const DatabaseSettings &dbSettings, bool create) { // create the appropriate database structure - if (dbSettings.type.Equals("sqlite3")) + if (dbSettings.type == "sqlite3") { m_pDB.reset( new SqliteDatabase() ) ; } #ifdef HAS_MYSQL - else if (dbSettings.type.Equals("mysql")) + else if (dbSettings.type == "mysql") { m_pDB.reset( new MysqlDatabase() ) ; } @@ -470,7 +470,7 @@ bool CDatabase::Connect(const std::string &dbName, const DatabaseSettings &dbSet // test if db already exists, if not we need to create the tables if (!m_pDB->exists() && create) { - if (dbSettings.type.Equals("sqlite3")) + if (dbSettings.type == "sqlite3") { // Modern file systems have a cluster/block size of 4k. // To gain better performance when performing write @@ -486,7 +486,7 @@ bool CDatabase::Connect(const std::string &dbName, const DatabaseSettings &dbSet } // sqlite3 post connection operations - if (dbSettings.type.Equals("sqlite3")) + if (dbSettings.type == "sqlite3") { m_pDS->exec("PRAGMA cache_size=4096\n"); m_pDS->exec("PRAGMA synchronous='NORMAL'\n"); diff --git a/xbmc/dbwrappers/dataset.h b/xbmc/dbwrappers/dataset.h index e208aa5583..99d9f076db 100644 --- a/xbmc/dbwrappers/dataset.h +++ b/xbmc/dbwrappers/dataset.h @@ -309,7 +309,7 @@ public: virtual int exec() = 0; virtual const void* getExecRes()=0; /* as open, but with our query exept Sql */ - virtual bool query(const char *sql) = 0; + virtual bool query(const std::string &sql) = 0; /* Close SQL Query*/ virtual void close(); /* This function looks for field Field_name with value equal Field_value diff --git a/xbmc/dbwrappers/mysqldataset.cpp b/xbmc/dbwrappers/mysqldataset.cpp index 945d0804e4..6161c473bf 100644 --- a/xbmc/dbwrappers/mysqldataset.cpp +++ b/xbmc/dbwrappers/mysqldataset.cpp @@ -1471,7 +1471,7 @@ const void* MysqlDataset::getExecRes() { } -bool MysqlDataset::query(const char *query) { +bool MysqlDataset::query(const std::string &query) { if(!handle()) throw DbErrors("No Database Connection"); std::string qry = query; int fs = qry.find("select"); @@ -1568,10 +1568,6 @@ bool MysqlDataset::query(const char *query) { return true; } -bool MysqlDataset::query(const string &q) { - return query(q.c_str()); -} - void MysqlDataset::open(const string &sql) { set_select_sql(sql); open(); diff --git a/xbmc/dbwrappers/mysqldataset.h b/xbmc/dbwrappers/mysqldataset.h index fb87b3f9e9..c73f0d99c1 100644 --- a/xbmc/dbwrappers/mysqldataset.h +++ b/xbmc/dbwrappers/mysqldataset.h @@ -148,7 +148,6 @@ or insert() operations default = false) */ virtual int exec (const std::string &sql); virtual const void* getExecRes(); /* as open, but with our query exept Sql */ - virtual bool query(const char *query); virtual bool query(const std::string &query); /* func. closes a query */ virtual void close(void); diff --git a/xbmc/dbwrappers/sqlitedataset.cpp b/xbmc/dbwrappers/sqlitedataset.cpp index 56c0ee7f41..632556a96f 100644 --- a/xbmc/dbwrappers/sqlitedataset.cpp +++ b/xbmc/dbwrappers/sqlitedataset.cpp @@ -637,7 +637,7 @@ const void* SqliteDataset::getExecRes() { } -bool SqliteDataset::query(const char *query) { +bool SqliteDataset::query(const std::string &query) { if(!handle()) throw DbErrors("No Database Connection"); std::string qry = query; int fs = qry.find("select"); @@ -648,7 +648,7 @@ bool SqliteDataset::query(const char *query) { close(); sqlite3_stmt *stmt = NULL; - if (db->setErr(sqlite3_prepare_v2(handle(),query,-1,&stmt, NULL),query) != SQLITE_OK) + if (db->setErr(sqlite3_prepare_v2(handle(),query.c_str(),-1,&stmt, NULL),query.c_str()) != SQLITE_OK) throw DbErrors(db->getErrorMsg()); // column headers @@ -688,7 +688,7 @@ bool SqliteDataset::query(const char *query) { } result.records.push_back(res); } - if (db->setErr(sqlite3_finalize(stmt),query) == SQLITE_OK) + if (db->setErr(sqlite3_finalize(stmt),query.c_str()) == SQLITE_OK) { active = true; ds_state = dsSelect; @@ -701,10 +701,6 @@ bool SqliteDataset::query(const char *query) { } } -bool SqliteDataset::query(const string &q){ - return query(q.c_str()); -} - void SqliteDataset::open(const string &sql) { set_select_sql(sql); open(); diff --git a/xbmc/dbwrappers/sqlitedataset.h b/xbmc/dbwrappers/sqlitedataset.h index 6b768f0661..32b5636725 100644 --- a/xbmc/dbwrappers/sqlitedataset.h +++ b/xbmc/dbwrappers/sqlitedataset.h @@ -148,7 +148,6 @@ or insert() operations default = false) */ virtual int exec (const std::string &sql); virtual const void* getExecRes(); /* as open, but with our query exept Sql */ - virtual bool query(const char *query); virtual bool query(const std::string &query); /* func. closes a query */ virtual void close(void); diff --git a/xbmc/dialogs/GUIDialogCache.cpp b/xbmc/dialogs/GUIDialogCache.cpp index 4049074c7b..1ab8e9c04b 100644 --- a/xbmc/dialogs/GUIDialogCache.cpp +++ b/xbmc/dialogs/GUIDialogCache.cpp @@ -28,10 +28,10 @@ #include "threads/SingleLock.h" #include "utils/TimeUtils.h" -CGUIDialogCache::CGUIDialogCache(DWORD dwDelay, const std::string& strHeader, const std::string& strMsg) : CThread("GUIDialogCache") +CGUIDialogCache::CGUIDialogCache(DWORD dwDelay, const std::string& strHeader, const std::string& strMsg) : CThread("GUIDialogCache"), + m_strHeader(strHeader), + m_strLinePrev(strMsg) { - m_strHeader = strHeader; - m_strLinePrev = strMsg; bSentCancel = false; m_pDlg = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); diff --git a/xbmc/dialogs/GUIDialogCache.h b/xbmc/dialogs/GUIDialogCache.h index cd585bc187..6f7d138793 100644 --- a/xbmc/dialogs/GUIDialogCache.h +++ b/xbmc/dialogs/GUIDialogCache.h @@ -50,9 +50,9 @@ protected: XbmcThreads::EndTime m_endtime; CGUIDialogProgress* m_pDlg; + std::string m_strHeader; std::string m_strLinePrev; std::string m_strLinePrev2; - std::string m_strHeader; bool bSentCancel; bool m_bOpenTried; }; diff --git a/xbmc/dialogs/GUIDialogFileBrowser.cpp b/xbmc/dialogs/GUIDialogFileBrowser.cpp index 1b51d699f1..e157427150 100644 --- a/xbmc/dialogs/GUIDialogFileBrowser.cpp +++ b/xbmc/dialogs/GUIDialogFileBrowser.cpp @@ -444,7 +444,7 @@ void CGUIDialogFileBrowser::Update(const std::string &strDirectory) } m_viewControl.SetItems(*m_vecItems); - m_viewControl.SetCurrentView((m_browsingForImages && CAutoSwitch::ByFileCount(*m_vecItems)) ? DEFAULT_VIEW_ICONS : DEFAULT_VIEW_LIST); + m_viewControl.SetCurrentView((m_browsingForImages && CAutoSwitch::ByFileCount(*m_vecItems)) ? CONTROL_THUMBS : CONTROL_LIST); std::string strPath2 = m_Directory->GetPath(); URIUtils::RemoveSlashAtEnd(strPath2); diff --git a/xbmc/dialogs/GUIDialogGamepad.cpp b/xbmc/dialogs/GUIDialogGamepad.cpp index c43959d9aa..fdd2c619fc 100644 --- a/xbmc/dialogs/GUIDialogGamepad.cpp +++ b/xbmc/dialogs/GUIDialogGamepad.cpp @@ -32,8 +32,6 @@ CGUIDialogGamepad::CGUIDialogGamepad(void) : CGUIDialogBoxBase(WINDOW_DIALOG_GAMEPAD, "DialogGamepad.xml") { m_bCanceled = false; - m_strUserInput = ""; - m_strPassword = ""; m_iRetries = 0; m_bUserInputCleanup = true; } diff --git a/xbmc/dialogs/GUIDialogKaiToast.cpp b/xbmc/dialogs/GUIDialogKaiToast.cpp index 97b0ccd473..f362b7ab83 100644 --- a/xbmc/dialogs/GUIDialogKaiToast.cpp +++ b/xbmc/dialogs/GUIDialogKaiToast.cpp @@ -37,7 +37,6 @@ CCriticalSection CGUIDialogKaiToast::m_critical; CGUIDialogKaiToast::CGUIDialogKaiToast(void) : CGUIDialog(WINDOW_DIALOG_KAI_TOAST, "DialogKaiToast.xml") { - m_defaultIcon = ""; m_loadType = LOAD_ON_GUI_INIT; m_timer = 0; m_toastDisplayTime = 0; @@ -110,7 +109,7 @@ bool CGUIDialogKaiToast::DoWork() { CSingleLock lock(m_critical); - if (m_notifications.size() > 0 && + if (!m_notifications.empty() && CTimeUtils::GetFrameTime() - m_timer > m_toastMessageTime) { Notification toast = m_notifications.front(); diff --git a/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp b/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp index 5c6170c8a6..6ea4b0a216 100644 --- a/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp +++ b/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp @@ -32,6 +32,7 @@ #include "utils/RegExp.h" #include "utils/StringUtils.h" #include "ApplicationMessenger.h" +#include "windowing/WindowingFactory.h" #define BUTTON_ID_OFFSET 100 #define BUTTONS_PER_ROW 20 @@ -66,7 +67,6 @@ CGUIDialogKeyboardGeneric::CGUIDialogKeyboardGeneric() m_hiddenInput = false; m_keyType = LOWER; m_currentLayout = 0; - m_strHeading = ""; m_loadType = KEEP_IN_MEMORY; } @@ -76,6 +76,7 @@ void CGUIDialogKeyboardGeneric::OnWindowLoaded() CGUIEditControl *edit = (CGUIEditControl *)GetControl(CTL_EDIT); if (edit) edit->SetShowCursorAlways(true); + g_Windowing.EnableTextInput(false); CGUIDialog::OnWindowLoaded(); } @@ -220,7 +221,6 @@ bool CGUIDialogKeyboardGeneric::OnMessage(CGUIMessage& message) break; case GUI_MSG_SET_TEXT: - case GUI_MSG_INPUT_TEXT: case GUI_MSG_INPUT_TEXT_EDIT: { // the edit control only handles these messages if it is either focues @@ -271,9 +271,9 @@ void CGUIDialogKeyboardGeneric::Character(const std::string &ch) CGUIControl *edit = GetControl(CTL_EDIT); if (edit) { - CGUIMessage msg(GUI_MSG_INPUT_TEXT, GetID(), CTL_EDIT); - msg.SetLabel(ch); - edit->OnMessage(msg); + CAction action(ACTION_INPUT_TEXT); + action.SetText(ch); + edit->OnAction(action); } } diff --git a/xbmc/dialogs/GUIDialogMediaFilter.cpp b/xbmc/dialogs/GUIDialogMediaFilter.cpp index 651e04d8ad..52ecd96e89 100644 --- a/xbmc/dialogs/GUIDialogMediaFilter.cpp +++ b/xbmc/dialogs/GUIDialogMediaFilter.cpp @@ -762,17 +762,17 @@ void CGUIDialogMediaFilter::GetRange(const Filter &filter, int &min, int &interv std::string year; if (m_mediaType == "movies") { - table = "movieview"; + table = "movie_view"; year = DatabaseUtils::GetField(FieldYear, MediaTypeMovie, DatabaseQueryPartWhere); } else if (m_mediaType == "tvshows") { - table = "tvshowview"; + table = "tvshow_view"; year = StringUtils::Format("strftime(\"%%Y\", %s)", DatabaseUtils::GetField(FieldYear, MediaTypeTvShow, DatabaseQueryPartWhere).c_str()); } else if (m_mediaType == "musicvideos") { - table = "musicvideoview"; + table = "musicvideo_view"; year = DatabaseUtils::GetField(FieldYear, MediaTypeMusicVideo, DatabaseQueryPartWhere); } @@ -805,7 +805,7 @@ void CGUIDialogMediaFilter::GetRange(const Filter &filter, int &min, int &interv { std::string field = StringUtils::Format("CAST(strftime(\"%%s\", c%02d) AS INTEGER)", VIDEODB_ID_EPISODE_AIRED); - GetMinMax("episodeview", field, min, max); + GetMinMax("episode_view", field, min, max); interval = 60 * 60 * 24 * 7; // 1 week } } diff --git a/xbmc/dialogs/GUIDialogSelect.cpp b/xbmc/dialogs/GUIDialogSelect.cpp index a31660ebe0..736eb1a17c 100644 --- a/xbmc/dialogs/GUIDialogSelect.cpp +++ b/xbmc/dialogs/GUIDialogSelect.cpp @@ -276,7 +276,7 @@ void CGUIDialogSelect::SetSelected(std::vector<int> selectedIndexes) if (selectedIndexes.empty()) return; - for (std::vector<int>::const_iterator it = selectedIndexes.begin(); it != selectedIndexes.end(); it++) + for (std::vector<int>::const_iterator it = selectedIndexes.begin(); it != selectedIndexes.end(); ++it) SetSelected(*it); } @@ -285,7 +285,7 @@ void CGUIDialogSelect::SetSelected(const std::vector<std::string> &selectedLabel if (selectedLabels.empty()) return; - for (std::vector<std::string>::const_iterator it = selectedLabels.begin(); it != selectedLabels.end(); it++) + for (std::vector<std::string>::const_iterator it = selectedLabels.begin(); it != selectedLabels.end(); ++it) SetSelected(*it); } diff --git a/xbmc/epg/Epg.cpp b/xbmc/epg/Epg.cpp index 44ea32b397..0b9580dbe0 100644 --- a/xbmc/epg/Epg.cpp +++ b/xbmc/epg/Epg.cpp @@ -48,8 +48,6 @@ CEpg::CEpg(int iEpgID, const std::string &strName /* = "" */, const std::string m_strScraperName(strScraperName), m_bUpdateLastScanTime(false) { - CPVRChannelPtr empty; - m_pvrChannel = empty; } CEpg::CEpg(CPVRChannelPtr channel, bool bLoadedFromDb /* = false */) : @@ -73,8 +71,6 @@ CEpg::CEpg(void) : m_iEpgID(0), m_bUpdateLastScanTime(false) { - CPVRChannelPtr empty; - m_pvrChannel = empty; } CEpg::~CEpg(void) @@ -95,11 +91,8 @@ CEpg &CEpg::operator =(const CEpg &right) m_lastScanTime = right.m_lastScanTime; m_pvrChannel = right.m_pvrChannel; - for (map<CDateTime, CEpgInfoTagPtr>::const_iterator it = right.m_tags.begin(); it != right.m_tags.end(); it++) - { - CEpgInfoTagPtr EITPtr (new CEpgInfoTag(*it->second)); - m_tags.insert(make_pair(it->first, EITPtr)); - } + for (map<CDateTime, CEpgInfoTagPtr>::const_iterator it = right.m_tags.begin(); it != right.m_tags.end(); ++it) + m_tags.insert(make_pair(it->first, it->second)); return *this; } @@ -183,17 +176,14 @@ void CEpg::Cleanup(const CDateTime &Time) } } -bool CEpg::InfoTagNow(CEpgInfoTag &tag, bool bUpdateIfNeeded /* = true */) +CEpgInfoTagPtr CEpg::GetTagNow(bool bUpdateIfNeeded /* = true */) const { CSingleLock lock(m_critSection); if (m_nowActiveStart.IsValid()) { map<CDateTime, CEpgInfoTagPtr>::const_iterator it = m_tags.find(m_nowActiveStart); if (it != m_tags.end() && it->second->IsActive()) - { - tag = *it->second; - return true; - } + return it->second; } if (bUpdateIfNeeded) @@ -201,13 +191,12 @@ bool CEpg::InfoTagNow(CEpgInfoTag &tag, bool bUpdateIfNeeded /* = true */) CEpgInfoTagPtr lastActiveTag; /* one of the first items will always match if the list is sorted */ - for (map<CDateTime, CEpgInfoTagPtr>::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) + for (map<CDateTime, CEpgInfoTagPtr>::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) { if (it->second->IsActive()) { m_nowActiveStart = it->first; - tag = *it->second; - return true; + return it->second; } else if (it->second->WasActive()) lastActiveTag = it->second; @@ -216,60 +205,48 @@ bool CEpg::InfoTagNow(CEpgInfoTag &tag, bool bUpdateIfNeeded /* = true */) /* there might be a gap between the last and next event. return the last if found and it ended not more than 5 minutes ago */ if (lastActiveTag && lastActiveTag->EndAsUTC() + CDateTimeSpan(0, 0, 5, 0) >= CDateTime::GetUTCDateTime()) - { - tag = *lastActiveTag; - return true; - } + return lastActiveTag; } - return false; + return CEpgInfoTagPtr(); } -bool CEpg::InfoTagNext(CEpgInfoTag &tag) +CEpgInfoTagPtr CEpg::GetTagNext() const { - CEpgInfoTag nowTag; - if (InfoTagNow(nowTag)) + CEpgInfoTagPtr nowTag(GetTagNow()); + if (nowTag) { CSingleLock lock(m_critSection); - map<CDateTime, CEpgInfoTagPtr>::const_iterator it = m_tags.find(nowTag.StartAsUTC()); + map<CDateTime, CEpgInfoTagPtr>::const_iterator it = m_tags.find(nowTag->StartAsUTC()); if (it != m_tags.end() && ++it != m_tags.end()) - { - tag = *it->second; - return true; - } + return it->second; } else if (Size() > 0) { /* return the first event that is in the future */ - for (map<CDateTime, CEpgInfoTagPtr>::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) + for (map<CDateTime, CEpgInfoTagPtr>::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) { if (it->second->InTheFuture()) - { - tag = *it->second; - return true; - } + return it->second; } } - return false; + return CEpgInfoTagPtr(); } bool CEpg::CheckPlayingEvent(void) { - bool bReturn(false); - CEpgInfoTag previousTag, newTag; - bool bGotPreviousTag = InfoTagNow(previousTag, false); - bool bGotCurrentTag = InfoTagNow(newTag); + CEpgInfoTagPtr previousTag(GetTagNow(false)); + CEpgInfoTagPtr newTag(GetTagNow(true)); - bool bTagChanged = bGotCurrentTag && (!bGotPreviousTag || previousTag != newTag); - bool bTagRemoved = !bGotCurrentTag && bGotPreviousTag; + bool bTagChanged = newTag && (!previousTag || *previousTag != *newTag); + bool bTagRemoved = !newTag && previousTag; if (bTagChanged || bTagRemoved) { NotifyObservers(ObservableMessageEpgActiveItem); - bReturn = true; + return true; } - - return bReturn; + return false; } CEpgInfoTagPtr CEpg::GetTag(const CDateTime &StartTime) const @@ -281,34 +258,31 @@ CEpgInfoTagPtr CEpg::GetTag(const CDateTime &StartTime) const return it->second; } - CEpgInfoTagPtr empty; - return empty; + return CEpgInfoTagPtr(); } CEpgInfoTagPtr CEpg::GetTagBetween(const CDateTime &beginTime, const CDateTime &endTime) const { CSingleLock lock(m_critSection); - for (map<CDateTime, CEpgInfoTagPtr>::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) + for (map<CDateTime, CEpgInfoTagPtr>::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) { if (it->second->StartAsUTC() >= beginTime && it->second->EndAsUTC() <= endTime) return it->second; } - CEpgInfoTagPtr retVal; - return retVal; + return CEpgInfoTagPtr(); } CEpgInfoTagPtr CEpg::GetTagAround(const CDateTime &time) const { CSingleLock lock(m_critSection); - for (map<CDateTime, CEpgInfoTagPtr>::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) + for (map<CDateTime, CEpgInfoTagPtr>::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) { if ((it->second->StartAsUTC() < time) && (it->second->EndAsUTC() > time)) return it->second; } - CEpgInfoTagPtr retVal; - return retVal; + return CEpgInfoTagPtr(); } void CEpg::AddEntry(const CEpgInfoTag &tag) @@ -320,7 +294,7 @@ void CEpg::AddEntry(const CEpgInfoTag &tag) newTag = itr->second; else { - newTag = CEpgInfoTagPtr(new CEpgInfoTag(this, m_pvrChannel, m_strName, m_pvrChannel ? m_pvrChannel->IconPath() : "")); + newTag.reset(new CEpgInfoTag(this, m_pvrChannel, m_strName, m_pvrChannel ? m_pvrChannel->IconPath() : "")); m_tags.insert(make_pair(tag.StartAsUTC(), newTag)); } @@ -347,7 +321,7 @@ bool CEpg::UpdateEntry(const CEpgInfoTag &tag, bool bUpdateDatabase /* = false * else { /* create a new tag if no tag with this ID exists */ - infoTag = CEpgInfoTagPtr(new CEpgInfoTag(this, m_pvrChannel, m_strName, m_pvrChannel ? m_pvrChannel->IconPath() : "")); + infoTag.reset(new CEpgInfoTag(this, m_pvrChannel, m_strName, m_pvrChannel ? m_pvrChannel->IconPath() : "")); infoTag->SetUniqueBroadcastID(tag.UniqueBroadcastID()); m_tags.insert(make_pair(tag.StartAsUTC(), infoTag)); bNewTag = true; @@ -355,7 +329,7 @@ bool CEpg::UpdateEntry(const CEpgInfoTag &tag, bool bUpdateDatabase /* = false * infoTag->Update(tag, bNewTag); infoTag->m_epg = this; - infoTag->m_pvrChannel = m_pvrChannel; + infoTag->SetPVRChannel(m_pvrChannel); UpdateRecording(infoTag); if (bUpdateDatabase) @@ -364,7 +338,7 @@ bool CEpg::UpdateEntry(const CEpgInfoTag &tag, bool bUpdateDatabase /* = false * return true; } -void CEpg::UpdateRecording(CEpgInfoTagPtr tag) +void CEpg::UpdateRecording(CEpgInfoTagPtr &tag) { if (!tag) return; @@ -420,7 +394,7 @@ bool CEpg::UpdateEntries(const CEpg &epg, bool bStoreInDb /* = true */) CLog::Log(LOGDEBUG, "EPG - %s - %zu entries in memory before merging", __FUNCTION__, m_tags.size()); #endif /* copy over tags */ - for (map<CDateTime, CEpgInfoTagPtr>::const_iterator it = epg.m_tags.begin(); it != epg.m_tags.end(); it++) + for (map<CDateTime, CEpgInfoTagPtr>::const_iterator it = epg.m_tags.begin(); it != epg.m_tags.end(); ++it) UpdateEntry(*it->second, bStoreInDb, false); #if EPG_DEBUGGING @@ -527,8 +501,8 @@ int CEpg::Get(CFileItemList &results) const CSingleLock lock(m_critSection); - for (map<CDateTime, CEpgInfoTagPtr>::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) - results.Add(CFileItemPtr(new CFileItem(*it->second))); + for (map<CDateTime, CEpgInfoTagPtr>::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) + results.Add(CFileItemPtr(new CFileItem(it->second))); return results.Size() - iInitialSize; } @@ -542,10 +516,10 @@ int CEpg::Get(CFileItemList &results, const EpgSearchFilter &filter) const CSingleLock lock(m_critSection); - for (map<CDateTime, CEpgInfoTagPtr>::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) + for (map<CDateTime, CEpgInfoTagPtr>::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) { if (filter.FilterEntry(*it->second)) - results.Add(CFileItemPtr(new CFileItem(*it->second))); + results.Add(CFileItemPtr(new CFileItem(it->second))); } return results.Size() - iInitialSize; @@ -576,10 +550,10 @@ bool CEpg::Persist(void) m_iEpgID = iId; } - for (std::map<int, CEpgInfoTagPtr>::iterator it = m_deletedTags.begin(); it != m_deletedTags.end(); it++) + for (std::map<int, CEpgInfoTagPtr>::iterator it = m_deletedTags.begin(); it != m_deletedTags.end(); ++it) database->Delete(*it->second); - for (std::map<int, CEpgInfoTagPtr>::iterator it = m_changedTags.begin(); it != m_changedTags.end(); it++) + for (std::map<int, CEpgInfoTagPtr>::iterator it = m_changedTags.begin(); it != m_changedTags.end(); ++it) it->second->Persist(false); if (m_bUpdateLastScanTime) @@ -766,8 +740,8 @@ bool CEpg::UpdateEntry(const EPG_TAG *data, bool bUpdateDatabase /* = false */) if (!data) return false; - CEpgInfoTag tag(*data); - return UpdateEntry(tag, bUpdateDatabase); + CEpgInfoTagPtr tag(new CEpgInfoTag(*data)); + return UpdateEntry(*tag, bUpdateDatabase); } bool CEpg::IsRadio(void) const @@ -818,7 +792,7 @@ CEpgInfoTagPtr CEpg::GetPreviousEvent(const CEpgInfoTag& tag) const map<CDateTime, CEpgInfoTagPtr>::const_iterator it = m_tags.find(tag.StartAsUTC()); if (it != m_tags.end() && it != m_tags.begin()) { - it--; + --it; return it->second; } @@ -861,7 +835,7 @@ void CEpg::SetChannel(PVR::CPVRChannelPtr channel) channel->SetEpgID(m_iEpgID); } m_pvrChannel = channel; - for (map<CDateTime, CEpgInfoTagPtr>::iterator it = m_tags.begin(); it != m_tags.end(); it++) + for (map<CDateTime, CEpgInfoTagPtr>::iterator it = m_tags.begin(); it != m_tags.end(); ++it) it->second->SetPVRChannel(m_pvrChannel); } } diff --git a/xbmc/epg/Epg.h b/xbmc/epg/Epg.h index 4a5c66eb44..da5ad15c94 100644 --- a/xbmc/epg/Epg.h +++ b/xbmc/epg/Epg.h @@ -165,16 +165,16 @@ namespace EPG void Clear(void); /*! - * @brief Get the event that is occurring now. - * @return The current event. + * @brief Get the event that is occurring now + * @return The current event or NULL if it wasn't found. */ - bool InfoTagNow(CEpgInfoTag &tag, bool bUpdateIfNeeded = true); + CEpgInfoTagPtr GetTagNow(bool bUpdateIfNeeded = true) const; /*! - * @brief Get the event that will occur next. - * @return The next event. + * @brief Get the event that will occur next + * @return The next event or NULL if it wasn't found. */ - bool InfoTagNext(CEpgInfoTag &tag); + CEpgInfoTagPtr GetTagNext() const; /*! * @brief Get the event that occurs at the given time. @@ -340,7 +340,7 @@ namespace EPG bool IsRemovableTag(const EPG::CEpgInfoTag &tag) const; - void UpdateRecording(CEpgInfoTagPtr tag); + void UpdateRecording(CEpgInfoTagPtr &tag); std::map<CDateTime, CEpgInfoTagPtr> m_tags; std::map<int, CEpgInfoTagPtr> m_changedTags; @@ -352,7 +352,7 @@ namespace EPG int m_iEpgID; /*!< the database ID of this table */ std::string m_strName; /*!< the name of this table */ std::string m_strScraperName; /*!< the name of the scraper to use */ - CDateTime m_nowActiveStart; /*!< the start time of the tag that is currently active */ + mutable CDateTime m_nowActiveStart; /*!< the start time of the tag that is currently active */ CDateTime m_lastScanTime; /*!< the last time the EPG has been updated */ diff --git a/xbmc/epg/EpgContainer.cpp b/xbmc/epg/EpgContainer.cpp index 425adbab65..c42118414c 100644 --- a/xbmc/epg/EpgContainer.cpp +++ b/xbmc/epg/EpgContainer.cpp @@ -342,7 +342,7 @@ CEpg *CEpgContainer::GetById(int iEpgId) const CEpg *CEpgContainer::GetByChannel(const CPVRChannel &channel) const { CSingleLock lock(m_critSection); - for (map<unsigned int, CEpg *>::const_iterator it = m_epgs.begin(); it != m_epgs.end(); it++) + for (map<unsigned int, CEpg *>::const_iterator it = m_epgs.begin(); it != m_epgs.end(); ++it) if (channel.ChannelID() == it->second->ChannelID()) return it->second; @@ -598,7 +598,7 @@ bool CEpgContainer::UpdateEPG(bool bOnlyPending /* = false */) invalidTables.push_back(epg); } - for (vector<CEpg*>::iterator it = invalidTables.begin(); it != invalidTables.end(); it++) + for (vector<CEpg*>::iterator it = invalidTables.begin(); it != invalidTables.end(); ++it) DeleteEpg(**it, true); if (bInterrupted) diff --git a/xbmc/epg/EpgDatabase.cpp b/xbmc/epg/EpgDatabase.cpp index c9c74765f2..8e21e5033b 100644 --- a/xbmc/epg/EpgDatabase.cpp +++ b/xbmc/epg/EpgDatabase.cpp @@ -60,6 +60,7 @@ void CEpgDatabase::CreateTables(void) "sTitle varchar(128), " "sPlotOutline text, " "sPlot text, " + "sIconPath varchar(255), " "iStartTime integer, " "iEndTime integer, " "iGenreType integer, " @@ -98,6 +99,9 @@ void CEpgDatabase::UpdateTables(int iVersion) if (iVersion < 8) m_pDS->exec("ALTER TABLE epgtags ADD sRecordingId varchar(128);"); + + if (iVersion < 9) + m_pDS->exec("ALTER TABLE epgtags ADD sIconPath varchar(255);"); } bool CEpgDatabase::DeleteEpg(void) @@ -196,39 +200,40 @@ int CEpgDatabase::Get(CEpg &epg) { while (!m_pDS->eof()) { - CEpgInfoTag newTag; + CEpgInfoTagPtr newTag(new CEpgInfoTag()); time_t iStartTime, iEndTime, iFirstAired; iStartTime = (time_t) m_pDS->fv("iStartTime").get_asInt(); CDateTime startTime(iStartTime); - newTag.m_startTime = startTime; + newTag->m_startTime = startTime; iEndTime = (time_t) m_pDS->fv("iEndTime").get_asInt(); CDateTime endTime(iEndTime); - newTag.m_endTime = endTime; + newTag->m_endTime = endTime; iFirstAired = (time_t) m_pDS->fv("iFirstAired").get_asInt(); CDateTime firstAired(iFirstAired); - newTag.m_firstAired = firstAired; - - newTag.m_iUniqueBroadcastID = m_pDS->fv("iBroadcastUid").get_asInt(); - newTag.m_iBroadcastId = m_pDS->fv("idBroadcast").get_asInt(); - newTag.m_strTitle = m_pDS->fv("sTitle").get_asString().c_str(); - newTag.m_strPlotOutline = m_pDS->fv("sPlotOutline").get_asString().c_str(); - newTag.m_strPlot = m_pDS->fv("sPlot").get_asString().c_str(); - newTag.m_iGenreType = m_pDS->fv("iGenreType").get_asInt(); - newTag.m_iGenreSubType = m_pDS->fv("iGenreSubType").get_asInt(); - newTag.m_genre = StringUtils::Split(m_pDS->fv("sGenre").get_asString().c_str(), g_advancedSettings.m_videoItemSeparator); - newTag.m_iParentalRating = m_pDS->fv("iParentalRating").get_asInt(); - newTag.m_iStarRating = m_pDS->fv("iStarRating").get_asInt(); - newTag.m_bNotify = m_pDS->fv("bNotify").get_asBool(); - newTag.m_iEpisodeNumber = m_pDS->fv("iEpisodeId").get_asInt(); - newTag.m_iEpisodePart = m_pDS->fv("iEpisodePart").get_asInt(); - newTag.m_strEpisodeName = m_pDS->fv("sEpisodeName").get_asString().c_str(); - newTag.m_iSeriesNumber = m_pDS->fv("iSeriesId").get_asInt(); - newTag.m_strRecordingId = m_pDS->fv("sRecordingId").get_asString().c_str(); - - epg.AddEntry(newTag); + newTag->m_firstAired = firstAired; + + newTag->m_iUniqueBroadcastID = m_pDS->fv("iBroadcastUid").get_asInt(); + newTag->m_iBroadcastId = m_pDS->fv("idBroadcast").get_asInt(); + newTag->m_strTitle = m_pDS->fv("sTitle").get_asString().c_str(); + newTag->m_strPlotOutline = m_pDS->fv("sPlotOutline").get_asString().c_str(); + newTag->m_strPlot = m_pDS->fv("sPlot").get_asString().c_str(); + newTag->m_iGenreType = m_pDS->fv("iGenreType").get_asInt(); + newTag->m_iGenreSubType = m_pDS->fv("iGenreSubType").get_asInt(); + newTag->m_genre = StringUtils::Split(m_pDS->fv("sGenre").get_asString().c_str(), g_advancedSettings.m_videoItemSeparator); + newTag->m_iParentalRating = m_pDS->fv("iParentalRating").get_asInt(); + newTag->m_iStarRating = m_pDS->fv("iStarRating").get_asInt(); + newTag->m_bNotify = m_pDS->fv("bNotify").get_asBool(); + newTag->m_iEpisodeNumber = m_pDS->fv("iEpisodeId").get_asInt(); + newTag->m_iEpisodePart = m_pDS->fv("iEpisodePart").get_asInt(); + newTag->m_strEpisodeName = m_pDS->fv("sEpisodeName").get_asString().c_str(); + newTag->m_iSeriesNumber = m_pDS->fv("iSeriesId").get_asInt(); + newTag->m_strRecordingId = m_pDS->fv("sRecordingId").get_asString().c_str(); + newTag->m_strIconPath = m_pDS->fv("sIconPath").get_asString().c_str(); + + epg.AddEntry(*newTag); ++iReturn; m_pDS->next(); @@ -272,7 +277,7 @@ bool CEpgDatabase::PersistLastEpgScanTime(int iEpgId /* = 0 */, bool bQueueWrite bool CEpgDatabase::Persist(const map<unsigned int, CEpg *> &epgs) { - for (map<unsigned int, CEpg *>::const_iterator it = epgs.begin(); it != epgs.end(); it++) + for (map<unsigned int, CEpg *>::const_iterator it = epgs.begin(); it != epgs.end(); ++it) { CEpg *epg = it->second; if (epg) @@ -332,12 +337,12 @@ int CEpgDatabase::Persist(const CEpgInfoTag &tag, bool bSingleUpdate /* = true * if (iBroadcastId < 0) { strQuery = PrepareSQL("REPLACE INTO epgtags (idEpg, iStartTime, " - "iEndTime, sTitle, sPlotOutline, sPlot, iGenreType, iGenreSubType, sGenre, " + "iEndTime, sTitle, sPlotOutline, sPlot, sIconPath, iGenreType, iGenreSubType, sGenre, " "iFirstAired, iParentalRating, iStarRating, bNotify, iSeriesId, " "iEpisodeId, iEpisodePart, sEpisodeName, iBroadcastUid, sRecordingId) " - "VALUES (%u, %u, %u, '%s', '%s', '%s', %i, %i, '%s', %u, %i, %i, %i, %i, %i, %i, '%s', %i, '%s');", + "VALUES (%u, %u, %u, '%s', '%s', '%s', '%s', %i, %i, '%s', %u, %i, %i, %i, %i, %i, %i, '%s', %i, '%s');", tag.EpgID(), iStartTime, iEndTime, - tag.Title(true).c_str(), tag.PlotOutline(true).c_str(), tag.Plot(true).c_str(), tag.GenreType(), tag.GenreSubType(), strGenre.c_str(), + tag.Title(true).c_str(), tag.PlotOutline(true).c_str(), tag.Plot(true).c_str(), tag.Icon().c_str(), tag.GenreType(), tag.GenreSubType(), strGenre.c_str(), iFirstAired, tag.ParentalRating(), tag.StarRating(), tag.Notify(), tag.SeriesNum(), tag.EpisodeNum(), tag.EpisodePart(), tag.EpisodeName().c_str(), tag.UniqueBroadcastID(), tag.RecordingId().c_str()); @@ -345,12 +350,12 @@ int CEpgDatabase::Persist(const CEpgInfoTag &tag, bool bSingleUpdate /* = true * else { strQuery = PrepareSQL("REPLACE INTO epgtags (idEpg, iStartTime, " - "iEndTime, sTitle, sPlotOutline, sPlot, iGenreType, iGenreSubType, sGenre, " + "iEndTime, sTitle, sPlotOutline, sPlot, sIconPath, iGenreType, iGenreSubType, sGenre, " "iFirstAired, iParentalRating, iStarRating, bNotify, iSeriesId, " "iEpisodeId, iEpisodePart, sEpisodeName, iBroadcastUid, idBroadcast, sRecordingId) " - "VALUES (%u, %u, %u, '%s', '%s', '%s', %i, %i, '%s', %u, %i, %i, %i, %i, %i, %i, '%s', %i, %i, '%s');", + "VALUES (%u, %u, %u, '%s', '%s', '%s', '%s', %i, %i, '%s', %u, %i, %i, %i, %i, %i, %i, '%s', %i, %i, '%s');", tag.EpgID(), iStartTime, iEndTime, - tag.Title(true).c_str(), tag.PlotOutline(true).c_str(), tag.Plot(true).c_str(), tag.GenreType(), tag.GenreSubType(), strGenre.c_str(), + tag.Title(true).c_str(), tag.PlotOutline(true).c_str(), tag.Plot(true).c_str(), tag.Icon().c_str(), tag.GenreType(), tag.GenreSubType(), strGenre.c_str(), iFirstAired, tag.ParentalRating(), tag.StarRating(), tag.Notify(), tag.SeriesNum(), tag.EpisodeNum(), tag.EpisodePart(), tag.EpisodeName().c_str(), tag.UniqueBroadcastID(), iBroadcastId, tag.RecordingId().c_str()); diff --git a/xbmc/epg/EpgDatabase.h b/xbmc/epg/EpgDatabase.h index 5236d5774c..6d1b698354 100644 --- a/xbmc/epg/EpgDatabase.h +++ b/xbmc/epg/EpgDatabase.h @@ -54,7 +54,7 @@ namespace EPG * @brief Get the minimal database version that is required to operate correctly. * @return The minimal database version. */ - virtual int GetSchemaVersion(void) const { return 8; }; + virtual int GetSchemaVersion(void) const { return 9; }; /*! * @brief Get the default sqlite database filename. diff --git a/xbmc/epg/EpgInfoTag.cpp b/xbmc/epg/EpgInfoTag.cpp index 20691c87e2..6a4dbd5c30 100644 --- a/xbmc/epg/EpgInfoTag.cpp +++ b/xbmc/epg/EpgInfoTag.cpp @@ -38,6 +38,11 @@ using namespace std; using namespace EPG; using namespace PVR; +CEpgInfoTagPtr CEpgInfoTag::CreateDefaultTag() +{ + return CEpgInfoTagPtr(new CEpgInfoTag()); +} + CEpgInfoTag::CEpgInfoTag(void) : m_bNotify(false), m_bChanged(false), @@ -52,11 +57,6 @@ CEpgInfoTag::CEpgInfoTag(void) : m_iUniqueBroadcastID(-1), m_epg(NULL) { - CPVRChannelPtr emptyChannel; - m_pvrChannel = emptyChannel; - - CPVRTimerInfoTagPtr emptyTimer; - m_timer = emptyTimer; } CEpgInfoTag::CEpgInfoTag(CEpg *epg, PVR::CPVRChannelPtr pvrChannel, const std::string &strTableName /* = "" */, const std::string &strIconPath /* = "" */) : @@ -75,8 +75,6 @@ CEpgInfoTag::CEpgInfoTag(CEpg *epg, PVR::CPVRChannelPtr pvrChannel, const std::s m_epg(epg), m_pvrChannel(pvrChannel) { - CPVRTimerInfoTagPtr emptyTimer; - m_timer = emptyTimer; } CEpgInfoTag::CEpgInfoTag(const EPG_TAG &data) : @@ -93,12 +91,6 @@ CEpgInfoTag::CEpgInfoTag(const EPG_TAG &data) : m_iUniqueBroadcastID(-1), m_epg(NULL) { - CPVRChannelPtr emptyChannel; - m_pvrChannel = emptyChannel; - - CPVRTimerInfoTagPtr emptyTimer; - m_timer = emptyTimer; - SetStartFromUTC(data.startTime + g_advancedSettings.m_iPVRTimeCorrection); SetEndFromUTC(data.endTime + g_advancedSettings.m_iPVRTimeCorrection); SetGenre(data.iGenreType, data.iGenreSubType, data.strGenreDescription); @@ -125,36 +117,6 @@ CEpgInfoTag::CEpgInfoTag(const EPG_TAG &data) : SetRecordingId(data.strRecordingId); } -CEpgInfoTag::CEpgInfoTag(const CEpgInfoTag &tag) : - m_bNotify(tag.m_bNotify), - m_bChanged(tag.m_bChanged), - m_iBroadcastId(tag.m_iBroadcastId), - m_iGenreType(tag.m_iGenreType), - m_iGenreSubType(tag.m_iGenreSubType), - m_iParentalRating(tag.m_iParentalRating), - m_iStarRating(tag.m_iStarRating), - m_iSeriesNumber(tag.m_iSeriesNumber), - m_iEpisodeNumber(tag.m_iEpisodeNumber), - m_iEpisodePart(tag.m_iEpisodePart), - m_iUniqueBroadcastID(tag.m_iUniqueBroadcastID), - m_strTitle(tag.m_strTitle), - m_strPlotOutline(tag.m_strPlotOutline), - m_strPlot(tag.m_strPlot), - m_genre(tag.m_genre), - m_strEpisodeName(tag.m_strEpisodeName), - m_strIconPath(tag.m_strIconPath), - m_strFileNameAndPath(tag.m_strFileNameAndPath), - m_startTime(tag.m_startTime), - m_endTime(tag.m_endTime), - m_firstAired(tag.m_firstAired), - m_strRecordingId(tag.m_strRecordingId), - m_timer(tag.m_timer), - m_recording(tag.m_recording), - m_epg(tag.m_epg), - m_pvrChannel(tag.m_pvrChannel) -{ -} - CEpgInfoTag::~CEpgInfoTag() { ClearTimer(); @@ -198,40 +160,6 @@ bool CEpgInfoTag::operator !=(const CEpgInfoTag& right) const return !(*this == right); } -CEpgInfoTag &CEpgInfoTag::operator =(const CEpgInfoTag &other) -{ - CSingleLock lock(other.m_critSection); - - m_bNotify = other.m_bNotify; - m_bChanged = other.m_bChanged; - m_iBroadcastId = other.m_iBroadcastId; - m_iGenreType = other.m_iGenreType; - m_iGenreSubType = other.m_iGenreSubType; - m_iParentalRating = other.m_iParentalRating; - m_iStarRating = other.m_iStarRating; - m_iSeriesNumber = other.m_iSeriesNumber; - m_iEpisodeNumber = other.m_iEpisodeNumber; - m_iEpisodePart = other.m_iEpisodePart; - m_iUniqueBroadcastID = other.m_iUniqueBroadcastID; - m_strTitle = other.m_strTitle; - m_strPlotOutline = other.m_strPlotOutline; - m_strPlot = other.m_strPlot; - m_genre = other.m_genre; - m_strEpisodeName = other.m_strEpisodeName; - m_strIconPath = other.m_strIconPath; - m_strFileNameAndPath = other.m_strFileNameAndPath; - m_startTime = other.m_startTime; - m_endTime = other.m_endTime; - m_firstAired = other.m_firstAired; - m_timer = other.m_timer; - m_strRecordingId = other.m_strRecordingId; - m_recording = other.m_recording; - m_epg = other.m_epg; - m_pvrChannel = other.m_pvrChannel; - - return *this; -} - void CEpgInfoTag::Serialize(CVariant &value) const { value["broadcastid"] = m_iUniqueBroadcastID; @@ -950,7 +878,8 @@ bool CEpgInfoTag::Update(const CEpgInfoTag &tag, bool bUpdateBroadcastId /* = tr EpgID() != tag.EpgID() || m_pvrChannel != tag.m_pvrChannel || m_genre != tag.m_genre || - m_strRecordingId != tag.m_strRecordingId + m_strRecordingId != tag.m_strRecordingId || + m_strIconPath != tag.m_strIconPath ); if (bUpdateBroadcastId) bChanged = bChanged || m_iBroadcastId != tag.m_iBroadcastId; @@ -989,6 +918,7 @@ bool CEpgInfoTag::Update(const CEpgInfoTag &tag, bool bUpdateBroadcastId /* = tr m_strEpisodeName = tag.m_strEpisodeName; m_iUniqueBroadcastID = tag.m_iUniqueBroadcastID; m_strRecordingId = tag.m_strRecordingId; + m_strIconPath = tag.m_strIconPath; m_bChanged = true; } diff --git a/xbmc/epg/EpgInfoTag.h b/xbmc/epg/EpgInfoTag.h index ff1e4a0945..de0162fb05 100644 --- a/xbmc/epg/EpgInfoTag.h +++ b/xbmc/epg/EpgInfoTag.h @@ -44,9 +44,17 @@ namespace EPG { friend class CEpg; friend class CEpgDatabase; - friend class PVR::CPVRTimerInfoTag; public: + /*! + * @brief Create a new empty event . + */ + static CEpgInfoTagPtr CreateDefaultTag(); + + private: + /*! + * @brief Create a new empty event. + */ CEpgInfoTag(void); /*! @@ -60,16 +68,23 @@ namespace EPG */ CEpgInfoTag(const EPG_TAG &data); - /*! - * @brief Create a new EPG infotag with 'tag' as content. - * @param tag The tag's content. - */ + // Prevent copy construction, even for CEpgInfoTag instances and friends. + // Note: Only declared, but intentionally not implemented + // to prevent compiler generated copy ctor and to force + // a linker error in case somebody tries to call it. CEpgInfoTag(const CEpgInfoTag &tag); + + // Prevent copy by assignment, even for CEpgInfoTag instances and friends. + // Note: Only declared, but intentionally not implemented + // to prevent compiler generated assignment operator and to force + // a linker error in case somebody tries to call it. + CEpgInfoTag &operator =(const CEpgInfoTag &other); + + public: virtual ~CEpgInfoTag(); bool operator ==(const CEpgInfoTag& right) const; bool operator !=(const CEpgInfoTag& right) const; - CEpgInfoTag &operator =(const CEpgInfoTag &other); virtual void Serialize(CVariant &value) const; @@ -464,7 +479,8 @@ namespace EPG * @return True if something changed, false otherwise. */ bool Update(const CEpgInfoTag &tag, bool bUpdateBroadcastId = true); - protected: + + private: /*! * @brief Hook that is called when the start date changed. */ diff --git a/xbmc/epg/EpgSearchFilter.cpp b/xbmc/epg/EpgSearchFilter.cpp index 8b3e9e8d64..39e328d0a2 100644 --- a/xbmc/epg/EpgSearchFilter.cpp +++ b/xbmc/epg/EpgSearchFilter.cpp @@ -133,13 +133,19 @@ int EpgSearchFilter::RemoveDuplicates(CFileItemList &results) for (unsigned int iResultPtr = 0; iResultPtr < iSize; iResultPtr++) { - const CEpgInfoTag *epgentry_1 = results.Get(iResultPtr)->GetEPGInfoTag(); + const CEpgInfoTagPtr epgentry_1(results.Get(iResultPtr)->GetEPGInfoTag()); + if (!epgentry_1) + continue; + for (unsigned int iTagPtr = 0; iTagPtr < iSize; iTagPtr++) { - const CEpgInfoTag *epgentry_2 = results.Get(iTagPtr)->GetEPGInfoTag(); if (iResultPtr == iTagPtr) continue; + const CEpgInfoTagPtr epgentry_2(results.Get(iTagPtr)->GetEPGInfoTag()); + if (!epgentry_2) + continue; + if (epgentry_1->Title() != epgentry_2->Title() || epgentry_1->Plot() != epgentry_2->Plot() || epgentry_1->PlotOutline() != epgentry_2->PlotOutline()) @@ -207,7 +213,7 @@ int EpgSearchFilter::FilterRecordings(CFileItemList &results) for (int iResultPtr = 0; iResultPtr < results.Size(); iResultPtr++) { - const CEpgInfoTag *epgentry = results.Get(iResultPtr)->GetEPGInfoTag(); + const CEpgInfoTagPtr epgentry(results.Get(iResultPtr)->GetEPGInfoTag()); /* no match */ if (!epgentry || @@ -244,7 +250,7 @@ int EpgSearchFilter::FilterTimers(CFileItemList &results) for (int iResultPtr = 0; iResultPtr < results.Size(); iResultPtr++) { - const CEpgInfoTag *epgentry = results.Get(iResultPtr)->GetEPGInfoTag(); + const CEpgInfoTagPtr epgentry(results.Get(iResultPtr)->GetEPGInfoTag()); if (!epgentry || *epgentry->ChannelTag() != *timer->ChannelTag() || epgentry->StartAsUTC() < timer->StartAsUTC() || diff --git a/xbmc/epg/GUIEPGGridContainer.cpp b/xbmc/epg/GUIEPGGridContainer.cpp index c322a54ece..2c3d624b20 100644 --- a/xbmc/epg/GUIEPGGridContainer.cpp +++ b/xbmc/epg/GUIEPGGridContainer.cpp @@ -753,7 +753,10 @@ bool CGUIEPGGridContainer::OnMessage(CGUIMessage& message) itemsPointer.start = 0; for (unsigned int i = 0; i < m_programmeItems.size(); ++i) { - const CEpgInfoTag* tag = ((CFileItem*)m_programmeItems[i].get())->GetEPGInfoTag(); + const CEpgInfoTagPtr tag(((CFileItem*)m_programmeItems[i].get())->GetEPGInfoTag()); + if (!tag) + continue; + CPVRChannelPtr channel = tag->ChannelTag(); if (!channel) continue; @@ -855,10 +858,11 @@ void CGUIEPGGridContainer::UpdateItems() for (unsigned int row = 0; row < m_epgItemsPtr.size(); ++row) { - CDateTime gridCursor = m_gridStart; //reset cursor for new channel - unsigned long progIdx = m_epgItemsPtr[row].start; - unsigned long lastIdx = m_epgItemsPtr[row].stop; - int iEpgId = ((CFileItem *)m_programmeItems[progIdx].get())->GetEPGInfoTag()->EpgID(); + CDateTime gridCursor = m_gridStart; //reset cursor for new channel + unsigned long progIdx = m_epgItemsPtr[row].start; + unsigned long lastIdx = m_epgItemsPtr[row].stop; + const CEpgInfoTagPtr info = ((CFileItem *)m_programmeItems[progIdx].get())->GetEPGInfoTag(); + int iEpgId = info ? info->EpgID() : -1; /** FOR EACH BLOCK **********************************************************************/ @@ -867,8 +871,8 @@ void CGUIEPGGridContainer::UpdateItems() while (progIdx <= lastIdx) { CGUIListItemPtr item = m_programmeItems[progIdx]; - const CEpgInfoTag* tag = ((CFileItem *)item.get())->GetEPGInfoTag(); - if (tag == NULL) + const CEpgInfoTagPtr tag(((CFileItem *)item.get())->GetEPGInfoTag()); + if (!tag) { progIdx++; continue; @@ -901,7 +905,7 @@ void CGUIEPGGridContainer::UpdateItems() { if (!item) { - CEpgInfoTag gapTag; + CEpgInfoTagPtr gapTag(CEpgInfoTag::CreateDefaultTag()); CFileItemPtr gapItem(new CFileItem(gapTag)); for (int i = block ; i > block - itemSize; i--) { @@ -910,8 +914,9 @@ void CGUIEPGGridContainer::UpdateItems() } else { - const CEpgInfoTag* tag = ((CFileItem *)item.get())->GetEPGInfoTag(); - m_gridIndex[row][savedBlock].item->SetProperty("GenreType", tag->GenreType()); + const CEpgInfoTagPtr tag(((CFileItem *)item.get())->GetEPGInfoTag()); + if (tag) + m_gridIndex[row][savedBlock].item->SetProperty("GenreType", tag->GenreType()); } m_gridIndex[row][savedBlock].originWidth = itemSize*m_blockSize; @@ -1833,11 +1838,11 @@ void CGUIEPGGridContainer::SetRenderOffset(const CPoint &offset) void CGUIEPGGridContainer::FreeItemsMemory() { // free memory of items - for (std::vector<CGUIListItemPtr>::iterator it = m_channelItems.begin(); it != m_channelItems.end(); it++) + for (std::vector<CGUIListItemPtr>::iterator it = m_channelItems.begin(); it != m_channelItems.end(); ++it) (*it)->FreeMemory(); - for (std::vector<CGUIListItemPtr>::iterator it = m_rulerItems.begin(); it != m_rulerItems.end(); it++) + for (std::vector<CGUIListItemPtr>::iterator it = m_rulerItems.begin(); it != m_rulerItems.end(); ++it) (*it)->FreeMemory(); - for (std::vector<CGUIListItemPtr>::iterator it = m_programmeItems.begin(); it != m_programmeItems.end(); it++) + for (std::vector<CGUIListItemPtr>::iterator it = m_programmeItems.begin(); it != m_programmeItems.end(); ++it) (*it)->FreeMemory(); } diff --git a/xbmc/epg/GUIEPGGridContainer.h b/xbmc/epg/GUIEPGGridContainer.h index 981ca0d7fc..bd7fa1b40e 100644 --- a/xbmc/epg/GUIEPGGridContainer.h +++ b/xbmc/epg/GUIEPGGridContainer.h @@ -30,7 +30,7 @@ namespace EPG { #define MAXCHANNELS 20 - #define MAXBLOCKS (16 * 24 * 60 / 5) //! 16 days of 5 minute blocks (14 days for upcoming data + 1 day for past data + 1 day for fillers) + #define MAXBLOCKS (33 * 24 * 60 / 5) //! 33 days of 5 minute blocks (31 days for upcoming data + 1 day for past data + 1 day for fillers) struct GridItemsPtr { diff --git a/xbmc/filesystem/BlurayFile.cpp b/xbmc/filesystem/BlurayFile.cpp index 2731f1cc8f..b46378080a 100644 --- a/xbmc/filesystem/BlurayFile.cpp +++ b/xbmc/filesystem/BlurayFile.cpp @@ -20,71 +20,31 @@ #include "system.h" #ifdef HAVE_LIBBLURAY +#include <assert.h> + #include "BlurayFile.h" #include "URL.h" -#include "utils/StringUtils.h" namespace XFILE { CBlurayFile::CBlurayFile(void) - { - } + : COverrideFile(false) + { } CBlurayFile::~CBlurayFile(void) - { - Close(); - } + { } - CURL CBlurayFile::RemoveProtocol(const CURL& url) + std::string CBlurayFile::TranslatePath(const CURL& url) { assert(url.IsProtocol("bluray")); std::string host = url.GetHostName(); std::string filename = url.GetFileName(); if (host.empty() || filename.empty()) - return CURL(); - return CURL(host.append(filename)); - } - - bool CBlurayFile::Open(const CURL& url) - { - return m_file.Open(RemoveProtocol(url)); - } - - bool CBlurayFile::Exists(const CURL& url) - { - return m_file.Exists(RemoveProtocol(url)); - } - - int CBlurayFile::Stat(const CURL& url, struct __stat64* buffer) - { - return m_file.Stat(RemoveProtocol(url), buffer); - } - - ssize_t CBlurayFile::Read(void* lpBuf, size_t uiBufSize) - { - return m_file.Read(lpBuf, uiBufSize); - } - - int64_t CBlurayFile::Seek(int64_t iFilePosition, int iWhence /*=SEEK_SET*/) - { - return m_file.Seek(iFilePosition, iWhence); - } + return ""; - void CBlurayFile::Close() - { - m_file.Close(); - } - - int64_t CBlurayFile::GetPosition() - { - return m_file.GetPosition(); - } - - int64_t CBlurayFile::GetLength() - { - return m_file.GetLength(); + return host.append(filename); } } /* namespace XFILE */ #endif diff --git a/xbmc/filesystem/BlurayFile.h b/xbmc/filesystem/BlurayFile.h index e05b9de026..f14d2e2b29 100644 --- a/xbmc/filesystem/BlurayFile.h +++ b/xbmc/filesystem/BlurayFile.h @@ -20,33 +20,18 @@ * */ -#include "File.h" -#include "IFile.h" - +#include "filesystem/OverrideFile.h" namespace XFILE { - class CBlurayFile : public IFile + class CBlurayFile : public COverrideFile { public: CBlurayFile(); virtual ~CBlurayFile(); - virtual bool Open(const CURL& url); - virtual bool Exists(const CURL& url); - virtual int Stat(const CURL& url, struct __stat64* buffer); - - virtual ssize_t Read(void* lpBuf, size_t uiBufSize); - virtual int64_t Seek(int64_t iFilePosition, int iWhence = SEEK_SET); - virtual void Close(); - virtual int64_t GetPosition(); - virtual int64_t GetLength(); - protected: - CFile m_file; - - private: - CURL RemoveProtocol(const CURL& url); + virtual std::string TranslatePath(const CURL& url); }; } diff --git a/xbmc/filesystem/CurlFile.cpp b/xbmc/filesystem/CurlFile.cpp index 02e962b1d4..7d68daba12 100644 --- a/xbmc/filesystem/CurlFile.cpp +++ b/xbmc/filesystem/CurlFile.cpp @@ -225,6 +225,7 @@ CCurlFile::CReadState::CReadState() m_multiHandle = NULL; m_overflowBuffer = NULL; m_overflowSize = 0; + m_stillRunning = 0; m_filePos = 0; m_fileSize = 0; m_bufferSize = 0; @@ -374,6 +375,9 @@ CCurlFile::~CCurlFile() } CCurlFile::CCurlFile() + : m_writeOffset(0) + , m_overflowBuffer(NULL) + , m_overflowSize(0) { g_curlInterface.Load(); // loads the curl dll and resolves exports etc. m_opened = false; diff --git a/xbmc/filesystem/DAVFile.cpp b/xbmc/filesystem/DAVFile.cpp index 4e89a9e652..9713c59e8e 100644 --- a/xbmc/filesystem/DAVFile.cpp +++ b/xbmc/filesystem/DAVFile.cpp @@ -49,7 +49,7 @@ bool CDAVFile::Execute(const CURL& url) CLog::Log(LOGDEBUG, "CDAVFile::Execute(%p) %s", (void*)this, m_url.c_str()); - ASSERT(!(!m_state->m_easyHandle ^ !m_state->m_multiHandle)); + assert(!(!m_state->m_easyHandle ^ !m_state->m_multiHandle)); if( m_state->m_easyHandle == NULL ) g_curlInterface.easy_aquire(url2.GetProtocol().c_str(), url2.GetHostName().c_str(), diff --git a/xbmc/filesystem/DllLibCurl.cpp b/xbmc/filesystem/DllLibCurl.cpp index 62c8ce2c12..e58373ef75 100644 --- a/xbmc/filesystem/DllLibCurl.cpp +++ b/xbmc/filesystem/DllLibCurl.cpp @@ -165,7 +165,7 @@ void DllLibCurlGlobal::CheckIdle() it = m_sessions.erase(it); continue; } - it++; + ++it; } /* check if we should unload the dll */ @@ -182,7 +182,7 @@ void DllLibCurlGlobal::easy_aquire(const char *protocol, const char *hostname, C CSingleLock lock(m_critSection); VEC_CURLSESSIONS::iterator it; - for(it = m_sessions.begin(); it != m_sessions.end(); it++) + for(it = m_sessions.begin(); it != m_sessions.end(); ++it) { if( !it->m_busy ) { @@ -261,7 +261,7 @@ void DllLibCurlGlobal::easy_release(CURL_HANDLE** easy_handle, CURLM** multi_han } VEC_CURLSESSIONS::iterator it; - for(it = m_sessions.begin(); it != m_sessions.end(); it++) + for(it = m_sessions.begin(); it != m_sessions.end(); ++it) { if( it->m_easy == easy && (multi == NULL || it->m_multi == multi) ) { @@ -280,7 +280,7 @@ CURL_HANDLE* DllLibCurlGlobal::easy_duphandle(CURL_HANDLE* easy_handle) CSingleLock lock(m_critSection); VEC_CURLSESSIONS::iterator it; - for(it = m_sessions.begin(); it != m_sessions.end(); it++) + for(it = m_sessions.begin(); it != m_sessions.end(); ++it) { if( it->m_easy == easy_handle ) { @@ -305,7 +305,7 @@ void DllLibCurlGlobal::easy_duplicate(CURL_HANDLE* easy, CURLM* multi, CURL_HAND *multi_out = DllLibCurl::multi_init(); VEC_CURLSESSIONS::iterator it; - for(it = m_sessions.begin(); it != m_sessions.end(); it++) + for(it = m_sessions.begin(); it != m_sessions.end(); ++it) { if( it->m_easy == easy ) { diff --git a/xbmc/filesystem/DllLibCurl.h b/xbmc/filesystem/DllLibCurl.h index 304459f655..db97f923ea 100644 --- a/xbmc/filesystem/DllLibCurl.h +++ b/xbmc/filesystem/DllLibCurl.h @@ -21,6 +21,8 @@ #include "DynamicDll.h" #include "threads/CriticalSection.h" +#include <stdio.h> +#include <vector> /* put types of curl in namespace to avoid namespace pollution */ namespace XCURL diff --git a/xbmc/filesystem/FTPParse.cpp b/xbmc/filesystem/FTPParse.cpp index 4ede2c748b..90aee7a581 100644 --- a/xbmc/filesystem/FTPParse.cpp +++ b/xbmc/filesystem/FTPParse.cpp @@ -38,7 +38,6 @@ using namespace std; CFTPParse::CFTPParse() { - m_name = ""; m_flagtrycwd = 0; m_flagtryretr = 0; m_size = 0; diff --git a/xbmc/filesystem/File.cpp b/xbmc/filesystem/File.cpp index c25667d320..0764bcc3d4 100644 --- a/xbmc/filesystem/File.cpp +++ b/xbmc/filesystem/File.cpp @@ -505,6 +505,15 @@ ssize_t CFile::Read(void *lpBuf, size_t uiBufSize) if (uiBufSize > SSIZE_MAX) uiBufSize = SSIZE_MAX; + if (uiBufSize == 0) + { + // "test" read with zero size + // some VFSs don't handle correctly null buffer pointer + // provide valid buffer pointer for them + char dummy; + return m_pFile->Read(&dummy, 0); + } + if(m_pBuffer) { if(m_flags & READ_TRUNCATED) @@ -527,17 +536,6 @@ ssize_t CFile::Read(void *lpBuf, size_t uiBufSize) try { - if (uiBufSize == 0) - { // "test" read with zero size - if (lpBuf != NULL) - return m_pFile->Read(lpBuf, 0); - - // some VFSs don't handle correctly null buffer pointer - // provide valid buffer pointer for them - auto_buffer dummyBuf(255); - return m_pFile->Read(dummyBuf.get(), 0); - } - if(m_flags & READ_TRUNCATED) { const ssize_t nBytes = m_pFile->Read(lpBuf, uiBufSize); @@ -1034,10 +1032,15 @@ CFileStreamBuffer::int_type CFileStreamBuffer::underflow() memmove(m_buffer, egptr()-backsize, backsize); } - unsigned int size = m_file->Read(m_buffer+backsize, m_frontsize); + ssize_t size = m_file->Read(m_buffer+backsize, m_frontsize); - if(size == 0) + if (size == 0) return traits_type::eof(); + else if (size < 0) + { + CLog::LogF(LOGWARNING, "Error reading file - assuming eof"); + return traits_type::eof(); + } setg(m_buffer, m_buffer+backsize, m_buffer+backsize+size); return traits_type::to_int_type(*gptr()); diff --git a/xbmc/filesystem/FileCache.cpp b/xbmc/filesystem/FileCache.cpp index 127d9fbdf6..3880c58d99 100644 --- a/xbmc/filesystem/FileCache.cpp +++ b/xbmc/filesystem/FileCache.cpp @@ -95,7 +95,13 @@ private: }; -CFileCache::CFileCache(bool useDoubleCache) : CThread("FileCache") +CFileCache::CFileCache(bool useDoubleCache) + : CThread("FileCache") + , m_seekPossible(0) + , m_chunkSize(0) + , m_writeRate(0) + , m_writeRateActual(0) + , m_cacheFull(false) { m_bDeleteCache = true; m_nSeekResult = 0; @@ -119,11 +125,15 @@ CFileCache::CFileCache(bool useDoubleCache) : CThread("FileCache") { m_pCache = new CDoubleCache(m_pCache); } - m_seekPossible = 0; - m_cacheFull = false; } -CFileCache::CFileCache(CCacheStrategy *pCache, bool bDeleteCache) : CThread("FileCacheStrategy") +CFileCache::CFileCache(CCacheStrategy *pCache, bool bDeleteCache) + : CThread("FileCacheStrategy") + , m_seekPossible(0) + , m_chunkSize(0) + , m_writeRate(0) + , m_writeRateActual(0) + , m_cacheFull(false) { m_pCache = pCache; m_bDeleteCache = bDeleteCache; @@ -131,7 +141,6 @@ CFileCache::CFileCache(CCacheStrategy *pCache, bool bDeleteCache) : CThread("Fil m_readPos = 0; m_writePos = 0; m_nSeekResult = 0; - m_chunkSize = 0; } CFileCache::~CFileCache() diff --git a/xbmc/filesystem/HTSPDirectory.cpp b/xbmc/filesystem/HTSPDirectory.cpp index 7a32250d35..95b58aec56 100644 --- a/xbmc/filesystem/HTSPDirectory.cpp +++ b/xbmc/filesystem/HTSPDirectory.cpp @@ -91,7 +91,7 @@ CHTSPDirectorySession* CHTSPDirectorySession::Acquire(const CURL& url) { CSingleLock lock(g_section); - for(SSessions::iterator it = g_sessions.begin(); it != g_sessions.end(); it++) + for(SSessions::iterator it = g_sessions.begin(); it != g_sessions.end(); ++it) { if(it->hostname == url.GetHostName() && it->port == url.GetPort() @@ -129,7 +129,7 @@ void CHTSPDirectorySession::Release(CHTSPDirectorySession* &session) return; CSingleLock lock(g_section); - for(SSessions::iterator it = g_sessions.begin(); it != g_sessions.end(); it++) + for(SSessions::iterator it = g_sessions.begin(); it != g_sessions.end(); ++it) { if(it->session == session) { @@ -156,7 +156,7 @@ void CHTSPDirectorySession::CheckIdle(DWORD idle) it = g_sessions.erase(it); } else - it++; + ++it; } } @@ -329,7 +329,7 @@ SChannels CHTSPDirectorySession::GetChannels(STag& tag) SChannels channels; std::vector<int>::iterator it; - for(it = tag.channels.begin(); it != tag.channels.end(); it++) + for(it = tag.channels.begin(); it != tag.channels.end(); ++it) { SChannels::iterator it2 = m_channels.find(*it); if(it2 == m_channels.end()) @@ -375,7 +375,7 @@ bool CHTSPDirectory::GetChannels( const CURL &base SEvent event; - for(SChannels::iterator it = channels.begin(); it != channels.end(); it++) + for(SChannels::iterator it = channels.begin(); it != channels.end(); ++it) { if(!m_session->GetEvent(event, it->second.event)) event.Clear(); @@ -439,7 +439,7 @@ bool CHTSPDirectory::GetDirectory(const CURL& url, CFileItemList &items) STags tags = m_session->GetTags(); std::string filename, label; - for(STags::iterator it = tags.begin(); it != tags.end(); it++) + for(STags::iterator it = tags.begin(); it != tags.end(); ++it) { filename = StringUtils::Format("tags/%d/", it->second.id); label = StringUtils::Format("Tag: %s", it->second.name.c_str()); diff --git a/xbmc/filesystem/ISOFile.cpp b/xbmc/filesystem/ISOFile.cpp index 00cac8b397..1ca560d31b 100644 --- a/xbmc/filesystem/ISOFile.cpp +++ b/xbmc/filesystem/ISOFile.cpp @@ -34,8 +34,9 @@ using namespace XFILE; ////////////////////////////////////////////////////////////////////// //********************************************************************************************* CISOFile::CISOFile() + : m_bOpened(false) + , m_hFile(INVALID_HANDLE_VALUE) { - m_bOpened = false; } //********************************************************************************************* diff --git a/xbmc/filesystem/Makefile.in b/xbmc/filesystem/Makefile.in index 144bebc4de..72b5126021 100644 --- a/xbmc/filesystem/Makefile.in +++ b/xbmc/filesystem/Makefile.in @@ -50,6 +50,8 @@ SRCS += MythFile.cpp SRCS += MythSession.cpp SRCS += NSFFileDirectory.cpp SRCS += OGGFileDirectory.cpp +SRCS += OverrideDirectory.cpp +SRCS += OverrideFile.cpp SRCS += PlaylistDirectory.cpp SRCS += PlaylistFileDirectory.cpp SRCS += PipeFile.cpp diff --git a/xbmc/filesystem/MultiPathFile.cpp b/xbmc/filesystem/MultiPathFile.cpp index 6cc7db9dd7..f2a567bc24 100644 --- a/xbmc/filesystem/MultiPathFile.cpp +++ b/xbmc/filesystem/MultiPathFile.cpp @@ -23,18 +23,15 @@ #include "utils/URIUtils.h" #include "URL.h" -using namespace XFILE; using namespace std; using namespace XFILE; CMultiPathFile::CMultiPathFile(void) -{ -} + : COverrideFile(false) +{ } CMultiPathFile::~CMultiPathFile(void) -{ - Close(); -} +{ } bool CMultiPathFile::Open(const CURL& url) { @@ -94,27 +91,7 @@ int CMultiPathFile::Stat(const CURL& url, struct __stat64* buffer) return -1; } -ssize_t CMultiPathFile::Read(void* lpBuf, size_t uiBufSize) -{ - return m_file.Read(lpBuf, uiBufSize); -} - -int64_t CMultiPathFile::Seek(int64_t iFilePosition, int iWhence /*=SEEK_SET*/) -{ - return m_file.Seek(iFilePosition, iWhence); -} - -void CMultiPathFile::Close() -{ - m_file.Close(); -} - -int64_t CMultiPathFile::GetPosition() -{ - return m_file.GetPosition(); -} - -int64_t CMultiPathFile::GetLength() +std::string CMultiPathFile::TranslatePath(const CURL& url) { - return m_file.GetLength(); + return url.Get(); } diff --git a/xbmc/filesystem/MultiPathFile.h b/xbmc/filesystem/MultiPathFile.h index 3d50537736..ecd5761c93 100644 --- a/xbmc/filesystem/MultiPathFile.h +++ b/xbmc/filesystem/MultiPathFile.h @@ -19,12 +19,11 @@ * */ -#include "File.h" -#include "IFile.h" +#include "filesystem/OverrideFile.h" namespace XFILE { - class CMultiPathFile: public IFile + class CMultiPathFile : public COverrideFile { public: CMultiPathFile(void); @@ -33,13 +32,7 @@ namespace XFILE virtual bool Exists(const CURL& url); virtual int Stat(const CURL& url, struct __stat64* buffer); - virtual ssize_t Read(void* lpBuf, size_t uiBufSize); - virtual int64_t Seek(int64_t iFilePosition, int iWhence = SEEK_SET); - virtual void Close(); - virtual int64_t GetPosition(); - virtual int64_t GetLength(); - protected: - CFile m_file; + virtual std::string TranslatePath(const CURL &url); }; } diff --git a/xbmc/filesystem/MythDirectory.h b/xbmc/filesystem/MythDirectory.h index 14bd263ad4..deeab322da 100644 --- a/xbmc/filesystem/MythDirectory.h +++ b/xbmc/filesystem/MythDirectory.h @@ -66,7 +66,6 @@ private: DllLibCMyth* m_dll; cmyth_database_t m_database; cmyth_recorder_t m_recorder; - cmyth_proginfo_t m_program; }; } diff --git a/xbmc/filesystem/MythSession.cpp b/xbmc/filesystem/MythSession.cpp index 19bef8b949..5c73aa57d5 100644 --- a/xbmc/filesystem/MythSession.cpp +++ b/xbmc/filesystem/MythSession.cpp @@ -67,7 +67,7 @@ void CMythSession::CheckIdle() } else { - it++; + ++it; } } } @@ -77,7 +77,7 @@ CMythSession* CMythSession::AquireSession(const CURL& url) CSingleLock lock(m_section_session); vector<CMythSession*>::iterator it; - for (it = m_sessions.begin(); it != m_sessions.end(); it++) + for (it = m_sessions.begin(); it != m_sessions.end(); ++it) { CMythSession* session = *it; if (session->CanSupport(url)) @@ -358,14 +358,15 @@ void CMythSession::SetSeasonAndEpisode(const cmyth_proginfo_t &program, int *sea return; } -CMythSession::CMythSession(const CURL& url) : CThread("MythSession") +CMythSession::CMythSession(const CURL& url) : CThread("MythSession"), + m_hostname(url.GetHostName()), + m_username(url.GetUserName() == "" ? MYTH_DEFAULT_USERNAME : url.GetUserName()), + m_password(url.GetPassWord() == "" ? MYTH_DEFAULT_PASSWORD : url.GetPassWord()) { m_control = NULL; m_event = NULL; m_database = NULL; - m_hostname = url.GetHostName(); - m_username = url.GetUserName() == "" ? MYTH_DEFAULT_USERNAME : url.GetUserName(); - m_password = url.GetPassWord() == "" ? MYTH_DEFAULT_PASSWORD : url.GetPassWord(); + m_listener = NULL; m_port = url.HasPort() ? url.GetPort() : MYTH_DEFAULT_PORT; m_timestamp = XbmcThreads::SystemClockMillis(); m_dll = new DllLibCMyth; diff --git a/xbmc/filesystem/NFSDirectory.cpp b/xbmc/filesystem/NFSDirectory.cpp index 50c9a87dff..c3d15666ae 100644 --- a/xbmc/filesystem/NFSDirectory.cpp +++ b/xbmc/filesystem/NFSDirectory.cpp @@ -57,7 +57,7 @@ bool CNFSDirectory::GetDirectoryFromExportList(const std::string& strPath, CFile std::list<std::string> exportList=gNfsConnection.GetExportList(url); std::list<std::string>::iterator it; - for(it=exportList.begin();it!=exportList.end();it++) + for(it=exportList.begin();it!=exportList.end();++it) { std::string currentExport(*it); URIUtils::RemoveSlashAtEnd(nonConstStrPath); diff --git a/xbmc/filesystem/NFSFile.cpp b/xbmc/filesystem/NFSFile.cpp index 610ace887f..9354fd5d5e 100644 --- a/xbmc/filesystem/NFSFile.cpp +++ b/xbmc/filesystem/NFSFile.cpp @@ -137,7 +137,7 @@ void CNfsConnection::clearMembers() void CNfsConnection::destroyOpenContexts() { CSingleLock lock(openContextLock); - for(tOpenContextMap::iterator it = m_openContextMap.begin();it!=m_openContextMap.end();it++) + for(tOpenContextMap::iterator it = m_openContextMap.begin();it!=m_openContextMap.end();++it) { m_pLibNfs->nfs_destroy_context(it->second.pContext); } @@ -258,7 +258,7 @@ bool CNfsConnection::splitUrlIntoExportAndPath(const CURL& url,std::string &expo std::list<std::string>::iterator it; - for(it=exportList.begin();it!=exportList.end();it++) + for(it=exportList.begin();it!=exportList.end();++it) { //if path starts with the current export path if(StringUtils::StartsWith(path, *it)) @@ -291,12 +291,11 @@ bool CNfsConnection::splitUrlIntoExportAndPath(const CURL& url,std::string &expo bool CNfsConnection::Connect(const CURL& url, std::string &relativePath) { CSingleLock lock(*this); - bool ret = false; int nfsRet = 0; std::string exportPath; resolveHost(url); - ret = splitUrlIntoExportAndPath(url, exportPath, relativePath); + bool ret = splitUrlIntoExportAndPath(url, exportPath, relativePath); if( (ret && (exportPath != m_exportPath || url.GetHostName() != m_hostName)) || @@ -374,7 +373,7 @@ void CNfsConnection::CheckIfIdle() { CSingleLock lock(keepAliveLock); //handle keep alive on opened files - for( tFileKeepAliveMap::iterator it = m_KeepAliveTimeouts.begin();it!=m_KeepAliveTimeouts.end();it++) + for( tFileKeepAliveMap::iterator it = m_KeepAliveTimeouts.begin();it!=m_KeepAliveTimeouts.end();++it) { if(it->second.refreshCounter > 0) { diff --git a/xbmc/filesystem/OverrideDirectory.cpp b/xbmc/filesystem/OverrideDirectory.cpp new file mode 100644 index 0000000000..52f32a6d2e --- /dev/null +++ b/xbmc/filesystem/OverrideDirectory.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2014 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "OverrideDirectory.h" +#include "URL.h" +#include "filesystem/Directory.h" + +using namespace XFILE; + + +COverrideDirectory::COverrideDirectory() +{ } + + +COverrideDirectory::~COverrideDirectory() +{ } + +bool COverrideDirectory::Create(const CURL& url) +{ + std::string translatedPath = TranslatePath(url); + + return CDirectory::Create(translatedPath.c_str()); +} + +bool COverrideDirectory::Remove(const CURL& url) +{ + std::string translatedPath = TranslatePath(url); + + return CDirectory::Remove(translatedPath.c_str()); +} + +bool COverrideDirectory::Exists(const CURL& url) +{ + std::string translatedPath = TranslatePath(url); + + return CDirectory::Exists(translatedPath.c_str()); +} diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecCC.h b/xbmc/filesystem/OverrideDirectory.h index 0c0265ae92..24ca502758 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecCC.h +++ b/xbmc/filesystem/OverrideDirectory.h @@ -1,7 +1,6 @@ #pragma once - /* - * Copyright (C) 2005-2013 Team XBMC + * Copyright (C) 2014 Team XBMC * http://xbmc.org * * This Program is free software; you can redistribute it and/or modify @@ -20,22 +19,21 @@ * */ -#include "DVDOverlayCodec.h" - -class CDVDOverlayText; +#include "filesystem/IDirectory.h" -class CDVDOverlayCodecCC : public CDVDOverlayCodec +namespace XFILE +{ +class COverrideDirectory : public IDirectory { public: - CDVDOverlayCodecCC(); - virtual ~CDVDOverlayCodecCC(); - virtual bool Open(CDVDStreamInfo &hints, CDVDCodecOptions &options); - virtual void Dispose(); - virtual int Decode(DemuxPacket *pPacket); - virtual void Reset(); - virtual void Flush(); - virtual CDVDOverlay* GetOverlay(); + COverrideDirectory(); + virtual ~COverrideDirectory(); + + virtual bool Create(const CURL& url); + virtual bool Exists(const CURL& url); + virtual bool Remove(const CURL& url); -private: - CDVDOverlayText* m_pCurrentOverlay; +protected: + virtual std::string TranslatePath(const CURL &url) = 0; }; +} diff --git a/xbmc/filesystem/OverrideFile.cpp b/xbmc/filesystem/OverrideFile.cpp new file mode 100644 index 0000000000..c8d8a39561 --- /dev/null +++ b/xbmc/filesystem/OverrideFile.cpp @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2014 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include <sys/stat.h> + +#include "OverrideFile.h" +#include "URL.h" + +using namespace XFILE; + + +COverrideFile::COverrideFile(bool writable) + : m_writable(writable) +{ } + + +COverrideFile::~COverrideFile() +{ + Close(); +} + +bool COverrideFile::Open(const CURL& url) +{ + std::string strFileName = TranslatePath(url); + + return m_file.Open(strFileName); +} + +bool COverrideFile::OpenForWrite(const CURL& url, bool bOverWrite /* = false */) +{ + if (!m_writable) + return false; + + std::string strFileName = TranslatePath(url); + + return m_file.OpenForWrite(strFileName, bOverWrite); +} + +bool COverrideFile::Delete(const CURL& url) +{ + if (!m_writable) + return false; + + std::string strFileName = TranslatePath(url); + + return m_file.Delete(strFileName); +} + +bool COverrideFile::Exists(const CURL& url) +{ + std::string strFileName = TranslatePath(url); + + return m_file.Exists(strFileName); +} + +int COverrideFile::Stat(const CURL& url, struct __stat64* buffer) +{ + std::string strFileName = TranslatePath(url); + + return m_file.Stat(strFileName, buffer); +} + +bool COverrideFile::Rename(const CURL& url, const CURL& urlnew) +{ + if (!m_writable) + return false; + + std::string strFileName = TranslatePath(url); + std::string strFileName2 = TranslatePath(urlnew); + + return m_file.Rename(strFileName, strFileName2); +} + +int COverrideFile::Stat(struct __stat64* buffer) +{ + return m_file.Stat(buffer); +} + +ssize_t COverrideFile::Read(void* lpBuf, size_t uiBufSize) +{ + return m_file.Read(lpBuf, uiBufSize); +} + +ssize_t COverrideFile::Write(const void* lpBuf, size_t uiBufSize) +{ + if (!m_writable) + return -1; + + return m_file.Write(lpBuf, uiBufSize); +} + +int64_t COverrideFile::Seek(int64_t iFilePosition, int iWhence /*=SEEK_SET*/) +{ + return m_file.Seek(iFilePosition, iWhence); +} + +void COverrideFile::Close() +{ + m_file.Close(); +} + +int64_t COverrideFile::GetPosition() +{ + return m_file.GetPosition(); +} + +int64_t COverrideFile::GetLength() +{ + return m_file.GetLength(); +} diff --git a/xbmc/filesystem/OverrideFile.h b/xbmc/filesystem/OverrideFile.h new file mode 100644 index 0000000000..cfa7274fc0 --- /dev/null +++ b/xbmc/filesystem/OverrideFile.h @@ -0,0 +1,54 @@ +#pragma once +/* + * Copyright (C) 2014 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "filesystem/File.h" +#include "filesystem/IFile.h" + +namespace XFILE +{ +class COverrideFile : public IFile +{ +public: + COverrideFile(bool writable); + virtual ~COverrideFile(); + + virtual bool Open(const CURL& url); + virtual bool Exists(const CURL& url); + virtual int Stat(const CURL& url, struct __stat64* buffer); + virtual int Stat(struct __stat64* buffer); + virtual bool OpenForWrite(const CURL& url, bool bOverWrite = false); + virtual bool Delete(const CURL& url); + virtual bool Rename(const CURL& url, const CURL& urlnew); + + virtual ssize_t Read(void* lpBuf, size_t uiBufSize); + virtual ssize_t Write(const void* lpBuf, size_t uiBufSize); + virtual int64_t Seek(int64_t iFilePosition, int iWhence = SEEK_SET); + virtual void Close(); + virtual int64_t GetPosition(); + virtual int64_t GetLength(); + +protected: + virtual std::string TranslatePath(const CURL &url) = 0; + + CFile m_file; + bool m_writable; +}; +} diff --git a/xbmc/filesystem/PVRDirectory.cpp b/xbmc/filesystem/PVRDirectory.cpp index 29f7693698..7680f58fba 100644 --- a/xbmc/filesystem/PVRDirectory.cpp +++ b/xbmc/filesystem/PVRDirectory.cpp @@ -118,5 +118,6 @@ bool CPVRDirectory::IsLiveTV(const std::string& strPath) bool CPVRDirectory::HasRecordings() { - return g_PVRRecordings->GetNumRecordings() > 0; + return g_PVRManager.IsStarted() ? + g_PVRRecordings->GetNumRecordings() > 0 : false; } diff --git a/xbmc/filesystem/PipeFile.cpp b/xbmc/filesystem/PipeFile.cpp index 9bbfe6cc0d..238753508f 100644 --- a/xbmc/filesystem/PipeFile.cpp +++ b/xbmc/filesystem/PipeFile.cpp @@ -214,7 +214,7 @@ void CPipeFile::RemoveListener(IPipeListener *l) if ( (*i) == l) i = m_listeners.erase(i); else - i++; + ++i; } } diff --git a/xbmc/filesystem/PipesManager.cpp b/xbmc/filesystem/PipesManager.cpp index e84fb08f25..2c8cc37fb8 100644 --- a/xbmc/filesystem/PipesManager.cpp +++ b/xbmc/filesystem/PipesManager.cpp @@ -257,7 +257,7 @@ void Pipe::RemoveListener(IPipeListener *l) if ( (*i) == l) i = m_listeners.erase(i); else - i++; + ++i; } } diff --git a/xbmc/filesystem/PluginDirectory.cpp b/xbmc/filesystem/PluginDirectory.cpp index fcc88cab8e..4237d6bf38 100644 --- a/xbmc/filesystem/PluginDirectory.cpp +++ b/xbmc/filesystem/PluginDirectory.cpp @@ -50,6 +50,9 @@ int CPluginDirectory::handleCounter = 0; CCriticalSection CPluginDirectory::m_handleLock; CPluginDirectory::CPluginDirectory() + : m_cancelled(false) + , m_success(false) + , m_totalItems(0) { m_listItems = new CFileItemList; m_fileResult = new CFileItem; @@ -499,10 +502,10 @@ bool CPluginDirectory::WaitOnScriptResult(const std::string &scriptPath, int scr if (progressBar) { progressBar->SetHeading(scriptName); - progressBar->SetLine(0, retrievingDir ? 1040 : 10214); + progressBar->SetLine(0, 10214); progressBar->SetLine(1, ""); progressBar->SetLine(2, ""); - progressBar->ShowProgressBar(retrievingDir); + progressBar->ShowProgressBar(false); progressBar->StartModal(); } } diff --git a/xbmc/filesystem/RTVFile.cpp b/xbmc/filesystem/RTVFile.cpp index e1dac313bf..26a50baaff 100644 --- a/xbmc/filesystem/RTVFile.cpp +++ b/xbmc/filesystem/RTVFile.cpp @@ -46,6 +46,7 @@ CRTVFile::CRTVFile() { m_filePos = 0; m_fileSize = 0; + m_iport = 0; m_bOpened = false; m_rtvd = NULL; } diff --git a/xbmc/filesystem/RarFile.cpp b/xbmc/filesystem/RarFile.cpp index 37e70e0726..d88a724638 100644 --- a/xbmc/filesystem/RarFile.cpp +++ b/xbmc/filesystem/RarFile.cpp @@ -43,7 +43,11 @@ using namespace std; #define SEEKTIMOUT 30000 #ifdef HAS_FILESYSTEM_RAR -CRarFileExtractThread::CRarFileExtractThread() : CThread("RarFileExtract"), hRunning(true), hQuit(true) +CRarFileExtractThread::CRarFileExtractThread() + : CThread("RarFileExtract") + , hRunning(true) + , hQuit(true) + , m_iSize(0) { m_pArc = NULL; m_pCmd = NULL; @@ -130,6 +134,9 @@ CRarFile::CRarFile() m_bUseFile = false; m_bOpen = false; m_bSeekable = true; + m_iFilePosition = 0; + m_iFileSize = 0; + m_iBufferStart = 0; } CRarFile::~CRarFile() @@ -550,7 +557,7 @@ void CRarFile::InitFromUrl(const CURL& url) m_bFileOptions = 0; - for( vector<std::string>::iterator it = options.begin();it != options.end(); it++) + for( vector<std::string>::iterator it = options.begin();it != options.end(); ++it) { size_t iEqual = (*it).find('='); if(iEqual != std::string::npos) @@ -645,11 +652,10 @@ bool CRarFile::OpenInArchive() AddEndSlash(m_pCmd->ExtrPath); // Set password for encrypted archives - if ((m_strPassword.size() > 0) && - (m_strPassword.size() < sizeof (m_pCmd->Password))) - { - strcpy(m_pCmd->Password, m_strPassword.c_str()); - } + if (m_strPassword.length() > MAXPASSWORD - 1) + CLog::Log(LOGWARNING,"OpenInArchive: Supplied password is too long %d", (int) m_strPassword.length()); + strncpy(m_pCmd->Password, m_strPassword.c_str(), sizeof (m_pCmd->Password) - 1); + m_pCmd->Password[sizeof (m_pCmd->Password) - 1] = 0; m_pCmd->ParseDone(); diff --git a/xbmc/filesystem/RarManager.cpp b/xbmc/filesystem/RarManager.cpp index 67972382b2..602e94af17 100644 --- a/xbmc/filesystem/RarManager.cpp +++ b/xbmc/filesystem/RarManager.cpp @@ -50,6 +50,7 @@ CFileInfo::CFileInfo() m_bAutoDel = true; m_iUsed = 0; m_iIsSeekable = -1; + m_iOffset = 0; } CFileInfo::~CFileInfo() @@ -225,7 +226,7 @@ bool CRarManager::CacheRarredFile(std::string& strPathInCache, const std::string if (iOffset == -1 && j != m_ExFiles.end()) // grab from list { - for( ArchiveList_struct* pIterator = j->second.first; pIterator ; pIterator ? pIterator = pIterator->next : NULL) + for( ArchiveList_struct* pIterator = j->second.first; pIterator; pIterator = pIterator->next) { std::string strName; @@ -325,7 +326,7 @@ bool CRarManager::GetFilesInRar(CFileItemList& vecpItems, const std::string& str std::string strCompare = strPathInRar; if (!URIUtils::HasSlashAtEnd(strCompare) && !strCompare.empty()) strCompare += '/'; - for( pIterator = pFileList; pIterator ; pIterator ? pIterator = pIterator->next : NULL) + for( pIterator = pFileList; pIterator ; pIterator = pIterator->next ) { std::string strName; @@ -460,7 +461,7 @@ void CRarManager::ClearCache(bool force) #ifdef HAS_FILESYSTEM_RAR CSingleLock lock(m_CritSection); map<std::string, pair<ArchiveList_struct*,vector<CFileInfo> > >::iterator j; - for (j = m_ExFiles.begin() ; j != m_ExFiles.end() ; j++) + for (j = m_ExFiles.begin() ; j != m_ExFiles.end() ; ++j) { for (vector<CFileInfo>::iterator it2 = j->second.second.begin(); it2 != j->second.second.end(); ++it2) diff --git a/xbmc/filesystem/SAPDirectory.cpp b/xbmc/filesystem/SAPDirectory.cpp index 065a947aec..d90663431c 100644 --- a/xbmc/filesystem/SAPDirectory.cpp +++ b/xbmc/filesystem/SAPDirectory.cpp @@ -332,7 +332,7 @@ bool CSAPSessions::ParseAnnounce(char* data, int len) } // check if we can find this session in our cache - for(std::vector<CSession>::iterator it = m_sessions.begin(); it != m_sessions.end(); it++) + for(std::vector<CSession>::iterator it = m_sessions.begin(); it != m_sessions.end(); ++it) { if(it->origin == header.origin && it->msgid == header.msgid @@ -496,7 +496,7 @@ namespace XFILE g_sapsessions.Create(); // check if we can find this session in our cache - for(std::vector<CSAPSessions::CSession>::iterator it = g_sapsessions.m_sessions.begin(); it != g_sapsessions.m_sessions.end(); it++) + for(std::vector<CSAPSessions::CSession>::iterator it = g_sapsessions.m_sessions.begin(); it != g_sapsessions.m_sessions.end(); ++it) { if(it->payload_type != "application/sdp") diff --git a/xbmc/filesystem/SAPFile.cpp b/xbmc/filesystem/SAPFile.cpp index 4633f4eed7..fe7b7f6106 100644 --- a/xbmc/filesystem/SAPFile.cpp +++ b/xbmc/filesystem/SAPFile.cpp @@ -37,6 +37,7 @@ using namespace XFILE; ////////////////////////////////////////////////////////////////////// CSAPFile::CSAPFile() + : m_len(0) {} CSAPFile::~CSAPFile() @@ -48,7 +49,7 @@ bool CSAPFile::Open(const CURL& url) std::string path = url.Get(); CSingleLock lock(g_sapsessions.m_section); - for(vector<CSAPSessions::CSession>::iterator it = g_sapsessions.m_sessions.begin(); it != g_sapsessions.m_sessions.end(); it++) + for(vector<CSAPSessions::CSession>::iterator it = g_sapsessions.m_sessions.begin(); it != g_sapsessions.m_sessions.end(); ++it) { if(it->path == path) { @@ -69,7 +70,7 @@ bool CSAPFile::Exists(const CURL& url) std::string path = url.Get(); CSingleLock lock(g_sapsessions.m_section); - for(vector<CSAPSessions::CSession>::iterator it = g_sapsessions.m_sessions.begin(); it != g_sapsessions.m_sessions.end(); it++) + for(vector<CSAPSessions::CSession>::iterator it = g_sapsessions.m_sessions.begin(); it != g_sapsessions.m_sessions.end(); ++it) { if(it->path == path) return true; @@ -93,7 +94,7 @@ int CSAPFile::Stat(const CURL& url, struct __stat64* buffer) CSingleLock lock(g_sapsessions.m_section); - for(vector<CSAPSessions::CSession>::iterator it = g_sapsessions.m_sessions.begin(); it != g_sapsessions.m_sessions.end(); it++) + for(vector<CSAPSessions::CSession>::iterator it = g_sapsessions.m_sessions.begin(); it != g_sapsessions.m_sessions.end(); ++it) { if(it->path == path) { @@ -163,7 +164,7 @@ bool CSAPFile::Delete(const CURL& url) std::string path = url.Get(); CSingleLock lock(g_sapsessions.m_section); - for(vector<CSAPSessions::CSession>::iterator it = g_sapsessions.m_sessions.begin(); it != g_sapsessions.m_sessions.end(); it++) + for(vector<CSAPSessions::CSession>::iterator it = g_sapsessions.m_sessions.begin(); it != g_sapsessions.m_sessions.end(); ++it) { if(it->path == path) { diff --git a/xbmc/filesystem/SFTPFile.cpp b/xbmc/filesystem/SFTPFile.cpp index 5b5ad10970..363ba9ce13 100644 --- a/xbmc/filesystem/SFTPFile.cpp +++ b/xbmc/filesystem/SFTPFile.cpp @@ -48,7 +48,7 @@ using namespace XFILE; using namespace std; -static std::string CorrectPath(const std::string path) +static std::string CorrectPath(const std::string& path) { if (path == "~") return "./"; @@ -245,17 +245,15 @@ bool CSFTPSession::GetDirectory(const std::string &base, const std::string &fold bool CSFTPSession::DirectoryExists(const char *path) { - bool exists = false; uint32_t permissions = 0; - exists = GetItemPermissions(path, permissions); + bool exists = GetItemPermissions(path, permissions); return exists && S_ISDIR(permissions); } bool CSFTPSession::FileExists(const char *path) { - bool exists = false; uint32_t permissions = 0; - exists = GetItemPermissions(path, permissions); + bool exists = GetItemPermissions(path, permissions); return exists && S_ISREG(permissions); } @@ -435,11 +433,19 @@ bool CSFTPSession::Connect(const std::string &host, unsigned int port, const std return false; } +#if LIBSSH_VERSION_MINOR >= 6 + int method = ssh_userauth_list(m_session, NULL); +#else int method = ssh_auth_list(m_session); +#endif // Try to authenticate with public key first int publicKeyAuth = SSH_AUTH_DENIED; +#if LIBSSH_VERSION_MINOR >= 6 + if (method & SSH_AUTH_METHOD_PUBLICKEY && (publicKeyAuth = ssh_userauth_publickey_auto(m_session, NULL, NULL)) == SSH_AUTH_ERROR) +#else if (method & SSH_AUTH_METHOD_PUBLICKEY && (publicKeyAuth = ssh_userauth_autopubkey(m_session, NULL)) == SSH_AUTH_ERROR) +#endif { CLog::Log(LOGERROR, "SFTPSession: Failed to authenticate via publickey '%s'", ssh_get_error(m_session)); return false; @@ -566,7 +572,7 @@ void CSFTPSessionManager::ClearOutIdleSessions() if (iter->second->IsIdle()) sessions.erase(iter++); else - iter++; + ++iter; } } diff --git a/xbmc/filesystem/SMBDirectory.cpp b/xbmc/filesystem/SMBDirectory.cpp index 026bd02b65..29951c83b2 100644 --- a/xbmc/filesystem/SMBDirectory.cpp +++ b/xbmc/filesystem/SMBDirectory.cpp @@ -44,12 +44,6 @@ #include <libsmbclient.h> -#if defined(TARGET_DARWIN) -#define XBMC_SMB_MOUNT_PATH "Library/Application Support/Kodi/Mounts/" -#else -#define XBMC_SMB_MOUNT_PATH "/media/kodi/smb/" -#endif - struct CachedDirEntry { unsigned int type; @@ -285,7 +279,6 @@ int CSMBDirectory::OpenDir(const CURL& url, std::string& strAuth) bool CSMBDirectory::Create(const CURL& url2) { - bool success = true; CSingleLock lock(smb); smb.Init(); @@ -294,7 +287,7 @@ bool CSMBDirectory::Create(const CURL& url2) std::string strFileName = smb.URLEncode(url); int result = smbc_mkdir(strFileName.c_str(), 0); - success = (result == 0 || EEXIST == errno); + bool success = (result == 0 || EEXIST == errno); if(!success) CLog::Log(LOGERROR, "%s - Error( %s )", __FUNCTION__, strerror(errno)); @@ -337,87 +330,3 @@ bool CSMBDirectory::Exists(const CURL& url2) return S_ISDIR(info.st_mode); } -std::string CSMBDirectory::MountShare(const std::string &smbPath, const std::string &strType, const std::string &strName, - const std::string &strUser, const std::string &strPass) -{ - UnMountShare(strType, strName); - - std::string strMountPoint = GetMountPoint(strType, strName); - -#if defined(TARGET_DARWIN) - // Create the directory. - strMountPoint = CURL::Decode(strMountPoint); - CreateDirectory(strMountPoint.c_str(), NULL); - - // Massage the path. - std::string smbFullPath = "//"; - if (smbFullPath.length() > 0) - { - smbFullPath += strUser; - if (strPass.length() > 0) - smbFullPath += ":" + strPass; - - smbFullPath += "@"; - } - - std::string newPath = smbPath; - StringUtils::TrimLeft(newPath, "/"); - smbFullPath += newPath; - - // Make the mount command. - vector<string> args; - args.push_back("/sbin/mount_smbfs"); - args.push_back("-o"); - args.push_back("nobrowse"); - args.push_back(smbFullPath); - args.push_back(strMountPoint); - - // Execute it. - if (CUtil::Command(args)) - return strMountPoint; -#else - CUtil::SudoCommand("mkdir -p " + strMountPoint); - - std::string strCmd = "mount -t cifs " + smbPath + " " + strMountPoint + - " -o rw,nobrl,directio"; - if (!strUser.empty()) - strCmd += ",user=" + strUser + ",password=" + strPass; - else - strCmd += ",guest"; - - if (CUtil::SudoCommand(strCmd)) - return strMountPoint; -#endif - return ""; -} - -void CSMBDirectory::UnMountShare(const std::string &strType, const std::string &strName) -{ -#if defined(TARGET_DARWIN) - // Decode the path. - std::string strMountPoint(CURL::Decode(GetMountPoint(strType, strName))); - - // Make the unmount command. - vector<string> args; - args.push_back("/sbin/umount"); - args.push_back(strMountPoint); - - // Execute command. - CUtil::Command(args); -#else - std::string strCmd = "umount " + GetMountPoint(strType, strName); - CUtil::SudoCommand(strCmd); -#endif -} - -std::string CSMBDirectory::GetMountPoint(const std::string &strType, const std::string &strName) -{ - std::string strPath(CURL::Encode(strType + strName)); - -#if defined(TARGET_DARWIN) - std::string str = getenv("HOME"); - return str + "/" + XBMC_SMB_MOUNT_PATH + strPath; -#else - return XBMC_SMB_MOUNT_PATH + strPath; -#endif -} diff --git a/xbmc/filesystem/SMBDirectory.h b/xbmc/filesystem/SMBDirectory.h index 896523fb03..97cb136961 100644 --- a/xbmc/filesystem/SMBDirectory.h +++ b/xbmc/filesystem/SMBDirectory.h @@ -38,15 +38,6 @@ public: int Open(const CURL &url); - //MountShare will try to mount the smb share and return the path to the mount point (or empty string if failed) - static std::string MountShare(const std::string &smbPath, const std::string &strType, const std::string &strName, - const std::string &strUser, const std::string &strPass); - - static void UnMountShare(const std::string &strType, const std::string &strName); - static std::string GetMountPoint(const std::string &strType, const std::string &strName); - - static bool MountShare(const std::string &strType, CMediaSource &share); - private: int OpenDir(const CURL &url, std::string& strAuth); }; diff --git a/xbmc/filesystem/SMBFile.cpp b/xbmc/filesystem/SMBFile.cpp index 35c6dc5d4b..603f99d2a5 100644 --- a/xbmc/filesystem/SMBFile.cpp +++ b/xbmc/filesystem/SMBFile.cpp @@ -60,6 +60,10 @@ CSMB::CSMB() { m_IdleTimeout = 0; m_context = NULL; +#ifdef TARGET_POSIX + m_OpenConnections = 0; + m_IdleTimeout = 0; +#endif } CSMB::~CSMB() @@ -204,7 +208,7 @@ std::string CSMB::URLEncode(const CURL &url) std::vector<std::string> parts; std::vector<std::string>::iterator it; StringUtils::Tokenize(url.GetFileName(), parts, "/"); - for( it = parts.begin(); it != parts.end(); it++ ) + for( it = parts.begin(); it != parts.end(); ++it ) { flat += "/"; flat += URLEncode((*it)); diff --git a/xbmc/filesystem/ShoutcastFile.cpp b/xbmc/filesystem/ShoutcastFile.cpp index 4ed46bbc94..472f3ed83e 100644 --- a/xbmc/filesystem/ShoutcastFile.cpp +++ b/xbmc/filesystem/ShoutcastFile.cpp @@ -48,6 +48,7 @@ CShoutcastFile::CShoutcastFile() : m_buffer = NULL; m_cacheReader = NULL; m_tagPos = 0; + m_metaint = 0; } CShoutcastFile::~CShoutcastFile() diff --git a/xbmc/filesystem/SmartPlaylistDirectory.cpp b/xbmc/filesystem/SmartPlaylistDirectory.cpp index 9e86466def..a872c30c8d 100644 --- a/xbmc/filesystem/SmartPlaylistDirectory.cpp +++ b/xbmc/filesystem/SmartPlaylistDirectory.cpp @@ -82,7 +82,7 @@ namespace XFILE // get all virtual folders and add them to the item list playlist.GetVirtualFolders(virtualFolders); - for (std::vector<std::string>::const_iterator virtualFolder = virtualFolders.begin(); virtualFolder != virtualFolders.end(); virtualFolder++) + for (std::vector<std::string>::const_iterator virtualFolder = virtualFolders.begin(); virtualFolder != virtualFolders.end(); ++virtualFolder) { CFileItemPtr pItem = CFileItemPtr(new CFileItem(*virtualFolder, true)); IFileDirectory *dir = CFileDirectoryFactory::Create(pItem->GetURL(), pItem.get()); diff --git a/xbmc/filesystem/SpecialProtocolDirectory.cpp b/xbmc/filesystem/SpecialProtocolDirectory.cpp index 31c924e434..39f8bd258b 100644 --- a/xbmc/filesystem/SpecialProtocolDirectory.cpp +++ b/xbmc/filesystem/SpecialProtocolDirectory.cpp @@ -54,20 +54,7 @@ bool CSpecialProtocolDirectory::GetDirectory(const CURL& url, CFileItemList &ite return false; } -bool CSpecialProtocolDirectory::Create(const CURL& url) +std::string CSpecialProtocolDirectory::TranslatePath(const CURL &url) { - std::string translatedPath = CSpecialProtocol::TranslatePath(url); - return CDirectory::Create(translatedPath.c_str()); -} - -bool CSpecialProtocolDirectory::Remove(const CURL& url) -{ - std::string translatedPath = CSpecialProtocol::TranslatePath(url); - return CDirectory::Remove(translatedPath.c_str()); -} - -bool CSpecialProtocolDirectory::Exists(const CURL& url) -{ - std::string translatedPath = CSpecialProtocol::TranslatePath(url); - return CDirectory::Exists(translatedPath.c_str()); + return CSpecialProtocol::TranslatePath(url); } diff --git a/xbmc/filesystem/SpecialProtocolDirectory.h b/xbmc/filesystem/SpecialProtocolDirectory.h index 64208011f2..327e44087f 100644 --- a/xbmc/filesystem/SpecialProtocolDirectory.h +++ b/xbmc/filesystem/SpecialProtocolDirectory.h @@ -19,18 +19,18 @@ * */ -#include "IDirectory.h" +#include "filesystem/OverrideDirectory.h" namespace XFILE { - class CSpecialProtocolDirectory : public IDirectory + class CSpecialProtocolDirectory : public COverrideDirectory { public: CSpecialProtocolDirectory(void); virtual ~CSpecialProtocolDirectory(void); virtual bool GetDirectory(const CURL& url, CFileItemList &items); - virtual bool Create(const CURL& url); - virtual bool Exists(const CURL& url); - virtual bool Remove(const CURL& url); + + protected: + virtual std::string TranslatePath(const CURL &url); }; } diff --git a/xbmc/filesystem/SpecialProtocolFile.cpp b/xbmc/filesystem/SpecialProtocolFile.cpp index f72bbb04a8..0a59dc3e24 100644 --- a/xbmc/filesystem/SpecialProtocolFile.cpp +++ b/xbmc/filesystem/SpecialProtocolFile.cpp @@ -19,99 +19,19 @@ */ #include "SpecialProtocolFile.h" -#include "SpecialProtocol.h" #include "URL.h" - -#include <sys/stat.h> +#include "filesystem/SpecialProtocol.h" using namespace XFILE; CSpecialProtocolFile::CSpecialProtocolFile(void) -{ -} + : COverrideFile(true) +{ } CSpecialProtocolFile::~CSpecialProtocolFile(void) -{ - Close(); -} - -bool CSpecialProtocolFile::Open(const CURL& url) -{ - std::string strFileName=CSpecialProtocol::TranslatePath(url); - - return m_file.Open(strFileName); -} - -bool CSpecialProtocolFile::OpenForWrite(const CURL& url, bool bOverWrite /*=false */) -{ - std::string strFileName=CSpecialProtocol::TranslatePath(url); - - return m_file.OpenForWrite(strFileName,bOverWrite); -} - -bool CSpecialProtocolFile::Delete(const CURL& url) -{ - std::string strFileName=CSpecialProtocol::TranslatePath(url); - - return m_file.Delete(strFileName); -} - -bool CSpecialProtocolFile::Exists(const CURL& url) -{ - std::string strFileName=CSpecialProtocol::TranslatePath(url); - - return m_file.Exists(strFileName); -} - -int CSpecialProtocolFile::Stat(const CURL& url, struct __stat64* buffer) -{ - std::string strFileName=CSpecialProtocol::TranslatePath(url); - - return m_file.Stat(strFileName, buffer); -} +{ } -bool CSpecialProtocolFile::Rename(const CURL& url, const CURL& urlnew) +std::string CSpecialProtocolFile::TranslatePath(const CURL& url) { - std::string strFileName=CSpecialProtocol::TranslatePath(url); - std::string strFileName2=CSpecialProtocol::TranslatePath(urlnew); - - return m_file.Rename(strFileName,strFileName2); -} - -int CSpecialProtocolFile::Stat(struct __stat64* buffer) -{ - return m_file.Stat(buffer); -} - -ssize_t CSpecialProtocolFile::Read(void* lpBuf, size_t uiBufSize) -{ - return m_file.Read(lpBuf, uiBufSize); -} - -ssize_t CSpecialProtocolFile::Write(const void* lpBuf, size_t uiBufSize) -{ - return m_file.Write(lpBuf,uiBufSize); -} - -int64_t CSpecialProtocolFile::Seek(int64_t iFilePosition, int iWhence /*=SEEK_SET*/) -{ - return m_file.Seek(iFilePosition, iWhence); + return CSpecialProtocol::TranslatePath(url); } - -void CSpecialProtocolFile::Close() -{ - m_file.Close(); -} - -int64_t CSpecialProtocolFile::GetPosition() -{ - return m_file.GetPosition(); -} - -int64_t CSpecialProtocolFile::GetLength() -{ - return m_file.GetLength(); -} - - - diff --git a/xbmc/filesystem/SpecialProtocolFile.h b/xbmc/filesystem/SpecialProtocolFile.h index 680c4a7572..40fdcb9aac 100644 --- a/xbmc/filesystem/SpecialProtocolFile.h +++ b/xbmc/filesystem/SpecialProtocolFile.h @@ -19,32 +19,17 @@ * */ -#include "File.h" -#include "IFile.h" +#include "filesystem/OverrideFile.h" namespace XFILE { -class CSpecialProtocolFile : public IFile +class CSpecialProtocolFile : public COverrideFile { public: CSpecialProtocolFile(void); virtual ~CSpecialProtocolFile(void); - virtual bool Open(const CURL& url); - virtual bool Exists(const CURL& url); - virtual int Stat(const CURL& url, struct __stat64* buffer); - virtual int Stat(struct __stat64* buffer); - virtual bool OpenForWrite(const CURL& url, bool bOverWrite = false); - virtual bool Delete(const CURL& url); - virtual bool Rename(const CURL& url, const CURL& urlnew); - - virtual ssize_t Read(void* lpBuf, size_t uiBufSize); - virtual ssize_t Write(const void* lpBuf, size_t uiBufSize); - virtual int64_t Seek(int64_t iFilePosition, int iWhence = SEEK_SET); - virtual void Close(); - virtual int64_t GetPosition(); - virtual int64_t GetLength(); protected: - CFile m_file; + virtual std::string TranslatePath(const CURL& url); }; } diff --git a/xbmc/filesystem/StackDirectory.cpp b/xbmc/filesystem/StackDirectory.cpp index 095c1749b6..6772ced3dc 100644 --- a/xbmc/filesystem/StackDirectory.cpp +++ b/xbmc/filesystem/StackDirectory.cpp @@ -65,12 +65,12 @@ namespace XFILE vector<std::string>::const_iterator itRegExp = strRegExps.begin(); while (itRegExp != strRegExps.end()) { - tempRE.RegComp(*itRegExp); + (void)tempRE.RegComp(*itRegExp); if (tempRE.GetCaptureTotal() == 4) RegExps.push_back(tempRE); else CLog::Log(LOGERROR, "Invalid video stack RE (%s). Must have exactly 4 captures.", itRegExp->c_str()); - itRegExp++; + ++itRegExp; } return GetStackedTitlePath(strPath, RegExps); } @@ -147,7 +147,7 @@ namespace XFILE } } offset = 0; - itRegExp++; + ++itRegExp; } if (!strCommonDir.empty() && !strStackTitle.empty()) strStackTitlePath = strCommonDir + strStackTitle; @@ -188,7 +188,7 @@ namespace XFILE return false; // because " , " is used as a seperator any "," in the real paths are double escaped - for (vector<std::string>::iterator itPath = vecPaths.begin(); itPath != vecPaths.end(); itPath++) + for (vector<std::string>::iterator itPath = vecPaths.begin(); itPath != vecPaths.end(); ++itPath) StringUtils::Replace(*itPath, ",,", ","); return true; diff --git a/xbmc/filesystem/TuxBoxDirectory.cpp b/xbmc/filesystem/TuxBoxDirectory.cpp index c86e3a28c4..c33906b130 100644 --- a/xbmc/filesystem/TuxBoxDirectory.cpp +++ b/xbmc/filesystem/TuxBoxDirectory.cpp @@ -194,7 +194,7 @@ void CTuxBoxDirectory::GetRootAndChildStringEnigma2(std::string& strBQRequest, s strXMLChildString = StringUtils::Format("e2bouquet"); } -bool CTuxBoxDirectory::GetRootAndChildString(const std::string strPath, std::string& strBQRequest, std::string& strXMLRootString, std::string& strXMLChildString ) +bool CTuxBoxDirectory::GetRootAndChildString(const std::string& strPath, std::string& strBQRequest, std::string& strXMLRootString, std::string& strXMLChildString ) { //Advanced Settings: RootMode! Movies: if(g_advancedSettings.m_iTuxBoxDefaultRootMenu == 3) //Movies! Fixed-> mode=3&submode=4 diff --git a/xbmc/filesystem/TuxBoxDirectory.h b/xbmc/filesystem/TuxBoxDirectory.h index 9ef62c707f..ce3173a7fd 100644 --- a/xbmc/filesystem/TuxBoxDirectory.h +++ b/xbmc/filesystem/TuxBoxDirectory.h @@ -36,7 +36,7 @@ namespace XFILE virtual bool AllowAll() const { return true; } virtual DIR_CACHE_TYPE GetCacheType(const CURL& url) const { return DIR_CACHE_ALWAYS; }; private: - bool GetRootAndChildString(const std::string strPath, std::string& strBQRequest, std::string& strXMLRootString, std::string& strXMLChildString ); + bool GetRootAndChildString(const std::string& strPath, std::string& strBQRequest, std::string& strXMLRootString, std::string& strXMLChildString ); void GetRootAndChildStringEnigma2(std::string& strBQRequest, std::string& strXMLRootString, std::string& strXMLChildString ); }; } diff --git a/xbmc/filesystem/UDFFile.cpp b/xbmc/filesystem/UDFFile.cpp index c72bb0ff17..138c1388f8 100644 --- a/xbmc/filesystem/UDFFile.cpp +++ b/xbmc/filesystem/UDFFile.cpp @@ -36,8 +36,9 @@ using namespace XFILE; ////////////////////////////////////////////////////////////////////// //********************************************************************************************* CUDFFile::CUDFFile() + : m_bOpened(false) + , m_hFile(INVALID_HANDLE_VALUE) { - m_bOpened = false; } //********************************************************************************************* diff --git a/xbmc/filesystem/UPnPDirectory.cpp b/xbmc/filesystem/UPnPDirectory.cpp index 9f2c5b7a6b..d80d13c18f 100644 --- a/xbmc/filesystem/UPnPDirectory.cpp +++ b/xbmc/filesystem/UPnPDirectory.cpp @@ -343,7 +343,7 @@ CUPnPDirectory::GetDirectory(const CURL& url, CFileItemList &items) NPT_String max_string = ""; int max_count = 0; - for(std::map<NPT_String, int>::iterator it = classes.begin(); it != classes.end(); it++) + for(std::map<NPT_String, int>::iterator it = classes.begin(); it != classes.end(); ++it) { if(it->second > max_count) { diff --git a/xbmc/filesystem/VTPDirectory.cpp b/xbmc/filesystem/VTPDirectory.cpp index c67f3fe0e6..0e294e13df 100644 --- a/xbmc/filesystem/VTPDirectory.cpp +++ b/xbmc/filesystem/VTPDirectory.cpp @@ -46,7 +46,7 @@ bool CVTPDirectory::GetChannels(const std::string& base, CFileItemList &items) return false; vector<CVTPSession::Channel>::iterator it; - for(it = channels.begin(); it != channels.end(); it++) + for(it = channels.begin(); it != channels.end(); ++it) { CFileItemPtr item(new CFileItem("", false)); diff --git a/xbmc/filesystem/VTPSession.cpp b/xbmc/filesystem/VTPSession.cpp index 9956c2272b..cce190cb35 100644 --- a/xbmc/filesystem/VTPSession.cpp +++ b/xbmc/filesystem/VTPSession.cpp @@ -367,7 +367,7 @@ bool CVTPSession::GetChannels(std::vector<Channel> &channels) if(!SendCommand("LSTC", code, lines)) return false; - for(std::vector<std::string>::iterator it = lines.begin(); it != lines.end(); it++) + for(std::vector<std::string>::iterator it = lines.begin(); it != lines.end(); ++it) { std::string& data(*it); size_t space, colon; diff --git a/xbmc/filesystem/ZipFile.cpp b/xbmc/filesystem/ZipFile.cpp index 7cc9c1d517..614b20fa5e 100644 --- a/xbmc/filesystem/ZipFile.cpp +++ b/xbmc/filesystem/ZipFile.cpp @@ -347,10 +347,10 @@ ssize_t CZipFile::Read(void* lpBuf, size_t uiBufSize) { if (uiBufSize+m_iFilePos > mZipItem.csize) uiBufSize = mZipItem.csize-m_iFilePos; - if (uiBufSize < 0) - { + + if (uiBufSize == 0) return 0; // we are past eof, this shouldn't happen but test anyway - } + ssize_t iResult = mFile.Read(lpBuf,uiBufSize); if (iResult < 0) return -1; diff --git a/xbmc/filesystem/iso9660.cpp b/xbmc/filesystem/iso9660.cpp index c39f07c732..fbe34b20e1 100644 --- a/xbmc/filesystem/iso9660.cpp +++ b/xbmc/filesystem/iso9660.cpp @@ -227,14 +227,20 @@ struct iso_dirtree *iso9660::ReadRecursiveDirFromSector( DWORD sector, const cha } m_lastpath->next = ( struct iso_directories *)malloc( sizeof( struct iso_directories ) ); if (!m_lastpath->next ) + { + free(pCurr_dir_cache); return NULL; + } m_lastpath = m_lastpath->next; m_lastpath->next = NULL; m_lastpath->dir = pDir; m_lastpath->path = (char *)malloc(strlen(path) + 1); if (!m_lastpath->path ) + { + free(pCurr_dir_cache); return NULL; + } strcpy( m_lastpath->path, path ); @@ -291,12 +297,18 @@ struct iso_dirtree *iso9660::ReadRecursiveDirFromSector( DWORD sector, const cha pFile_Pointer->dirpointer = NULL; pFile_Pointer->path = (char *)malloc(strlen(path) + 1); if (!pFile_Pointer->path) + { + free(pCurr_dir_cache); return NULL; + } strcpy( pFile_Pointer->path, path ); pFile_Pointer->name = (char *)malloc( temp_text.length() + 1); if (!pFile_Pointer->name) + { + free(pCurr_dir_cache); return NULL; + } strcpy( pFile_Pointer->name , temp_text.c_str()); #ifdef _DEBUG_OUTPUT diff --git a/xbmc/filesystem/udf25.cpp b/xbmc/filesystem/udf25.cpp index fdbda46221..c5f7b268ba 100644 --- a/xbmc/filesystem/udf25.cpp +++ b/xbmc/filesystem/udf25.cpp @@ -848,7 +848,7 @@ int udf25::UDFMapICB( struct AD ICB, struct Partition *partition, struct FileAD return 0; } -int udf25::UDFScanDir( struct FileAD Dir, char *FileName, struct Partition *partition, struct AD *FileICB, int cache_file_info) +int udf25::UDFScanDir(const struct FileAD& Dir, char *FileName, struct Partition *partition, struct AD *FileICB, int cache_file_info) { char filename[ MAX_UDF_FILE_NAME_LEN ]; uint8_t directory_base[ 2 * DVD_VIDEO_LB_LEN + 2048]; @@ -934,11 +934,12 @@ int udf25::UDFScanDir( struct FileAD Dir, char *FileName, struct Partition *part return 0; p = 0; - while( p < Dir.AD_chain[0].Length ) { + uint32_t l = Dir.AD_chain[0].Length; + while (p < l) { if( p > DVD_VIDEO_LB_LEN ) { ++lbnum; p -= DVD_VIDEO_LB_LEN; - Dir.AD_chain[0].Length -= DVD_VIDEO_LB_LEN; + l -= DVD_VIDEO_LB_LEN; if( DVDReadLBUDF( lbnum, 2, directory, 0 ) <= 0 ) { return 0; } diff --git a/xbmc/filesystem/udf25.h b/xbmc/filesystem/udf25.h index c3a45f3cc7..1ee5cd81d6 100644 --- a/xbmc/filesystem/udf25.h +++ b/xbmc/filesystem/udf25.h @@ -217,7 +217,7 @@ private: int DVDReadLBUDF( uint32_t lb_number, size_t block_count, unsigned char *data, int encrypted ); int ReadAt( int64_t pos, size_t len, unsigned char *data ); int UDFMapICB( struct AD ICB, struct Partition *partition, struct FileAD *File ); - int UDFScanDir( struct FileAD Dir, char *FileName, struct Partition *partition, struct AD *FileICB, int cache_file_info); + int UDFScanDir( const struct FileAD& Dir, char *FileName, struct Partition *partition, struct AD *FileICB, int cache_file_info); int SetUDFCache(UDFCacheType type, uint32_t nr, void *data); protected: /* Filesystem cache */ diff --git a/xbmc/guilib/D3DResource.cpp b/xbmc/guilib/D3DResource.cpp index f811c497a9..24b920937f 100644 --- a/xbmc/guilib/D3DResource.cpp +++ b/xbmc/guilib/D3DResource.cpp @@ -226,7 +226,7 @@ CD3DEffect::~CD3DEffect() Release(); } -bool CD3DEffect::Create(const CStdString &effectString, DefinesMap* defines) +bool CD3DEffect::Create(const std::string &effectString, DefinesMap* defines) { Release(); m_effectString = effectString; @@ -335,12 +335,12 @@ bool CD3DEffect::CreateEffect() definemacros.back().Name = 0; definemacros.back().Definition = 0; - hr = D3DXCreateEffect(g_Windowing.Get3DDevice(), m_effectString, m_effectString.length(), &definemacros[0], NULL, 0, NULL, &m_effect, &pError ); + hr = D3DXCreateEffect(g_Windowing.Get3DDevice(), m_effectString.c_str(), m_effectString.length(), &definemacros[0], NULL, 0, NULL, &m_effect, &pError ); if(hr == S_OK) return true; else if(pError) { - CStdString error; + std::string error; error.assign((const char*)pError->GetBufferPointer(), pError->GetBufferSize()); CLog::Log(LOGERROR, "CD3DEffect::CreateEffect(): %s", error.c_str()); } diff --git a/xbmc/guilib/D3DResource.h b/xbmc/guilib/D3DResource.h index 7e21dbd275..1004ba611f 100644 --- a/xbmc/guilib/D3DResource.h +++ b/xbmc/guilib/D3DResource.h @@ -21,7 +21,7 @@ #pragma once #ifdef HAS_DX -#include "utils/StdString.h" +#include <string> #include <map> class ID3DResource @@ -82,14 +82,14 @@ private: BYTE* m_data; }; -typedef std::map<CStdString, CStdString> DefinesMap; +typedef std::map<std::string, std::string> DefinesMap; class CD3DEffect : public ID3DResource { public: CD3DEffect(); virtual ~CD3DEffect(); - bool Create(const CStdString &effectString, DefinesMap* defines); + bool Create(const std::string &effectString, DefinesMap* defines); void Release(); bool SetFloatArray(D3DXHANDLE handle, const float* val, unsigned int count); bool SetMatrix(D3DXHANDLE handle, const D3DXMATRIX* mat); @@ -108,7 +108,7 @@ public: virtual void OnResetDevice(); private: bool CreateEffect(); - CStdString m_effectString; + std::string m_effectString; ID3DXEffect *m_effect; DefinesMap m_defines; }; diff --git a/xbmc/guilib/DDSImage.cpp b/xbmc/guilib/DDSImage.cpp index 80f422a244..e9800a0e47 100644 --- a/xbmc/guilib/DDSImage.cpp +++ b/xbmc/guilib/DDSImage.cpp @@ -20,7 +20,7 @@ #include "DDSImage.h" #include "XBTF.h" -#include "libsquish/squish.h" +#include <squish.h> #include "utils/log.h" #include <string.h> diff --git a/xbmc/guilib/GUIAction.cpp b/xbmc/guilib/GUIAction.cpp index f3ffeaff28..360e7e182f 100644 --- a/xbmc/guilib/GUIAction.cpp +++ b/xbmc/guilib/GUIAction.cpp @@ -41,7 +41,7 @@ bool CGUIAction::ExecuteActions(int controlID, int parentID) const { if (m_actions.size() == 0) return false; // take a copy of actions that satisfy our conditions - vector<CStdString> actions; + vector<std::string> actions; for (ciActions it = m_actions.begin() ; it != m_actions.end() ; ++it) { if (it->condition.empty() || g_infoManager.EvaluateBool(it->condition)) @@ -52,7 +52,7 @@ bool CGUIAction::ExecuteActions(int controlID, int parentID) const } // execute them bool retval = false; - for (vector<CStdString>::iterator i = actions.begin(); i != actions.end(); ++i) + for (vector<std::string>::iterator i = actions.begin(); i != actions.end(); ++i) { CGUIMessage msg(GUI_MSG_EXECUTE, controlID, parentID); msg.SetStringParam(*i); @@ -81,7 +81,7 @@ int CGUIAction::GetNavigation() const void CGUIAction::SetNavigation(int id) { if (id == 0) return; - CStdString strId = StringUtils::Format("%i", id); + std::string strId = StringUtils::Format("%i", id); for (iActions it = m_actions.begin() ; it != m_actions.end() ; ++it) { if (StringUtils::IsInteger(it->action) && it->condition.empty()) diff --git a/xbmc/guilib/GUIAction.h b/xbmc/guilib/GUIAction.h index 4d596d346d..18f1c9d3ae 100644 --- a/xbmc/guilib/GUIAction.h +++ b/xbmc/guilib/GUIAction.h @@ -19,8 +19,8 @@ * */ +#include <string> #include <vector> -#include "utils/StdString.h" class CGUIControl; @@ -56,8 +56,8 @@ public: private: struct cond_action_pair { - CStdString condition; - CStdString action; + std::string condition; + std::string action; }; std::vector<cond_action_pair> m_actions; diff --git a/xbmc/guilib/GUIAudioManager.cpp b/xbmc/guilib/GUIAudioManager.cpp index bab2d32427..67b174486e 100644 --- a/xbmc/guilib/GUIAudioManager.cpp +++ b/xbmc/guilib/GUIAudioManager.cpp @@ -132,7 +132,7 @@ void CGUIAudioManager::PlayWindowSound(int id, WINDOW_SOUND event) } // \brief Play a sound given by filename -void CGUIAudioManager::PlayPythonSound(const CStdString& strFileName, bool useCached /*= true*/) +void CGUIAudioManager::PlayPythonSound(const std::string& strFileName, bool useCached /*= true*/) { CSingleLock lock(m_cs); @@ -161,7 +161,7 @@ void CGUIAudioManager::PlayPythonSound(const CStdString& strFileName, bool useCa if (!sound) return; - m_pythonSounds.insert(pair<const CStdString, IAESound*>(strFileName, sound)); + m_pythonSounds.insert(pair<const std::string, IAESound*>(strFileName, sound)); sound->Play(); } @@ -216,7 +216,7 @@ bool CGUIAudioManager::Load() else Enable(true); - CStdString soundSkin = CSettings::Get().GetString("lookandfeel.soundskin"); + std::string soundSkin = CSettings::Get().GetString("lookandfeel.soundskin"); if (soundSkin == "SKINDEFAULT") { @@ -230,7 +230,7 @@ bool CGUIAudioManager::Load() m_strMediaDir = URIUtils::AddFileToFolder("special://xbmc/sounds", soundSkin); } - CStdString strSoundsXml = URIUtils::AddFileToFolder(m_strMediaDir, "sounds.xml"); + std::string strSoundsXml = URIUtils::AddFileToFolder(m_strMediaDir, "sounds.xml"); // Load our xml file CXBMCTinyXML xmlDoc; @@ -245,7 +245,7 @@ bool CGUIAudioManager::Load() } TiXmlElement* pRoot = xmlDoc.RootElement(); - CStdString strValue = pRoot->Value(); + std::string strValue = pRoot->Value(); if ( strValue != "sounds") { CLog::Log(LOGNOTICE, "%s Doesn't contain <sounds>", strSoundsXml.c_str()); @@ -268,13 +268,13 @@ bool CGUIAudioManager::Load() } TiXmlNode* pFileNode = pAction->FirstChild("file"); - CStdString strFile; + std::string strFile; if (pFileNode && pFileNode->FirstChild()) strFile += pFileNode->FirstChild()->Value(); if (id > 0 && !strFile.empty()) { - CStdString filename = URIUtils::AddFileToFolder(m_strMediaDir, strFile); + std::string filename = URIUtils::AddFileToFolder(m_strMediaDir, strFile); IAESound *sound = LoadSound(filename); if (sound) m_actionSoundMap.insert(pair<int, IAESound *>(id, sound)); @@ -315,7 +315,7 @@ bool CGUIAudioManager::Load() return true; } -IAESound* CGUIAudioManager::LoadSound(const CStdString &filename) +IAESound* CGUIAudioManager::LoadSound(const std::string &filename) { CSingleLock lock(m_cs); soundCache::iterator it = m_soundCache.find(filename); @@ -364,7 +364,7 @@ void CGUIAudioManager::FreeSoundAllUsage(IAESound *sound) } // \brief Load a window node of the config file (sounds.xml) -IAESound* CGUIAudioManager::LoadWindowSound(TiXmlNode* pWindowNode, const CStdString& strIdentifier) +IAESound* CGUIAudioManager::LoadWindowSound(TiXmlNode* pWindowNode, const std::string& strIdentifier) { if (!pWindowNode) return NULL; diff --git a/xbmc/guilib/GUIAudioManager.h b/xbmc/guilib/GUIAudioManager.h index c52934e4f3..62a50e9c8c 100644 --- a/xbmc/guilib/GUIAudioManager.h +++ b/xbmc/guilib/GUIAudioManager.h @@ -21,12 +21,12 @@ */ #include <map> +#include <string> #include "cores/AudioEngine/Interfaces/AESound.h" #include "settings/lib/ISettingCallback.h" #include "threads/CriticalSection.h" #include "utils/log.h" -#include "utils/StdString.h" // forward definitions class CAction; @@ -66,31 +66,31 @@ public: void PlayActionSound(const CAction& action); void PlayWindowSound(int id, WINDOW_SOUND event); - void PlayPythonSound(const CStdString& strFileName, bool useCached = true); + void PlayPythonSound(const std::string& strFileName, bool useCached = true); void Enable(bool bEnable); void SetVolume(float level); void Stop(); private: - typedef std::map<const CStdString, CSoundInfo> soundCache; + typedef std::map<const std::string, CSoundInfo> soundCache; typedef std::map<int, IAESound* > actionSoundMap; typedef std::map<int, CWindowSounds > windowSoundMap; - typedef std::map<const CStdString, IAESound* > pythonSoundsMap; + typedef std::map<const std::string, IAESound* > pythonSoundsMap; soundCache m_soundCache; actionSoundMap m_actionSoundMap; windowSoundMap m_windowSoundMap; pythonSoundsMap m_pythonSounds; - CStdString m_strMediaDir; + std::string m_strMediaDir; bool m_bEnabled; CCriticalSection m_cs; - IAESound* LoadSound(const CStdString &filename); + IAESound* LoadSound(const std::string &filename); void FreeSound(IAESound *sound); void FreeSoundAllUsage(IAESound *sound); - IAESound* LoadWindowSound(TiXmlNode* pWindowNode, const CStdString& strIdentifier); + IAESound* LoadWindowSound(TiXmlNode* pWindowNode, const std::string& strIdentifier); }; extern CGUIAudioManager g_audioManager; diff --git a/xbmc/guilib/GUIBaseContainer.cpp b/xbmc/guilib/GUIBaseContainer.cpp index 263838b67e..8413d5c03e 100644 --- a/xbmc/guilib/GUIBaseContainer.cpp +++ b/xbmc/guilib/GUIBaseContainer.cpp @@ -588,7 +588,7 @@ void CGUIBaseContainer::OnJumpSMS(int letter) if (letter < 2 || letter > 9 || !m_letterOffsets.size()) return; - const CStdString letters = letterMap[letter - 2]; + const std::string letters = letterMap[letter - 2]; // find where we currently are int offset = CorrectOffset(GetOffset(), GetCursor()); unsigned int currentLetter = 0; @@ -596,7 +596,7 @@ void CGUIBaseContainer::OnJumpSMS(int letter) currentLetter++; // now switch to the next letter - CStdString current = m_letterOffsets[currentLetter].second; + std::string current = m_letterOffsets[currentLetter].second; size_t startPos = (letters.find(current) + 1) % letters.size(); // now jump to letters[startPos], or another one in the same range if possible size_t pos = startPos; @@ -939,13 +939,13 @@ void CGUIBaseContainer::UpdateScrollByLetter() m_letterOffsets.clear(); // for scrolling by letter we have an offset table into our vector. - CStdString currentMatch; + std::string currentMatch; for (unsigned int i = 0; i < m_items.size(); i++) { CGUIListItemPtr item = m_items[i]; // The letter offset jumping is only for ASCII characters at present, and // our checks are all done in uppercase - CStdString nextLetter; + std::string nextLetter; std::wstring character = item->GetSortLabel().substr(0, 1); StringUtils::ToUpper(character); g_charsetConverter.wToUTF8(character, nextLetter); diff --git a/xbmc/guilib/GUIBaseContainer.h b/xbmc/guilib/GUIBaseContainer.h index bd23ee4459..e2ae8cc8dc 100644 --- a/xbmc/guilib/GUIBaseContainer.h +++ b/xbmc/guilib/GUIBaseContainer.h @@ -173,7 +173,7 @@ protected: void OnPrevLetter(); void OnJumpLetter(char letter, bool skip = false); void OnJumpSMS(int letter); - std::vector< std::pair<int, CStdString> > m_letterOffsets; + std::vector< std::pair<int, std::string> > m_letterOffsets; /*! \brief Set the cursor position Should be used by all base classes rather than directly setting it, as @@ -216,7 +216,7 @@ private: // letter match searching CStopWatch m_matchTimer; - CStdString m_match; + std::string m_match; float m_scrollItemsPerFrame; static const int letter_match_timeout = 1000; diff --git a/xbmc/guilib/GUIButtonControl.cpp b/xbmc/guilib/GUIButtonControl.cpp index e1aea6c550..ac0c1889e4 100644 --- a/xbmc/guilib/GUIButtonControl.cpp +++ b/xbmc/guilib/GUIButtonControl.cpp @@ -122,7 +122,7 @@ void CGUIButtonControl::ProcessText(unsigned int currentTime) changed |= m_label.SetScrolling(HasFocus()); // render the second label if it exists - CStdString label2(m_info2.GetLabel(m_parentID)); + std::string label2(m_info2.GetLabel(m_parentID)); changed |= m_label2.SetMaxRect(m_posX, m_posY, m_width, m_height); changed |= m_label2.SetText(label2); if (!label2.empty()) @@ -288,13 +288,13 @@ std::string CGUIButtonControl::GetDescription() const return strLabel; } -CStdString CGUIButtonControl::GetLabel2() const +std::string CGUIButtonControl::GetLabel2() const { - CStdString strLabel(m_info2.GetLabel(m_parentID)); + std::string strLabel(m_info2.GetLabel(m_parentID)); return strLabel; } -void CGUIButtonControl::PythonSetLabel(const CStdString &strFont, const string &strText, color_t textColor, color_t shadowColor, color_t focusedColor) +void CGUIButtonControl::PythonSetLabel(const std::string &strFont, const string &strText, color_t textColor, color_t shadowColor, color_t focusedColor) { m_label.GetLabelInfo().font = g_fontManager.GetFont(strFont); m_label.GetLabelInfo().textColor = textColor; diff --git a/xbmc/guilib/GUIButtonControl.h b/xbmc/guilib/GUIButtonControl.h index 007b0b33a9..84b456fad0 100644 --- a/xbmc/guilib/GUIButtonControl.h +++ b/xbmc/guilib/GUIButtonControl.h @@ -63,13 +63,13 @@ public: void SetFocusActions(const CGUIAction& focusActions) { m_focusActions = focusActions; }; void SetUnFocusActions(const CGUIAction& unfocusActions) { m_unfocusActions = unfocusActions; }; const CLabelInfo& GetLabelInfo() const { return m_label.GetLabelInfo(); }; - virtual CStdString GetLabel() const { return GetDescription(); }; - virtual CStdString GetLabel2() const; + virtual std::string GetLabel() const { return GetDescription(); }; + virtual std::string GetLabel2() const; void SetSelected(bool bSelected); virtual std::string GetDescription() const; void SetAlpha(unsigned char alpha); - void PythonSetLabel(const CStdString &strFont, const std::string &strText, color_t textColor, color_t shadowColor, color_t focusedColor); + void PythonSetLabel(const std::string &strFont, const std::string &strText, color_t textColor, color_t shadowColor, color_t focusedColor); void PythonSetDisabledColor(color_t disabledColor); virtual void OnClick(); diff --git a/xbmc/guilib/GUICheckMarkControl.cpp b/xbmc/guilib/GUICheckMarkControl.cpp index bf7bcbb6a0..f0ca27cce2 100644 --- a/xbmc/guilib/GUICheckMarkControl.cpp +++ b/xbmc/guilib/GUICheckMarkControl.cpp @@ -179,7 +179,7 @@ void CGUICheckMarkControl::SetLabel(const string &label) } } -void CGUICheckMarkControl::PythonSetLabel(const CStdString &strFont, const string &strText, color_t textColor) +void CGUICheckMarkControl::PythonSetLabel(const std::string &strFont, const string &strText, color_t textColor) { m_label.GetLabelInfo().font = g_fontManager.GetFont(strFont); m_label.GetLabelInfo().textColor = textColor; diff --git a/xbmc/guilib/GUICheckMarkControl.h b/xbmc/guilib/GUICheckMarkControl.h index c4fe4d6c41..83c3644692 100644 --- a/xbmc/guilib/GUICheckMarkControl.h +++ b/xbmc/guilib/GUICheckMarkControl.h @@ -58,7 +58,7 @@ public: void SetSelected(bool bOnOff); bool GetSelected() const; - void PythonSetLabel(const CStdString &strFont, const std::string &strText, color_t textColor); + void PythonSetLabel(const std::string &strFont, const std::string &strText, color_t textColor); void PythonSetDisabledColor(color_t disabledColor); protected: diff --git a/xbmc/guilib/GUIColorManager.cpp b/xbmc/guilib/GUIColorManager.cpp index e71d171818..74b88c7cc0 100644 --- a/xbmc/guilib/GUIColorManager.cpp +++ b/xbmc/guilib/GUIColorManager.cpp @@ -43,7 +43,7 @@ void CGUIColorManager::Clear() } // load the color file in -void CGUIColorManager::Load(const CStdString &colorFile) +void CGUIColorManager::Load(const std::string &colorFile) { Clear(); @@ -53,8 +53,8 @@ void CGUIColorManager::Load(const CStdString &colorFile) LoadXML(xmlDoc); // first load the default color map if it exists - CStdString basePath = URIUtils::AddFileToFolder(g_SkinInfo->Path(), "colors"); - CStdString path = URIUtils::AddFileToFolder(basePath, "defaults.xml"); + std::string basePath = URIUtils::AddFileToFolder(g_SkinInfo->Path(), "colors"); + std::string path = URIUtils::AddFileToFolder(basePath, "defaults.xml"); if (xmlDoc.LoadFile(CSpecialProtocol::TranslatePathConvertCase(path))) LoadXML(xmlDoc); @@ -76,8 +76,8 @@ bool CGUIColorManager::LoadXML(CXBMCTinyXML &xmlDoc) { TiXmlElement* pRootElement = xmlDoc.RootElement(); - CStdString strValue = pRootElement->Value(); - if (strValue != CStdString("colors")) + std::string strValue = pRootElement->Value(); + if (strValue != std::string("colors")) { CLog::Log(LOGERROR, "color file doesnt start with <colors>"); return false; @@ -91,7 +91,7 @@ bool CGUIColorManager::LoadXML(CXBMCTinyXML &xmlDoc) { color_t value = 0xffffffff; sscanf(color->FirstChild()->Value(), "%x", (unsigned int*) &value); - CStdString name = color->Attribute("name"); + std::string name = color->Attribute("name"); iColor it = m_colors.find(name); if (it != m_colors.end()) (*it).second = value; @@ -104,10 +104,10 @@ bool CGUIColorManager::LoadXML(CXBMCTinyXML &xmlDoc) } // lookup a color and return it's hex value -color_t CGUIColorManager::GetColor(const CStdString &color) const +color_t CGUIColorManager::GetColor(const std::string &color) const { // look in our color map - CStdString trimmed(color); + std::string trimmed(color); StringUtils::TrimLeft(trimmed, "= "); icColor it = m_colors.find(trimmed); if (it != m_colors.end()) diff --git a/xbmc/guilib/GUIColorManager.h b/xbmc/guilib/GUIColorManager.h index dd940fadc0..a8af509678 100644 --- a/xbmc/guilib/GUIColorManager.h +++ b/xbmc/guilib/GUIColorManager.h @@ -33,9 +33,9 @@ \brief */ -#include "utils/StdString.h" - #include <map> +#include <string> +#include <stdint.h> class CXBMCTinyXML; @@ -47,18 +47,18 @@ public: CGUIColorManager(void); virtual ~CGUIColorManager(void); - void Load(const CStdString &colorFile); + void Load(const std::string &colorFile); - color_t GetColor(const CStdString &color) const; + color_t GetColor(const std::string &color) const; void Clear(); protected: bool LoadXML(CXBMCTinyXML &xmlDoc); - std::map<CStdString, color_t> m_colors; - typedef std::map<CStdString, color_t>::iterator iColor; - typedef std::map<CStdString, color_t>::const_iterator icColor; + std::map<std::string, color_t> m_colors; + typedef std::map<std::string, color_t>::iterator iColor; + typedef std::map<std::string, color_t>::const_iterator icColor; }; /*! diff --git a/xbmc/guilib/GUIControl.cpp b/xbmc/guilib/GUIControl.cpp index e3d04dbf4d..be7b62d5cf 100644 --- a/xbmc/guilib/GUIControl.cpp +++ b/xbmc/guilib/GUIControl.cpp @@ -393,7 +393,7 @@ void CGUIControl::SetEnabled(bool bEnable) } } -void CGUIControl::SetEnableCondition(const CStdString &expression) +void CGUIControl::SetEnableCondition(const std::string &expression) { if (expression == "true") m_enabled = true; @@ -629,7 +629,7 @@ void CGUIControl::SetInitialVisibility() MarkDirtyRegion(); } -void CGUIControl::SetVisibleCondition(const CStdString &expression, const CStdString &allowHiddenFocus) +void CGUIControl::SetVisibleCondition(const std::string &expression, const std::string &allowHiddenFocus) { if (expression == "true") m_visible = VISIBLE; diff --git a/xbmc/guilib/GUIControl.h b/xbmc/guilib/GUIControl.h index 85bd23b153..9dd7cd99e7 100644 --- a/xbmc/guilib/GUIControl.h +++ b/xbmc/guilib/GUIControl.h @@ -207,9 +207,9 @@ public: virtual void SetWidth(float width); virtual void SetHeight(float height); virtual void SetVisible(bool bVisible, bool setVisState = false); - void SetVisibleCondition(const CStdString &expression, const CStdString &allowHiddenFocus = ""); + void SetVisibleCondition(const std::string &expression, const std::string &allowHiddenFocus = ""); bool HasVisibleCondition() const { return m_visibleCondition != NULL; }; - void SetEnableCondition(const CStdString &expression); + void SetEnableCondition(const std::string &expression); virtual void UpdateVisibility(const CGUIListItem *item = NULL); virtual void SetInitialVisibility(); virtual void SetEnabled(bool bEnable); @@ -281,6 +281,8 @@ public: enum GUIVISIBLE { HIDDEN = 0, DELAYED, VISIBLE }; + enum GUISCROLLVALUE { FOCUS = 0, NEVER, ALWAYS }; + #ifdef _DEBUG virtual void DumpTextureUse() {}; #endif diff --git a/xbmc/guilib/GUIControlFactory.cpp b/xbmc/guilib/GUIControlFactory.cpp index e5ef0e6cb8..a4cb4f48ec 100644 --- a/xbmc/guilib/GUIControlFactory.cpp +++ b/xbmc/guilib/GUIControlFactory.cpp @@ -115,7 +115,7 @@ static const ControlMapping controls[] = {"epggrid", CGUIControl::GUICONTAINER_EPGGRID}, {"panel", CGUIControl::GUICONTAINER_PANEL}}; -CGUIControl::GUICONTROLTYPES CGUIControlFactory::TranslateControlType(const CStdString &type) +CGUIControl::GUICONTROLTYPES CGUIControlFactory::TranslateControlType(const std::string &type) { for (unsigned int i = 0; i < ARRAY_SIZE(controls); ++i) if (StringUtils::EqualsNoCase(type, controls[i].name)) @@ -123,7 +123,7 @@ CGUIControl::GUICONTROLTYPES CGUIControlFactory::TranslateControlType(const CStd return CGUIControl::GUICONTROL_UNKNOWN; } -CStdString CGUIControlFactory::TranslateControlType(CGUIControl::GUICONTROLTYPES type) +std::string CGUIControlFactory::TranslateControlType(CGUIControl::GUICONTROLTYPES type) { for (unsigned int i = 0; i < ARRAY_SIZE(controls); ++i) if (type == controls[i].type) @@ -300,7 +300,7 @@ bool CGUIControlFactory::GetDimensions(const TiXmlNode *node, const char *leftTa bool CGUIControlFactory::GetAspectRatio(const TiXmlNode* pRootNode, const char* strTag, CAspectRatio &aspect) { - CStdString ratio; + std::string ratio; const TiXmlElement *node = pRootNode->FirstChildElement(strTag); if (!node || !node->FirstChild()) return false; @@ -314,7 +314,7 @@ bool CGUIControlFactory::GetAspectRatio(const TiXmlNode* pRootNode, const char* const char *attribute = node->Attribute("align"); if (attribute) { - CStdString align(attribute); + std::string align(attribute); if (StringUtils::EqualsNoCase(align, "center")) aspect.align = ASPECT_ALIGN_CENTER | (aspect.align & ASPECT_ALIGNY_MASK); else if (StringUtils::EqualsNoCase(align, "right")) aspect.align = ASPECT_ALIGN_RIGHT | (aspect.align & ASPECT_ALIGNY_MASK); else if (StringUtils::EqualsNoCase(align, "left")) aspect.align = ASPECT_ALIGN_LEFT | (aspect.align & ASPECT_ALIGNY_MASK); @@ -322,7 +322,7 @@ bool CGUIControlFactory::GetAspectRatio(const TiXmlNode* pRootNode, const char* attribute = node->Attribute("aligny"); if (attribute) { - CStdString align(attribute); + std::string align(attribute); if (StringUtils::EqualsNoCase(align, "center")) aspect.align = ASPECT_ALIGNY_CENTER | (aspect.align & ASPECT_ALIGN_MASK); else if (StringUtils::EqualsNoCase(align, "bottom")) aspect.align = ASPECT_ALIGNY_BOTTOM | (aspect.align & ASPECT_ALIGN_MASK); else if (StringUtils::EqualsNoCase(align, "top")) aspect.align = ASPECT_ALIGNY_TOP | (aspect.align & ASPECT_ALIGN_MASK); @@ -330,7 +330,7 @@ bool CGUIControlFactory::GetAspectRatio(const TiXmlNode* pRootNode, const char* attribute = node->Attribute("scalediffuse"); if (attribute) { - CStdString scale(attribute); + std::string scale(attribute); if (StringUtils::EqualsNoCase(scale, "true") || StringUtils::EqualsNoCase(scale, "yes")) aspect.scaleDiffuse = true; else @@ -368,7 +368,7 @@ bool CGUIControlFactory::GetTexture(const TiXmlNode* pRootNode, const char* strT return true; } -void CGUIControlFactory::GetRectFromString(const CStdString &string, CRect &rect) +void CGUIControlFactory::GetRectFromString(const std::string &string, CRect &rect) { // format is rect="left[,top,right,bottom]" std::vector<std::string> strRect = StringUtils::Split(string, ','); @@ -393,7 +393,7 @@ bool CGUIControlFactory::GetAlignment(const TiXmlNode* pRootNode, const char* st const TiXmlNode* pNode = pRootNode->FirstChild(strTag); if (!pNode || !pNode->FirstChild()) return false; - CStdString strAlign = pNode->FirstChild()->Value(); + std::string strAlign = pNode->FirstChild()->Value(); if (strAlign == "right" || strAlign == "bottom") alignment = XBFONT_RIGHT; else if (strAlign == "center") alignment = XBFONT_CENTER_X; else if (strAlign == "justify") alignment = XBFONT_JUSTIFIED; @@ -409,7 +409,7 @@ bool CGUIControlFactory::GetAlignmentY(const TiXmlNode* pRootNode, const char* s return false; } - CStdString strAlign = pNode->FirstChild()->Value(); + std::string strAlign = pNode->FirstChild()->Value(); alignment = 0; if (strAlign == "center") @@ -451,7 +451,7 @@ bool CGUIControlFactory::GetConditionalVisibility(const TiXmlNode* control, std: bool CGUIControlFactory::GetConditionalVisibility(const TiXmlNode *control, std::string &condition) { - CStdString allowHiddenFocus; + std::string allowHiddenFocus; return GetConditionalVisibility(control, condition, allowHiddenFocus); } @@ -477,7 +477,7 @@ bool CGUIControlFactory::GetAnimations(TiXmlNode *control, const CRect &rect, in const char *end = hidden.Attribute("end"); if (start && end) { - CStdString temp = end; + std::string temp = end; hidden.SetAttribute("end", start); hidden.SetAttribute("start", temp.c_str()); } @@ -529,13 +529,13 @@ bool CGUIControlFactory::GetHitRect(const TiXmlNode *control, CRect &rect) return false; } -bool CGUIControlFactory::GetScroller(const TiXmlNode *control, const CStdString &scrollerTag, CScroller& scroller) +bool CGUIControlFactory::GetScroller(const TiXmlNode *control, const std::string &scrollerTag, CScroller& scroller) { const TiXmlElement* node = control->FirstChildElement(scrollerTag); if (node) { unsigned int scrollTime; - if (XMLUtils::GetUInt(control, scrollerTag, scrollTime)) + if (XMLUtils::GetUInt(control, scrollerTag.c_str(), scrollTime)) { scroller = CScroller(scrollTime, CAnimEffect::GetTweener(node)); return true; @@ -566,7 +566,7 @@ bool CGUIControlFactory::GetInfoColor(const TiXmlNode *control, const char *strT return false; } -void CGUIControlFactory::GetInfoLabel(const TiXmlNode *pControlNode, const CStdString &labelTag, CGUIInfoLabel &infoLabel, int parentID) +void CGUIControlFactory::GetInfoLabel(const TiXmlNode *pControlNode, const std::string &labelTag, CGUIInfoLabel &infoLabel, int parentID) { vector<CGUIInfoLabel> labels; GetInfoLabels(pControlNode, labelTag, labels, parentID); @@ -579,22 +579,22 @@ bool CGUIControlFactory::GetInfoLabelFromElement(const TiXmlElement *element, CG if (!element || !element->FirstChild()) return false; - CStdString label = element->FirstChild()->Value(); + std::string label = element->FirstChild()->Value(); if (label.empty() || label == "-") return false; - CStdString fallback = XMLUtils::GetAttribute(element, "fallback"); + std::string fallback = XMLUtils::GetAttribute(element, "fallback"); if (StringUtils::IsNaturalNumber(label)) - label = g_localizeStrings.Get(atoi(label)); + label = g_localizeStrings.Get(atoi(label.c_str())); if (StringUtils::IsNaturalNumber(fallback)) - fallback = g_localizeStrings.Get(atoi(fallback)); + fallback = g_localizeStrings.Get(atoi(fallback.c_str())); else g_charsetConverter.unknownToUTF8(fallback); infoLabel.SetLabel(label, fallback, parentID); return true; } -void CGUIControlFactory::GetInfoLabels(const TiXmlNode *pControlNode, const CStdString &labelTag, vector<CGUIInfoLabel> &infoLabels, int parentID) +void CGUIControlFactory::GetInfoLabels(const TiXmlNode *pControlNode, const std::string &labelTag, vector<CGUIInfoLabel> &infoLabels, int parentID) { // we can have the following infolabels: // 1. <number>1234</number> -> direct number @@ -604,7 +604,7 @@ void CGUIControlFactory::GetInfoLabels(const TiXmlNode *pControlNode, const CStd int labelNumber = 0; if (XMLUtils::GetInt(pControlNode, "number", labelNumber)) { - CStdString label = StringUtils::Format("%i", labelNumber); + std::string label = StringUtils::Format("%i", labelNumber); infoLabels.push_back(CGUIInfoLabel(label)); return; // done } @@ -619,7 +619,7 @@ void CGUIControlFactory::GetInfoLabels(const TiXmlNode *pControlNode, const CStd const TiXmlNode *infoNode = pControlNode->FirstChild("info"); if (infoNode) { // <info> nodes override <label>'s (backward compatibility) - CStdString fallback; + std::string fallback; if (infoLabels.size()) fallback = infoLabels[0].GetLabel(0); infoLabels.clear(); @@ -627,7 +627,7 @@ void CGUIControlFactory::GetInfoLabels(const TiXmlNode *pControlNode, const CStd { if (infoNode->FirstChild()) { - CStdString info = StringUtils::Format("$INFO[%s]", infoNode->FirstChild()->Value()); + std::string info = StringUtils::Format("$INFO[%s]", infoNode->FirstChild()->Value()); infoLabels.push_back(CGUIInfoLabel(info, fallback, parentID)); } infoNode = infoNode->NextSibling("info"); @@ -636,17 +636,17 @@ void CGUIControlFactory::GetInfoLabels(const TiXmlNode *pControlNode, const CStd } // Convert a string to a GUI label, by translating/parsing the label for localisable strings -CStdString CGUIControlFactory::FilterLabel(const CStdString &label) +std::string CGUIControlFactory::FilterLabel(const std::string &label) { - CStdString viewLabel = label; + std::string viewLabel = label; if (StringUtils::IsNaturalNumber(viewLabel)) - viewLabel = g_localizeStrings.Get(atoi(label)); + viewLabel = g_localizeStrings.Get(atoi(label.c_str())); else g_charsetConverter.unknownToUTF8(viewLabel); return viewLabel; } -bool CGUIControlFactory::GetString(const TiXmlNode* pRootNode, const char *strTag, CStdString &text) +bool CGUIControlFactory::GetString(const TiXmlNode* pRootNode, const char *strTag, std::string &text) { if (!XMLUtils::GetString(pRootNode, strTag, text)) return false; @@ -657,9 +657,9 @@ bool CGUIControlFactory::GetString(const TiXmlNode* pRootNode, const char *strTa return true; } -CStdString CGUIControlFactory::GetType(const TiXmlElement *pControlNode) +std::string CGUIControlFactory::GetType(const TiXmlElement *pControlNode) { - CStdString type = XMLUtils::GetAttribute(pControlNode, "type"); + std::string type = XMLUtils::GetAttribute(pControlNode, "type"); if (type.empty()) // backward compatibility - not desired XMLUtils::GetString(pControlNode, "type", type); return type; @@ -668,7 +668,7 @@ CStdString CGUIControlFactory::GetType(const TiXmlElement *pControlNode) CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlElement* pControlNode, bool insideContainer) { // get the control type - CStdString strType = GetType(pControlNode); + std::string strType = GetType(pControlNode); CGUIControl::GUICONTROLTYPES type = TranslateControlType(strType); int id = 0; @@ -682,17 +682,17 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl CGUIInfoColor colorDiffuse(0xFFFFFFFF); int defaultControl = 0; bool defaultAlways = false; - CStdString strTmp; + std::string strTmp; int singleInfo = 0; - CStdString strLabel; + std::string strLabel; int iUrlSet=0; - CStdString toggleSelect; + std::string toggleSelect; float spinWidth = 16; float spinHeight = 16; float spinPosX = 0, spinPosY = 0; float checkWidth = 0, checkHeight = 0; - CStdString strSubType; + std::string strSubType; int iType = SPIN_CONTROL_TYPE_TEXT; int iMin = 0; int iMax = 100; @@ -728,8 +728,8 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl CGUIAction focusActions; CGUIAction unfocusActions; CGUIAction textChangeActions; - CStdString strTitle = ""; - CStdString strRSSTags = ""; + std::string strTitle = ""; + std::string strRSSTags = ""; float buttonGap = 5; int iMovementRange = 0; @@ -740,12 +740,12 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl aspect.ratio = CAspectRatio::AR_KEEP; } - CStdString allowHiddenFocus; - CStdString enableCondition; + std::string allowHiddenFocus; + std::string enableCondition; vector<CAnimation> animations; - bool bScrollLabel = false; + CGUIControl::GUISCROLLVALUE scrollValue = CGUIControl::FOCUS; bool bPulse = true; unsigned int timePerImage = 0; unsigned int fadeTime = 0; @@ -769,9 +769,9 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl float radioPosX = 0; float radioPosY = 0; - CStdString altLabel; - CStdString strLabel2; - CStdString action; + std::string altLabel; + std::string strLabel2; + std::string action; int focusPosition = 0; int scrollTime = 200; @@ -785,7 +785,7 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl bool hasCamera = false; bool resetOnLabelChange = true; bool bPassword = false; - CStdString visibleCondition; + std::string visibleCondition; ///////////////////////////////////////////////////////////////////////////// // Read control properties from XML @@ -856,7 +856,7 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl XMLUtils::GetFloat(pControlNode, "textoffsety", labelInfo.offsetY); int angle = 0; // use the negative angle to compensate for our vertically flipped cartesian plane if (XMLUtils::GetInt(pControlNode, "angle", angle)) labelInfo.angle = (float)-angle; - CStdString strFont; + std::string strFont; if (XMLUtils::GetString(pControlNode, "font", strFont)) labelInfo.font = g_fontManager.GetFont(strFont); uint32_t alignY = 0; @@ -872,7 +872,7 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl focusActions.m_sendThreadMessages = unfocusActions.m_sendThreadMessages = true; GetActions(pControlNode, "altclick", altclickActions); - CStdString infoString; + std::string infoString; if (XMLUtils::GetString(pControlNode, "info", infoString)) singleInfo = g_infoManager.TranslateString(infoString); @@ -997,7 +997,11 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl XMLUtils::GetFloat(pControlNode, "itemgap", buttonGap); XMLUtils::GetInt(pControlNode, "movement", iMovementRange); GetAspectRatio(pControlNode, "aspectratio", aspect); - XMLUtils::GetBoolean(pControlNode, "scroll", bScrollLabel); + + bool alwaysScroll; + if (XMLUtils::GetBoolean(pControlNode, "scroll", alwaysScroll)) + scrollValue = alwaysScroll ? CGUIControl::ALWAYS : CGUIControl::NEVER; + XMLUtils::GetBoolean(pControlNode,"pulseonselect", bPulse); XMLUtils::GetInt(pControlNode, "timeblocks", timeBlocks); XMLUtils::GetInt(pControlNode, "rulerunit", rulerUnit); @@ -1016,7 +1020,7 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl XMLUtils::GetFloat(pControlNode, "radioheight", radioHeight); XMLUtils::GetFloat(pControlNode, "radioposx", radioPosX); XMLUtils::GetFloat(pControlNode, "radioposy", radioPosY); - CStdString borderStr; + std::string borderStr; if (XMLUtils::GetString(pControlNode, "bordersize", borderStr)) GetRectFromString(borderStr, borderSize); @@ -1033,7 +1037,7 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl // view type VIEW_TYPE viewType = VIEW_TYPE_NONE; - CStdString viewLabel; + std::string viewLabel; if (type == CGUIControl::GUICONTAINER_PANEL) { viewType = VIEW_TYPE_ICON; @@ -1052,7 +1056,7 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl TiXmlElement *itemElement = pControlNode->FirstChildElement("viewtype"); if (itemElement && itemElement->FirstChild()) { - CStdString type = itemElement->FirstChild()->Value(); + std::string type = itemElement->FirstChild()->Value(); if (type == "list") viewType = VIEW_TYPE_LIST; else if (type == "icon") @@ -1128,7 +1132,7 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl const CGUIInfoLabel &content = (infoLabels.size()) ? infoLabels[0] : CGUIInfoLabel(""); if (insideContainer) { // inside lists we use CGUIListLabel - control = new CGUIListLabel(parentID, id, posX, posY, width, height, labelInfo, content, bScrollLabel); + control = new CGUIListLabel(parentID, id, posX, posY, width, height, labelInfo, content, scrollValue); } else { @@ -1136,7 +1140,7 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl parentID, id, posX, posY, width, height, labelInfo, wrapMultiLine, bHasPath); ((CGUILabelControl *)control)->SetInfo(content); - ((CGUILabelControl *)control)->SetWidthControl(minWidth, bScrollLabel); + ((CGUILabelControl *)control)->SetWidthControl(minWidth, (scrollValue == CGUIControl::ALWAYS) ? true : false); } } else if (type == CGUIControl::GUICONTROL_EDIT) diff --git a/xbmc/guilib/GUIControlFactory.h b/xbmc/guilib/GUIControlFactory.h index ce86f2e135..41f1ac8e61 100644 --- a/xbmc/guilib/GUIControlFactory.h +++ b/xbmc/guilib/GUIControlFactory.h @@ -51,13 +51,13 @@ public: \param type name of the control \return type of control */ - static CGUIControl::GUICONTROLTYPES TranslateControlType(const CStdString &type); + static CGUIControl::GUICONTROLTYPES TranslateControlType(const std::string &type); /*! \brief translate from control type to control name \param type type of the control \return name of control */ - static CStdString TranslateControlType(CGUIControl::GUICONTROLTYPES type); + static std::string TranslateControlType(CGUIControl::GUICONTROLTYPES type); static bool GetAspectRatio(const TiXmlNode* pRootNode, const char* strTag, CAspectRatio &aspectRatio); static bool GetInfoTexture(const TiXmlNode* pRootNode, const char* strTag, CTextureInfo &image, CGUIInfoLabel &info, int parentID); @@ -77,20 +77,20 @@ public: \return true if a valid info label was read, false otherwise */ static bool GetInfoLabelFromElement(const TiXmlElement *element, CGUIInfoLabel &infoLabel, int parentID); - static void GetInfoLabel(const TiXmlNode *pControlNode, const CStdString &labelTag, CGUIInfoLabel &infoLabel, int parentID); - static void GetInfoLabels(const TiXmlNode *pControlNode, const CStdString &labelTag, std::vector<CGUIInfoLabel> &infoLabels, int parentID); + static void GetInfoLabel(const TiXmlNode *pControlNode, const std::string &labelTag, CGUIInfoLabel &infoLabel, int parentID); + static void GetInfoLabels(const TiXmlNode *pControlNode, const std::string &labelTag, std::vector<CGUIInfoLabel> &infoLabels, int parentID); static bool GetColor(const TiXmlNode* pRootNode, const char* strTag, color_t &value); static bool GetInfoColor(const TiXmlNode* pRootNode, const char* strTag, CGUIInfoColor &value, int parentID); - static CStdString FilterLabel(const CStdString &label); + static std::string FilterLabel(const std::string &label); static bool GetConditionalVisibility(const TiXmlNode* control, std::string &condition); static bool GetActions(const TiXmlNode* pRootNode, const char* strTag, CGUIAction& actions); - static void GetRectFromString(const CStdString &string, CRect &rect); + static void GetRectFromString(const std::string &string, CRect &rect); static bool GetHitRect(const TiXmlNode* pRootNode, CRect &rect); - static bool GetScroller(const TiXmlNode *pControlNode, const CStdString &scrollerTag, CScroller& scroller); + static bool GetScroller(const TiXmlNode *pControlNode, const std::string &scrollerTag, CScroller& scroller); private: - static CStdString GetType(const TiXmlElement *pControlNode); + static std::string GetType(const TiXmlElement *pControlNode); static bool GetConditionalVisibility(const TiXmlNode* control, std::string &condition, std::string &allowHiddenFocus); - bool GetString(const TiXmlNode* pRootNode, const char* strTag, CStdString& strString); + bool GetString(const TiXmlNode* pRootNode, const char* strTag, std::string& strString); static bool GetFloatRange(const TiXmlNode* pRootNode, const char* strTag, float& iMinValue, float& iMaxValue, float& iIntervalValue); static bool GetIntRange(const TiXmlNode* pRootNode, const char* strTag, int& iMinValue, int& iMaxValue, int& iIntervalValue); diff --git a/xbmc/guilib/GUIControlGroup.cpp b/xbmc/guilib/GUIControlGroup.cpp index 7858e42d1b..032c7d507d 100644 --- a/xbmc/guilib/GUIControlGroup.cpp +++ b/xbmc/guilib/GUIControlGroup.cpp @@ -135,7 +135,7 @@ void CGUIControlGroup::Render() bool CGUIControlGroup::OnAction(const CAction &action) { - ASSERT(false); // unimplemented + assert(false); // unimplemented return false; } diff --git a/xbmc/guilib/GUIControlProfiler.cpp b/xbmc/guilib/GUIControlProfiler.cpp index 55cabd9913..bee859c767 100644 --- a/xbmc/guilib/GUIControlProfiler.cpp +++ b/xbmc/guilib/GUIControlProfiler.cpp @@ -164,14 +164,14 @@ void CGUIControlProfilerItem::SaveToXML(TiXmlElement *parent) xmlControl->SetAttribute("type", lpszType); if (m_controlID != 0) { - CStdString str = StringUtils::Format("%u", m_controlID); + std::string str = StringUtils::Format("%u", m_controlID); xmlControl->SetAttribute("id", str.c_str()); } float pct = (float)GetTotalTime() / (float)m_pProfiler->GetTotalTime(); if (pct > 0.01f) { - CStdString str = StringUtils::Format("%.0f", pct * 100.0f); + std::string str = StringUtils::Format("%.0f", pct * 100.0f); xmlControl->SetAttribute("percent", str.c_str()); } @@ -188,7 +188,7 @@ void CGUIControlProfilerItem::SaveToXML(TiXmlElement *parent) unsigned int rend = m_renderTime / 100; if (vis || rend) { - CStdString val; + std::string val; TiXmlElement *elem = new TiXmlElement("rendertime"); xmlControl->LinkEndChild(elem); val = StringUtils::Format("%u", rend); @@ -343,7 +343,7 @@ bool CGUIControlProfiler::SaveResults(void) doc.InsertEndChild(decl); TiXmlElement *root = new TiXmlElement("guicontrolprofiler"); - CStdString str = StringUtils::Format("%d", m_iFrameCount); + std::string str = StringUtils::Format("%d", m_iFrameCount); root->SetAttribute("framecount", str.c_str()); root->SetAttribute("timeunit", "ms"); doc.LinkEndChild(root); diff --git a/xbmc/guilib/GUIControlProfiler.h b/xbmc/guilib/GUIControlProfiler.h index b5d2e14640..b62ebb352a 100644 --- a/xbmc/guilib/GUIControlProfiler.h +++ b/xbmc/guilib/GUIControlProfiler.h @@ -34,7 +34,7 @@ public: CGUIControlProfilerItem * m_pParent; CGUIControl *m_pControl; std::vector<CGUIControlProfilerItem *> m_vecChildren; - CStdString m_strDescription; + std::string m_strDescription; int m_controlID; CGUIControl::GUICONTROLTYPES m_ControlType; unsigned int m_visTime; @@ -71,8 +71,8 @@ public: void EndRender(CGUIControl *pControl); int GetMaxFrameCount(void) const { return m_iMaxFrameCount; }; void SetMaxFrameCount(int iMaxFrameCount) { m_iMaxFrameCount = iMaxFrameCount; }; - void SetOutputFile(const CStdString &strOutputFile) { m_strOutputFile = strOutputFile; }; - const CStdString &GetOutputFile(void) const { return m_strOutputFile; }; + void SetOutputFile(const std::string &strOutputFile) { m_strOutputFile = strOutputFile; }; + const std::string &GetOutputFile(void) const { return m_strOutputFile; }; bool SaveResults(void); unsigned int GetTotalTime(void) const { return m_ItemHead.GetTotalTime(); }; @@ -88,7 +88,7 @@ private: CGUIControlProfilerItem *FindOrAddControl(CGUIControl *pControl); static bool m_bIsRunning; - CStdString m_strOutputFile; + std::string m_strOutputFile; int m_iMaxFrameCount; int m_iFrameCount; }; diff --git a/xbmc/guilib/GUIDialog.cpp b/xbmc/guilib/GUIDialog.cpp index 65071de864..59b61d2f4e 100644 --- a/xbmc/guilib/GUIDialog.cpp +++ b/xbmc/guilib/GUIDialog.cpp @@ -28,7 +28,7 @@ #include "ApplicationMessenger.h" #include "Key.h" -CGUIDialog::CGUIDialog(int id, const CStdString &xmlFile) +CGUIDialog::CGUIDialog(int id, const std::string &xmlFile) : CGUIWindow(id, xmlFile) { m_bModal = true; @@ -160,7 +160,7 @@ void CGUIDialog::UpdateVisibility() } } -void CGUIDialog::DoModal_Internal(int iWindowID /*= WINDOW_INVALID */, const CStdString ¶m /* = "" */) +void CGUIDialog::DoModal_Internal(int iWindowID /*= WINDOW_INVALID */, const std::string ¶m /* = "" */) { //Lock graphic context here as it is sometimes called from non rendering threads //maybe we should have a critical section per window instead?? @@ -220,7 +220,7 @@ void CGUIDialog::Show_Internal() OnMessage(msg); } -void CGUIDialog::DoModal(int iWindowID /*= WINDOW_INVALID */, const CStdString ¶m) +void CGUIDialog::DoModal(int iWindowID /*= WINDOW_INVALID */, const std::string ¶m) { if (!g_application.IsCurrentThread()) { diff --git a/xbmc/guilib/GUIDialog.h b/xbmc/guilib/GUIDialog.h index ac8390492e..ce8c45b596 100644 --- a/xbmc/guilib/GUIDialog.h +++ b/xbmc/guilib/GUIDialog.h @@ -36,7 +36,7 @@ class CGUIDialog : public CGUIWindow { public: - CGUIDialog(int id, const CStdString &xmlFile); + CGUIDialog(int id, const std::string &xmlFile); virtual ~CGUIDialog(void); virtual bool OnAction(const CAction &action); @@ -44,7 +44,7 @@ public: virtual void DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions); virtual void Render(); - void DoModal(int iWindowID = WINDOW_INVALID, const CStdString ¶m = ""); // modal + void DoModal(int iWindowID = WINDOW_INVALID, const std::string ¶m = ""); // modal void Show(); // modeless virtual bool OnBack(int actionID); @@ -64,7 +64,7 @@ protected: virtual void OnWindowLoaded(); virtual void UpdateVisibility(); - virtual void DoModal_Internal(int iWindowID = WINDOW_INVALID, const CStdString ¶m = ""); // modal + virtual void DoModal_Internal(int iWindowID = WINDOW_INVALID, const std::string ¶m = ""); // modal virtual void Show_Internal(); // modeless virtual void OnDeinitWindow(int nextWindowID); diff --git a/xbmc/guilib/GUIEditControl.cpp b/xbmc/guilib/GUIEditControl.cpp index 5b10beabf8..96bcd87fa1 100644 --- a/xbmc/guilib/GUIEditControl.cpp +++ b/xbmc/guilib/GUIEditControl.cpp @@ -103,17 +103,6 @@ bool CGUIEditControl::OnMessage(CGUIMessage &message) SetLabel2(message.GetLabel()); UpdateText(); } - else if (message.GetMessage() == GUI_MSG_INPUT_TEXT && !message.GetLabel().empty() - && (HasFocus() || message.GetControlId() == GetID())) - { - m_edit.clear(); - std::wstring str; - g_charsetConverter.utf8ToW(message.GetLabel(), str); - m_text2.insert(m_cursorPos, str); - m_cursorPos += str.size(); - UpdateText(); - return true; - } else if (message.GetMessage() == GUI_MSG_INPUT_TEXT_EDIT && HasFocus()) { g_charsetConverter.utf8ToW(message.GetLabel(), m_edit); @@ -292,6 +281,16 @@ bool CGUIEditControl::OnAction(const CAction &action) OnSMSCharacter(action.GetID() - REMOTE_0); return true; } + else if (action.GetID() == ACTION_INPUT_TEXT) + { + m_edit.clear(); + std::wstring str; + g_charsetConverter.utf8ToW(action.GetText(), str); + m_text2.insert(m_cursorPos, str); + m_cursorPos += str.size(); + UpdateText(); + return true; + } } return CGUIButtonControl::OnAction(action); } @@ -303,10 +302,10 @@ void CGUIEditControl::OnClick() if (GetParentID() == WINDOW_DIALOG_KEYBOARD) return; - CStdString utf8; + std::string utf8; g_charsetConverter.wToUTF8(m_text2, utf8); bool textChanged = false; - CStdString heading = g_localizeStrings.Get(m_inputHeading ? m_inputHeading : 16028); + std::string heading = g_localizeStrings.Get(m_inputHeading ? m_inputHeading : 16028); switch (m_inputType) { case INPUT_TYPE_READONLY: @@ -324,7 +323,7 @@ void CGUIEditControl::OnClick() dateTime.SetFromDBTime(utf8); SYSTEMTIME time; dateTime.GetAsSystemTime(time); - if (CGUIDialogNumeric::ShowAndGetTime(time, heading > 0 ? heading : g_localizeStrings.Get(21420))) + if (CGUIDialogNumeric::ShowAndGetTime(time, !heading.empty() ? heading : g_localizeStrings.Get(21420))) { dateTime = CDateTime(time); utf8 = dateTime.GetAsLocalizedTime("", false); @@ -340,7 +339,7 @@ void CGUIEditControl::OnClick() dateTime = CDateTime(2000, 1, 1, 0, 0, 0); SYSTEMTIME date; dateTime.GetAsSystemTime(date); - if (CGUIDialogNumeric::ShowAndGetDate(date, heading > 0 ? heading : g_localizeStrings.Get(21420))) + if (CGUIDialogNumeric::ShowAndGetDate(date, !heading.empty() ? heading : g_localizeStrings.Get(21420))) { dateTime = CDateTime(date); utf8 = dateTime.GetAsDBDate(); @@ -405,7 +404,7 @@ void CGUIEditControl::RecalcLabelPosition() // ensure that our cursor is within our width ValidateCursor(); - CStdStringW text = GetDisplayedText(); + std::wstring text = GetDisplayedText(); m_textWidth = m_label.CalcTextWidth(text + L'|'); float beforeCursorWidth = m_label.CalcTextWidth(text.substr(0, m_cursorPos)); float afterCursorWidth = m_label.CalcTextWidth(text.substr(0, m_cursorPos) + L'|'); @@ -486,7 +485,7 @@ void CGUIEditControl::ProcessText(unsigned int currentTime) } changed |= m_label2.SetMaxRect(m_clipRect.x1 + m_textOffset, m_posY, m_clipRect.Width() - m_textOffset, m_height); - CStdStringW text = GetDisplayedText(); + std::wstring text = GetDisplayedText(); // add the cursor and highlighting if we're focused if ((HasFocus() || m_cursorShowAlways) && m_inputType != INPUT_TYPE_READONLY) changed |= SetStyledText(text); @@ -533,9 +532,9 @@ void CGUIEditControl::SetHint(const CGUIInfoLabel& hint) m_hintInfo = hint; } -CStdStringW CGUIEditControl::GetDisplayedText() const +std::wstring CGUIEditControl::GetDisplayedText() const { - CStdStringW text(m_text2); + std::wstring text(m_text2); if (m_inputType == INPUT_TYPE_PASSWORD || m_inputType == INPUT_TYPE_PASSWORD_MD5 || m_inputType == INPUT_TYPE_PASSWORD_NUMBER_VERIFY_NEW) { text.clear(); @@ -553,7 +552,7 @@ CStdStringW CGUIEditControl::GetDisplayedText() const return text; } -bool CGUIEditControl::SetStyledText(const CStdStringW &text) +bool CGUIEditControl::SetStyledText(const std::wstring &text) { vecText styled; styled.reserve(text.size() + 1); @@ -606,7 +605,7 @@ void CGUIEditControl::SetLabel(const std::string &text) void CGUIEditControl::SetLabel2(const std::string &text) { m_edit.clear(); - CStdStringW newText; + std::wstring newText; g_charsetConverter.utf8ToW(text, newText); if (newText != m_text2) { @@ -618,9 +617,9 @@ void CGUIEditControl::SetLabel2(const std::string &text) } } -CStdString CGUIEditControl::GetLabel2() const +std::string CGUIEditControl::GetLabel2() const { - CStdString text; + std::string text; g_charsetConverter.wToUTF8(m_text2, text); if (m_inputType == INPUT_TYPE_PASSWORD_MD5 && !m_isMD5) return XBMC::XBMC_MD5::GetMD5(text); @@ -684,8 +683,8 @@ void CGUIEditControl::OnSMSCharacter(unsigned int key) void CGUIEditControl::OnPasteClipboard() { - CStdStringW unicode_text; - CStdStringA utf8_text; + std::wstring unicode_text; + std::string utf8_text; // Get text from the clipboard utf8_text = g_Windowing.GetClipboardText(); @@ -694,8 +693,8 @@ void CGUIEditControl::OnPasteClipboard() // Insert the pasted text at the current cursor position. if (unicode_text.length() > 0) { - CStdStringW left_end = m_text2.substr(0, m_cursorPos); - CStdStringW right_end = m_text2.substr(m_cursorPos); + std::wstring left_end = m_text2.substr(0, m_cursorPos); + std::wstring right_end = m_text2.substr(m_cursorPos); m_text2 = left_end; m_text2.append(unicode_text); @@ -716,7 +715,7 @@ void CGUIEditControl::SetInputValidation(StringValidation::Validator inputValida ValidateInput(); } -bool CGUIEditControl::ValidateInput(const CStdStringW &data) const +bool CGUIEditControl::ValidateInput(const std::wstring &data) const { if (m_inputValidator == NULL) return true; diff --git a/xbmc/guilib/GUIEditControl.h b/xbmc/guilib/GUIEditControl.h index b10dadd4ab..6462f91e12 100644 --- a/xbmc/guilib/GUIEditControl.h +++ b/xbmc/guilib/GUIEditControl.h @@ -70,7 +70,7 @@ public: virtual void SetLabel2(const std::string &text); void SetHint(const CGUIInfoLabel& hint); - virtual CStdString GetLabel2() const; + virtual std::string GetLabel2() const; void SetShowCursorAlways(bool always) { m_cursorShowAlways = always; } @@ -91,8 +91,8 @@ protected: virtual void ProcessText(unsigned int currentTime); virtual void RenderText(); virtual CGUILabel::COLOR GetTextColor() const; - CStdStringW GetDisplayedText() const; - bool SetStyledText(const CStdStringW &text); + std::wstring GetDisplayedText() const; + bool SetStyledText(const std::wstring &text); void RecalcLabelPosition(); void ValidateCursor(); void UpdateText(bool sendUpdate = true); @@ -100,7 +100,7 @@ protected: void OnSMSCharacter(unsigned int key); void DefaultConstructor(); - virtual bool ValidateInput(const CStdStringW &data) const; + virtual bool ValidateInput(const std::wstring &data) const; void ValidateInput(); /*! \brief Clear out the current text input if it's an MD5 password. @@ -108,8 +108,8 @@ protected: */ bool ClearMD5(); - CStdStringW m_text2; - CStdString m_text; + std::wstring m_text2; + std::string m_text; CGUIInfoLabel m_hintInfo; float m_textOffset; float m_textWidth; diff --git a/xbmc/guilib/GUIFadeLabelControl.cpp b/xbmc/guilib/GUIFadeLabelControl.cpp index 844f96038c..19c646968c 100644 --- a/xbmc/guilib/GUIFadeLabelControl.cpp +++ b/xbmc/guilib/GUIFadeLabelControl.cpp @@ -241,13 +241,13 @@ std::string CGUIFadeLabelControl::GetDescription() const return (m_currentLabel < m_infoLabels.size()) ? m_infoLabels[m_currentLabel].GetLabel(m_parentID) : ""; } -CStdString CGUIFadeLabelControl::GetLabel() +std::string CGUIFadeLabelControl::GetLabel() { if (m_currentLabel > m_infoLabels.size()) m_currentLabel = 0; unsigned int numTries = 0; - CStdString label(m_infoLabels[m_currentLabel].GetLabel(m_parentID)); + std::string label(m_infoLabels[m_currentLabel].GetLabel(m_parentID)); while (label.empty() && ++numTries < m_infoLabels.size()) { if (++m_currentLabel >= m_infoLabels.size()) diff --git a/xbmc/guilib/GUIFadeLabelControl.h b/xbmc/guilib/GUIFadeLabelControl.h index c45ae9b5d4..6d6a59f25d 100644 --- a/xbmc/guilib/GUIFadeLabelControl.h +++ b/xbmc/guilib/GUIFadeLabelControl.h @@ -63,7 +63,7 @@ protected: \return the label that should be displayed. If empty, there is no label available. */ - CStdString GetLabel(); + std::string GetLabel(); std::vector< CGUIInfoLabel > m_infoLabels; unsigned int m_currentLabel; diff --git a/xbmc/guilib/GUIFont.cpp b/xbmc/guilib/GUIFont.cpp index a7ee668324..04511bd174 100644 --- a/xbmc/guilib/GUIFont.cpp +++ b/xbmc/guilib/GUIFont.cpp @@ -31,7 +31,7 @@ #define ROUND(x) (float)(MathUtils::round_int(x)) CScrollInfo::CScrollInfo(unsigned int wait /* = 50 */, float pos /* = 0 */, - int speed /* = defaultSpeed */, const CStdString &scrollSuffix /* = " | " */) + int speed /* = defaultSpeed */, const std::string &scrollSuffix /* = " | " */) { initialWait = wait; initialPos = pos; @@ -57,7 +57,7 @@ float CScrollInfo::GetPixelsPerFrame() return pixelSpeed * m_averageFrameTime; } -CGUIFont::CGUIFont(const CStdString& strFontName, uint32_t style, color_t textColor, +CGUIFont::CGUIFont(const std::string& strFontName, uint32_t style, color_t textColor, color_t shadowColor, float lineSpacing, float origHeight, CGUIFontTTFBase *font) { m_strFontName = strFontName; @@ -78,7 +78,7 @@ CGUIFont::~CGUIFont() m_font->RemoveReference(); } -CStdString& CGUIFont::GetFontName() +std::string& CGUIFont::GetFontName() { return m_strFontName; } diff --git a/xbmc/guilib/GUIFont.h b/xbmc/guilib/GUIFont.h index c55db48250..0b8e5ad1e2 100644 --- a/xbmc/guilib/GUIFont.h +++ b/xbmc/guilib/GUIFont.h @@ -27,8 +27,11 @@ * */ -#include "utils/StdString.h" #include <assert.h> +#include <math.h> +#include <string> +#include <stdint.h> +#include <vector> typedef uint32_t character_t; typedef uint32_t color_t; @@ -55,7 +58,7 @@ class CGUIFontTTFBase; class CScrollInfo { public: - CScrollInfo(unsigned int wait = 50, float pos = 0, int speed = defaultSpeed, const CStdString &scrollSuffix = " | "); + CScrollInfo(unsigned int wait = 50, float pos = 0, int speed = defaultSpeed, const std::string &scrollSuffix = " | "); void SetSpeed(int speed) { @@ -70,7 +73,7 @@ public: // value will mean the text starts to the right pixelPos = -initialPos; // privates: - m_averageFrameTime = 1000.f / abs(defaultSpeed); + m_averageFrameTime = 1000.f / fabs((float)defaultSpeed); m_lastFrameTime = 0; } uint32_t GetCurrentChar(const vecText &text) const @@ -90,7 +93,7 @@ public: unsigned int characterPos; unsigned int initialWait; float initialPos; - CStdStringW suffix; + std::wstring suffix; static const int defaultSpeed = 60; private: @@ -105,11 +108,11 @@ private: class CGUIFont { public: - CGUIFont(const CStdString& strFontName, uint32_t style, color_t textColor, + CGUIFont(const std::string& strFontName, uint32_t style, color_t textColor, color_t shadowColor, float lineSpacing, float origHeight, CGUIFontTTFBase *font); virtual ~CGUIFont(); - CStdString& GetFontName(); + std::string& GetFontName(); void DrawText( float x, float y, color_t color, color_t shadowColor, const vecText &text, uint32_t alignment, float maxPixelWidth) @@ -151,7 +154,7 @@ public: void SetFont(CGUIFontTTFBase* font); protected: - CStdString m_strFontName; + std::string m_strFontName; uint32_t m_style; color_t m_shadowColor; color_t m_textColor; diff --git a/xbmc/guilib/GUIFontManager.cpp b/xbmc/guilib/GUIFontManager.cpp index e4c20363a6..52ce8bdc0e 100644 --- a/xbmc/guilib/GUIFontManager.cpp +++ b/xbmc/guilib/GUIFontManager.cpp @@ -76,8 +76,8 @@ void GUIFontManager::RescaleFontSizeAndAspect(float *size, float *aspect, const *size /= scaleY; } -static bool CheckFont(CStdString& strPath, const CStdString& newPath, - const CStdString& filename) +static bool CheckFont(std::string& strPath, const std::string& newPath, + const std::string& filename) { if (!XFILE::CFile::Exists(strPath)) { @@ -91,7 +91,7 @@ static bool CheckFont(CStdString& strPath, const CStdString& newPath, return true; } -CGUIFont* GUIFontManager::LoadTTF(const CStdString& strFontName, const CStdString& strFilename, color_t textColor, color_t shadowColor, const int iSize, const int iStyle, bool border, float lineSpacing, float aspect, const RESOLUTION_INFO *sourceRes, bool preserveAspect) +CGUIFont* GUIFontManager::LoadTTF(const std::string& strFontName, const std::string& strFilename, color_t textColor, color_t shadowColor, const int iSize, const int iStyle, bool border, float lineSpacing, float aspect, const RESOLUTION_INFO *sourceRes, bool preserveAspect) { float originalAspect = aspect; @@ -107,7 +107,7 @@ CGUIFont* GUIFontManager::LoadTTF(const CStdString& strFontName, const CStdStrin RescaleFontSizeAndAspect(&newSize, &aspect, *sourceRes, preserveAspect); // First try to load the font from the skin - CStdString strPath; + std::string strPath; if (!CURL::IsFullPath(strFilename)) { strPath = URIUtils::AddFileToFolder(g_graphicsContext.GetMediaDir(), "fonts"); @@ -121,12 +121,12 @@ CGUIFont* GUIFontManager::LoadTTF(const CStdString& strFontName, const CStdStrin #endif // Check if the file exists, otherwise try loading it from the global media dir - CStdString file = URIUtils::GetFileName(strFilename); + std::string file = URIUtils::GetFileName(strFilename); if (!CheckFont(strPath,"special://home/media/Fonts",file)) CheckFont(strPath,"special://xbmc/media/Fonts",file); // check if we already have this font file loaded (font object could differ only by color or style) - CStdString TTFfontName = StringUtils::Format("%s_%f_%f%s", strFilename.c_str(), newSize, aspect, border ? "_border" : ""); + std::string TTFfontName = StringUtils::Format("%s_%f_%f%s", strFilename.c_str(), newSize, aspect, border ? "_border" : ""); CGUIFontTTFBase* pFontFile = GetFontFile(TTFfontName); if (!pFontFile) @@ -214,12 +214,12 @@ void GUIFontManager::ReloadTTFFonts(void) float aspect = fontInfo.aspect; float newSize = (float)fontInfo.size; - CStdString& strPath = fontInfo.fontFilePath; - CStdString& strFilename = fontInfo.fileName; + std::string& strPath = fontInfo.fontFilePath; + std::string& strFilename = fontInfo.fileName; RescaleFontSizeAndAspect(&newSize, &aspect, fontInfo.sourceRes, fontInfo.preserveAspect); - CStdString TTFfontName = StringUtils::Format("%s_%f_%f%s", strFilename.c_str(), newSize, aspect, fontInfo.border ? "_border" : ""); + std::string TTFfontName = StringUtils::Format("%s_%f_%f%s", strFilename.c_str(), newSize, aspect, fontInfo.border ? "_border" : ""); CGUIFontTTFBase* pFontFile = GetFontFile(TTFfontName); if (!pFontFile) { @@ -239,11 +239,11 @@ void GUIFontManager::ReloadTTFFonts(void) } } -void GUIFontManager::Unload(const CStdString& strFontName) +void GUIFontManager::Unload(const std::string& strFontName) { for (vector<CGUIFont*>::iterator iFont = m_vecFonts.begin(); iFont != m_vecFonts.end(); ++iFont) { - if ((*iFont)->GetFontName().Equals(strFontName)) + if (StringUtils::EqualsNoCase((*iFont)->GetFontName(), strFontName)) { delete (*iFont); m_vecFonts.erase(iFont); @@ -265,27 +265,27 @@ void GUIFontManager::FreeFontFile(CGUIFontTTFBase *pFont) } } -CGUIFontTTFBase* GUIFontManager::GetFontFile(const CStdString& strFileName) +CGUIFontTTFBase* GUIFontManager::GetFontFile(const std::string& strFileName) { for (int i = 0; i < (int)m_vecFontFiles.size(); ++i) { CGUIFontTTFBase* pFont = (CGUIFontTTFBase *)m_vecFontFiles[i]; - if (pFont->GetFileName().Equals(strFileName)) + if (StringUtils::EqualsNoCase(pFont->GetFileName(), strFileName)) return pFont; } return NULL; } -CGUIFont* GUIFontManager::GetFont(const CStdString& strFontName, bool fallback /*= true*/) +CGUIFont* GUIFontManager::GetFont(const std::string& strFontName, bool fallback /*= true*/) { for (int i = 0; i < (int)m_vecFonts.size(); ++i) { CGUIFont* pFont = m_vecFonts[i]; - if (pFont->GetFontName().Equals(strFontName)) + if (StringUtils::EqualsNoCase(pFont->GetFontName(), strFontName)) return pFont; } // fall back to "font13" if we have none - if (fallback && !strFontName.empty() && !strFontName.Equals("-") && !strFontName.Equals("font13")) + if (fallback && !strFontName.empty() && strFontName != "-" && !StringUtils::EqualsNoCase(strFontName, "font13")) return GetFont("font13"); return NULL; } @@ -413,7 +413,7 @@ void GUIFontManager::LoadFonts(const TiXmlNode* fontNode) if (!fontName.empty() && URIUtils::HasExtension(fileName, ".ttf")) { // TODO: Why do we tolower() this shit? - CStdString strFontFileName = fileName; + std::string strFontFileName = fileName; StringUtils::ToLower(strFontFileName); LoadTTF(fontName, strFontFileName, textColor, shadowColor, iSize, iStyle, false, lineSpacing, aspect); } diff --git a/xbmc/guilib/GUIFontManager.h b/xbmc/guilib/GUIFontManager.h index ff3a235dcd..1a681b07f5 100644 --- a/xbmc/guilib/GUIFontManager.h +++ b/xbmc/guilib/GUIFontManager.h @@ -43,8 +43,8 @@ struct OrigFontInfo { int size; float aspect; - CStdString fontFilePath; - CStdString fileName; + std::string fontFilePath; + std::string fileName; RESOLUTION_INFO sourceRes; bool preserveAspect; bool border; @@ -62,10 +62,10 @@ public: virtual bool OnMessage(CGUIMessage &message); - void Unload(const CStdString& strFontName); + void Unload(const std::string& strFontName); void LoadFonts(const std::string &fontSet); - CGUIFont* LoadTTF(const CStdString& strFontName, const CStdString& strFilename, color_t textColor, color_t shadowColor, const int iSize, const int iStyle, bool border = false, float lineSpacing = 1.0f, float aspect = 1.0f, const RESOLUTION_INFO *res = NULL, bool preserveAspect = false); - CGUIFont* GetFont(const CStdString& strFontName, bool fallback = true); + CGUIFont* LoadTTF(const std::string& strFontName, const std::string& strFilename, color_t textColor, color_t shadowColor, const int iSize, const int iStyle, bool border = false, float lineSpacing = 1.0f, float aspect = 1.0f, const RESOLUTION_INFO *res = NULL, bool preserveAspect = false); + CGUIFont* GetFont(const std::string& strFontName, bool fallback = true); /*! \brief return a default font \param border whether the font should be a font with an outline @@ -82,7 +82,7 @@ protected: void ReloadTTFFonts(); static void RescaleFontSizeAndAspect(float *size, float *aspect, const RESOLUTION_INFO &sourceRes, bool preserveAspect); void LoadFonts(const TiXmlNode* fontNode); - CGUIFontTTFBase* GetFontFile(const CStdString& strFontFile); + CGUIFontTTFBase* GetFontFile(const std::string& strFontFile); static void GetStyle(const TiXmlNode *fontNode, int &iStyle); std::vector<CGUIFont*> m_vecFonts; diff --git a/xbmc/guilib/GUIFontTTF.cpp b/xbmc/guilib/GUIFontTTF.cpp index 4e6fb671d8..8416bdc022 100644 --- a/xbmc/guilib/GUIFontTTF.cpp +++ b/xbmc/guilib/GUIFontTTF.cpp @@ -69,7 +69,7 @@ public: FT_Done_FreeType(m_library); } - FT_Face GetFont(const CStdString &filename, float size, float aspect, XUTILS::auto_buffer& memoryBuf) + FT_Face GetFont(const std::string &filename, float size, float aspect, XUTILS::auto_buffer& memoryBuf) { // don't have it yet - create it if (!m_library) @@ -153,7 +153,7 @@ private: XBMC_GLOBAL_REF(CFreeTypeLibrary, g_freeTypeLibrary); // our freetype library #define g_freeTypeLibrary XBMC_GLOBAL_USE(CFreeTypeLibrary) -CGUIFontTTFBase::CGUIFontTTFBase(const CStdString& strFileName) +CGUIFontTTFBase::CGUIFontTTFBase(const std::string& strFileName) { m_texture = NULL; m_char = NULL; @@ -245,7 +245,7 @@ void CGUIFontTTFBase::Clear() m_fontFileInMemory.clear(); } -bool CGUIFontTTFBase::Load(const CStdString& strFilename, float height, float aspect, float lineSpacing, bool border) +bool CGUIFontTTFBase::Load(const std::string& strFilename, float height, float aspect, float lineSpacing, bool border) { // we now know that this object is unique - only the GUIFont objects are non-unique, so no need // for reference tracking these fonts @@ -394,7 +394,7 @@ void CGUIFontTTFBase::DrawTextInternal(float x, float y, const vecColors &colors for (vecText::const_iterator pos = text.begin(); pos != text.end(); ++pos) { // If starting text on a new line, determine justification effects - // Get the current letter in the CStdString + // Get the current letter in the std::string color_t color = (*pos & 0xff0000) >> 16; if (color >= colors.size()) color = 0; diff --git a/xbmc/guilib/GUIFontTTF.h b/xbmc/guilib/GUIFontTTF.h index 1714ed7f51..2bb8a8da6a 100644 --- a/xbmc/guilib/GUIFontTTF.h +++ b/xbmc/guilib/GUIFontTTF.h @@ -27,6 +27,10 @@ * */ +#include <string> +#include <stdint.h> +#include <vector> + #include "utils/auto_buffer.h" // forward definition @@ -72,17 +76,17 @@ class CGUIFontTTFBase public: - CGUIFontTTFBase(const CStdString& strFileName); + CGUIFontTTFBase(const std::string& strFileName); virtual ~CGUIFontTTFBase(void); void Clear(); - bool Load(const CStdString& strFilename, float height = 20.0f, float aspect = 1.0f, float lineSpacing = 1.0f, bool border = false); + bool Load(const std::string& strFilename, float height = 20.0f, float aspect = 1.0f, float lineSpacing = 1.0f, bool border = false); virtual void Begin() = 0; virtual void End() = 0; - const CStdString& GetFileName() const { return m_strFileName; }; + const std::string& GetFileName() const { return m_strFileName; }; protected: struct Character @@ -106,7 +110,7 @@ protected: uint32_t alignment, float maxPixelWidth, bool scrolling); float m_height; - CStdString m_strFilename; + std::string m_strFilename; // Stuff for pre-rendering for speed inline Character *GetCharacter(character_t letter); @@ -167,7 +171,7 @@ protected: static int justification_word_weight; - CStdString m_strFileName; + std::string m_strFileName; XUTILS::auto_buffer m_fontFileInMemory; // used only in some cases, see CFreeTypeLibrary::GetFont() private: diff --git a/xbmc/guilib/GUIFontTTFDX.cpp b/xbmc/guilib/GUIFontTTFDX.cpp index e3eba247f0..44bd2306a0 100644 --- a/xbmc/guilib/GUIFontTTFDX.cpp +++ b/xbmc/guilib/GUIFontTTFDX.cpp @@ -37,7 +37,7 @@ using namespace std; -CGUIFontTTFDX::CGUIFontTTFDX(const CStdString& strFileName) +CGUIFontTTFDX::CGUIFontTTFDX(const std::string& strFileName) : CGUIFontTTFBase(strFileName) { m_speedupTexture = NULL; diff --git a/xbmc/guilib/GUIFontTTFDX.h b/xbmc/guilib/GUIFontTTFDX.h index 0431085eb3..f9f997746f 100644 --- a/xbmc/guilib/GUIFontTTFDX.h +++ b/xbmc/guilib/GUIFontTTFDX.h @@ -38,7 +38,7 @@ class CGUIFontTTFDX : public CGUIFontTTFBase { public: - CGUIFontTTFDX(const CStdString& strFileName); + CGUIFontTTFDX(const std::string& strFileName); virtual ~CGUIFontTTFDX(void); virtual void Begin(); diff --git a/xbmc/guilib/GUIFontTTFGL.cpp b/xbmc/guilib/GUIFontTTFGL.cpp index 6a8291b308..5a93cb0238 100644 --- a/xbmc/guilib/GUIFontTTFGL.cpp +++ b/xbmc/guilib/GUIFontTTFGL.cpp @@ -41,7 +41,7 @@ using namespace std; #if defined(HAS_GL) || defined(HAS_GLES) -CGUIFontTTFGL::CGUIFontTTFGL(const CStdString& strFileName) +CGUIFontTTFGL::CGUIFontTTFGL(const std::string& strFileName) : CGUIFontTTFBase(strFileName) { m_updateY1 = 0; diff --git a/xbmc/guilib/GUIFontTTFGL.h b/xbmc/guilib/GUIFontTTFGL.h index c0bb53af94..8b26b1570c 100644 --- a/xbmc/guilib/GUIFontTTFGL.h +++ b/xbmc/guilib/GUIFontTTFGL.h @@ -38,7 +38,7 @@ class CGUIFontTTFGL : public CGUIFontTTFBase { public: - CGUIFontTTFGL(const CStdString& strFileName); + CGUIFontTTFGL(const std::string& strFileName); virtual ~CGUIFontTTFGL(void); virtual void Begin(); diff --git a/xbmc/guilib/GUIImage.cpp b/xbmc/guilib/GUIImage.cpp index 6712722d98..8438135f7f 100644 --- a/xbmc/guilib/GUIImage.cpp +++ b/xbmc/guilib/GUIImage.cpp @@ -303,7 +303,7 @@ CRect CGUIImage::CalcRenderRegion() const return CGUIControl::CalcRenderRegion().Intersect(region); } -const CStdString &CGUIImage::GetFileName() const +const std::string &CGUIImage::GetFileName() const { return m_texture.GetFileName(); } @@ -320,7 +320,7 @@ void CGUIImage::SetCrossFade(unsigned int time) m_crossFadeTime = 1; } -void CGUIImage::SetFileName(const CStdString& strFileName, bool setConstant, const bool useCache) +void CGUIImage::SetFileName(const std::string& strFileName, bool setConstant, const bool useCache) { if (setConstant) m_info.SetLabel(strFileName, "", GetParentID()); @@ -331,7 +331,7 @@ void CGUIImage::SetFileName(const CStdString& strFileName, bool setConstant, con if (m_crossFadeTime) { // set filename on the next texture - if (m_currentTexture.Equals(strFileName)) + if (m_currentTexture == strFileName) return; // nothing to do - we already have this image if (m_texture.ReadyToRender() || m_texture.GetFileName().empty()) @@ -341,7 +341,7 @@ void CGUIImage::SetFileName(const CStdString& strFileName, bool setConstant, con } m_currentFadeTime = 0; } - if (!m_currentTexture.Equals(strFileName)) + if (m_currentTexture != strFileName) { // texture is changing - attempt to load it, and save the name in m_currentTexture. // we'll check whether it loaded or not in Render() m_currentTexture = strFileName; diff --git a/xbmc/guilib/GUIImage.h b/xbmc/guilib/GUIImage.h index 1f73229195..27f9fd9cc3 100644 --- a/xbmc/guilib/GUIImage.h +++ b/xbmc/guilib/GUIImage.h @@ -84,7 +84,7 @@ public: virtual void UpdateInfo(const CGUIListItem *item = NULL); virtual void SetInfo(const CGUIInfoLabel &info); - virtual void SetFileName(const CStdString& strFileName, bool setConstant = false, const bool useCache = true); + virtual void SetFileName(const std::string& strFileName, bool setConstant = false, const bool useCache = true); virtual void SetAspectRatio(const CAspectRatio &aspect); virtual void SetWidth(float width); virtual void SetHeight(float height); @@ -92,7 +92,7 @@ public: virtual std::string GetDescription() const; void SetCrossFade(unsigned int time); - const CStdString& GetFileName() const; + const std::string& GetFileName() const; float GetTextureWidth() const; float GetTextureHeight() const; @@ -116,7 +116,7 @@ protected: CGUITexture m_texture; std::vector<CFadingTexture *> m_fadingTextures; - CStdString m_currentTexture; + std::string m_currentTexture; std::string m_currentFallback; unsigned int m_crossFadeTime; diff --git a/xbmc/guilib/GUIIncludes.cpp b/xbmc/guilib/GUIIncludes.cpp index 0ebf072a3c..aa4d059629 100644 --- a/xbmc/guilib/GUIIncludes.cpp +++ b/xbmc/guilib/GUIIncludes.cpp @@ -98,7 +98,7 @@ void CGUIIncludes::ClearIncludes() m_files.clear(); } -bool CGUIIncludes::LoadIncludes(const CStdString &includeFile) +bool CGUIIncludes::LoadIncludes(const std::string &includeFile) { // check to see if we already have this loaded if (HasIncludeFile(includeFile)) @@ -131,8 +131,8 @@ bool CGUIIncludes::LoadIncludesFromXML(const TiXmlElement *root) { if (node->Attribute("name") && node->FirstChild()) { - CStdString tagName = node->Attribute("name"); - m_includes.insert(pair<CStdString, TiXmlElement>(tagName, *node)); + std::string tagName = node->Attribute("name"); + m_includes.insert(pair<std::string, TiXmlElement>(tagName, *node)); } else if (node->Attribute("file")) { // load this file in as well @@ -146,8 +146,8 @@ bool CGUIIncludes::LoadIncludesFromXML(const TiXmlElement *root) { if (node->Attribute("type") && node->FirstChild()) { - CStdString tagName = node->Attribute("type"); - m_defaults.insert(pair<CStdString, TiXmlElement>(tagName, *node)); + std::string tagName = node->Attribute("type"); + m_defaults.insert(pair<std::string, TiXmlElement>(tagName, *node)); } node = node->NextSiblingElement("default"); } @@ -157,7 +157,7 @@ bool CGUIIncludes::LoadIncludesFromXML(const TiXmlElement *root) { if (node->Attribute("name") && node->FirstChild()) { - CStdString tagName = node->Attribute("name"); + std::string tagName = node->Attribute("name"); m_constants.insert(make_pair(tagName, node->FirstChild()->ValueStr())); } node = node->NextSiblingElement("constant"); @@ -168,7 +168,7 @@ bool CGUIIncludes::LoadIncludesFromXML(const TiXmlElement *root) { if (node->Attribute("name") && node->FirstChild()) { - CStdString tagName = node->Attribute("name"); + std::string tagName = node->Attribute("name"); m_skinvariables.insert(make_pair(tagName, *node)); } node = node->NextSiblingElement("variable"); @@ -177,7 +177,7 @@ bool CGUIIncludes::LoadIncludesFromXML(const TiXmlElement *root) return true; } -bool CGUIIncludes::HasIncludeFile(const CStdString &file) const +bool CGUIIncludes::HasIncludeFile(const std::string &file) const { for (iFiles it = m_files.begin(); it != m_files.end(); ++it) if (*it == file) return true; @@ -205,11 +205,11 @@ void CGUIIncludes::ResolveIncludesForNode(TiXmlElement *node, std::map<INFO::Inf if (!node) return; // First add the defaults if this is for a control - CStdString type; + std::string type; if (node->ValueStr() == "control") { type = XMLUtils::GetAttribute(node, "type"); - map<CStdString, TiXmlElement>::const_iterator it = m_defaults.find(type); + map<std::string, TiXmlElement>::const_iterator it = m_defaults.find(type); if (it != m_defaults.end()) { // we don't insert <left> et. al. if <posx> or <posy> is specified @@ -258,8 +258,8 @@ void CGUIIncludes::ResolveIncludesForNode(TiXmlElement *node, std::map<INFO::Inf continue; } } - CStdString tagName = include->FirstChild()->Value(); - map<CStdString, TiXmlElement>::const_iterator it = m_includes.find(tagName); + std::string tagName = include->FirstChild()->Value(); + map<std::string, TiXmlElement>::const_iterator it = m_includes.find(tagName); if (it != m_includes.end()) { // found the tag(s) to include - let's replace it const TiXmlElement &element = (*it).second; @@ -295,21 +295,21 @@ void CGUIIncludes::ResolveIncludesForNode(TiXmlElement *node, std::map<INFO::Inf node->FirstChild()->SetValue(ResolveConstant(node->FirstChild()->ValueStr())); } -CStdString CGUIIncludes::ResolveConstant(const CStdString &constant) const +std::string CGUIIncludes::ResolveConstant(const std::string &constant) const { vector<string> values = StringUtils::Split(constant, ","); for (vector<string>::iterator i = values.begin(); i != values.end(); ++i) { - map<CStdString, CStdString>::const_iterator it = m_constants.find(*i); + map<std::string, std::string>::const_iterator it = m_constants.find(*i); if (it != m_constants.end()) *i = it->second; } return StringUtils::Join(values, ","); } -const INFO::CSkinVariableString* CGUIIncludes::CreateSkinVariable(const CStdString& name, int context) +const INFO::CSkinVariableString* CGUIIncludes::CreateSkinVariable(const std::string& name, int context) { - map<CStdString, TiXmlElement>::const_iterator it = m_skinvariables.find(name); + map<std::string, TiXmlElement>::const_iterator it = m_skinvariables.find(name); if (it != m_skinvariables.end()) return INFO::CSkinVariable::CreateFromXML(it->second, context); return NULL; diff --git a/xbmc/guilib/GUIIncludes.h b/xbmc/guilib/GUIIncludes.h index 004d401221..4c2140ff3f 100644 --- a/xbmc/guilib/GUIIncludes.h +++ b/xbmc/guilib/GUIIncludes.h @@ -20,10 +20,10 @@ * */ -#include "utils/StdString.h" - #include <map> #include <set> +#include <string> +#include <vector> #include "interfaces/info/InfoBool.h" // forward definitions @@ -40,7 +40,7 @@ public: ~CGUIIncludes(); void ClearIncludes(); - bool LoadIncludes(const CStdString &includeFile); + bool LoadIncludes(const std::string &includeFile); bool LoadIncludesFromXML(const TiXmlElement *root); /*! \brief Resolve <include>name</include> tags recursively for the given XML element @@ -49,18 +49,18 @@ public: \param node an XML Element - all child elements are traversed. */ void ResolveIncludes(TiXmlElement *node, std::map<INFO::InfoPtr, bool>* xmlIncludeConditions = NULL); - const INFO::CSkinVariableString* CreateSkinVariable(const CStdString& name, int context); + const INFO::CSkinVariableString* CreateSkinVariable(const std::string& name, int context); private: void ResolveIncludesForNode(TiXmlElement *node, std::map<INFO::InfoPtr, bool>* xmlIncludeConditions = NULL); - CStdString ResolveConstant(const CStdString &constant) const; - bool HasIncludeFile(const CStdString &includeFile) const; - std::map<CStdString, TiXmlElement> m_includes; - std::map<CStdString, TiXmlElement> m_defaults; - std::map<CStdString, TiXmlElement> m_skinvariables; - std::map<CStdString, CStdString> m_constants; - std::vector<CStdString> m_files; - typedef std::vector<CStdString>::const_iterator iFiles; + std::string ResolveConstant(const std::string &constant) const; + bool HasIncludeFile(const std::string &includeFile) const; + std::map<std::string, TiXmlElement> m_includes; + std::map<std::string, TiXmlElement> m_defaults; + std::map<std::string, TiXmlElement> m_skinvariables; + std::map<std::string, std::string> m_constants; + std::vector<std::string> m_files; + typedef std::vector<std::string>::const_iterator iFiles; std::set<std::string> m_constantAttributes; std::set<std::string> m_constantNodes; diff --git a/xbmc/guilib/GUIInfoTypes.cpp b/xbmc/guilib/GUIInfoTypes.cpp index 4fd7d6e80d..ead9dffadf 100644 --- a/xbmc/guilib/GUIInfoTypes.cpp +++ b/xbmc/guilib/GUIInfoTypes.cpp @@ -87,7 +87,7 @@ bool CGUIInfoColor::Update() // Expand the infolabel, and then convert it to a color std::string infoLabel(g_infoManager.GetLabel(m_info)); - color_t color = !infoLabel.empty() ? g_colorManager.GetColor(infoLabel) : 0; + color_t color = !infoLabel.empty() ? g_colorManager.GetColor(infoLabel.c_str()) : 0; if (m_color != color) { m_color = color; @@ -366,11 +366,11 @@ void CGUIInfoLabel::Parse(const std::string &label, int context) m_info.push_back(CInfoPortion(0, work, "")); } -CGUIInfoLabel::CInfoPortion::CInfoPortion(int info, const std::string &prefix, const std::string &postfix, bool escaped /*= false */) +CGUIInfoLabel::CInfoPortion::CInfoPortion(int info, const std::string &prefix, const std::string &postfix, bool escaped /*= false */): + m_prefix(prefix), + m_postfix(postfix) { m_info = info; - m_prefix = prefix; - m_postfix = postfix; m_escaped = escaped; // filter our prefix and postfix for comma's StringUtils::Replace(m_prefix, "$COMMA", ","); diff --git a/xbmc/guilib/GUILabel.cpp b/xbmc/guilib/GUILabel.cpp index 5ca8f4a4ca..759ac0975a 100644 --- a/xbmc/guilib/GUILabel.cpp +++ b/xbmc/guilib/GUILabel.cpp @@ -167,7 +167,7 @@ bool CGUILabel::SetStyledText(const vecText &text, const vecColors &colors) return true; } -bool CGUILabel::SetText(const CStdString &label) +bool CGUILabel::SetText(const std::string &label) { if (m_textLayout.Update(label, m_maxRect.Width(), m_invalid)) { // needed an update - reset scrolling and update our text layout @@ -180,7 +180,7 @@ bool CGUILabel::SetText(const CStdString &label) return false; } -bool CGUILabel::SetTextW(const CStdStringW &label) +bool CGUILabel::SetTextW(const std::wstring &label) { if (m_textLayout.UpdateW(label, m_maxRect.Width(), m_invalid)) { diff --git a/xbmc/guilib/GUILabel.h b/xbmc/guilib/GUILabel.h index 6bca836017..0a4faf11d0 100644 --- a/xbmc/guilib/GUILabel.h +++ b/xbmc/guilib/GUILabel.h @@ -70,7 +70,7 @@ public: float angle; CGUIFont *font; int scrollSpeed; - CStdString scrollSuffix; + std::string scrollSuffix; }; /*! @@ -117,17 +117,17 @@ public: /*! \brief Set the text to be displayed in the label Updates the label control and recomputes final position and size - \param text CStdString to set as this labels text + \param text std::string to set as this labels text \sa SetTextW, SetStyledText */ - bool SetText(const CStdString &label); + bool SetText(const std::string &label); /*! \brief Set the text to be displayed in the label Updates the label control and recomputes final position and size - \param text CStdStringW to set as this labels text + \param text std::wstring to set as this labels text \sa SetText, SetStyledText */ - bool SetTextW(const CStdStringW &label); + bool SetTextW(const std::wstring &label); /*! \brief Set styled text to be displayed in the label Updates the label control and recomputes final position and size @@ -189,11 +189,11 @@ public: float GetMaxWidth() const; /*! \brief Calculates the width of some text - \param text CStdStringW of text whose width we want + \param text std::wstring of text whose width we want \return width of the given text \sa GetTextWidth */ - float CalcTextWidth(const CStdStringW &text) const { return m_textLayout.GetTextWidth(text); }; + float CalcTextWidth(const std::wstring &text) const { return m_textLayout.GetTextWidth(text); }; const CLabelInfo& GetLabelInfo() const { return m_label; }; CLabelInfo &GetLabelInfo() { return m_label; }; diff --git a/xbmc/guilib/GUILabelControl.cpp b/xbmc/guilib/GUILabelControl.cpp index 47aef2ca11..59cf901e45 100644 --- a/xbmc/guilib/GUILabelControl.cpp +++ b/xbmc/guilib/GUILabelControl.cpp @@ -49,8 +49,8 @@ void CGUILabelControl::ShowCursor(bool bShow) void CGUILabelControl::SetCursorPos(int iPos) { - CStdString labelUTF8 = m_infoLabel.GetLabel(m_parentID); - CStdStringW label; + std::string labelUTF8 = m_infoLabel.GetLabel(m_parentID); + std::wstring label; g_charsetConverter.utf8ToW(labelUTF8, label); if (iPos > (int)label.length()) iPos = label.length(); if (iPos < 0) iPos = 0; @@ -76,12 +76,12 @@ bool CGUILabelControl::UpdateColors() void CGUILabelControl::UpdateInfo(const CGUIListItem *item) { - CStdString label(m_infoLabel.GetLabel(m_parentID)); + std::string label(m_infoLabel.GetLabel(m_parentID)); bool changed = false; if (m_startHighlight < m_endHighlight || m_startSelection < m_endSelection || m_bShowCursor) { - CStdStringW utf16; + std::wstring utf16; g_charsetConverter.utf8ToW(label, utf16); vecText text; text.reserve(utf16.size()+1); vecColors colors; @@ -216,7 +216,7 @@ bool CGUILabelControl::OnMessage(CGUIMessage& message) return CGUIControl::OnMessage(message); } -CStdString CGUILabelControl::ShortenPath(const CStdString &path) +std::string CGUILabelControl::ShortenPath(const std::string &path) { if (m_width == 0 || path.empty()) return path; @@ -236,7 +236,7 @@ CStdString CGUILabelControl::ShortenPath(const CStdString &path) if ( cDelim == '\0' ) return path; - CStdString workPath(path); + std::string workPath(path); // remove trailing slashes if (workPath.size() > 3) if (!StringUtils::EndsWith(workPath, "://") && diff --git a/xbmc/guilib/GUILabelControl.h b/xbmc/guilib/GUILabelControl.h index 5a6f7ff5d8..5e3e78fa65 100644 --- a/xbmc/guilib/GUILabelControl.h +++ b/xbmc/guilib/GUILabelControl.h @@ -66,7 +66,7 @@ public: protected: bool UpdateColors(); - CStdString ShortenPath(const CStdString &path); + std::string ShortenPath(const std::string &path); /*! \brief Return the maximum width of this label control. \return Return the width of the control if available, else the width of the current text. diff --git a/xbmc/guilib/GUIListContainer.cpp b/xbmc/guilib/GUIListContainer.cpp index 171b02c8e3..c3516ddcbf 100644 --- a/xbmc/guilib/GUIListContainer.cpp +++ b/xbmc/guilib/GUIListContainer.cpp @@ -295,8 +295,8 @@ CGUIListContainer::CGUIListContainer(int parentID, int controlID, float posX, fl CGUIListItemLayout layout; layout.CreateListControlLayouts(width, textureHeight + spaceBetweenItems, false, labelInfo, labelInfo2, textureButton, textureButtonFocus, textureHeight, itemWidth, itemHeight, "", ""); m_layouts.push_back(layout); - CStdString condition = StringUtils::Format("control.hasfocus(%i)", controlID); - CStdString condition2 = "!" + condition; + std::string condition = StringUtils::Format("control.hasfocus(%i)", controlID); + std::string condition2 = "!" + condition; CGUIListItemLayout focusLayout; focusLayout.CreateListControlLayouts(width, textureHeight + spaceBetweenItems, true, labelInfo, labelInfo2, textureButton, textureButtonFocus, textureHeight, itemWidth, itemHeight, condition2, condition); m_focusedLayouts.push_back(focusLayout); diff --git a/xbmc/guilib/GUIListItem.cpp b/xbmc/guilib/GUIListItem.cpp index 4920c715c8..56b13d643f 100644 --- a/xbmc/guilib/GUIListItem.cpp +++ b/xbmc/guilib/GUIListItem.cpp @@ -43,23 +43,18 @@ CGUIListItem::CGUIListItem(const CGUIListItem& item) CGUIListItem::CGUIListItem(void) { m_bIsFolder = false; - m_strLabel2 = ""; - m_strLabel = ""; m_bSelected = false; - m_strIcon = ""; m_overlayIcon = ICON_OVERLAY_NONE; m_layout = NULL; m_focusedLayout = NULL; } -CGUIListItem::CGUIListItem(const std::string& strLabel) +CGUIListItem::CGUIListItem(const std::string& strLabel): + m_strLabel(strLabel) { m_bIsFolder = false; - m_strLabel2 = ""; - m_strLabel = strLabel; SetSortLabel(strLabel); m_bSelected = false; - m_strIcon = ""; m_overlayIcon = ICON_OVERLAY_NONE; m_layout = NULL; m_focusedLayout = NULL; diff --git a/xbmc/guilib/GUIListItemLayout.cpp b/xbmc/guilib/GUIListItemLayout.cpp index 806a26b122..44744c5388 100644 --- a/xbmc/guilib/GUIListItemLayout.cpp +++ b/xbmc/guilib/GUIListItemLayout.cpp @@ -192,7 +192,7 @@ void CGUIListItemLayout::LoadLayout(TiXmlElement *layout, int context, bool focu } //#ifdef GUILIB_PYTHON_COMPATIBILITY -void CGUIListItemLayout::CreateListControlLayouts(float width, float height, bool focused, const CLabelInfo &labelInfo, const CLabelInfo &labelInfo2, const CTextureInfo &texture, const CTextureInfo &textureFocus, float texHeight, float iconWidth, float iconHeight, const CStdString &nofocusCondition, const CStdString &focusCondition) +void CGUIListItemLayout::CreateListControlLayouts(float width, float height, bool focused, const CLabelInfo &labelInfo, const CLabelInfo &labelInfo2, const CTextureInfo &texture, const CTextureInfo &textureFocus, float texHeight, float iconWidth, float iconHeight, const std::string &nofocusCondition, const std::string &focusCondition) { m_width = width; m_height = height; @@ -212,10 +212,10 @@ void CGUIListItemLayout::CreateListControlLayouts(float width, float height, boo image->SetAspectRatio(CAspectRatio::AR_KEEP); m_group.AddControl(image); float x = iconWidth + labelInfo.offsetX + 10; - CGUIListLabel *label = new CGUIListLabel(0, 0, x, labelInfo.offsetY, width - x - 18, height, labelInfo, CGUIInfoLabel("$INFO[ListItem.Label]", "", m_group.GetParentID()), false); + CGUIListLabel *label = new CGUIListLabel(0, 0, x, labelInfo.offsetY, width - x - 18, height, labelInfo, CGUIInfoLabel("$INFO[ListItem.Label]", "", m_group.GetParentID()), CGUIControl::FOCUS); m_group.AddControl(label); x = labelInfo2.offsetX ? labelInfo2.offsetX : m_width - 16; - label = new CGUIListLabel(0, 0, x, labelInfo2.offsetY, x - iconWidth - 20, height, labelInfo2, CGUIInfoLabel("$INFO[ListItem.Label2]", "", m_group.GetParentID()), false); + label = new CGUIListLabel(0, 0, x, labelInfo2.offsetY, x - iconWidth - 20, height, labelInfo2, CGUIInfoLabel("$INFO[ListItem.Label2]", "", m_group.GetParentID()), CGUIControl::FOCUS); m_group.AddControl(label); } //#endif diff --git a/xbmc/guilib/GUIListItemLayout.h b/xbmc/guilib/GUIListItemLayout.h index ce80d1c772..435f0e6395 100644 --- a/xbmc/guilib/GUIListItemLayout.h +++ b/xbmc/guilib/GUIListItemLayout.h @@ -46,7 +46,7 @@ public: void FreeResources(bool immediately = false); //#ifdef GUILIB_PYTHON_COMPATIBILITY - void CreateListControlLayouts(float width, float height, bool focused, const CLabelInfo &labelInfo, const CLabelInfo &labelInfo2, const CTextureInfo &texture, const CTextureInfo &textureFocus, float texHeight, float iconWidth, float iconHeight, const CStdString &nofocusCondition, const CStdString &focusCondition); + void CreateListControlLayouts(float width, float height, bool focused, const CLabelInfo &labelInfo, const CLabelInfo &labelInfo2, const CTextureInfo &texture, const CTextureInfo &textureFocus, float texHeight, float iconWidth, float iconHeight, const std::string &nofocusCondition, const std::string &focusCondition); //#endif void SetWidth(float width); diff --git a/xbmc/guilib/GUIListLabel.cpp b/xbmc/guilib/GUIListLabel.cpp index 12a3efa0e8..1df36b2d53 100644 --- a/xbmc/guilib/GUIListLabel.cpp +++ b/xbmc/guilib/GUIListLabel.cpp @@ -22,12 +22,12 @@ #include <limits> #include "addons/Skin.h" -CGUIListLabel::CGUIListLabel(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, const CGUIInfoLabel &info, bool alwaysScroll) +CGUIListLabel::CGUIListLabel(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, const CGUIInfoLabel &info, CGUIControl::GUISCROLLVALUE scroll) : CGUIControl(parentID, controlID, posX, posY, width, height) - , m_label(posX, posY, width, height, labelInfo, alwaysScroll ? CGUILabel::OVER_FLOW_SCROLL : CGUILabel::OVER_FLOW_TRUNCATE) + , m_label(posX, posY, width, height, labelInfo, (scroll == CGUIControl::ALWAYS) ? CGUILabel::OVER_FLOW_SCROLL : CGUILabel::OVER_FLOW_TRUNCATE) , m_info(info) { - m_alwaysScroll = alwaysScroll; + m_scroll = scroll; if (g_SkinInfo && g_SkinInfo->APIVersion() < ADDON::AddonVersion("5.1.0")) { if (labelInfo.align & XBFONT_RIGHT) @@ -46,7 +46,10 @@ CGUIListLabel::~CGUIListLabel(void) void CGUIListLabel::SetScrolling(bool scrolling) { - m_label.SetScrolling(scrolling || m_alwaysScroll); + if (m_scroll == CGUIControl::FOCUS) + m_label.SetScrolling(scrolling); + else + m_label.SetScrolling((m_scroll == CGUIControl::ALWAYS) ? true : false); } void CGUIListLabel::SetSelected(bool selected) @@ -118,7 +121,7 @@ void CGUIListLabel::SetWidth(float width) CGUIControl::SetWidth(m_width); } -void CGUIListLabel::SetLabel(const CStdString &label) +void CGUIListLabel::SetLabel(const std::string &label) { m_label.SetText(label); } diff --git a/xbmc/guilib/GUIListLabel.h b/xbmc/guilib/GUIListLabel.h index 05b2142413..fed91fea5d 100644 --- a/xbmc/guilib/GUIListLabel.h +++ b/xbmc/guilib/GUIListLabel.h @@ -36,7 +36,7 @@ class CGUIListLabel : public CGUIControl { public: - CGUIListLabel(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, const CGUIInfoLabel &label, bool alwaysScroll); + CGUIListLabel(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, const CGUIInfoLabel &label, CGUIControl::GUISCROLLVALUE scroll); virtual ~CGUIListLabel(void); virtual CGUIListLabel *Clone() const { return new CGUIListLabel(*this); }; @@ -48,7 +48,7 @@ public: virtual void SetInvalid(); virtual void SetWidth(float width); - void SetLabel(const CStdString &label); + void SetLabel(const std::string &label); void SetSelected(bool selected); void SetScrolling(bool scrolling); @@ -64,5 +64,5 @@ protected: CGUILabel m_label; CGUIInfoLabel m_info; - bool m_alwaysScroll; + CGUIControl::GUISCROLLVALUE m_scroll; }; diff --git a/xbmc/guilib/GUIMultiImage.cpp b/xbmc/guilib/GUIMultiImage.cpp index 57e8b9a252..614527fc56 100644 --- a/xbmc/guilib/GUIMultiImage.cpp +++ b/xbmc/guilib/GUIMultiImage.cpp @@ -99,7 +99,7 @@ void CGUIMultiImage::UpdateInfo(const CGUIListItem *item) // alloc as this can free our resources if (!m_texturePath.IsConstant()) { - CStdString texturePath; + std::string texturePath; if (item) texturePath = m_texturePath.GetItemLabel(item, true); else @@ -289,7 +289,7 @@ std::string CGUIMultiImage::GetDescription() const return m_image.GetDescription(); } -CGUIMultiImage::CMultiImageJob::CMultiImageJob(const CStdString &path) +CGUIMultiImage::CMultiImageJob::CMultiImageJob(const std::string &path) : m_path(path) { } @@ -307,7 +307,7 @@ bool CGUIMultiImage::CMultiImageJob::DoWork() { // Load in images from the directory specified // m_path is relative (as are all skin paths) - CStdString realPath = g_TextureManager.GetTexturePath(m_path, true); + std::string realPath = g_TextureManager.GetTexturePath(m_path, true); if (realPath.empty()) return true; diff --git a/xbmc/guilib/GUIMultiImage.h b/xbmc/guilib/GUIMultiImage.h index e3d07b287b..e4af967ae1 100644 --- a/xbmc/guilib/GUIMultiImage.h +++ b/xbmc/guilib/GUIMultiImage.h @@ -73,16 +73,16 @@ protected: class CMultiImageJob : public CJob { public: - CMultiImageJob(const CStdString &path); + CMultiImageJob(const std::string &path); virtual bool DoWork(); virtual const char *GetType() const { return "multiimage"; }; - std::vector<CStdString> m_files; - CStdString m_path; + std::vector<std::string> m_files; + std::string m_path; }; CGUIInfoLabel m_texturePath; - CStdString m_currentPath; + std::string m_currentPath; unsigned int m_currentImage; CStopWatch m_imageTimer; unsigned int m_timePerImage; @@ -91,7 +91,7 @@ protected: bool m_loop; bool m_bDynamicResourceAlloc; - std::vector<CStdString> m_files; + std::vector<std::string> m_files; CGUIImage m_image; diff --git a/xbmc/guilib/GUIMultiSelectText.cpp b/xbmc/guilib/GUIMultiSelectText.cpp index 473a52a81c..8a27a0eb8a 100644 --- a/xbmc/guilib/GUIMultiSelectText.cpp +++ b/xbmc/guilib/GUIMultiSelectText.cpp @@ -26,7 +26,7 @@ using namespace std; -CGUIMultiSelectTextControl::CSelectableString::CSelectableString(CGUIFont *font, const CStdString &text, bool selectable, const CStdString &clickAction) +CGUIMultiSelectTextControl::CSelectableString::CSelectableString(CGUIFont *font, const std::string &text, bool selectable, const std::string &clickAction) : m_text(font, false) { m_selectable = selectable; @@ -170,7 +170,7 @@ bool CGUIMultiSelectTextControl::OnAction(const CAction &action) if (action.GetID() == ACTION_SELECT_ITEM) { // item is clicked - see if we have a clickaction - CStdString clickAction; + std::string clickAction; unsigned int selected = 0; for (unsigned int i = 0; i < m_items.size(); i++) { @@ -290,7 +290,7 @@ int CGUIMultiSelectTextControl::GetItemFromPoint(const CPoint &point) const return -1; } -void CGUIMultiSelectTextControl::UpdateText(const CStdString &text) +void CGUIMultiSelectTextControl::UpdateText(const std::string &text) { if (text == m_oldText) return; @@ -303,11 +303,11 @@ void CGUIMultiSelectTextControl::UpdateText(const CStdString &text) size_t startUnclickable = 0; // add the first unclickable block - if (startClickable != CStdString::npos) + if (startClickable != std::string::npos) AddString(text.substr(startUnclickable, startClickable - startUnclickable), false); else AddString(text.substr(startUnclickable), false); - while (startClickable != CStdString::npos) + while (startClickable != std::string::npos) { // grep out the action and the end of the string size_t endAction = text.find(']', startClickable + 8); @@ -324,7 +324,7 @@ void CGUIMultiSelectTextControl::UpdateText(const CStdString &text) } startClickable = text.find("[ONCLICK", startUnclickable); // add the unclickable portion - if (startClickable != CStdString::npos) + if (startClickable != std::string::npos) AddString(text.substr(startUnclickable, startClickable - startUnclickable), false); else AddString(text.substr(startUnclickable), false); @@ -336,7 +336,7 @@ void CGUIMultiSelectTextControl::UpdateText(const CStdString &text) PositionButtons(); } -void CGUIMultiSelectTextControl::AddString(const CStdString &text, bool selectable, const CStdString &clickAction) +void CGUIMultiSelectTextControl::AddString(const std::string &text, bool selectable, const std::string &clickAction) { if (!text.empty()) m_items.push_back(CSelectableString(m_label.font, text, selectable, clickAction)); diff --git a/xbmc/guilib/GUIMultiSelectText.h b/xbmc/guilib/GUIMultiSelectText.h index 5c433f7962..7b390fc7b1 100644 --- a/xbmc/guilib/GUIMultiSelectText.h +++ b/xbmc/guilib/GUIMultiSelectText.h @@ -49,7 +49,7 @@ public: virtual std::string GetDescription() const; virtual bool CanFocus() const; - void UpdateText(const CStdString &text); + void UpdateText(const std::string &text); bool MoveLeft(); bool MoveRight(); void SelectItemFromPoint(const CPoint &point); @@ -62,7 +62,7 @@ public: protected: virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event); virtual bool UpdateColors(); - void AddString(const CStdString &text, bool selectable, const CStdString &clickAction = ""); + void AddString(const std::string &text, bool selectable, const std::string &clickAction = ""); void PositionButtons(); unsigned int GetNumSelectable() const; int GetItemFromPoint(const CPoint &point) const; @@ -72,17 +72,17 @@ protected: class CSelectableString { public: - CSelectableString(CGUIFont *font, const CStdString &text, bool selectable, const CStdString &clickAction); + CSelectableString(CGUIFont *font, const std::string &text, bool selectable, const std::string &clickAction); CGUITextLayout m_text; float m_length; bool m_selectable; - CStdString m_clickAction; + std::string m_clickAction; }; std::vector<CSelectableString> m_items; CLabelInfo m_label; CGUIInfoLabel m_info; - CStdString m_oldText; + std::string m_oldText; unsigned int m_renderTime; // scrolling diff --git a/xbmc/guilib/GUIRSSControl.cpp b/xbmc/guilib/GUIRSSControl.cpp index 8d985cf553..76f1789101 100644 --- a/xbmc/guilib/GUIRSSControl.cpp +++ b/xbmc/guilib/GUIRSSControl.cpp @@ -29,7 +29,7 @@ using namespace std; -CGUIRSSControl::CGUIRSSControl(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, const CGUIInfoColor &channelColor, const CGUIInfoColor &headlineColor, CStdString& strRSSTags) +CGUIRSSControl::CGUIRSSControl(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, const CGUIInfoColor &channelColor, const CGUIInfoColor &headlineColor, std::string& strRSSTags) : CGUIControl(parentID, controlID, posX, posY, width, height), m_label(labelInfo), m_channelColor(channelColor), diff --git a/xbmc/guilib/GUIRSSControl.h b/xbmc/guilib/GUIRSSControl.h index fa23842fde..33dc2f78af 100644 --- a/xbmc/guilib/GUIRSSControl.h +++ b/xbmc/guilib/GUIRSSControl.h @@ -44,7 +44,7 @@ class CRssReader; class CGUIRSSControl : public CGUIControl, public IRssObserver { public: - CGUIRSSControl(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, const CGUIInfoColor &channelColor, const CGUIInfoColor &headlineColor, CStdString& strRSSTags); + CGUIRSSControl(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, const CGUIInfoColor &channelColor, const CGUIInfoColor &headlineColor, std::string& strRSSTags); CGUIRSSControl(const CGUIRSSControl &from); virtual ~CGUIRSSControl(void); virtual CGUIRSSControl *Clone() const { return new CGUIRSSControl(*this); }; @@ -69,7 +69,7 @@ protected: CRssReader* m_pReader; vecText m_feed; - CStdString m_strRSSTags; + std::string m_strRSSTags; CLabelInfo m_label; CGUIInfoColor m_channelColor; diff --git a/xbmc/guilib/GUIRadioButtonControl.cpp b/xbmc/guilib/GUIRadioButtonControl.cpp index 6a0960441e..3323dc0107 100644 --- a/xbmc/guilib/GUIRadioButtonControl.cpp +++ b/xbmc/guilib/GUIRadioButtonControl.cpp @@ -204,7 +204,7 @@ bool CGUIRadioButtonControl::UpdateColors() return changed; } -void CGUIRadioButtonControl::SetToggleSelect(const CStdString &toggleSelect) +void CGUIRadioButtonControl::SetToggleSelect(const std::string &toggleSelect) { m_toggleSelect = g_infoManager.Register(toggleSelect, GetParentID()); } diff --git a/xbmc/guilib/GUIRadioButtonControl.h b/xbmc/guilib/GUIRadioButtonControl.h index 407ea4e715..2112962308 100644 --- a/xbmc/guilib/GUIRadioButtonControl.h +++ b/xbmc/guilib/GUIRadioButtonControl.h @@ -58,7 +58,7 @@ public: virtual void SetHeight(float height); virtual std::string GetDescription() const; void SetRadioDimensions(float posX, float posY, float width, float height); - void SetToggleSelect(const CStdString &toggleSelect); + void SetToggleSelect(const std::string &toggleSelect); bool IsSelected() const { return m_bSelected; }; protected: virtual bool UpdateColors(); diff --git a/xbmc/guilib/GUIShader.cpp b/xbmc/guilib/GUIShader.cpp index 23cb84f461..e7035565c3 100644 --- a/xbmc/guilib/GUIShader.cpp +++ b/xbmc/guilib/GUIShader.cpp @@ -88,8 +88,8 @@ bool CGUIShader::OnEnabled() { // This is called after glUseProgram() - glUniformMatrix4fv(m_hProj, 1, GL_FALSE, g_matrices.GetMatrix(MM_PROJECTION)); - glUniformMatrix4fv(m_hModel, 1, GL_FALSE, g_matrices.GetMatrix(MM_MODELVIEW)); + glUniformMatrix4fv(m_hProj, 1, GL_FALSE, glMatrixProject.Get()); + glUniformMatrix4fv(m_hModel, 1, GL_FALSE, glMatrixModview.Get()); return true; } diff --git a/xbmc/guilib/GUISliderControl.cpp b/xbmc/guilib/GUISliderControl.cpp index cc18c408a2..d97df5650d 100644 --- a/xbmc/guilib/GUISliderControl.cpp +++ b/xbmc/guilib/GUISliderControl.cpp @@ -253,7 +253,7 @@ void CGUISliderControl::SendClick() SEND_CLICK_MESSAGE(GetID(), GetParentID(), MathUtils::round_int(percent)); if (m_action && (!m_dragging || m_action->fireOnDrag)) { - CStdString action = StringUtils::Format(m_action->formatString, percent); + std::string action = StringUtils::Format(m_action->formatString, percent); CGUIMessage message(GUI_MSG_EXECUTE, m_controlID, m_parentID); message.SetStringParam(action); g_windowManager.SendMessage(message); @@ -595,7 +595,7 @@ std::string CGUISliderControl::GetDescription() const { if (!m_textValue.empty()) return m_textValue; - CStdString description; + std::string description; if (m_iType == SLIDER_CONTROL_TYPE_FLOAT) { if (m_rangeSelection) @@ -641,7 +641,7 @@ float CGUISliderControl::GetProportion(RangeSelector selector /* = RangeSelector return 0.01f * GetPercentage(selector); } -void CGUISliderControl::SetAction(const CStdString &action) +void CGUISliderControl::SetAction(const std::string &action) { for (size_t i = 0; i < sizeof(actions)/sizeof(SliderAction); i++) { diff --git a/xbmc/guilib/GUISliderControl.h b/xbmc/guilib/GUISliderControl.h index ef33c5f905..c0bc4fe754 100644 --- a/xbmc/guilib/GUISliderControl.h +++ b/xbmc/guilib/GUISliderControl.h @@ -86,8 +86,8 @@ public: void SetFloatInterval(float fInterval); void SetType(int iType) { m_iType = iType; }; virtual std::string GetDescription() const; - void SetTextValue(const CStdString &textValue) { m_textValue = textValue; }; - void SetAction(const CStdString &action); + void SetTextValue(const std::string &textValue) { m_textValue = textValue; }; + void SetAction(const std::string &action); protected: virtual bool HitTest(const CPoint &point) const; virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event); @@ -126,7 +126,7 @@ protected: float m_fEnd; int m_iInfoCode; - CStdString m_textValue; ///< Allows overriding of the text value to be displayed (parent must update when the slider updates) + std::string m_textValue; ///< Allows overriding of the text value to be displayed (parent must update when the slider updates) const SliderAction *m_action; ///< Allows the skin to configure the action of a click on the slider \sa SendClick bool m_dragging; ///< Whether we're in a (mouse/touch) drag operation or not - some actions are sent only on release. }; diff --git a/xbmc/guilib/GUISpinControl.cpp b/xbmc/guilib/GUISpinControl.cpp index b3ca0c798a..91739ea8a3 100644 --- a/xbmc/guilib/GUISpinControl.cpp +++ b/xbmc/guilib/GUISpinControl.cpp @@ -21,6 +21,7 @@ #include "GUISpinControl.h" #include "Key.h" #include "utils/StringUtils.h" +#include <stdio.h> using namespace std; @@ -370,7 +371,7 @@ void CGUISpinControl::Process(unsigned int currentTime, CDirtyRegionList &dirtyr strcpy(m_szTyped, ""); } - CStdString text; + std::string text; if (m_iType == SPIN_CONTROL_TYPE_INT) { @@ -409,11 +410,11 @@ void CGUISpinControl::Process(unsigned int currentTime, CDirtyRegionList &dirtyr { if (m_bShowRange) { - text = StringUtils::Format("(%i/%i) %s", m_iValue + 1, (int)m_vecLabels.size(), CStdString(m_vecLabels[m_iValue]).c_str() ); + text = StringUtils::Format("(%i/%i) %s", m_iValue + 1, (int)m_vecLabels.size(), std::string(m_vecLabels[m_iValue]).c_str() ); } else { - text = StringUtils::Format("%s", CStdString(m_vecLabels[m_iValue]).c_str() ); + text = StringUtils::Format("%s", std::string(m_vecLabels[m_iValue]).c_str() ); } } else text = StringUtils::Format("?%i?", m_iValue); @@ -438,6 +439,7 @@ void CGUISpinControl::Process(unsigned int currentTime, CDirtyRegionList &dirtyr changed |= m_imgspinDown.Process(currentTime); changed |= m_imgspinUp.Process(currentTime); changed |= m_imgspinUpFocus.Process(currentTime); + changed |= m_label.Process(currentTime); if (changed) MarkDirtyRegion(); @@ -511,7 +513,7 @@ void CGUISpinControl::SetFloatRange(float fStart, float fEnd) m_fEnd = fEnd; } -void CGUISpinControl::SetValueFromLabel(const CStdString &label) +void CGUISpinControl::SetValueFromLabel(const std::string &label) { if (m_iType == SPIN_CONTROL_TYPE_TEXT) { diff --git a/xbmc/guilib/GUISpinControl.h b/xbmc/guilib/GUISpinControl.h index a94c048278..5efd7c2aad 100644 --- a/xbmc/guilib/GUISpinControl.h +++ b/xbmc/guilib/GUISpinControl.h @@ -65,7 +65,7 @@ public: void SetRange(int iStart, int iEnd); void SetFloatRange(float fStart, float fEnd); void SetValue(int iValue); - void SetValueFromLabel(const CStdString &label); + void SetValueFromLabel(const std::string &label); void SetFloatValue(float fValue); void SetStringValue(const std::string& strValue); int GetValue() const; diff --git a/xbmc/guilib/GUISpinControlEx.cpp b/xbmc/guilib/GUISpinControlEx.cpp index 414e35dcd8..cc43bd106a 100644 --- a/xbmc/guilib/GUISpinControlEx.cpp +++ b/xbmc/guilib/GUISpinControlEx.cpp @@ -117,7 +117,7 @@ void CGUISpinControlEx::SetEnabled(bool bEnable) CGUISpinControl::SetEnabled(bEnable); } -const CStdString CGUISpinControlEx::GetCurrentLabel() const +const std::string CGUISpinControlEx::GetCurrentLabel() const { return CGUISpinControl::GetLabel(); } diff --git a/xbmc/guilib/GUISpinControlEx.h b/xbmc/guilib/GUISpinControlEx.h index cba5e1a870..d6b4af1709 100644 --- a/xbmc/guilib/GUISpinControlEx.h +++ b/xbmc/guilib/GUISpinControlEx.h @@ -53,7 +53,7 @@ public: virtual void FreeResources(bool immediately = false); virtual void DynamicResourceAlloc(bool bOnOff); virtual void SetInvalid(); - const CStdString GetCurrentLabel() const; + const std::string GetCurrentLabel() const; void SetText(const std::string & aLabel) {m_buttonControl.SetLabel(aLabel);}; virtual void SetEnabled(bool bEnable); virtual float GetXPosition() const { return m_buttonControl.GetXPosition();}; diff --git a/xbmc/guilib/GUIStaticItem.cpp b/xbmc/guilib/GUIStaticItem.cpp index c4d6f530b5..31b9314726 100644 --- a/xbmc/guilib/GUIStaticItem.cpp +++ b/xbmc/guilib/GUIStaticItem.cpp @@ -23,6 +23,7 @@ #include "GUIControlFactory.h" #include "GUIInfoManager.h" #include "utils/Variant.h" +#include "utils/StringUtils.h" using namespace std; @@ -42,7 +43,7 @@ CGUIStaticItem::CGUIStaticItem(const TiXmlElement *item, int parentID) : CFileIt CGUIControlFactory::GetInfoLabel(item, "thumb", thumb, parentID); CGUIControlFactory::GetInfoLabel(item, "icon", icon, parentID); const char *id = item->Attribute("id"); - CStdString condition; + std::string condition; CGUIControlFactory::GetConditionalVisibility(item, condition); SetVisibleCondition(condition, parentID); CGUIControlFactory::GetActions(item, "onclick", m_clickActions); @@ -59,7 +60,7 @@ CGUIStaticItem::CGUIStaticItem(const TiXmlElement *item, int parentID) : CFileIt const TiXmlElement *property = item->FirstChildElement("property"); while (property) { - CStdString name = XMLUtils::GetAttribute(property, "name"); + std::string name = XMLUtils::GetAttribute(property, "name"); CGUIInfoLabel prop; if (!name.empty() && CGUIControlFactory::GetInfoLabelFromElement(property, prop, parentID)) { @@ -72,7 +73,7 @@ CGUIStaticItem::CGUIStaticItem(const TiXmlElement *item, int parentID) : CFileIt } else { - CStdString label, label2, thumb, icon; + std::string label, label2, thumb, icon; label = XMLUtils::GetAttribute(item, "label"); label = CGUIControlFactory::FilterLabel(label); label2 = XMLUtils::GetAttribute(item, "label2"); label2 = CGUIControlFactory::FilterLabel(label2); thumb = XMLUtils::GetAttribute(item, "thumb"); thumb = CGUIControlFactory::FilterLabel(thumb); @@ -98,16 +99,16 @@ void CGUIStaticItem::UpdateProperties(int contextWindow) for (InfoVector::const_iterator i = m_info.begin(); i != m_info.end(); ++i) { const CGUIInfoLabel &info = i->first; - const CStdString &name = i->second; + const std::string &name = i->second; bool preferTexture = strnicmp("label", name.c_str(), 5) != 0; - CStdString value(info.GetLabel(contextWindow, preferTexture)); - if (name.Equals("label")) + std::string value(info.GetLabel(contextWindow, preferTexture)); + if (StringUtils::EqualsNoCase(name, "label")) SetLabel(value); - else if (name.Equals("label2")) + else if (StringUtils::EqualsNoCase(name, "label2")) SetLabel2(value); - else if (name.Equals("thumb")) + else if (StringUtils::EqualsNoCase(name, "thumb")) SetArt("thumb", value); - else if (name.Equals("icon")) + else if (StringUtils::EqualsNoCase(name, "icon")) SetIconImage(value); else SetProperty(name, value.c_str()); diff --git a/xbmc/guilib/GUIStaticItem.h b/xbmc/guilib/GUIStaticItem.h index 098d8e1eb7..207bdb7144 100644 --- a/xbmc/guilib/GUIStaticItem.h +++ b/xbmc/guilib/GUIStaticItem.h @@ -87,7 +87,7 @@ public: const CGUIAction &GetClickActions() const { return m_clickActions; }; private: - typedef std::vector< std::pair<CGUIInfoLabel, CStdString> > InfoVector; + typedef std::vector< std::pair<CGUIInfoLabel, std::string> > InfoVector; InfoVector m_info; INFO::InfoPtr m_visCondition; bool m_visState; diff --git a/xbmc/guilib/GUITextBox.cpp b/xbmc/guilib/GUITextBox.cpp index b7ef051041..b8a2be4458 100644 --- a/xbmc/guilib/GUITextBox.cpp +++ b/xbmc/guilib/GUITextBox.cpp @@ -370,9 +370,9 @@ int CGUITextBox::GetCurrentPage() const return m_offset / m_itemsPerPage + 1; } -CStdString CGUITextBox::GetLabel(int info) const +std::string CGUITextBox::GetLabel(int info) const { - CStdString label; + std::string label; switch (info) { case CONTAINER_NUM_PAGES: diff --git a/xbmc/guilib/GUITextBox.h b/xbmc/guilib/GUITextBox.h index 82c6bc610a..78e0f97743 100644 --- a/xbmc/guilib/GUITextBox.h +++ b/xbmc/guilib/GUITextBox.h @@ -61,7 +61,7 @@ public: void SetInfo(const CGUIInfoLabel &info); void SetAutoScrolling(const TiXmlNode *node); void ResetAutoScrolling(); - CStdString GetLabel(int info) const; + std::string GetLabel(int info) const; std::string GetDescription() const; void Scroll(unsigned int offset); diff --git a/xbmc/guilib/GUITextLayout.cpp b/xbmc/guilib/GUITextLayout.cpp index 031430d62e..bfe4e589a8 100644 --- a/xbmc/guilib/GUITextLayout.cpp +++ b/xbmc/guilib/GUITextLayout.cpp @@ -33,9 +33,9 @@ CGUIString::CGUIString(iString start, iString end, bool carriageReturn) m_carriageReturn = carriageReturn; } -CStdString CGUIString::GetAsString() const +std::string CGUIString::GetAsString() const { - CStdString text; + std::string text; for (unsigned int i = 0; i < m_text.size(); i++) text += (char)(m_text[i] & 0xff); return text; @@ -214,20 +214,20 @@ void CGUITextLayout::RenderOutline(float x, float y, color_t color, color_t outl m_font->End(); } -bool CGUITextLayout::Update(const CStdString &text, float maxWidth, bool forceUpdate /*= false*/, bool forceLTRReadingOrder /*= false*/) +bool CGUITextLayout::Update(const std::string &text, float maxWidth, bool forceUpdate /*= false*/, bool forceLTRReadingOrder /*= false*/) { if (text == m_lastUtf8Text && !forceUpdate && !m_lastUpdateW) return false; m_lastUtf8Text = text; m_lastUpdateW = false; - CStdStringW utf16; + std::wstring utf16; g_charsetConverter.utf8ToW(text, utf16, false); UpdateCommon(utf16, maxWidth, forceLTRReadingOrder); return true; } -bool CGUITextLayout::UpdateW(const CStdStringW &text, float maxWidth /*= 0*/, bool forceUpdate /*= false*/, bool forceLTRReadingOrder /*= false*/) +bool CGUITextLayout::UpdateW(const std::wstring &text, float maxWidth /*= 0*/, bool forceUpdate /*= false*/, bool forceLTRReadingOrder /*= false*/) { if (text == m_lastText && !forceUpdate && m_lastUpdateW) return false; @@ -238,7 +238,7 @@ bool CGUITextLayout::UpdateW(const CStdStringW &text, float maxWidth /*= 0*/, bo return true; } -void CGUITextLayout::UpdateCommon(const CStdStringW &text, float maxWidth, bool forceLTRReadingOrder) +void CGUITextLayout::UpdateCommon(const std::wstring &text, float maxWidth, bool forceLTRReadingOrder) { // parse the text for style information vecText parsedText; @@ -283,7 +283,7 @@ void CGUITextLayout::BidiTransform(vector<CGUIString> &lines, bool forceLTRReadi flippedText.reserve(line.m_text.size()); character_t sectionStyle = 0xffff0000; // impossible to achieve - CStdStringW sectionText; + std::wstring sectionText; for (vecText::iterator it = line.m_text.begin(); it != line.m_text.end(); ++it) { character_t style = *it & 0xffff0000; @@ -291,7 +291,7 @@ void CGUITextLayout::BidiTransform(vector<CGUIString> &lines, bool forceLTRReadi { if (!sectionText.empty()) { // style has changed, bidi flip text - CStdStringW sectionFlipped = BidiFlip(sectionText, forceLTRReadingOrder); + std::wstring sectionFlipped = BidiFlip(sectionText, forceLTRReadingOrder); for (unsigned int j = 0; j < sectionFlipped.size(); j++) flippedText.push_back(sectionStyle | sectionFlipped[j]); } @@ -304,7 +304,7 @@ void CGUITextLayout::BidiTransform(vector<CGUIString> &lines, bool forceLTRReadi // handle the last section if (!sectionText.empty()) { - CStdStringW sectionFlipped = BidiFlip(sectionText, forceLTRReadingOrder); + std::wstring sectionFlipped = BidiFlip(sectionText, forceLTRReadingOrder); for (unsigned int j = 0; j < sectionFlipped.size(); j++) flippedText.push_back(sectionStyle | sectionFlipped[j]); } @@ -314,10 +314,10 @@ void CGUITextLayout::BidiTransform(vector<CGUIString> &lines, bool forceLTRReadi } } -CStdStringW CGUITextLayout::BidiFlip(const CStdStringW &text, bool forceLTRReadingOrder) +std::wstring CGUITextLayout::BidiFlip(const std::wstring &text, bool forceLTRReadingOrder) { - CStdStringA utf8text; - CStdStringW visualText; + std::string utf8text; + std::wstring visualText; // convert to utf8, and back to utf16 with bidi flipping g_charsetConverter.wToUTF8(text, utf8text); @@ -326,9 +326,9 @@ CStdStringW CGUITextLayout::BidiFlip(const CStdStringW &text, bool forceLTRReadi return visualText; } -void CGUITextLayout::Filter(CStdString &text) +void CGUITextLayout::Filter(std::string &text) { - CStdStringW utf16; + std::wstring utf16; g_charsetConverter.utf8ToW(text, utf16, false); vecColors colors; vecText parsedText; @@ -339,7 +339,7 @@ void CGUITextLayout::Filter(CStdString &text) g_charsetConverter.wToUTF8(utf16, text); } -void CGUITextLayout::ParseText(const CStdStringW &text, uint32_t defaultStyle, color_t defaultColor, vecColors &colors, vecText &parsedText) +void CGUITextLayout::ParseText(const std::wstring &text, uint32_t defaultStyle, color_t defaultColor, vecColors &colors, vecText &parsedText) { // run through the string, searching for: // [B] or [/B] -> toggle bold on and off @@ -439,13 +439,13 @@ void CGUITextLayout::ParseText(const CStdStringW &text, uint32_t defaultStyle, c newColor = colorStack.top(); colorTagChange = true; } - if (finish != CStdString::npos) + if (finish != std::string::npos) pos = finish + 1; } if (newStyle || colorTagChange || newLine) { // we have a new style or a new color, so format up the previous segment - CStdStringW subText = text.substr(startPos, endPos - startPos); + std::wstring subText = text.substr(startPos, endPos - startPos); if (currentStyle & FONT_STYLE_UPPERCASE) StringUtils::ToUpper(subText); if (currentStyle & FONT_STYLE_LOWERCASE) @@ -465,7 +465,7 @@ void CGUITextLayout::ParseText(const CStdStringW &text, uint32_t defaultStyle, c pos = text.find(L'[', pos); } // now grab the remainder of the string - CStdStringW subText = text.substr(startPos); + std::wstring subText = text.substr(startPos); if (currentStyle & FONT_STYLE_UPPERCASE) StringUtils::ToUpper(subText); if (currentStyle & FONT_STYLE_LOWERCASE) @@ -619,7 +619,7 @@ void CGUITextLayout::GetFirstText(vecText &text) const text = m_lines[0].m_text; } -float CGUITextLayout::GetTextWidth(const CStdStringW &text) const +float CGUITextLayout::GetTextWidth(const std::wstring &text) const { // NOTE: Assumes a single line of text if (!m_font) return 0; @@ -639,7 +639,7 @@ std::string CGUITextLayout::GetText() const return m_lastUtf8Text; } -void CGUITextLayout::DrawText(CGUIFont *font, float x, float y, color_t color, color_t shadowColor, const CStdString &text, uint32_t align) +void CGUITextLayout::DrawText(CGUIFont *font, float x, float y, color_t color, color_t shadowColor, const std::string &text, uint32_t align) { if (!font) return; vecText utf32; @@ -647,7 +647,7 @@ void CGUITextLayout::DrawText(CGUIFont *font, float x, float y, color_t color, c font->DrawText(x, y, color, shadowColor, utf32, align, 0); } -void CGUITextLayout::AppendToUTF32(const CStdStringW &utf16, character_t colStyle, vecText &utf32) +void CGUITextLayout::AppendToUTF32(const std::wstring &utf16, character_t colStyle, vecText &utf32) { // NOTE: Assumes a single line of text utf32.reserve(utf32.size() + utf16.size()); @@ -655,9 +655,9 @@ void CGUITextLayout::AppendToUTF32(const CStdStringW &utf16, character_t colStyl utf32.push_back(utf16[i] | colStyle); } -void CGUITextLayout::AppendToUTF32(const CStdString &utf8, character_t colStyle, vecText &utf32) +void CGUITextLayout::AppendToUTF32(const std::string &utf8, character_t colStyle, vecText &utf32) { - CStdStringW utf16; + std::wstring utf16; // no need to bidiflip here - it's done in BidiTransform above g_charsetConverter.utf8ToW(utf8, utf16, false); AppendToUTF32(utf16, colStyle, utf32); diff --git a/xbmc/guilib/GUITextLayout.h b/xbmc/guilib/GUITextLayout.h index 2bb68eb1b6..f069d12965 100644 --- a/xbmc/guilib/GUITextLayout.h +++ b/xbmc/guilib/GUITextLayout.h @@ -20,8 +20,9 @@ * */ -#include "utils/StdString.h" +#include <string> +#include <stdint.h> #include <vector> #ifdef __GNUC__ @@ -55,7 +56,7 @@ public: CGUIString(iString start, iString end, bool carriageReturn); - CStdString GetAsString() const; + std::string GetAsString() const; vecText m_text; bool m_carriageReturn; // true if we have a carriage return here @@ -86,9 +87,9 @@ public: */ float GetTextWidth() const { return m_textWidth; }; - float GetTextWidth(const CStdStringW &text) const; - bool Update(const CStdString &text, float maxWidth = 0, bool forceUpdate = false, bool forceLTRReadingOrder = false); - bool UpdateW(const CStdStringW &text, float maxWidth = 0, bool forceUpdate = false, bool forceLTRReadingOrder = false); + float GetTextWidth(const std::wstring &text) const; + bool Update(const std::string &text, float maxWidth = 0, bool forceUpdate = false, bool forceLTRReadingOrder = false); + bool UpdateW(const std::wstring &text, float maxWidth = 0, bool forceUpdate = false, bool forceLTRReadingOrder = false); /*! \brief Update text from a pre-styled vecText/vecColors combination Allows styled text to be passed directly to the text layout. @@ -107,16 +108,16 @@ public: void SetMaxHeight(float fHeight); - static void DrawText(CGUIFont *font, float x, float y, color_t color, color_t shadowColor, const CStdString &text, uint32_t align); - static void Filter(CStdString &text); + static void DrawText(CGUIFont *font, float x, float y, color_t color, color_t shadowColor, const std::string &text, uint32_t align); + static void Filter(std::string &text); protected: void LineBreakText(const vecText &text, std::vector<CGUIString> &lines); void WrapText(const vecText &text, float maxWidth); static void BidiTransform(std::vector<CGUIString> &lines, bool forceLTRReadingOrder); - static CStdStringW BidiFlip(const CStdStringW &text, bool forceLTRReadingOrder); + static std::wstring BidiFlip(const std::wstring &text, bool forceLTRReadingOrder); void CalcTextExtent(); - void UpdateCommon(const CStdStringW &text, float maxWidth, bool forceLTRReadingOrder); + void UpdateCommon(const std::wstring &text, float maxWidth, bool forceLTRReadingOrder); /*! \brief Returns the text, utf8 encoded \return utf8 text @@ -138,7 +139,7 @@ protected: color_t m_textColor; std::string m_lastUtf8Text; - CStdStringW m_lastText; + std::wstring m_lastText; bool m_lastUpdateW; ///< true if the last string we updated was the wstring version float m_textWidth; float m_textHeight; @@ -152,8 +153,8 @@ private: character_t ch = letter & 0xffff; return ch == L' ' || (ch >=0x4e00 && ch <= 0x9fff); }; - static void AppendToUTF32(const CStdString &utf8, character_t colStyle, vecText &utf32); - static void AppendToUTF32(const CStdStringW &utf16, character_t colStyle, vecText &utf32); - static void ParseText(const CStdStringW &text, uint32_t defaultStyle, color_t defaultColor, vecColors &colors, vecText &parsedText); + static void AppendToUTF32(const std::string &utf8, character_t colStyle, vecText &utf32); + static void AppendToUTF32(const std::wstring &utf16, character_t colStyle, vecText &utf32); + static void ParseText(const std::wstring &text, uint32_t defaultStyle, color_t defaultColor, vecColors &colors, vecText &parsedText); }; diff --git a/xbmc/guilib/GUITexture.cpp b/xbmc/guilib/GUITexture.cpp index 7302f83063..3d1c4d3dc8 100644 --- a/xbmc/guilib/GUITexture.cpp +++ b/xbmc/guilib/GUITexture.cpp @@ -32,7 +32,7 @@ CTextureInfo::CTextureInfo() useLarge = false; } -CTextureInfo::CTextureInfo(const CStdString &file) +CTextureInfo::CTextureInfo(const std::string &file) { orientation = 0; useLarge = false; @@ -646,9 +646,9 @@ bool CGUITextureBase::SetAspectRatio(const CAspectRatio &aspect) return false; } -bool CGUITextureBase::SetFileName(const CStdString& filename) +bool CGUITextureBase::SetFileName(const std::string& filename) { - if (m_info.filename.Equals(filename)) return false; + if (m_info.filename == filename) return false; // Don't completely free resources here - we may be just changing // filenames mid-animation FreeResources(); diff --git a/xbmc/guilib/GUITexture.h b/xbmc/guilib/GUITexture.h index 40e75d68c3..c98857403a 100644 --- a/xbmc/guilib/GUITexture.h +++ b/xbmc/guilib/GUITexture.h @@ -72,14 +72,14 @@ class CTextureInfo { public: CTextureInfo(); - CTextureInfo(const CStdString &file); + CTextureInfo(const std::string &file); CTextureInfo& operator=(const CTextureInfo &right); bool useLarge; CRect border; // scaled - unneeded if we get rid of scale on load int orientation; // orientation of the texture (0 - 7 == EXIForientation - 1) - CStdString diffuse; // diffuse overlay texture + std::string diffuse; // diffuse overlay texture CGUIInfoColor diffuseColor; // diffuse color - CStdString filename; // main texture file + std::string filename; // main texture file }; class CGUITextureBase @@ -103,11 +103,11 @@ public: bool SetPosition(float x, float y); bool SetWidth(float width); bool SetHeight(float height); - bool SetFileName(const CStdString &filename); + bool SetFileName(const std::string &filename); void SetUseCache(const bool useCache = true); bool SetAspectRatio(const CAspectRatio &aspect); - const CStdString& GetFileName() const { return m_info.filename; }; + const std::string& GetFileName() const { return m_info.filename; }; float GetTextureWidth() const { return m_frameWidth; }; float GetTextureHeight() const { return m_frameHeight; }; float GetWidth() const { return m_width; }; diff --git a/xbmc/guilib/GUIToggleButtonControl.cpp b/xbmc/guilib/GUIToggleButtonControl.cpp index df33a3ee9d..bf0fe93cb7 100644 --- a/xbmc/guilib/GUIToggleButtonControl.cpp +++ b/xbmc/guilib/GUIToggleButtonControl.cpp @@ -168,7 +168,7 @@ void CGUIToggleButtonControl::OnClick() CGUIButtonControl::OnClick(); } -void CGUIToggleButtonControl::SetToggleSelect(const CStdString &toggleSelect) +void CGUIToggleButtonControl::SetToggleSelect(const std::string &toggleSelect) { m_toggleSelect = g_infoManager.Register(toggleSelect, GetParentID()); } diff --git a/xbmc/guilib/GUIToggleButtonControl.h b/xbmc/guilib/GUIToggleButtonControl.h index dea127d5f7..9b904c7935 100644 --- a/xbmc/guilib/GUIToggleButtonControl.h +++ b/xbmc/guilib/GUIToggleButtonControl.h @@ -54,7 +54,7 @@ public: void SetLabel(const std::string& strLabel); void SetAltLabel(const std::string& label); virtual std::string GetDescription() const; - void SetToggleSelect(const CStdString &toggleSelect); + void SetToggleSelect(const std::string &toggleSelect); void SetAltClickActions(const CGUIAction &clickActions); protected: diff --git a/xbmc/guilib/GUIWindow.cpp b/xbmc/guilib/GUIWindow.cpp index 18c302e0a0..6c0117ea22 100644 --- a/xbmc/guilib/GUIWindow.cpp +++ b/xbmc/guilib/GUIWindow.cpp @@ -46,12 +46,12 @@ using namespace std; -bool CGUIWindow::icompare::operator()(const CStdString &s1, const CStdString &s2) const +bool CGUIWindow::icompare::operator()(const std::string &s1, const std::string &s2) const { return StringUtils::CompareNoCase(s1, s2) < 0; } -CGUIWindow::CGUIWindow(int id, const CStdString &xmlFile) +CGUIWindow::CGUIWindow(int id, const std::string &xmlFile) { SetID(id); SetProperty("xmlfile", xmlFile); @@ -78,7 +78,7 @@ CGUIWindow::~CGUIWindow(void) delete m_windowXMLRootElement; } -bool CGUIWindow::Load(const CStdString& strFileName, bool bContainsPath) +bool CGUIWindow::Load(const std::string& strFileName, bool bContainsPath) { #ifdef HAS_PERFORMANCE_SAMPLE CPerformanceSample aSample("WindowLoad-" + strFileName, true); @@ -108,8 +108,8 @@ bool CGUIWindow::Load(const CStdString& strFileName, bool bContainsPath) CLog::Log(LOGINFO, "Loading skin file: %s, load type: %s", strFileName.c_str(), strLoadType); // Find appropriate skin folder + resolution to load from - CStdString strPath; - CStdString strLowerPath; + std::string strPath; + std::string strLowerPath; if (bContainsPath) strPath = strFileName; else @@ -132,7 +132,7 @@ bool CGUIWindow::Load(const CStdString& strFileName, bool bContainsPath) return ret; } -bool CGUIWindow::LoadXML(const CStdString &strPath, const CStdString &strLowerPath) +bool CGUIWindow::LoadXML(const std::string &strPath, const std::string &strLowerPath) { // load window xml if we don't have it stored yet if (!m_windowXMLRootElement) @@ -186,7 +186,7 @@ bool CGUIWindow::Load(TiXmlElement* pRootElement) TiXmlElement *pChild = pRootElement->FirstChildElement(); while (pChild) { - CStdString strValue = pChild->Value(); + std::string strValue = pChild->Value(); if (strValue == "type" && pChild->FirstChild()) { // if we have are a window type (ie not a dialog), and we have <type>dialog</type> @@ -207,7 +207,7 @@ bool CGUIWindow::Load(TiXmlElement* pRootElement) } else if (strValue == "visible" && pChild->FirstChild()) { - CStdString condition; + std::string condition; CGUIControlFactory::GetConditionalVisibility(pRootElement, condition); m_visibleCondition = g_infoManager.Register(condition, GetID()); } @@ -728,7 +728,7 @@ void CGUIWindow::AllocResources(bool forceLoad /*= FALSE */) if (forceLoad) { - CStdString xmlFile = GetProperty("xmlfile").asString(); + std::string xmlFile = GetProperty("xmlfile").asString(); if (xmlFile.size()) { bool bHasPath = xmlFile.find("\\") != std::string::npos || xmlFile.find("/") != std::string::npos; @@ -1001,16 +1001,16 @@ void CGUIWindow::DumpTextureUse() #endif } -void CGUIWindow::SetProperty(const CStdString &strKey, const CVariant &value) +void CGUIWindow::SetProperty(const std::string &strKey, const CVariant &value) { CSingleLock lock(*this); m_mapProperties[strKey] = value; } -CVariant CGUIWindow::GetProperty(const CStdString &strKey) const +CVariant CGUIWindow::GetProperty(const std::string &strKey) const { CSingleLock lock(*this); - std::map<CStdString, CVariant, icompare>::const_iterator iter = m_mapProperties.find(strKey); + std::map<std::string, CVariant, icompare>::const_iterator iter = m_mapProperties.find(strKey); if (iter == m_mapProperties.end()) return CVariant(CVariant::VariantTypeNull); diff --git a/xbmc/guilib/GUIWindow.h b/xbmc/guilib/GUIWindow.h index af82934aa7..2f4137e747 100644 --- a/xbmc/guilib/GUIWindow.h +++ b/xbmc/guilib/GUIWindow.h @@ -80,11 +80,11 @@ public: enum WINDOW_TYPE { WINDOW = 0, MODAL_DIALOG, MODELESS_DIALOG, BUTTON_MENU, SUB_MENU }; enum LOAD_TYPE { LOAD_EVERY_TIME, LOAD_ON_GUI_INIT, KEEP_IN_MEMORY }; - CGUIWindow(int id, const CStdString &xmlFile); + CGUIWindow(int id, const std::string &xmlFile); virtual ~CGUIWindow(void); bool Initialize(); // loads the window - bool Load(const CStdString& strFileName, bool bContainsPath = false); + bool Load(const std::string& strFileName, bool bContainsPath = false); void CenterWindow(); @@ -175,13 +175,13 @@ public: \param value value to set, may be a string, integer, boolean or double. \sa GetProperty */ - void SetProperty(const CStdString &key, const CVariant &value); + void SetProperty(const std::string &key, const CVariant &value); /*! \brief Retreive a property \param key name of the property to retrieve \return value of the property, empty if it doesn't exist */ - CVariant GetProperty(const CStdString &key) const; + CVariant GetProperty(const std::string &key) const; /*! \brief Clear a all the window's properties \sa SetProperty, HasProperty, GetProperty @@ -195,7 +195,7 @@ public: virtual void OnDeinitWindow(int nextWindowID); protected: virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event); - virtual bool LoadXML(const CStdString& strPath, const CStdString &strLowerPath); ///< Loads from the given file + virtual bool LoadXML(const std::string& strPath, const std::string &strLowerPath); ///< Loads from the given file bool Load(TiXmlElement *pRootElement); ///< Loads from the given XML root element /*! \brief Check if XML file needs (re)loading XML file has to be (re)loaded when window is not loaded or include conditions values were changed @@ -262,7 +262,7 @@ protected: bool m_animationsEnabled; struct icompare { - bool operator()(const CStdString &s1, const CStdString &s2) const; + bool operator()(const std::string &s1, const std::string &s2) const; }; CGUIAction m_loadActions; @@ -275,7 +275,7 @@ protected: int m_exclusiveMouseControl; ///< \brief id of child control that wishes to receive all mouse events \sa GUI_MSG_EXCLUSIVE_MOUSE private: - std::map<CStdString, CVariant, icompare> m_mapProperties; + std::map<std::string, CVariant, icompare> m_mapProperties; std::map<INFO::InfoPtr, bool> m_xmlIncludeConditions; ///< \brief used to store conditions used to resolve includes for this window }; diff --git a/xbmc/guilib/GUIWindowManager.cpp b/xbmc/guilib/GUIWindowManager.cpp index 788bbe9c34..787a34f02c 100644 --- a/xbmc/guilib/GUIWindowManager.cpp +++ b/xbmc/guilib/GUIWindowManager.cpp @@ -34,6 +34,7 @@ #include "windowing/WindowingFactory.h" #include "utils/Variant.h" #include "Key.h" +#include "utils/StringUtils.h" using namespace std; @@ -325,7 +326,7 @@ void CGUIWindowManager::PreviousWindow() return; } -void CGUIWindowManager::ChangeActiveWindow(int newWindow, const CStdString& strPath) +void CGUIWindowManager::ChangeActiveWindow(int newWindow, const std::string& strPath) { vector<string> params; if (!strPath.empty()) @@ -333,7 +334,7 @@ void CGUIWindowManager::ChangeActiveWindow(int newWindow, const CStdString& strP ActivateWindow(newWindow, params, true); } -void CGUIWindowManager::ActivateWindow(int iWindowID, const CStdString& strPath) +void CGUIWindowManager::ActivateWindow(int iWindowID, const std::string& strPath) { vector<string> params; if (!strPath.empty()) @@ -891,16 +892,18 @@ bool CGUIWindowManager::IsWindowActive(int id, bool ignoreClosing /* = true */) return false; // window isn't active } -bool CGUIWindowManager::IsWindowActive(const CStdString &xmlFile, bool ignoreClosing /* = true */) const +bool CGUIWindowManager::IsWindowActive(const std::string &xmlFile, bool ignoreClosing /* = true */) const { CSingleLock lock(g_graphicsContext); CGUIWindow *window = GetWindow(GetActiveWindow()); - if (window && URIUtils::GetFileName(window->GetProperty("xmlfile").asString()).Equals(xmlFile)) return true; + if (window && StringUtils::EqualsNoCase(URIUtils::GetFileName(window->GetProperty("xmlfile").asString()), xmlFile)) + return true; // run through the dialogs for (ciDialog it = m_activeDialogs.begin(); it != m_activeDialogs.end(); ++it) { CGUIWindow *window = *it; - if (URIUtils::GetFileName(window->GetProperty("xmlfile").asString()).Equals(xmlFile) && (!ignoreClosing || !window->IsAnimating(ANIM_TYPE_WINDOW_CLOSE))) + if (StringUtils::EqualsNoCase(URIUtils::GetFileName(window->GetProperty("xmlfile").asString()), xmlFile) && + (!ignoreClosing || !window->IsAnimating(ANIM_TYPE_WINDOW_CLOSE))) return true; } return false; // window isn't active @@ -911,7 +914,7 @@ bool CGUIWindowManager::IsWindowVisible(int id) const return IsWindowActive(id, false); } -bool CGUIWindowManager::IsWindowVisible(const CStdString &xmlFile) const +bool CGUIWindowManager::IsWindowVisible(const std::string &xmlFile) const { return IsWindowActive(xmlFile, false); } @@ -1020,10 +1023,10 @@ bool CGUIWindowManager::IsWindowTopMost(int id) const return false; } -bool CGUIWindowManager::IsWindowTopMost(const CStdString &xmlFile) const +bool CGUIWindowManager::IsWindowTopMost(const std::string &xmlFile) const { CGUIWindow *topMost = GetTopMostDialog(); - if (topMost && URIUtils::GetFileName(topMost->GetProperty("xmlfile").asString()).Equals(xmlFile)) + if (topMost && StringUtils::EqualsNoCase(URIUtils::GetFileName(topMost->GetProperty("xmlfile").asString()), xmlFile)) return true; return false; } diff --git a/xbmc/guilib/GUIWindowManager.h b/xbmc/guilib/GUIWindowManager.h index 4f1f96f838..e10ebe4e68 100644 --- a/xbmc/guilib/GUIWindowManager.h +++ b/xbmc/guilib/GUIWindowManager.h @@ -58,8 +58,8 @@ public: void AddCustomWindow(CGUIWindow* pWindow); void Remove(int id); void Delete(int id); - void ActivateWindow(int iWindowID, const CStdString &strPath = ""); - void ChangeActiveWindow(int iNewID, const CStdString &strPath = ""); + void ActivateWindow(int iWindowID, const std::string &strPath = ""); + void ChangeActiveWindow(int iNewID, const std::string &strPath = ""); void ActivateWindow(int iWindowID, const std::vector<std::string>& params, bool swappingWindows = false); void PreviousWindow(); @@ -133,9 +133,9 @@ public: bool IsWindowActive(int id, bool ignoreClosing = true) const; bool IsWindowVisible(int id) const; bool IsWindowTopMost(int id) const; - bool IsWindowActive(const CStdString &xmlFile, bool ignoreClosing = true) const; - bool IsWindowVisible(const CStdString &xmlFile) const; - bool IsWindowTopMost(const CStdString &xmlFile) const; + bool IsWindowActive(const std::string &xmlFile, bool ignoreClosing = true) const; + bool IsWindowVisible(const std::string &xmlFile) const; + bool IsWindowTopMost(const std::string &xmlFile) const; bool IsOverlayAllowed() const; void ShowOverlay(CGUIWindow::OVERLAY_STATE state); void GetActiveModelessWindows(std::vector<int> &ids); diff --git a/xbmc/guilib/GraphicContext.cpp b/xbmc/guilib/GraphicContext.cpp index d40e7a7131..b59bd2aeef 100644 --- a/xbmc/guilib/GraphicContext.cpp +++ b/xbmc/guilib/GraphicContext.cpp @@ -225,8 +225,8 @@ bool CGraphicContext::SetViewPort(float fx, float fy, float fwidth, float fheigh if (newRight > m_iScreenWidth) newRight = m_iScreenWidth; if (newBottom > m_iScreenHeight) newBottom = m_iScreenHeight; - ASSERT(newLeft < newRight); - ASSERT(newTop < newBottom); + assert(newLeft < newRight); + assert(newTop < newBottom); CRect newviewport((float)newLeft, (float)newTop, (float)newRight, (float)newBottom); @@ -877,7 +877,7 @@ void CGraphicContext::SetCameraPosition(const CPoint &camera) void CGraphicContext::RestoreCameraPosition() { // remove the top camera from the stack - ASSERT(m_cameras.size()); + assert(m_cameras.size()); m_cameras.pop(); UpdateCameraPosition(m_cameras.top()); } @@ -1011,7 +1011,7 @@ bool CGraphicContext::ToggleFullScreenRoot () return m_bFullScreenRoot; } -void CGraphicContext::SetMediaDir(const CStdString &strMediaDir) +void CGraphicContext::SetMediaDir(const std::string &strMediaDir) { g_TextureManager.SetTexturePath(strMediaDir); m_strMediaDir = strMediaDir; diff --git a/xbmc/guilib/GraphicContext.h b/xbmc/guilib/GraphicContext.h index c2a4c16b65..a108fcaf00 100644 --- a/xbmc/guilib/GraphicContext.h +++ b/xbmc/guilib/GraphicContext.h @@ -36,6 +36,7 @@ #endif +#include <string> #include <vector> #include <stack> #include <map> @@ -43,7 +44,6 @@ #include "TransformMatrix.h" // for the members m_guiTransform etc. #include "Geometry.h" // for CRect/CPoint #include "gui3d.h" -#include "utils/StdString.h" #include "Resolution.h" #include "utils/GlobalsHandling.h" #include "DirtyRegion.h" @@ -88,8 +88,8 @@ public: int GetWidth() const { return m_iScreenWidth; } int GetHeight() const { return m_iScreenHeight; } float GetFPS() const; - const CStdString& GetMediaDir() const { return m_strMediaDir; } - void SetMediaDir(const CStdString& strMediaDir); + const std::string& GetMediaDir() const { return m_strMediaDir; } + void SetMediaDir(const std::string& strMediaDir); bool SetViewPort(float fx, float fy , float fwidth, float fheight, bool intersectPrevious = false); void RestoreViewPort(); @@ -242,7 +242,7 @@ protected: int m_iScreenHeight; int m_iScreenWidth; int m_iScreenId; - CStdString m_strMediaDir; + std::string m_strMediaDir; CRect m_videoRect; bool m_bFullScreenRoot; bool m_bFullScreenVideo; diff --git a/xbmc/guilib/JpegIO.cpp b/xbmc/guilib/JpegIO.cpp index 236bd520b6..1f22fdb425 100644 --- a/xbmc/guilib/JpegIO.cpp +++ b/xbmc/guilib/JpegIO.cpp @@ -253,7 +253,7 @@ void CJpegIO::Close() ReleaseThumbnailBuffer(); } -bool CJpegIO::Open(const CStdString &texturePath, unsigned int minx, unsigned int miny, bool read) +bool CJpegIO::Open(const std::string &texturePath, unsigned int minx, unsigned int miny, bool read) { Close(); @@ -398,7 +398,7 @@ bool CJpegIO::Decode(const unsigned char *pixels, unsigned int pitch, unsigned i return true; } -bool CJpegIO::CreateThumbnail(const CStdString& sourceFile, const CStdString& destFile, int minx, int miny, bool rotateExif) +bool CJpegIO::CreateThumbnail(const std::string& sourceFile, const std::string& destFile, int minx, int miny, bool rotateExif) { //Copy sourceFile to buffer, pass to CreateThumbnailFromMemory for decode+re-encode if (!Open(sourceFile, minx, miny, false)) @@ -407,7 +407,7 @@ bool CJpegIO::CreateThumbnail(const CStdString& sourceFile, const CStdString& de return CreateThumbnailFromMemory(m_inputBuff, m_inputBuffSize, destFile, minx, miny); } -bool CJpegIO::CreateThumbnailFromMemory(unsigned char* buffer, unsigned int bufSize, const CStdString& destFile, unsigned int minx, unsigned int miny) +bool CJpegIO::CreateThumbnailFromMemory(unsigned char* buffer, unsigned int bufSize, const std::string& destFile, unsigned int minx, unsigned int miny) { //Decode a jpeg residing in buffer, pass to CreateThumbnailFromSurface for re-encode unsigned int pitch = 0; @@ -432,7 +432,7 @@ bool CJpegIO::CreateThumbnailFromMemory(unsigned char* buffer, unsigned int bufS return true; } -bool CJpegIO::CreateThumbnailFromSurface(unsigned char* buffer, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const CStdString& destFile) +bool CJpegIO::CreateThumbnailFromSurface(unsigned char* buffer, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const std::string& destFile) { //Encode raw data from buffer, save to destFile struct jpeg_compress_struct cinfo; @@ -535,7 +535,7 @@ bool CJpegIO::CreateThumbnailFromSurface(unsigned char* buffer, unsigned int wid // override libjpeg's error function to avoid an exit() call void CJpegIO::jpeg_error_exit(j_common_ptr cinfo) { - CStdString msg = StringUtils::Format("Error %i: %s",cinfo->err->msg_code, cinfo->err->jpeg_message_table[cinfo->err->msg_code]); + std::string msg = StringUtils::Format("Error %i: %s",cinfo->err->msg_code, cinfo->err->jpeg_message_table[cinfo->err->msg_code]); CLog::Log(LOGWARNING, "JpegIO: %s", msg.c_str()); my_error_mgr *myerr = (my_error_mgr*)cinfo->err; @@ -675,7 +675,7 @@ bool CJpegIO::LoadImageFromMemory(unsigned char* buffer, unsigned int bufSize, u return Read(buffer, bufSize, width, height); } -bool CJpegIO::CreateThumbnailFromSurface(unsigned char* bufferin, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const CStdString& destFile, +bool CJpegIO::CreateThumbnailFromSurface(unsigned char* bufferin, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const std::string& destFile, unsigned char* &bufferout, unsigned int &bufferoutSize) { //Encode raw data from buffer, save to destbuffer diff --git a/xbmc/guilib/JpegIO.h b/xbmc/guilib/JpegIO.h index 812906201b..fa91d7d2ec 100644 --- a/xbmc/guilib/JpegIO.h +++ b/xbmc/guilib/JpegIO.h @@ -27,7 +27,6 @@ #endif #include <jpeglib.h> -#include "utils/StdString.h" #include "iimage.h" class CJpegIO : public IImage @@ -36,16 +35,16 @@ class CJpegIO : public IImage public: CJpegIO(); ~CJpegIO(); - bool Open(const CStdString& m_texturePath, unsigned int minx=0, unsigned int miny=0, bool read=true); + bool Open(const std::string& m_texturePath, unsigned int minx=0, unsigned int miny=0, bool read=true); bool Read(unsigned char* buffer, unsigned int bufSize, unsigned int minx, unsigned int miny); - bool CreateThumbnail(const CStdString& sourceFile, const CStdString& destFile, int minx, int miny, bool rotateExif); - bool CreateThumbnailFromMemory(unsigned char* buffer, unsigned int bufSize, const CStdString& destFile, unsigned int minx, unsigned int miny); - static bool CreateThumbnailFromSurface(unsigned char* buffer, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const CStdString& destFile); + bool CreateThumbnail(const std::string& sourceFile, const std::string& destFile, int minx, int miny, bool rotateExif); + bool CreateThumbnailFromMemory(unsigned char* buffer, unsigned int bufSize, const std::string& destFile, unsigned int minx, unsigned int miny); + static bool CreateThumbnailFromSurface(unsigned char* buffer, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const std::string& destFile); void Close(); // methods for the imagefactory virtual bool Decode(const unsigned char *pixels, unsigned int pitch, unsigned int format); virtual bool LoadImageFromMemory(unsigned char* buffer, unsigned int bufSize, unsigned int width, unsigned int height); - virtual bool CreateThumbnailFromSurface(unsigned char* bufferin, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const CStdString& destFile, + virtual bool CreateThumbnailFromSurface(unsigned char* bufferin, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const std::string& destFile, unsigned char* &bufferout, unsigned int &bufferoutSize); virtual void ReleaseThumbnailBuffer(); @@ -57,7 +56,7 @@ protected: unsigned char *m_inputBuff; unsigned int m_inputBuffSize; struct jpeg_decompress_struct m_cinfo; - CStdString m_texturePath; + std::string m_texturePath; unsigned char* m_thumbnailbuffer; }; diff --git a/xbmc/guilib/Key.cpp b/xbmc/guilib/Key.cpp index f5972ac251..de12ba587f 100644 --- a/xbmc/guilib/Key.cpp +++ b/xbmc/guilib/Key.cpp @@ -171,7 +171,7 @@ void CKey::SetFromService(bool fromService) m_fromService = fromService; } -CAction::CAction(int actionID, float amount1 /* = 1.0f */, float amount2 /* = 0.0f */, const CStdString &name /* = "" */, unsigned int holdTime /*= 0*/) +CAction::CAction(int actionID, float amount1 /* = 1.0f */, float amount2 /* = 0.0f */, const std::string &name /* = "" */, unsigned int holdTime /*= 0*/) { m_id = actionID; m_amount[0] = amount1; @@ -185,7 +185,7 @@ CAction::CAction(int actionID, float amount1 /* = 1.0f */, float amount2 /* = 0. m_holdTime = holdTime; } -CAction::CAction(int actionID, unsigned int state, float posX, float posY, float offsetX, float offsetY, const CStdString &name) +CAction::CAction(int actionID, unsigned int state, float posX, float posY, float offsetX, float offsetY, const std::string &name) { m_id = actionID; m_amount[0] = posX; @@ -212,7 +212,7 @@ CAction::CAction(int actionID, wchar_t unicode) m_holdTime = 0; } -CAction::CAction(int actionID, const CStdString &name, const CKey &key) +CAction::CAction(int actionID, const std::string &name, const CKey &key) { m_id = actionID; m_name = name; diff --git a/xbmc/guilib/Key.h b/xbmc/guilib/Key.h index 1a6e46d0f4..cd723aacc5 100644 --- a/xbmc/guilib/Key.h +++ b/xbmc/guilib/Key.h @@ -28,7 +28,8 @@ * */ -#include "utils/StdString.h" +#include <string> +#include <stdint.h> // Reserved 0 - 255 // XBIRRemote.h @@ -88,8 +89,13 @@ #define KEY_MOUSE_LONG_CLICK 0xE020 #define KEY_MOUSE_WHEEL_UP 0xE101 #define KEY_MOUSE_WHEEL_DOWN 0xE102 -#define KEY_MOUSE_DRAG 0xE103 -#define KEY_MOUSE_MOVE 0xE104 +#define KEY_MOUSE_MOVE 0xE103 +#define KEY_MOUSE_DRAG 0xE104 +#define KEY_MOUSE_DRAG_START 0xE105 +#define KEY_MOUSE_DRAG_END 0xE106 +#define KEY_MOUSE_RDRAG 0xE107 +#define KEY_MOUSE_RDRAG_START 0xE108 +#define KEY_MOUSE_RDRAG_END 0xE109 #define KEY_MOUSE_NOOP 0xEFFF #define KEY_MOUSE_END 0xEFFF @@ -346,6 +352,7 @@ #define ACTION_SETTINGS_LEVEL_CHANGE 242 #define ACTION_TRIGGER_OSD 243 // show autoclosing OSD. Can b used in videoFullScreen.xml window id=2005 +#define ACTION_INPUT_TEXT 244 // touch actions #define ACTION_TOUCH_TAP 401 @@ -395,10 +402,10 @@ class CKey; class CAction { public: - CAction(int actionID, float amount1 = 1.0f, float amount2 = 0.0f, const CStdString &name = "", unsigned int holdTime = 0); + CAction(int actionID, float amount1 = 1.0f, float amount2 = 0.0f, const std::string &name = "", unsigned int holdTime = 0); CAction(int actionID, wchar_t unicode); - CAction(int actionID, unsigned int state, float posX, float posY, float offsetX, float offsetY, const CStdString &name = ""); - CAction(int actionID, const CStdString &name, const CKey &key); + CAction(int actionID, unsigned int state, float posX, float posY, float offsetX, float offsetY, const std::string &name = ""); + CAction(int actionID, const std::string &name, const CKey &key); CAction(int actionID, const std::string &name); /*! \brief Identifier of the action @@ -416,7 +423,17 @@ public: /*! \brief Human-readable name of the action \return name of the action */ - const CStdString &GetName() const { return m_name; }; + const std::string &GetName() const { return m_name; }; + + /*! \brief Text of the action if any + \return text payload of this action. + */ + const std::string &GetText() const { return m_text; }; + + /*! \brief Set the text payload of the action + \param text to be set + */ + void SetText(const std::string &text) { m_text = text; }; /*! \brief Get an amount associated with this action \param zero-based index of amount to retrieve, defaults to 0 @@ -446,7 +463,7 @@ public: private: int m_id; - CStdString m_name; + std::string m_name; static const unsigned int max_amounts = 4; // Must be at least 4. float m_amount[max_amounts]; @@ -455,6 +472,7 @@ private: unsigned int m_holdTime; unsigned int m_buttonCode; wchar_t m_unicode; + std::string m_text; }; /*! diff --git a/xbmc/guilib/Makefile.in b/xbmc/guilib/Makefile.in index 086fb0d6e0..68c11f4e06 100644 --- a/xbmc/guilib/Makefile.in +++ b/xbmc/guilib/Makefile.in @@ -82,6 +82,7 @@ ifeq (@USE_OPENGL@,1) SRCS += TextureGL.cpp SRCS += GUIFontTTFGL.cpp SRCS += GUITextureGL.cpp +SRCS += MatrixGLES.cpp endif ifeq (@USE_OPENGLES@,1) diff --git a/xbmc/guilib/MatrixGLES.cpp b/xbmc/guilib/MatrixGLES.cpp index af3fe47a68..13d27749b6 100644 --- a/xbmc/guilib/MatrixGLES.cpp +++ b/xbmc/guilib/MatrixGLES.cpp @@ -21,7 +21,7 @@ #include "system.h" -#if HAS_GLES == 2 +#if defined(HAS_GL) || HAS_GLES == 2 #include "system_gl.h" #include <cmath> @@ -31,77 +31,18 @@ #include "utils/CPUInfo.h" #endif -CMatrixGLES g_matrices; -#define MODE_WITHIN_RANGE(m) ((m >= 0) && (m < (int)MM_MATRIXSIZE)) - -CMatrixGLES::CMatrixGLES() -{ - for (unsigned int i=0; i < MM_MATRIXSIZE; i++) - { - m_matrices[i].push_back(MatrixWrapper()); - MatrixMode((EMATRIXMODE)i); - LoadIdentity(); - } - m_matrixMode = (EMATRIXMODE)-1; - m_pMatrix = NULL; -#if defined(__ARM_NEON__) - m_has_neon = (g_cpuInfo.GetCPUFeatures() & CPU_FEATURE_NEON) == CPU_FEATURE_NEON; +#ifdef HAS_GL +CMatrixGLStack glMatrixModview(GL_MODELVIEW); +CMatrixGLStack glMatrixProject(GL_PROJECTION); +CMatrixGLStack glMatrixTexture(GL_TEXTURE); +#else +CMatrixGLStack glMatrixModview(0); +CMatrixGLStack glMatrixProject(0); +CMatrixGLStack glMatrixTexture(0); #endif -} - -CMatrixGLES::~CMatrixGLES() -{ -} - -GLfloat* CMatrixGLES::GetMatrix(EMATRIXMODE mode) -{ - if (MODE_WITHIN_RANGE(mode)) - { - if (!m_matrices[mode].empty()) - { - return m_matrices[mode].back(); - } - } - return NULL; -} - -void CMatrixGLES::MatrixMode(EMATRIXMODE mode) -{ - if (MODE_WITHIN_RANGE(mode)) - { - m_matrixMode = mode; - m_pMatrix = m_matrices[mode].back(); - } - else - { - m_matrixMode = (EMATRIXMODE)-1; - m_pMatrix = NULL; - } -} - -void CMatrixGLES::PushMatrix() -{ - if (m_pMatrix && MODE_WITHIN_RANGE(m_matrixMode)) - { - m_matrices[m_matrixMode].push_back(MatrixWrapper(m_pMatrix)); - m_pMatrix = m_matrices[m_matrixMode].back(); - } -} - -void CMatrixGLES::PopMatrix() -{ - if (MODE_WITHIN_RANGE(m_matrixMode)) - { - if (m_matrices[m_matrixMode].size() > 1) - { - m_matrices[m_matrixMode].pop_back(); - } - m_pMatrix = m_matrices[m_matrixMode].back(); - } -} -void CMatrixGLES::LoadIdentity() +void CMatrixGL::LoadIdentity() { if (m_pMatrix) { @@ -112,7 +53,7 @@ void CMatrixGLES::LoadIdentity() } } -void CMatrixGLES::Ortho(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f) +void CMatrixGL::Ortho(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f) { GLfloat u = 2.0f / (r - l); GLfloat v = 2.0f / (t - b); @@ -127,7 +68,7 @@ void CMatrixGLES::Ortho(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, G MultMatrixf(matrix); } -void CMatrixGLES::Ortho2D(GLfloat l, GLfloat r, GLfloat b, GLfloat t) +void CMatrixGL::Ortho2D(GLfloat l, GLfloat r, GLfloat b, GLfloat t) { GLfloat u = 2.0f / (r - l); GLfloat v = 2.0f / (t - b); @@ -140,7 +81,7 @@ void CMatrixGLES::Ortho2D(GLfloat l, GLfloat r, GLfloat b, GLfloat t) MultMatrixf(matrix); } -void CMatrixGLES::Frustum(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f) +void CMatrixGL::Frustum(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f) { GLfloat u = (2.0f * n) / (r - l); GLfloat v = (2.0f * n) / (t - b); @@ -155,7 +96,7 @@ void CMatrixGLES::Frustum(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, MultMatrixf(matrix); } -void CMatrixGLES::Translatef(GLfloat x, GLfloat y, GLfloat z) +void CMatrixGL::Translatef(GLfloat x, GLfloat y, GLfloat z) { GLfloat matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, @@ -164,7 +105,7 @@ void CMatrixGLES::Translatef(GLfloat x, GLfloat y, GLfloat z) MultMatrixf(matrix); } -void CMatrixGLES::Scalef(GLfloat x, GLfloat y, GLfloat z) +void CMatrixGL::Scalef(GLfloat x, GLfloat y, GLfloat z) { GLfloat matrix[16] = { x, 0.0f, 0.0f, 0.0f, 0.0f, y, 0.0f, 0.0f, @@ -173,7 +114,7 @@ void CMatrixGLES::Scalef(GLfloat x, GLfloat y, GLfloat z) MultMatrixf(matrix); } -void CMatrixGLES::Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) +void CMatrixGL::Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) { GLfloat modulous = sqrt((x*x)+(y*y)+(z*z)); if (modulous != 0.0) @@ -242,12 +183,12 @@ inline void Matrix4Mul(const float* src_mat_1, const float* src_mat_2, float* ds ); } #endif -void CMatrixGLES::MultMatrixf(const GLfloat *matrix) +void CMatrixGL::MultMatrixf(const GLfloat *matrix) { if (m_pMatrix) { #if defined(__ARM_NEON__) - if (m_has_neon) + if ((g_cpuInfo.GetCPUFeatures() & CPU_FEATURE_NEON) == CPU_FEATURE_NEON) { GLfloat m[16]; Matrix4Mul(m_pMatrix, matrix, m); @@ -278,7 +219,7 @@ void CMatrixGLES::MultMatrixf(const GLfloat *matrix) } // gluLookAt implementation taken from Mesa3D -void CMatrixGLES::LookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez, GLfloat centerx, GLfloat centery, GLfloat centerz, GLfloat upx, GLfloat upy, GLfloat upz) +void CMatrixGL::LookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez, GLfloat centerx, GLfloat centery, GLfloat centerz, GLfloat upx, GLfloat upy, GLfloat upz) { GLfloat forward[3], side[3], up[3]; GLfloat m[4][4]; @@ -350,7 +291,7 @@ static void __gluMultMatrixVecf(const GLfloat matrix[16], const GLfloat in[4], G } // gluProject implementation taken from Mesa3D -bool CMatrixGLES::Project(GLfloat objx, GLfloat objy, GLfloat objz, const GLfloat modelMatrix[16], const GLfloat projMatrix[16], const GLint viewport[4], GLfloat* winx, GLfloat* winy, GLfloat* winz) +bool CMatrixGL::Project(GLfloat objx, GLfloat objy, GLfloat objz, const GLfloat modelMatrix[16], const GLfloat projMatrix[16], const GLint viewport[4], GLfloat* winx, GLfloat* winy, GLfloat* winz) { GLfloat in[4]; GLfloat out[4]; @@ -381,17 +322,20 @@ bool CMatrixGLES::Project(GLfloat objx, GLfloat objy, GLfloat objz, const GLfloa return true; } -void CMatrixGLES::PrintMatrix(void) +void CMatrixGL::PrintMatrix(void) { - for (unsigned int i=0; i < MM_MATRIXSIZE; i++) - { - GLfloat *m = GetMatrix((EMATRIXMODE)i); - CLog::Log(LOGDEBUG, "MatrixGLES - Matrix:%d", i); - CLog::Log(LOGDEBUG, "%f %f %f %f", m[0], m[4], m[8], m[12]); - CLog::Log(LOGDEBUG, "%f %f %f %f", m[1], m[5], m[9], m[13]); - CLog::Log(LOGDEBUG, "%f %f %f %f", m[2], m[6], m[10], m[14]); - CLog::Log(LOGDEBUG, "%f %f %f %f", m[3], m[7], m[11], m[15]); - } + CLog::Log(LOGDEBUG, "%f %f %f %f", m_pMatrix[0], m_pMatrix[4], m_pMatrix[8], m_pMatrix[12]); + CLog::Log(LOGDEBUG, "%f %f %f %f", m_pMatrix[1], m_pMatrix[5], m_pMatrix[9], m_pMatrix[13]); + CLog::Log(LOGDEBUG, "%f %f %f %f", m_pMatrix[2], m_pMatrix[6], m_pMatrix[10], m_pMatrix[14]); + CLog::Log(LOGDEBUG, "%f %f %f %f", m_pMatrix[3], m_pMatrix[7], m_pMatrix[11], m_pMatrix[15]); +} + +void CMatrixGLStack::Load() +{ +#ifdef HAS_GL + glMatrixMode(m_type); + glLoadMatrixf(m_current); +#endif } #endif diff --git a/xbmc/guilib/MatrixGLES.h b/xbmc/guilib/MatrixGLES.h index f4be9be824..3fc7960d94 100644 --- a/xbmc/guilib/MatrixGLES.h +++ b/xbmc/guilib/MatrixGLES.h @@ -1,6 +1,6 @@ #pragma once /* -* Copyright (C) 2005-2013 Team XBMC + * Copyright (C) 2005-2013 Team XBMC * http://xbmc.org * * This Program is free software; you can redistribute it and/or modify @@ -19,28 +19,22 @@ * */ -#include <vector> -#include <string.h> -enum EMATRIXMODE -{ - MM_PROJECTION = 0, - MM_MODELVIEW, - MM_TEXTURE, - MM_MATRIXSIZE // Must be last! used for size of matrices -}; +#include <cmath> +#include <cstring> +#include <stack> -class CMatrixGLES +class CMatrixGL { public: - CMatrixGLES(); - ~CMatrixGLES(); - - GLfloat* GetMatrix(EMATRIXMODE mode); - - void MatrixMode(EMATRIXMODE mode); - void PushMatrix(); - void PopMatrix(); + + CMatrixGL() { memset(&m_pMatrix, 0, sizeof(m_pMatrix)); }; + CMatrixGL(const float matrix[16]) { memcpy(m_pMatrix, matrix, sizeof(m_pMatrix)); } + CMatrixGL(const CMatrixGL &rhs ) { memcpy(m_pMatrix, rhs.m_pMatrix, sizeof(m_pMatrix)); } + CMatrixGL &operator=( const CMatrixGL &rhs ) { memcpy(m_pMatrix, rhs.m_pMatrix, sizeof(m_pMatrix)); return *this;} + operator float*() { return m_pMatrix; } + operator const float*() const { return m_pMatrix; } + void LoadIdentity(); void Ortho(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); void Ortho2D(GLfloat l, GLfloat r, GLfloat b, GLfloat t); @@ -50,29 +44,52 @@ public: void Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); void MultMatrixf(const GLfloat *matrix); void LookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez, GLfloat centerx, GLfloat centery, GLfloat centerz, GLfloat upx, GLfloat upy, GLfloat upz); - void PrintMatrix(void); + static bool Project(GLfloat objx, GLfloat objy, GLfloat objz, const GLfloat modelMatrix[16], const GLfloat projMatrix[16], const GLint viewport[4], GLfloat* winx, GLfloat* winy, GLfloat* winz); -protected: + void PrintMatrix(void); - struct MatrixWrapper + GLfloat m_pMatrix[16]; +}; + +class CMatrixGLStack +{ +public: + CMatrixGLStack(GLenum type) + : m_type(type) + {} + + void Push() { - MatrixWrapper(){ memset(&m_values, 0, sizeof(m_values)); }; - MatrixWrapper( const float values[16]) { memcpy(m_values,values,sizeof(m_values)); } - MatrixWrapper( const MatrixWrapper &rhs ) { memcpy(m_values, rhs.m_values, sizeof(m_values)); } - MatrixWrapper &operator=( const MatrixWrapper &rhs ) { memcpy(m_values, rhs.m_values, sizeof(m_values)); return *this;} - operator float*() { return m_values; } - operator const float*() const { return m_values; } - - float m_values[16]; - }; - - std::vector<struct MatrixWrapper> m_matrices[(int)MM_MATRIXSIZE]; - GLfloat *m_pMatrix; - EMATRIXMODE m_matrixMode; -#if defined(__ARM_NEON__) - bool m_has_neon; -#endif + m_stack.push(m_current); + } + + void Clear() + { + m_stack = std::stack<CMatrixGL>(); + } + + void Pop() + { + if(!m_stack.empty()) + { + m_current = m_stack.top(); + m_stack.pop(); + } + } + + void Load(); + void PopLoad() { Pop(); Load(); } + + CMatrixGL& Get() { return m_current; } + CMatrixGL* operator->() { return &m_current; } + +private: + GLint m_type; + std::stack<CMatrixGL> m_stack; + CMatrixGL m_current; }; -extern CMatrixGLES g_matrices; +extern CMatrixGLStack glMatrixModview; +extern CMatrixGLStack glMatrixProject; +extern CMatrixGLStack glMatrixTexture; diff --git a/xbmc/guilib/Resolution.h b/xbmc/guilib/Resolution.h index 08be14e1d6..edc4076835 100644 --- a/xbmc/guilib/Resolution.h +++ b/xbmc/guilib/Resolution.h @@ -21,7 +21,7 @@ #pragma once #include <stdint.h> -#include "utils/StdString.h" +#include <string> typedef int DisplayMode; #define DM_WINDOWED -1 @@ -95,11 +95,11 @@ struct RESOLUTION_INFO uint32_t dwFlags; float fPixelRatio; float fRefreshRate; - CStdString strMode; - CStdString strOutput; - CStdString strId; + std::string strMode; + std::string strOutput; + std::string strId; public: - RESOLUTION_INFO(int width = 1280, int height = 720, float aspect = 0, const CStdString &mode = "") + RESOLUTION_INFO(int width = 1280, int height = 720, float aspect = 0, const std::string &mode = "") { iWidth = width; iHeight = height; diff --git a/xbmc/guilib/StereoscopicsManager.cpp b/xbmc/guilib/StereoscopicsManager.cpp index 35ba5974fa..be2f479971 100644 --- a/xbmc/guilib/StereoscopicsManager.cpp +++ b/xbmc/guilib/StereoscopicsManager.cpp @@ -147,7 +147,7 @@ RENDER_STEREO_MODE CStereoscopicsManager::GetNextSupportedStereoMode(const RENDE std::string CStereoscopicsManager::DetectStereoModeByString(const std::string &needle) { std::string stereoMode = "mono"; - CStdString searchString(needle); + std::string searchString(needle); CRegExp re(true); if (!re.RegComp(g_advancedSettings.m_stereoscopicregex_3d.c_str())) @@ -183,7 +183,7 @@ std::string CStereoscopicsManager::DetectStereoModeByString(const std::string &n return stereoMode; } -RENDER_STEREO_MODE CStereoscopicsManager::GetStereoModeByUserChoice(const CStdString &heading) +RENDER_STEREO_MODE CStereoscopicsManager::GetStereoModeByUserChoice(const std::string &heading) { RENDER_STEREO_MODE mode = GetStereoMode(); // if no stereo mode is set already, suggest mode of current video by preselecting it @@ -205,7 +205,7 @@ RENDER_STEREO_MODE CStereoscopicsManager::GetStereoModeByUserChoice(const CStdSt if (g_Windowing.SupportsStereo(selectableMode)) { selectableModes.push_back(selectableMode); - CStdString label = GetLabelForStereoMode((RENDER_STEREO_MODE) i); + std::string label = GetLabelForStereoMode((RENDER_STEREO_MODE) i); pDlgSelect->Add( label ); if (mode == selectableMode) pDlgSelect->SetSelected( label ); @@ -227,7 +227,7 @@ RENDER_STEREO_MODE CStereoscopicsManager::GetStereoModeOfPlayingVideo(void) { RENDER_STEREO_MODE mode = RENDER_STEREO_MODE_OFF; - CStdString playerMode = g_infoManager.GetLabel(VIDEOPLAYER_STEREOSCOPIC_MODE); + std::string playerMode = g_infoManager.GetLabel(VIDEOPLAYER_STEREOSCOPIC_MODE); if (!playerMode.empty()) { int convertedMode = ConvertVideoToGuiStereoMode(playerMode); @@ -239,7 +239,7 @@ RENDER_STEREO_MODE CStereoscopicsManager::GetStereoModeOfPlayingVideo(void) return mode; } -CStdString CStereoscopicsManager::GetLabelForStereoMode(const RENDER_STEREO_MODE &mode) +const std::string &CStereoscopicsManager::GetLabelForStereoMode(const RENDER_STEREO_MODE &mode) const { if (mode == RENDER_STEREO_MODE_AUTO) return g_localizeStrings.Get(36532); @@ -476,20 +476,18 @@ void CStereoscopicsManager::OnPlaybackStarted(void) RENDER_STEREO_MODE preferred = GetPreferredPlaybackMode(); RENDER_STEREO_MODE playing = GetStereoModeOfPlayingVideo(); - int idx_playing = -1 - , idx_mono = -1; - + int idx_playing = -1; // add choices - int idx_preferred = pDlgSelect->Add((CStdString)g_localizeStrings.Get(36524) // preferred + int idx_preferred = pDlgSelect->Add(g_localizeStrings.Get(36524) // preferred + " (" + GetLabelForStereoMode(preferred) + ")"); - idx_mono = pDlgSelect->Add(GetLabelForStereoMode(RENDER_STEREO_MODE_MONO)); // mono / 2d + int idx_mono = pDlgSelect->Add(GetLabelForStereoMode(RENDER_STEREO_MODE_MONO)); // mono / 2d if(playing != RENDER_STEREO_MODE_OFF && playing != preferred && g_Windowing.SupportsStereo(playing)) - idx_playing = pDlgSelect->Add((CStdString)g_localizeStrings.Get(36532) + idx_playing = pDlgSelect->Add(g_localizeStrings.Get(36532) + " (" + GetLabelForStereoMode(playing) + ")"); diff --git a/xbmc/guilib/StereoscopicsManager.h b/xbmc/guilib/StereoscopicsManager.h index 422cba20ec..2fc155c156 100644 --- a/xbmc/guilib/StereoscopicsManager.h +++ b/xbmc/guilib/StereoscopicsManager.h @@ -58,9 +58,9 @@ public: RENDER_STEREO_MODE GetStereoMode(void); RENDER_STEREO_MODE GetNextSupportedStereoMode(const RENDER_STEREO_MODE ¤tMode, int step = 1); std::string DetectStereoModeByString(const std::string &needle); - RENDER_STEREO_MODE GetStereoModeByUserChoice(const CStdString &heading = ""); + RENDER_STEREO_MODE GetStereoModeByUserChoice(const std::string &heading = ""); RENDER_STEREO_MODE GetStereoModeOfPlayingVideo(void); - CStdString GetLabelForStereoMode(const RENDER_STEREO_MODE &mode); + const std::string &GetLabelForStereoMode(const RENDER_STEREO_MODE &mode) const; RENDER_STEREO_MODE GetPreferredPlaybackMode(void); int ConvertVideoToGuiStereoMode(const std::string &mode); /** diff --git a/xbmc/guilib/Texture.cpp b/xbmc/guilib/Texture.cpp index e2bb759a6a..b669acfbb8 100644 --- a/xbmc/guilib/Texture.cpp +++ b/xbmc/guilib/Texture.cpp @@ -174,7 +174,7 @@ void CBaseTexture::ClampToEdge() } } -CBaseTexture *CBaseTexture::LoadFromFile(const CStdString& texturePath, unsigned int idealWidth, unsigned int idealHeight, bool autoRotate, bool requirePixels, const std::string& strMimeType) +CBaseTexture *CBaseTexture::LoadFromFile(const std::string& texturePath, unsigned int idealWidth, unsigned int idealHeight, bool autoRotate, bool requirePixels, const std::string& strMimeType) { #if defined(TARGET_ANDROID) CURL url(texturePath); @@ -217,7 +217,7 @@ CBaseTexture *CBaseTexture::LoadFromFileInMemory(unsigned char *buffer, size_t b return NULL; } -bool CBaseTexture::LoadFromFileInternal(const CStdString& texturePath, unsigned int maxWidth, unsigned int maxHeight, bool autoRotate, bool requirePixels, const std::string& strMimeType) +bool CBaseTexture::LoadFromFileInternal(const std::string& texturePath, unsigned int maxWidth, unsigned int maxHeight, bool autoRotate, bool requirePixels, const std::string& strMimeType) { if (URIUtils::HasExtension(texturePath, ".dds")) { // special case for DDS images diff --git a/xbmc/guilib/Texture.h b/xbmc/guilib/Texture.h index 02de47dda2..70a1a633fc 100644 --- a/xbmc/guilib/Texture.h +++ b/xbmc/guilib/Texture.h @@ -22,7 +22,6 @@ #include "system.h" #include "gui3d.h" -#include "utils/StdString.h" #include "XBTF.h" #include "guilib/imagefactory.h" @@ -57,7 +56,7 @@ public: \param strMimeType mimetype of the given texture if available (defaults to empty) \return a CBaseTexture pointer to the created texture - NULL if the texture failed to load. */ - static CBaseTexture *LoadFromFile(const CStdString& texturePath, unsigned int idealWidth = 0, unsigned int idealHeight = 0, + static CBaseTexture *LoadFromFile(const std::string& texturePath, unsigned int idealWidth = 0, unsigned int idealHeight = 0, bool autoRotate = false, bool requirePixels = false, const std::string& strMimeType = ""); /*! \brief Load a texture from a file in memory @@ -112,7 +111,7 @@ private: protected: bool LoadFromFileInMem(unsigned char* buffer, size_t size, const std::string& mimeType, unsigned int maxWidth, unsigned int maxHeight); - bool LoadFromFileInternal(const CStdString& texturePath, unsigned int maxWidth, unsigned int maxHeight, bool autoRotate, bool requirePixels, const std::string& strMimeType = ""); + bool LoadFromFileInternal(const std::string& texturePath, unsigned int maxWidth, unsigned int maxHeight, bool autoRotate, bool requirePixels, const std::string& strMimeType = ""); bool LoadIImage(IImage* pImage, unsigned char* buffer, unsigned int bufSize, unsigned int width, unsigned int height, bool autoRotate=false); // helpers for computation of texture parameters for compressed textures unsigned int GetPitch(unsigned int width) const; diff --git a/xbmc/guilib/TextureBundle.cpp b/xbmc/guilib/TextureBundle.cpp index 2642d3793c..fe58d5c8aa 100644 --- a/xbmc/guilib/TextureBundle.cpp +++ b/xbmc/guilib/TextureBundle.cpp @@ -31,7 +31,7 @@ CTextureBundle::~CTextureBundle(void) { } -bool CTextureBundle::HasFile(const CStdString& Filename) +bool CTextureBundle::HasFile(const std::string& Filename) { if (m_useXBT) { @@ -57,7 +57,7 @@ bool CTextureBundle::HasFile(const CStdString& Filename) } } -void CTextureBundle::GetTexturesFromPath(const CStdString &path, std::vector<CStdString> &textures) +void CTextureBundle::GetTexturesFromPath(const std::string &path, std::vector<std::string> &textures) { if (m_useXBT) { @@ -69,7 +69,7 @@ void CTextureBundle::GetTexturesFromPath(const CStdString &path, std::vector<CSt } } -bool CTextureBundle::LoadTexture(const CStdString& Filename, CBaseTexture** ppTexture, +bool CTextureBundle::LoadTexture(const std::string& Filename, CBaseTexture** ppTexture, int &width, int &height) { if (m_useXBT) @@ -86,7 +86,7 @@ bool CTextureBundle::LoadTexture(const CStdString& Filename, CBaseTexture** ppTe } } -int CTextureBundle::LoadAnim(const CStdString& Filename, CBaseTexture*** ppTextures, +int CTextureBundle::LoadAnim(const std::string& Filename, CBaseTexture*** ppTextures, int &width, int &height, int& nLoops, int** ppDelays) { if (m_useXBT) @@ -116,7 +116,7 @@ void CTextureBundle::SetThemeBundle(bool themeBundle) m_tbXBT.SetThemeBundle(themeBundle); } -CStdString CTextureBundle::Normalize(const CStdString &name) +std::string CTextureBundle::Normalize(const std::string &name) { return CTextureBundleXBT::Normalize(name); } diff --git a/xbmc/guilib/TextureBundle.h b/xbmc/guilib/TextureBundle.h index 80071e6135..7fddb30e28 100644 --- a/xbmc/guilib/TextureBundle.h +++ b/xbmc/guilib/TextureBundle.h @@ -20,7 +20,8 @@ * */ -#include "utils/StdString.h" +#include <string> +#include <vector> #include "TextureBundleXPR.h" #include "TextureBundleXBT.h" @@ -33,13 +34,13 @@ public: void Cleanup(); void SetThemeBundle(bool themeBundle); - bool HasFile(const CStdString& Filename); - void GetTexturesFromPath(const CStdString &path, std::vector<CStdString> &textures); - static CStdString Normalize(const CStdString &name); + bool HasFile(const std::string& Filename); + void GetTexturesFromPath(const std::string &path, std::vector<std::string> &textures); + static std::string Normalize(const std::string &name); - bool LoadTexture(const CStdString& Filename, CBaseTexture** ppTexture, int &width, int &height); + bool LoadTexture(const std::string& Filename, CBaseTexture** ppTexture, int &width, int &height); - int LoadAnim(const CStdString& Filename, CBaseTexture*** ppTextures, int &width, int &height, int& nLoops, int** ppDelays); + int LoadAnim(const std::string& Filename, CBaseTexture*** ppTextures, int &width, int &height, int& nLoops, int** ppDelays); private: CTextureBundleXPR m_tbXPR; diff --git a/xbmc/guilib/TextureBundleXBT.cpp b/xbmc/guilib/TextureBundleXBT.cpp index df75beab99..089bab1c92 100644 --- a/xbmc/guilib/TextureBundleXBT.cpp +++ b/xbmc/guilib/TextureBundleXBT.cpp @@ -18,7 +18,7 @@ * */ -#include "libsquish/squish.h" +#include "squish.h" #include "system.h" #include "TextureBundleXBT.h" #include "Texture.h" @@ -54,16 +54,16 @@ bool CTextureBundleXBT::OpenBundle() Cleanup(); // Find the correct texture file (skin or theme) - CStdString strPath; + std::string strPath; if (m_themeBundle) { // if we are the theme bundle, we only load if the user has chosen // a valid theme (or the skin has a default one) - CStdString theme = CSettings::Get().GetString("lookandfeel.skintheme"); + std::string theme = CSettings::Get().GetString("lookandfeel.skintheme"); if (!theme.empty() && !StringUtils::EqualsNoCase(theme, "SKINDEFAULT")) { - CStdString themeXBT(URIUtils::ReplaceExtension(theme, ".xbt")); + std::string themeXBT(URIUtils::ReplaceExtension(theme, ".xbt")); strPath = URIUtils::AddFileToFolder(g_graphicsContext.GetMediaDir(), "media"); strPath = URIUtils::AddFileToFolder(strPath, themeXBT); } @@ -97,7 +97,7 @@ bool CTextureBundleXBT::OpenBundle() return true; } -bool CTextureBundleXBT::HasFile(const CStdString& Filename) +bool CTextureBundleXBT::HasFile(const std::string& Filename) { if (!m_XBTFReader.IsOpen() && !OpenBundle()) return false; @@ -109,11 +109,11 @@ bool CTextureBundleXBT::HasFile(const CStdString& Filename) return false; } - CStdString name = Normalize(Filename); + std::string name = Normalize(Filename); return m_XBTFReader.Exists(name); } -void CTextureBundleXBT::GetTexturesFromPath(const CStdString &path, std::vector<CStdString> &textures) +void CTextureBundleXBT::GetTexturesFromPath(const std::string &path, std::vector<std::string> &textures) { if (path.size() > 1 && path[1] == ':') return; @@ -121,22 +121,22 @@ void CTextureBundleXBT::GetTexturesFromPath(const CStdString &path, std::vector< if (!m_XBTFReader.IsOpen() && !OpenBundle()) return; - CStdString testPath = Normalize(path); + std::string testPath = Normalize(path); URIUtils::AddSlashAtEnd(testPath); std::vector<CXBTFFile>& files = m_XBTFReader.GetFiles(); for (size_t i = 0; i < files.size(); i++) { - CStdString path = files[i].GetPath(); + std::string path = files[i].GetPath(); if (StringUtils::StartsWithNoCase(path, testPath)) textures.push_back(path); } } -bool CTextureBundleXBT::LoadTexture(const CStdString& Filename, CBaseTexture** ppTexture, +bool CTextureBundleXBT::LoadTexture(const std::string& Filename, CBaseTexture** ppTexture, int &width, int &height) { - CStdString name = Normalize(Filename); + std::string name = Normalize(Filename); CXBTFFile* file = m_XBTFReader.Find(name); if (!file) @@ -157,10 +157,10 @@ bool CTextureBundleXBT::LoadTexture(const CStdString& Filename, CBaseTexture** p return true; } -int CTextureBundleXBT::LoadAnim(const CStdString& Filename, CBaseTexture*** ppTextures, +int CTextureBundleXBT::LoadAnim(const std::string& Filename, CBaseTexture*** ppTextures, int &width, int &height, int& nLoops, int** ppDelays) { - CStdString name = Normalize(Filename); + std::string name = Normalize(Filename); CXBTFFile* file = m_XBTFReader.Find(name); if (!file) @@ -192,7 +192,7 @@ int CTextureBundleXBT::LoadAnim(const CStdString& Filename, CBaseTexture*** ppTe return nTextures; } -bool CTextureBundleXBT::ConvertFrameToTexture(const CStdString& name, CXBTFFrame& frame, CBaseTexture** ppTexture) +bool CTextureBundleXBT::ConvertFrameToTexture(const std::string& name, CXBTFFrame& frame, CBaseTexture** ppTexture) { // found texture - allocate the necessary buffers squish::u8 *buffer = new squish::u8[(size_t)frame.GetPackedSize()]; @@ -258,9 +258,9 @@ void CTextureBundleXBT::SetThemeBundle(bool themeBundle) // normalize to how it's stored within the bundle // lower case + using forward slash rather than back slash -CStdString CTextureBundleXBT::Normalize(const CStdString &name) +std::string CTextureBundleXBT::Normalize(const std::string &name) { - CStdString newName(name); + std::string newName(name); StringUtils::Trim(newName); StringUtils::ToLower(newName); diff --git a/xbmc/guilib/TextureBundleXBT.h b/xbmc/guilib/TextureBundleXBT.h index cc6d913056..9a2f89d2fa 100644 --- a/xbmc/guilib/TextureBundleXBT.h +++ b/xbmc/guilib/TextureBundleXBT.h @@ -20,8 +20,8 @@ * */ -#include "utils/StdString.h" #include <map> +#include <string> #include "XBTFReader.h" class CBaseTexture; @@ -34,19 +34,19 @@ public: void Cleanup(); void SetThemeBundle(bool themeBundle); - bool HasFile(const CStdString& Filename); - void GetTexturesFromPath(const CStdString &path, std::vector<CStdString> &textures); - static CStdString Normalize(const CStdString &name); + bool HasFile(const std::string& Filename); + void GetTexturesFromPath(const std::string &path, std::vector<std::string> &textures); + static std::string Normalize(const std::string &name); - bool LoadTexture(const CStdString& Filename, CBaseTexture** ppTexture, + bool LoadTexture(const std::string& Filename, CBaseTexture** ppTexture, int &width, int &height); - int LoadAnim(const CStdString& Filename, CBaseTexture*** ppTextures, + int LoadAnim(const std::string& Filename, CBaseTexture*** ppTextures, int &width, int &height, int& nLoops, int** ppDelays); private: bool OpenBundle(); - bool ConvertFrameToTexture(const CStdString& name, CXBTFFrame& frame, CBaseTexture** ppTexture); + bool ConvertFrameToTexture(const std::string& name, CXBTFFrame& frame, CBaseTexture** ppTexture); time_t m_TimeStamp; diff --git a/xbmc/guilib/TextureBundleXPR.cpp b/xbmc/guilib/TextureBundleXPR.cpp index b104b444c1..14e976d648 100644 --- a/xbmc/guilib/TextureBundleXPR.cpp +++ b/xbmc/guilib/TextureBundleXPR.cpp @@ -124,16 +124,16 @@ bool CTextureBundleXPR::OpenBundle() if (m_hFile != NULL) Cleanup(); - CStdString strPath; + std::string strPath; if (m_themeBundle) { // if we are the theme bundle, we only load if the user has chosen // a valid theme (or the skin has a default one) - CStdString theme = CSettings::Get().GetString("lookandfeel.skintheme"); + std::string theme = CSettings::Get().GetString("lookandfeel.skintheme"); if (!theme.empty() && !StringUtils::EqualsNoCase(theme, "SKINDEFAULT")) { - CStdString themeXPR(URIUtils::ReplaceExtension(theme, ".xpr")); + std::string themeXPR(URIUtils::ReplaceExtension(theme, ".xpr")); strPath = URIUtils::AddFileToFolder(g_graphicsContext.GetMediaDir(), "media"); strPath = URIUtils::AddFileToFolder(strPath, themeXPR); } @@ -146,7 +146,7 @@ bool CTextureBundleXPR::OpenBundle() strPath = CSpecialProtocol::TranslatePathConvertCase(strPath); #ifndef TARGET_POSIX - CStdStringW strPathW; + std::wstring strPathW; g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(strPath), strPathW, false); m_hFile = _wfopen(strPathW.c_str(), L"rb"); #else @@ -199,7 +199,7 @@ bool CTextureBundleXPR::OpenBundle() n = (HeaderSize - sizeof(XPR_HEADER)) / sizeof(DiskFileHeader_t); for (unsigned i = 0; i < n; ++i) { - std::pair<CStdString, FileHeader_t> entry; + std::pair<std::string, FileHeader_t> entry; entry.first = Normalize(FileHeader[i].Name); entry.second.Offset = Endian_SwapLE32(FileHeader[i].Offset); entry.second.UnpackedSize = Endian_SwapLE32(FileHeader[i].UnpackedSize); @@ -229,7 +229,7 @@ void CTextureBundleXPR::Cleanup() m_FileHeaders.clear(); } -bool CTextureBundleXPR::HasFile(const CStdString& Filename) +bool CTextureBundleXPR::HasFile(const std::string& Filename) { if (m_hFile == NULL && !OpenBundle()) return false; @@ -245,11 +245,11 @@ bool CTextureBundleXPR::HasFile(const CStdString& Filename) return false; } - CStdString name = Normalize(Filename); + std::string name = Normalize(Filename); return m_FileHeaders.find(name) != m_FileHeaders.end(); } -void CTextureBundleXPR::GetTexturesFromPath(const CStdString &path, std::vector<CStdString> &textures) +void CTextureBundleXPR::GetTexturesFromPath(const std::string &path, std::vector<std::string> &textures) { if (path.size() > 1 && path[1] == ':') return; @@ -257,10 +257,10 @@ void CTextureBundleXPR::GetTexturesFromPath(const CStdString &path, std::vector< if (m_hFile == NULL && !OpenBundle()) return; - CStdString testPath = Normalize(path); + std::string testPath = Normalize(path); if (!URIUtils::HasSlashAtEnd(testPath)) testPath += "\\"; - std::map<CStdString, FileHeader_t>::iterator it; + std::map<std::string, FileHeader_t>::iterator it; for (it = m_FileHeaders.begin(); it != m_FileHeaders.end(); ++it) { if (StringUtils::StartsWithNoCase(it->first, testPath)) @@ -268,11 +268,11 @@ void CTextureBundleXPR::GetTexturesFromPath(const CStdString &path, std::vector< } } -bool CTextureBundleXPR::LoadFile(const CStdString& Filename, CAutoTexBuffer& UnpackedBuf) +bool CTextureBundleXPR::LoadFile(const std::string& Filename, CAutoTexBuffer& UnpackedBuf) { - CStdString name = Normalize(Filename); + std::string name = Normalize(Filename); - std::map<CStdString, FileHeader_t>::iterator file = m_FileHeaders.find(name); + std::map<std::string, FileHeader_t>::iterator file = m_FileHeaders.find(name); if (file == m_FileHeaders.end()) return false; @@ -341,7 +341,7 @@ bool CTextureBundleXPR::LoadFile(const CStdString& Filename, CAutoTexBuffer& Unp return success; } -bool CTextureBundleXPR::LoadTexture(const CStdString& Filename, CBaseTexture** ppTexture, +bool CTextureBundleXPR::LoadTexture(const std::string& Filename, CBaseTexture** ppTexture, int &width, int &height) { DWORD ResDataOffset; @@ -411,7 +411,7 @@ PackedLoadError: return false; } -int CTextureBundleXPR::LoadAnim(const CStdString& Filename, CBaseTexture*** ppTextures, +int CTextureBundleXPR::LoadAnim(const std::string& Filename, CBaseTexture*** ppTextures, int &width, int &height, int& nLoops, int** ppDelays) { DWORD ResDataOffset; @@ -506,9 +506,9 @@ void CTextureBundleXPR::SetThemeBundle(bool themeBundle) // normalize to how it's stored within the bundle // lower case + using \\ rather than / -CStdString CTextureBundleXPR::Normalize(const CStdString &name) +std::string CTextureBundleXPR::Normalize(const std::string &name) { - CStdString newName(name); + std::string newName(name); StringUtils::Trim(newName); StringUtils::ToLower(newName); StringUtils::Replace(newName, '/','\\'); diff --git a/xbmc/guilib/TextureBundleXPR.h b/xbmc/guilib/TextureBundleXPR.h index c2a444ecb1..75fe794605 100644 --- a/xbmc/guilib/TextureBundleXPR.h +++ b/xbmc/guilib/TextureBundleXPR.h @@ -20,9 +20,10 @@ * */ -#include "utils/StdString.h" -#include <stdint.h> #include <map> +#include <string> +#include <stdint.h> +#include <vector> class CAutoTexBuffer; class CBaseTexture; @@ -39,13 +40,13 @@ class CTextureBundleXPR FILE* m_hFile; time_t m_TimeStamp; - std::map<CStdString, FileHeader_t> m_FileHeaders; - typedef std::map<CStdString, FileHeader_t>::iterator iFiles; + std::map<std::string, FileHeader_t> m_FileHeaders; + typedef std::map<std::string, FileHeader_t>::iterator iFiles; bool m_themeBundle; bool OpenBundle(); - bool LoadFile(const CStdString& Filename, CAutoTexBuffer& UnpackedBuf); + bool LoadFile(const std::string& Filename, CAutoTexBuffer& UnpackedBuf); public: CTextureBundleXPR(void); @@ -54,14 +55,14 @@ public: void Cleanup(); void SetThemeBundle(bool themeBundle); - bool HasFile(const CStdString& Filename); - void GetTexturesFromPath(const CStdString &path, std::vector<CStdString> &textures); - static CStdString Normalize(const CStdString &name); + bool HasFile(const std::string& Filename); + void GetTexturesFromPath(const std::string &path, std::vector<std::string> &textures); + static std::string Normalize(const std::string &name); - bool LoadTexture(const CStdString& Filename, CBaseTexture** ppTexture, + bool LoadTexture(const std::string& Filename, CBaseTexture** ppTexture, int &width, int &height); - int LoadAnim(const CStdString& Filename, CBaseTexture*** ppTextures, + int LoadAnim(const std::string& Filename, CBaseTexture*** ppTextures, int &width, int &height, int& nLoops, int** ppDelays); }; diff --git a/xbmc/guilib/TextureManager.cpp b/xbmc/guilib/TextureManager.cpp index b930ed7bc7..794b37b632 100644 --- a/xbmc/guilib/TextureManager.cpp +++ b/xbmc/guilib/TextureManager.cpp @@ -134,7 +134,7 @@ CTextureMap::CTextureMap() m_memUsage = 0; } -CTextureMap::CTextureMap(const CStdString& textureName, int width, int height, int loops) +CTextureMap::CTextureMap(const std::string& textureName, int width, int height, int loops) : m_texture(width, height, loops) { m_textureName = textureName; @@ -162,7 +162,7 @@ bool CTextureMap::Release() return false; } -const CStdString& CTextureMap::GetName() const +const std::string& CTextureMap::GetName() const { return m_textureName; } @@ -228,7 +228,7 @@ CGUITextureManager::~CGUITextureManager(void) /************************************************************************/ /* */ /************************************************************************/ -bool CGUITextureManager::CanLoad(const CStdString &texturePath) +bool CGUITextureManager::CanLoad(const std::string &texturePath) { if (texturePath == "-") return false; @@ -240,7 +240,7 @@ bool CGUITextureManager::CanLoad(const CStdString &texturePath) return URIUtils::IsHD(texturePath); } -bool CGUITextureManager::HasTexture(const CStdString &textureName, CStdString *path, int *bundle, int *size) +bool CGUITextureManager::HasTexture(const std::string &textureName, std::string *path, int *bundle, int *size) { // default values if (bundle) *bundle = -1; @@ -251,7 +251,7 @@ bool CGUITextureManager::HasTexture(const CStdString &textureName, CStdString *p return false; // Check our loaded and bundled textures - we store in bundles using \\. - CStdString bundledName = CTextureBundle::Normalize(textureName); + std::string bundledName = CTextureBundle::Normalize(textureName); for (int i = 0; i < (int)m_vecTextures.size(); ++i) { CTextureMap *pMap = m_vecTextures[i]; @@ -271,16 +271,16 @@ bool CGUITextureManager::HasTexture(const CStdString &textureName, CStdString *p } } - CStdString fullPath = GetTexturePath(textureName); + std::string fullPath = GetTexturePath(textureName); if (path) *path = fullPath; return !fullPath.empty(); } -const CTextureArray& CGUITextureManager::Load(const CStdString& strTextureName, bool checkBundleOnly /*= false */) +const CTextureArray& CGUITextureManager::Load(const std::string& strTextureName, bool checkBundleOnly /*= false */) { - CStdString strPath; + std::string strPath; static CTextureArray emptyTexture; int bundle = -1; int size = 0; @@ -429,7 +429,7 @@ const CTextureArray& CGUITextureManager::Load(const CStdString& strTextureName, } -void CGUITextureManager::ReleaseTexture(const CStdString& strTextureName, bool immediately /*= false */) +void CGUITextureManager::ReleaseTexture(const std::string& strTextureName, bool immediately /*= false */) { CSingleLock lock(g_graphicsContext); @@ -552,24 +552,24 @@ unsigned int CGUITextureManager::GetMemoryUsage() const return memUsage; } -void CGUITextureManager::SetTexturePath(const CStdString &texturePath) +void CGUITextureManager::SetTexturePath(const std::string &texturePath) { CSingleLock lock(m_section); m_texturePaths.clear(); AddTexturePath(texturePath); } -void CGUITextureManager::AddTexturePath(const CStdString &texturePath) +void CGUITextureManager::AddTexturePath(const std::string &texturePath) { CSingleLock lock(m_section); if (!texturePath.empty()) m_texturePaths.push_back(texturePath); } -void CGUITextureManager::RemoveTexturePath(const CStdString &texturePath) +void CGUITextureManager::RemoveTexturePath(const std::string &texturePath) { CSingleLock lock(m_section); - for (vector<CStdString>::iterator it = m_texturePaths.begin(); it != m_texturePaths.end(); ++it) + for (vector<std::string>::iterator it = m_texturePaths.begin(); it != m_texturePaths.end(); ++it) { if (*it == texturePath) { @@ -579,16 +579,16 @@ void CGUITextureManager::RemoveTexturePath(const CStdString &texturePath) } } -CStdString CGUITextureManager::GetTexturePath(const CStdString &textureName, bool directory /* = false */) +std::string CGUITextureManager::GetTexturePath(const std::string &textureName, bool directory /* = false */) { if (CURL::IsFullPath(textureName)) return textureName; else { // texture doesn't include the full path, so check all fallbacks CSingleLock lock(m_section); - for (vector<CStdString>::iterator it = m_texturePaths.begin(); it != m_texturePaths.end(); ++it) + for (vector<std::string>::iterator it = m_texturePaths.begin(); it != m_texturePaths.end(); ++it) { - CStdString path = URIUtils::AddFileToFolder(it->c_str(), "media"); + std::string path = URIUtils::AddFileToFolder(it->c_str(), "media"); path = URIUtils::AddFileToFolder(path, textureName); if (directory) { @@ -605,7 +605,7 @@ CStdString CGUITextureManager::GetTexturePath(const CStdString &textureName, boo return ""; } -void CGUITextureManager::GetBundledTexturesFromPath(const CStdString& texturePath, std::vector<CStdString> &items) +void CGUITextureManager::GetBundledTexturesFromPath(const std::string& texturePath, std::vector<std::string> &items) { m_TexBundle[0].GetTexturesFromPath(texturePath, items); if (items.empty()) diff --git a/xbmc/guilib/TextureManager.h b/xbmc/guilib/TextureManager.h index aca77747b4..96d3bcce1f 100644 --- a/xbmc/guilib/TextureManager.h +++ b/xbmc/guilib/TextureManager.h @@ -73,13 +73,13 @@ class CTextureMap { public: CTextureMap(); - CTextureMap(const CStdString& textureName, int width, int height, int loops); + CTextureMap(const std::string& textureName, int width, int height, int loops); virtual ~CTextureMap(); void Add(CBaseTexture* texture, int delay); bool Release(); - const CStdString& GetName() const; + const std::string& GetName() const; const CTextureArray& GetTexture(); void Dump() const; uint32_t GetMemoryUsage() const; @@ -88,7 +88,7 @@ public: protected: void FreeTexture(); - CStdString m_textureName; + std::string m_textureName; CTextureArray m_texture; unsigned int m_referenceCount; uint32_t m_memUsage; @@ -107,20 +107,20 @@ public: CGUITextureManager(void); virtual ~CGUITextureManager(void); - bool HasTexture(const CStdString &textureName, CStdString *path = NULL, int *bundle = NULL, int *size = NULL); - static bool CanLoad(const CStdString &texturePath); ///< Returns true if the texture manager can load this texture - const CTextureArray& Load(const CStdString& strTextureName, bool checkBundleOnly = false); - void ReleaseTexture(const CStdString& strTextureName, bool immediately = false); + bool HasTexture(const std::string &textureName, std::string *path = NULL, int *bundle = NULL, int *size = NULL); + static bool CanLoad(const std::string &texturePath); ///< Returns true if the texture manager can load this texture + const CTextureArray& Load(const std::string& strTextureName, bool checkBundleOnly = false); + void ReleaseTexture(const std::string& strTextureName, bool immediately = false); void Cleanup(); void Dump() const; uint32_t GetMemoryUsage() const; void Flush(); - CStdString GetTexturePath(const CStdString& textureName, bool directory = false); - void GetBundledTexturesFromPath(const CStdString& texturePath, std::vector<CStdString> &items); + std::string GetTexturePath(const std::string& textureName, bool directory = false); + void GetBundledTexturesFromPath(const std::string& texturePath, std::vector<std::string> &items); - void AddTexturePath(const CStdString &texturePath); ///< Add a new path to the paths to check when loading media - void SetTexturePath(const CStdString &texturePath); ///< Set a single path as the path to check when loading media (clear then add) - void RemoveTexturePath(const CStdString &texturePath); ///< Remove a path from the paths to check when loading media + void AddTexturePath(const std::string &texturePath); ///< Add a new path to the paths to check when loading media + void SetTexturePath(const std::string &texturePath); ///< Set a single path as the path to check when loading media (clear then add) + void RemoveTexturePath(const std::string &texturePath); ///< Remove a path from the paths to check when loading media void FreeUnusedTextures(unsigned int timeDelay = 0); ///< Free textures (called from app thread only) void ReleaseHwTexture(unsigned int texture); @@ -133,7 +133,7 @@ protected: // we have 2 texture bundles (one for the base textures, one for the theme) CTextureBundle m_TexBundle[2]; - std::vector<CStdString> m_texturePaths; + std::vector<std::string> m_texturePaths; CCriticalSection m_section; }; diff --git a/xbmc/guilib/TexturePi.cpp b/xbmc/guilib/TexturePi.cpp index a17bfba970..77d408ad89 100644 --- a/xbmc/guilib/TexturePi.cpp +++ b/xbmc/guilib/TexturePi.cpp @@ -112,7 +112,7 @@ void CPiTexture::Update(unsigned int width, unsigned int height, unsigned int pi CGLTexture::Update(width, height, pitch, format, pixels, loadToGPU); } -bool CPiTexture::LoadFromFileInternal(const CStdString& texturePath, unsigned int maxWidth, unsigned int maxHeight, bool autoRotate, bool requirePixels, const std::string& strMimeType) +bool CPiTexture::LoadFromFileInternal(const std::string& texturePath, unsigned int maxWidth, unsigned int maxHeight, bool autoRotate, bool requirePixels, const std::string& strMimeType) { if (URIUtils::HasExtension(texturePath, ".jpg|.tbn")) { diff --git a/xbmc/guilib/TexturePi.h b/xbmc/guilib/TexturePi.h index b0fa8e483a..a60464fe8c 100644 --- a/xbmc/guilib/TexturePi.h +++ b/xbmc/guilib/TexturePi.h @@ -38,7 +38,7 @@ public: void LoadToGPU(); void Update(unsigned int width, unsigned int height, unsigned int pitch, unsigned int format, const unsigned char *pixels, bool loadToGPU); void Allocate(unsigned int width, unsigned int height, unsigned int format); - bool LoadFromFileInternal(const CStdString& texturePath, unsigned int maxWidth, unsigned int maxHeight, bool autoRotate, bool requirePixels, const std::string& strMimeType = ""); + bool LoadFromFileInternal(const std::string& texturePath, unsigned int maxWidth, unsigned int maxHeight, bool autoRotate, bool requirePixels, const std::string& strMimeType = ""); protected: diff --git a/xbmc/guilib/VisibleEffect.cpp b/xbmc/guilib/VisibleEffect.cpp index ea855a1d5d..a8fb55773a 100644 --- a/xbmc/guilib/VisibleEffect.cpp +++ b/xbmc/guilib/VisibleEffect.cpp @@ -625,17 +625,17 @@ void CAnimation::Create(const TiXmlElement *node, const CRect &rect, int context const TiXmlElement *effect = node->FirstChildElement("effect"); - CStdString type = node->FirstChild()->Value(); + std::string type = node->FirstChild()->Value(); m_type = ANIM_TYPE_CONDITIONAL; if (effect) // new layout type = XMLUtils::GetAttribute(node, "type"); if (StringUtils::StartsWithNoCase(type, "visible")) m_type = ANIM_TYPE_VISIBLE; - else if (type.Equals("hidden")) m_type = ANIM_TYPE_HIDDEN; - else if (type.Equals("focus")) m_type = ANIM_TYPE_FOCUS; - else if (type.Equals("unfocus")) m_type = ANIM_TYPE_UNFOCUS; - else if (type.Equals("windowopen")) m_type = ANIM_TYPE_WINDOW_OPEN; - else if (type.Equals("windowclose")) m_type = ANIM_TYPE_WINDOW_CLOSE; + else if (StringUtils::EqualsNoCase(type, "hidden")) m_type = ANIM_TYPE_HIDDEN; + else if (StringUtils::EqualsNoCase(type, "focus")) m_type = ANIM_TYPE_FOCUS; + else if (StringUtils::EqualsNoCase(type, "unfocus")) m_type = ANIM_TYPE_UNFOCUS; + else if (StringUtils::EqualsNoCase(type, "windowopen")) m_type = ANIM_TYPE_WINDOW_OPEN; + else if (StringUtils::EqualsNoCase(type, "windowclose")) m_type = ANIM_TYPE_WINDOW_CLOSE; // sanity check if (m_type == ANIM_TYPE_CONDITIONAL) { @@ -657,7 +657,7 @@ void CAnimation::Create(const TiXmlElement *node, const CRect &rect, int context if (!effect) { // old layout: // <animation effect="fade" start="0" end="100" delay="10" time="2000" condition="blahdiblah" reversible="false">focus</animation> - CStdString type = XMLUtils::GetAttribute(node, "effect"); + std::string type = XMLUtils::GetAttribute(node, "effect"); AddEffect(type, node, rect); } while (effect) @@ -666,7 +666,7 @@ void CAnimation::Create(const TiXmlElement *node, const CRect &rect, int context // <effect type="fade" start="0" end="100" delay="10" time="2000" /> // ... // </animation> - CStdString type = XMLUtils::GetAttribute(effect, "type"); + std::string type = XMLUtils::GetAttribute(effect, "type"); AddEffect(type, effect, rect); effect = effect->NextSiblingElement("effect"); } @@ -681,20 +681,20 @@ void CAnimation::Create(const TiXmlElement *node, const CRect &rect, int context m_length = total - m_delay; } -void CAnimation::AddEffect(const CStdString &type, const TiXmlElement *node, const CRect &rect) +void CAnimation::AddEffect(const std::string &type, const TiXmlElement *node, const CRect &rect) { CAnimEffect *effect = NULL; - if (type.Equals("fade")) + if (StringUtils::EqualsNoCase(type, "fade")) effect = new CFadeEffect(node, m_type < 0); - else if (type.Equals("slide")) + else if (StringUtils::EqualsNoCase(type, "slide")) effect = new CSlideEffect(node); - else if (type.Equals("rotate")) + else if (StringUtils::EqualsNoCase(type, "rotate")) effect = new CRotateEffect(node, CAnimEffect::EFFECT_TYPE_ROTATE_Z); - else if (type.Equals("rotatey")) + else if (StringUtils::EqualsNoCase(type, "rotatey")) effect = new CRotateEffect(node, CAnimEffect::EFFECT_TYPE_ROTATE_Y); - else if (type.Equals("rotatex")) + else if (StringUtils::EqualsNoCase(type, "rotatex")) effect = new CRotateEffect(node, CAnimEffect::EFFECT_TYPE_ROTATE_X); - else if (type.Equals("zoom")) + else if (StringUtils::EqualsNoCase(type, "zoom")) effect = new CZoomEffect(node, rect); if (effect) diff --git a/xbmc/guilib/VisibleEffect.h b/xbmc/guilib/VisibleEffect.h index 5efac319cd..22e781228d 100644 --- a/xbmc/guilib/VisibleEffect.h +++ b/xbmc/guilib/VisibleEffect.h @@ -31,10 +31,12 @@ class CGUIListItem; #include "TransformMatrix.h" // needed for the TransformMatrix member #include "Geometry.h" // for CPoint, CRect -#include "utils/StdString.h" #include "boost/shared_ptr.hpp" #include "interfaces/info/InfoBool.h" +#include <string> +#include <vector> + enum ANIMATION_TYPE { ANIM_TYPE_UNFOCUS = -3, @@ -177,7 +179,7 @@ public: private: void Calculate(const CPoint &point); - void AddEffect(const CStdString &type, const TiXmlElement *node, const CRect &rect); + void AddEffect(const std::string &type, const TiXmlElement *node, const CRect &rect); enum ANIM_REPEAT { ANIM_REPEAT_NONE = 0, ANIM_REPEAT_PULSE, ANIM_REPEAT_LOOP }; diff --git a/xbmc/guilib/XBTFReader.cpp b/xbmc/guilib/XBTFReader.cpp index b1a245386b..7dafc1ff4d 100644 --- a/xbmc/guilib/XBTFReader.cpp +++ b/xbmc/guilib/XBTFReader.cpp @@ -22,6 +22,7 @@ #include "XBTFReader.h" #include "utils/EndianSwap.h" #include "utils/CharsetConverter.h" +#include <stdio.h> #ifdef TARGET_WINDOWS #include "FileSystem/SpecialProtocol.h" #endif @@ -53,12 +54,12 @@ bool CXBTFReader::IsOpen() const return m_file != NULL; } -bool CXBTFReader::Open(const CStdString& fileName) +bool CXBTFReader::Open(const std::string& fileName) { m_fileName = fileName; #ifdef TARGET_WINDOWS - CStdStringW strPathW; + std::wstring strPathW; g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(m_fileName), strPathW, false); m_file = _wfopen(strPathW.c_str(), L"rb"); #else @@ -166,14 +167,14 @@ time_t CXBTFReader::GetLastModificationTimestamp() return fileStat.st_mtime; } -bool CXBTFReader::Exists(const CStdString& name) +bool CXBTFReader::Exists(const std::string& name) { return Find(name) != NULL; } -CXBTFFile* CXBTFReader::Find(const CStdString& name) +CXBTFFile* CXBTFReader::Find(const std::string& name) { - std::map<CStdString, CXBTFFile>::iterator iter = m_filesMap.find(name); + std::map<std::string, CXBTFFile>::iterator iter = m_filesMap.find(name); if (iter == m_filesMap.end()) { return NULL; diff --git a/xbmc/guilib/XBTFReader.h b/xbmc/guilib/XBTFReader.h index ec1a96d43d..35f4edce48 100644 --- a/xbmc/guilib/XBTFReader.h +++ b/xbmc/guilib/XBTFReader.h @@ -23,7 +23,7 @@ #include <vector> #include <map> -#include "utils/StdString.h" +#include <string> #include "XBTF.h" class CXBTFReader @@ -31,19 +31,19 @@ class CXBTFReader public: CXBTFReader(); bool IsOpen() const; - bool Open(const CStdString& fileName); + bool Open(const std::string& fileName); void Close(); time_t GetLastModificationTimestamp(); - bool Exists(const CStdString& name); - CXBTFFile* Find(const CStdString& name); + bool Exists(const std::string& name); + CXBTFFile* Find(const std::string& name); bool Load(const CXBTFFrame& frame, unsigned char* buffer); std::vector<CXBTFFile>& GetFiles(); private: CXBTF m_xbtf; - CStdString m_fileName; + std::string m_fileName; FILE* m_file; - std::map<CStdString, CXBTFFile> m_filesMap; + std::map<std::string, CXBTFFile> m_filesMap; }; #endif diff --git a/xbmc/guilib/cximage.cpp b/xbmc/guilib/cximage.cpp index b1c9234e79..d2b4b85836 100644 --- a/xbmc/guilib/cximage.cpp +++ b/xbmc/guilib/cximage.cpp @@ -113,7 +113,7 @@ bool CXImage::Decode(const unsigned char *pixels, unsigned int pitch, unsigned i return true; } -bool CXImage::CreateThumbnailFromSurface(unsigned char* bufferin, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const CStdString& destFile, +bool CXImage::CreateThumbnailFromSurface(unsigned char* bufferin, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const std::string& destFile, unsigned char* &bufferout, unsigned int &bufferoutSize) { if (!bufferin || !m_dll.IsLoaded()) diff --git a/xbmc/guilib/cximage.h b/xbmc/guilib/cximage.h index e6233fd323..87eec766d1 100644 --- a/xbmc/guilib/cximage.h +++ b/xbmc/guilib/cximage.h @@ -30,7 +30,7 @@ public: virtual bool LoadImageFromMemory(unsigned char* buffer, unsigned int bufSize, unsigned int width, unsigned int height); virtual bool Decode(const unsigned char *pixels, unsigned int pitch, unsigned int format); - virtual bool CreateThumbnailFromSurface(unsigned char* bufferin, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const CStdString& destFile, + virtual bool CreateThumbnailFromSurface(unsigned char* bufferin, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const std::string& destFile, unsigned char* &bufferout, unsigned int &bufferoutSize); virtual void ReleaseThumbnailBuffer(); @@ -39,4 +39,4 @@ private: ImageInfo m_image; std::string m_strMimeType; BYTE* m_thumbnailbuffer; -};
\ No newline at end of file +}; diff --git a/xbmc/guilib/iimage.h b/xbmc/guilib/iimage.h index 84f29c60a7..e7e805af69 100644 --- a/xbmc/guilib/iimage.h +++ b/xbmc/guilib/iimage.h @@ -18,7 +18,7 @@ * <http://www.gnu.org/licenses/>. * */ -#include "utils/StdString.h" +#include <string> class IImage { @@ -57,7 +57,7 @@ public: \param bufferoutSize The output buffer size \return true if the thumbnail was successfully created */ - virtual bool CreateThumbnailFromSurface(unsigned char* bufferin, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const CStdString& destFile, + virtual bool CreateThumbnailFromSurface(unsigned char* bufferin, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const std::string& destFile, unsigned char* &bufferout, unsigned int &bufferoutSize)=0; /*! \brief Frees the output buffer allocated by CreateThumbnailFromSurface @@ -80,4 +80,4 @@ protected: unsigned int m_orientation; bool m_hasAlpha; -};
\ No newline at end of file +}; diff --git a/xbmc/input/ButtonTranslator.cpp b/xbmc/input/ButtonTranslator.cpp index c297408f36..11307b4d2b 100644 --- a/xbmc/input/ButtonTranslator.cpp +++ b/xbmc/input/ButtonTranslator.cpp @@ -411,8 +411,13 @@ static const ActionMapping mousekeys[] = { "longclick", KEY_MOUSE_LONG_CLICK }, { "wheelup", KEY_MOUSE_WHEEL_UP }, { "wheeldown", KEY_MOUSE_WHEEL_DOWN }, + { "mousemove", KEY_MOUSE_MOVE }, { "mousedrag", KEY_MOUSE_DRAG }, - { "mousemove", KEY_MOUSE_MOVE } + { "mousedragstart", KEY_MOUSE_DRAG_START }, + { "mousedragend", KEY_MOUSE_DRAG_END }, + { "mouserdrag", KEY_MOUSE_RDRAG }, + { "mouserdragstart", KEY_MOUSE_RDRAG_START }, + { "mouserdragend", KEY_MOUSE_RDRAG_END } }; static const ActionMapping touchcommands[] = diff --git a/xbmc/input/MouseStat.cpp b/xbmc/input/MouseStat.cpp index a8143c913d..8167741a38 100644 --- a/xbmc/input/MouseStat.cpp +++ b/xbmc/input/MouseStat.cpp @@ -129,9 +129,15 @@ void CMouseStat::HandleEvent(XBMC_Event& newEvent) bNothingDown = false; break; case CButtonState::MB_DRAG_START: + bHold[i] = CButtonState::MB_DRAG_START; + bNothingDown = false; + break; case CButtonState::MB_DRAG: + bHold[i] = CButtonState::MB_DRAG; + bNothingDown = false; + break; case CButtonState::MB_DRAG_END: - bHold[i] = action - CButtonState::MB_DRAG_START + 1; + bHold[i] = CButtonState::MB_DRAG_END; bNothingDown = false; break; default: @@ -163,9 +169,37 @@ void CMouseStat::HandleEvent(XBMC_Event& newEvent) if (m_Key == KEY_MOUSE_NOOP) { - // The bHold array is set true if CButtonState::Update spots a mouse drag - if (bHold[MOUSE_LEFT_BUTTON]) - m_Key = KEY_MOUSE_DRAG; + // The bHold array is set to the drag action + if (bHold[MOUSE_LEFT_BUTTON] != 0) + { + switch (bHold[MOUSE_LEFT_BUTTON]) + { + case CButtonState::MB_DRAG: + m_Key = KEY_MOUSE_DRAG; + break; + case CButtonState::MB_DRAG_START: + m_Key = KEY_MOUSE_DRAG_START; + break; + case CButtonState::MB_DRAG_END: + m_Key = KEY_MOUSE_DRAG_END; + break; + } + } + else if (bHold[MOUSE_RIGHT_BUTTON] != 0) + { + switch (bHold[MOUSE_RIGHT_BUTTON]) + { + case CButtonState::MB_DRAG: + m_Key = KEY_MOUSE_RDRAG; + break; + case CButtonState::MB_DRAG_START: + m_Key = KEY_MOUSE_RDRAG_START; + break; + case CButtonState::MB_DRAG_END: + m_Key = KEY_MOUSE_RDRAG_END; + break; + } + } // dz is +1 on wheel up and -1 on wheel down else if (m_mouseState.dz > 0) diff --git a/xbmc/interfaces/Builtins.cpp b/xbmc/interfaces/Builtins.cpp index d99f047b2c..339272d441 100644 --- a/xbmc/interfaces/Builtins.cpp +++ b/xbmc/interfaces/Builtins.cpp @@ -96,6 +96,7 @@ #include <vector> #include "settings/AdvancedSettings.h" #include "settings/DisplaySettings.h" +#include "powermanagement/PowerManager.h" using namespace std; using namespace XFILE; @@ -244,6 +245,39 @@ bool CBuiltins::HasCommand(const std::string& execString) return false; } +bool CBuiltins::IsSystemPowerdownCommand(const std::string& execString) +{ + std::string execute; + vector<string> params; + CUtil::SplitExecFunction(execString, execute, params); + StringUtils::ToLower(execute); + + // Check if action is resulting in system powerdown. + if (execute == "reboot" || + execute == "restart" || + execute == "reset" || + execute == "powerdown" || + execute == "hibernate" || + execute == "suspend" ) + { + return true; + } + else if (execute == "shutdown") + { + switch (CSettings::Get().GetInt("powermanagement.shutdownstate")) + { + case POWERSTATE_SHUTDOWN: + case POWERSTATE_SUSPEND: + case POWERSTATE_HIBERNATE: + return true; + + default: + return false; + } + } + return false; +} + void CBuiltins::GetHelp(std::string &help) { help.clear(); @@ -1285,6 +1319,19 @@ int CBuiltins::Execute(const std::string& execString) } else if (execute == "skin.setimage") { + if (params.size() > 2) + { + value = params[2]; + URIUtils::AddSlashAtEnd(value); + bool bIsSource; + if (CUtil::GetMatchingSource(value,localShares,bIsSource) < 0) // path is outside shares - add it as a separate one + { + CMediaSource share; + share.strName = g_localizeStrings.Get(13278); + share.strPath = value; + localShares.push_back(share); + } + } if (CGUIDialogFileBrowser::ShowAndGetImage(localShares, g_localizeStrings.Get(1030), value)) CSkinSettings::Get().SetString(string, value); } diff --git a/xbmc/interfaces/Builtins.h b/xbmc/interfaces/Builtins.h index e30385c68c..9488c02f63 100644 --- a/xbmc/interfaces/Builtins.h +++ b/xbmc/interfaces/Builtins.h @@ -26,6 +26,7 @@ class CBuiltins { public: static bool HasCommand(const std::string& execString); + static bool IsSystemPowerdownCommand(const std::string& execString); static void GetHelp(std::string &help); static int Execute(const std::string& execString); }; diff --git a/xbmc/interfaces/info/SkinVariable.h b/xbmc/interfaces/info/SkinVariable.h index 0fa6c53a43..d101c2325f 100644 --- a/xbmc/interfaces/info/SkinVariable.h +++ b/xbmc/interfaces/info/SkinVariable.h @@ -19,7 +19,8 @@ * */ -#include "utils/StdString.h" +#include <string> +#include <vector> #include "guilib/GUIInfoTypes.h" #include "interfaces/info/InfoBool.h" diff --git a/xbmc/interfaces/json-rpc/FileItemHandler.cpp b/xbmc/interfaces/json-rpc/FileItemHandler.cpp index 60fe6256ac..3066bf00e3 100644 --- a/xbmc/interfaces/json-rpc/FileItemHandler.cpp +++ b/xbmc/interfaces/json-rpc/FileItemHandler.cpp @@ -357,7 +357,7 @@ void CFileItemHandler::HandleFileItem(const char *ID, bool allowFile, const char if (item->HasPVRChannelInfoTag()) FillDetails(item->GetPVRChannelInfoTag(), item, fields, object, thumbLoader); if (item->HasEPGInfoTag()) - FillDetails(item->GetEPGInfoTag(), item, fields, object, thumbLoader); + FillDetails(item->GetEPGInfoTag().get(), item, fields, object, thumbLoader); if (item->HasPVRRecordingInfoTag()) FillDetails(item->GetPVRRecordingInfoTag(), item, fields, object, thumbLoader); if (item->HasPVRTimerInfoTag()) diff --git a/xbmc/interfaces/json-rpc/GUIOperations.cpp b/xbmc/interfaces/json-rpc/GUIOperations.cpp index 33bd50510b..d213c8d454 100644 --- a/xbmc/interfaces/json-rpc/GUIOperations.cpp +++ b/xbmc/interfaces/json-rpc/GUIOperations.cpp @@ -137,7 +137,7 @@ JSONRPC_STATUS CGUIOperations::GetPropertyValue(const std::string &property, CVa result["label"] = g_infoManager.GetLabel(g_infoManager.TranslateString("System.CurrentControl")); else if (property == "skin") { - CStdString skinId = CSettings::Get().GetString("lookandfeel.skin"); + std::string skinId = CSettings::Get().GetString("lookandfeel.skin"); AddonPtr addon; CAddonMgr::Get().GetAddon(skinId, addon, ADDON_SKIN); diff --git a/xbmc/interfaces/json-rpc/PlayerOperations.cpp b/xbmc/interfaces/json-rpc/PlayerOperations.cpp index 4cbdc24bc6..dc84202b4d 100644 --- a/xbmc/interfaces/json-rpc/PlayerOperations.cpp +++ b/xbmc/interfaces/json-rpc/PlayerOperations.cpp @@ -1203,9 +1203,9 @@ JSONRPC_STATUS CPlayerOperations::GetPropertyValue(PlayerType player, const std: ms = (int)(g_application.GetTime() * 1000.0); else { - EPG::CEpgInfoTag epg; - if (GetCurrentEpg(epg)) - ms = epg.Progress() * 1000; + EPG::CEpgInfoTagPtr epg(GetCurrentEpg()); + if (epg) + ms = epg->Progress() * 1000; } MillisecondsToTimeObject(ms, result); @@ -1232,9 +1232,9 @@ JSONRPC_STATUS CPlayerOperations::GetPropertyValue(PlayerType player, const std: result = g_application.GetPercentage(); else { - EPG::CEpgInfoTag epg; - if (GetCurrentEpg(epg)) - result = epg.ProgressPercentage(); + EPG::CEpgInfoTagPtr epg(GetCurrentEpg()); + if (epg) + result = epg->ProgressPercentage(); else result = 0; } @@ -1265,9 +1265,9 @@ JSONRPC_STATUS CPlayerOperations::GetPropertyValue(PlayerType player, const std: ms = (int)(g_application.GetTotalTime() * 1000.0); else { - EPG::CEpgInfoTag epg; - if (GetCurrentEpg(epg)) - ms = epg.GetDuration() * 1000; + EPG::CEpgInfoTagPtr epg(GetCurrentEpg()); + if (epg) + ms = epg->GetDuration() * 1000; } MillisecondsToTimeObject(ms, result); @@ -1661,17 +1661,14 @@ bool CPlayerOperations::IsPVRChannel() return g_PVRManager.IsPlayingTV() || g_PVRManager.IsPlayingRadio(); } -bool CPlayerOperations::GetCurrentEpg(EPG::CEpgInfoTag &epg) +EPG::CEpgInfoTagPtr CPlayerOperations::GetCurrentEpg() { if (!g_PVRManager.IsPlayingTV() && !g_PVRManager.IsPlayingRadio()) - return false; + return EPG::CEpgInfoTagPtr(); CPVRChannelPtr currentChannel; if (!g_PVRManager.GetCurrentChannel(currentChannel)) - return false; + return EPG::CEpgInfoTagPtr(); - if (!currentChannel->GetEPGNow(epg)) - return false; - - return true; + return currentChannel->GetEPGNow(); } diff --git a/xbmc/interfaces/json-rpc/PlayerOperations.h b/xbmc/interfaces/json-rpc/PlayerOperations.h index fc804e8d66..b2c9274287 100644 --- a/xbmc/interfaces/json-rpc/PlayerOperations.h +++ b/xbmc/interfaces/json-rpc/PlayerOperations.h @@ -25,6 +25,7 @@ namespace EPG { class CEpgInfoTag; + typedef boost::shared_ptr<EPG::CEpgInfoTag> CEpgInfoTagPtr; } namespace JSONRPC @@ -76,6 +77,6 @@ namespace JSONRPC static int ParseRepeatState(const CVariant &repeat); static double ParseTimeInSeconds(const CVariant &time); static bool IsPVRChannel(); - static bool GetCurrentEpg(EPG::CEpgInfoTag &epg); + static EPG::CEpgInfoTagPtr GetCurrentEpg(); }; } diff --git a/xbmc/interfaces/python/AddonPythonInvoker.h b/xbmc/interfaces/python/AddonPythonInvoker.h index 8517981d12..452d4118d0 100644 --- a/xbmc/interfaces/python/AddonPythonInvoker.h +++ b/xbmc/interfaces/python/AddonPythonInvoker.h @@ -24,7 +24,7 @@ class CAddonPythonInvoker : public CPythonInvoker { public: - CAddonPythonInvoker(ILanguageInvocationHandler *invocationHandler); + explicit CAddonPythonInvoker(ILanguageInvocationHandler *invocationHandler); virtual ~CAddonPythonInvoker(); protected: diff --git a/xbmc/interfaces/python/PythonInvoker.h b/xbmc/interfaces/python/PythonInvoker.h index 8b22826064..1f64cd8c6b 100644 --- a/xbmc/interfaces/python/PythonInvoker.h +++ b/xbmc/interfaces/python/PythonInvoker.h @@ -29,7 +29,7 @@ class CPythonInvoker : public ILanguageInvoker { public: - CPythonInvoker(ILanguageInvocationHandler *invocationHandler); + explicit CPythonInvoker(ILanguageInvocationHandler *invocationHandler); virtual ~CPythonInvoker(); virtual bool Execute(const std::string &script, const std::vector<std::string> &arguments = std::vector<std::string>()); diff --git a/xbmc/main/osx/SDLMain.mm b/xbmc/main/osx/SDLMain.mm index 853c5684a6..81260340ac 100644 --- a/xbmc/main/osx/SDLMain.mm +++ b/xbmc/main/osx/SDLMain.mm @@ -19,7 +19,6 @@ //hack around problem with xbmc's typedef int BOOL // and obj-c's typedef unsigned char BOOL #define BOOL XBMC_BOOL -#import "utils/StdString.h" #import "PlatformDefs.h" #import "ApplicationMessenger.h" #import "storage/osx/DarwinStorageProvider.h" diff --git a/xbmc/music/Album.cpp b/xbmc/music/Album.cpp index e5ceccc385..0307d91f45 100644 --- a/xbmc/music/Album.cpp +++ b/xbmc/music/Album.cpp @@ -42,8 +42,8 @@ CAlbum::CAlbum(const CFileItem& item) { // have musicbrainz artist info, so use it for (size_t i = 0; i < tag.GetMusicBrainzAlbumArtistID().size(); i++) { - CStdString artistId = tag.GetMusicBrainzAlbumArtistID()[i]; - CStdString artistName; + std::string artistId = tag.GetMusicBrainzAlbumArtistID()[i]; + std::string artistName; /* We try and get the corresponding artist name from the album artist tag. We match on the same index, and if that fails just use the first name we have. @@ -62,7 +62,7 @@ CAlbum::CAlbum(const CFileItem& item) } if (artistName.empty()) artistName = artistId; - CStdString strJoinPhrase = (i == tag.GetMusicBrainzAlbumArtistID().size()-1) ? "" : g_advancedSettings.m_musicItemSeparator; + std::string strJoinPhrase = (i == tag.GetMusicBrainzAlbumArtistID().size()-1) ? "" : g_advancedSettings.m_musicItemSeparator; CArtistCredit artistCredit(artistName, tag.GetMusicBrainzAlbumArtistID()[i], strJoinPhrase); artistCredits.push_back(artistCredit); } @@ -71,7 +71,7 @@ CAlbum::CAlbum(const CFileItem& item) { // no musicbrainz info, so fill in directly for (vector<string>::const_iterator it = tag.GetAlbumArtist().begin(); it != tag.GetAlbumArtist().end(); ++it) { - CStdString strJoinPhrase = (it == --tag.GetAlbumArtist().end() ? "" : g_advancedSettings.m_musicItemSeparator); + std::string strJoinPhrase = (it == --tag.GetAlbumArtist().end() ? "" : g_advancedSettings.m_musicItemSeparator); CArtistCredit artistCredit(*it, "", strJoinPhrase); artistCredits.push_back(artistCredit); } @@ -135,12 +135,12 @@ void CAlbum::MergeScrapedAlbum(const CAlbum& source, bool override /* = true */) infoSongs = source.infoSongs; } -CStdString CAlbum::GetArtistString() const +std::string CAlbum::GetArtistString() const { return StringUtils::Join(artist, g_advancedSettings.m_musicItemSeparator); } -CStdString CAlbum::GetGenreString() const +std::string CAlbum::GetGenreString() const { return StringUtils::Join(genre, g_advancedSettings.m_musicItemSeparator); } @@ -199,14 +199,14 @@ bool CAlbum::Load(const TiXmlElement *album, bool append, bool prioritise) } size_t iThumbCount = thumbURL.m_url.size(); - CStdString xmlAdd = thumbURL.m_xml; + std::string xmlAdd = thumbURL.m_xml; const TiXmlElement* thumb = album->FirstChildElement("thumb"); while (thumb) { thumbURL.ParseElement(thumb); if (prioritise) { - CStdString temp; + std::string temp; temp << *thumb; xmlAdd = temp+xmlAdd; } @@ -247,8 +247,8 @@ bool CAlbum::Load(const TiXmlElement *album, bool append, bool prioritise) { for (vector<string>::const_iterator it = artist.begin(); it != artist.end(); ++it) { - CArtistCredit artistCredit(*it, StringUtils::EmptyString, - it == --artist.end() ? StringUtils::EmptyString : g_advancedSettings.m_musicItemSeparator); + CArtistCredit artistCredit(*it, "", + it == --artist.end() ? "" : g_advancedSettings.m_musicItemSeparator); artistCredits.push_back(artistCredit); } } @@ -290,7 +290,7 @@ bool CAlbum::Load(const TiXmlElement *album, bool append, bool prioritise) bIncrement = true; XMLUtils::GetString(node,"title",song.strTitle); - CStdString strDur; + std::string strDur; XMLUtils::GetString(node,"duration",strDur); song.iDuration = StringUtils::TimeStringToSeconds(strDur); @@ -305,7 +305,7 @@ bool CAlbum::Load(const TiXmlElement *album, bool append, bool prioritise) return true; } -bool CAlbum::Save(TiXmlNode *node, const CStdString &tag, const CStdString& strPath) +bool CAlbum::Save(TiXmlNode *node, const std::string &tag, const std::string& strPath) { if (!node) return false; diff --git a/xbmc/music/Album.h b/xbmc/music/Album.h index 116aa08841..4b85b13ce2 100644 --- a/xbmc/music/Album.h +++ b/xbmc/music/Album.h @@ -66,8 +66,8 @@ public: infoSongs.clear(); } - CStdString GetArtistString() const; - CStdString GetGenreString() const; + std::string GetArtistString() const; + std::string GetGenreString() const; /*! \brief Load album information from an XML file. See CVideoInfoTag::Load for a description of the types of elements we load. @@ -77,11 +77,11 @@ public: \sa CVideoInfoTag::Load */ bool Load(const TiXmlElement *element, bool append = false, bool prioritise = false); - bool Save(TiXmlNode *node, const CStdString &tag, const CStdString& strPath); + bool Save(TiXmlNode *node, const std::string &tag, const std::string& strPath); long idAlbum; - CStdString strAlbum; - CStdString strMusicBrainzAlbumID; + std::string strAlbum; + std::string strMusicBrainzAlbumID; std::vector<std::string> artist; VECARTISTCREDITS artistCredits; std::vector<std::string> genre; @@ -90,11 +90,11 @@ public: std::vector<std::string> styles; std::vector<std::string> themes; std::map<std::string, std::string> art; - CStdString strReview; - CStdString strLabel; - CStdString strType; - CStdString strPath; - CStdString m_strDateOfRelease; + std::string strReview; + std::string strLabel; + std::string strType; + std::string strPath; + std::string m_strDateOfRelease; int iRating; int iYear; bool bCompilation; diff --git a/xbmc/music/Artist.cpp b/xbmc/music/Artist.cpp index ac076248fe..89c5dc9932 100644 --- a/xbmc/music/Artist.cpp +++ b/xbmc/music/Artist.cpp @@ -74,7 +74,7 @@ bool CArtist::Load(const TiXmlElement *artist, bool append, bool prioritise) XMLUtils::GetString(artist, "disbanded", strDisbanded); size_t iThumbCount = thumbURL.m_url.size(); - CStdString xmlAdd = thumbURL.m_xml; + std::string xmlAdd = thumbURL.m_xml; const TiXmlElement* thumb = artist->FirstChildElement("thumb"); while (thumb) @@ -82,7 +82,7 @@ bool CArtist::Load(const TiXmlElement *artist, bool append, bool prioritise) thumbURL.ParseElement(thumb); if (prioritise) { - CStdString temp; + std::string temp; temp << *thumb; xmlAdd = temp+xmlAdd; } @@ -102,8 +102,8 @@ bool CArtist::Load(const TiXmlElement *artist, bool append, bool prioritise) const TiXmlNode* title = node->FirstChild("title"); if (title && title->FirstChild()) { - CStdString strTitle = title->FirstChild()->Value(); - CStdString strYear; + std::string strTitle = title->FirstChild()->Value(); + std::string strYear; const TiXmlNode* year = node->FirstChild("year"); if (year && year->FirstChild()) strYear = year->FirstChild()->Value(); @@ -131,7 +131,7 @@ bool CArtist::Load(const TiXmlElement *artist, bool append, bool prioritise) return true; } -bool CArtist::Save(TiXmlNode *node, const CStdString &tag, const CStdString& strPath) +bool CArtist::Save(TiXmlNode *node, const std::string &tag, const std::string& strPath) { if (!node) return false; @@ -173,7 +173,7 @@ bool CArtist::Save(TiXmlNode *node, const CStdString &tag, const CStdString& str } // albums - for (vector< pair<CStdString,CStdString> >::const_iterator it = discography.begin(); it != discography.end(); ++it) + for (vector< pair<std::string,std::string> >::const_iterator it = discography.begin(); it != discography.end(); ++it) { // add a <album> tag TiXmlElement cast("album"); diff --git a/xbmc/music/Artist.h b/xbmc/music/Artist.h index b7535b77e0..824ca6fb7c 100644 --- a/xbmc/music/Artist.h +++ b/xbmc/music/Artist.h @@ -21,11 +21,11 @@ */ #include <map> +#include <string> #include <vector> #include "utils/ScraperUrl.h" #include "utils/Fanart.h" -#include "utils/StdString.h" class TiXmlNode; class CAlbum; @@ -78,24 +78,24 @@ public: \sa CVideoInfoTag::Load */ bool Load(const TiXmlElement *element, bool append = false, bool prioritise = false); - bool Save(TiXmlNode *node, const CStdString &tag, const CStdString& strPath); + bool Save(TiXmlNode *node, const std::string &tag, const std::string& strPath); - CStdString strArtist; - CStdString strMusicBrainzArtistID; + std::string strArtist; + std::string strMusicBrainzArtistID; std::vector<std::string> genre; - CStdString strBiography; + std::string strBiography; std::vector<std::string> styles; std::vector<std::string> moods; std::vector<std::string> instruments; - CStdString strBorn; - CStdString strFormed; - CStdString strDied; - CStdString strDisbanded; + std::string strBorn; + std::string strFormed; + std::string strDied; + std::string strDisbanded; std::vector<std::string> yearsActive; - CStdString strPath; + std::string strPath; CScraperUrl thumbURL; CFanart fanart; - std::vector<std::pair<CStdString,CStdString> > discography; + std::vector<std::pair<std::string,std::string> > discography; }; class CArtistCredit diff --git a/xbmc/music/GUIViewStateMusic.cpp b/xbmc/music/GUIViewStateMusic.cpp index 51406c7150..4d25e496e1 100644 --- a/xbmc/music/GUIViewStateMusic.cpp +++ b/xbmc/music/GUIViewStateMusic.cpp @@ -87,7 +87,7 @@ CGUIViewStateMusicSearch::CGUIViewStateMusicSearch(const CFileItemList& items) : sortAttribute = SortAttributeIgnoreArticle; AddSortMethod(SortByTitle, sortAttribute, 556, LABEL_MASKS("%T - %A", "%D", "%L", "%A")); // Title, Artist, Duration| empty, empty - SetSortMethod(SortByTitle, sortAttribute); + SetSortMethod(SortByTitle); const CViewState *viewState = CViewStateSettings::Get().Get("musicnavsongs"); SetViewAsControl(viewState->m_viewMode); @@ -172,7 +172,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item case NODE_TYPE_ARTIST: { AddSortMethod(SortByArtist, sortAttribute, 557, LABEL_MASKS("%F", "", "%A", "")); // Filename, empty | Artist, empty - SetSortMethod(SortByArtist, sortAttribute); + SetSortMethod(SortByArtist); const CViewState *viewState = CViewStateSettings::Get().Get("musicnavartists"); SetViewAsControl(viewState->m_viewMode); @@ -277,7 +277,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item // the "All Albums" entries always default to SortByAlbum as this is most logical - user can always // change it and the change will be saved for this particular path if (dir.IsAllItem(items.GetPath())) - SetSortMethod(SortByAlbum, sortAttribute); + SetSortMethod(SortByAlbum); else SetSortMethod(viewState->m_sortDescription); @@ -560,7 +560,7 @@ CGUIViewStateWindowMusicSongs::CGUIViewStateWindowMusicSongs(const CFileItemList else if (items.GetPath() == "special://musicplaylists/") { // playlists list sorts by label only, ignoring folders AddSortMethod(SortByLabel, SortAttributeIgnoreFolders, 551, LABEL_MASKS("%F", "%D", "%L", "")); // Filename, Duration | Foldername, empty - SetSortMethod(SortByLabel, SortAttributeIgnoreFolders); + SetSortMethod(SortByLabel); } else { diff --git a/xbmc/music/MusicDatabase.cpp b/xbmc/music/MusicDatabase.cpp index ea3ac5a0bc..3b7426ea07 100644 --- a/xbmc/music/MusicDatabase.cpp +++ b/xbmc/music/MusicDatabase.cpp @@ -341,7 +341,7 @@ void CMusicDatabase::CreateViews() int CMusicDatabase::AddAlbumInfoSong(int idAlbum, const CSong& song) { - CStdString strSQL = PrepareSQL("SELECT idAlbumInfoSong FROM albuminfosong WHERE idAlbumInfo = %i and iTrack = %i", idAlbum, song.iTrack); + std::string strSQL = PrepareSQL("SELECT idAlbumInfoSong FROM albuminfosong WHERE idAlbumInfo = %i and iTrack = %i", idAlbum, song.iTrack); int idAlbumInfoSong = (int)strtol(GetSingleValue(strSQL).c_str(), NULL, 10); if (idAlbumInfoSong > 0) { @@ -500,15 +500,15 @@ bool CMusicDatabase::UpdateAlbum(CAlbum& album) } int CMusicDatabase::AddSong(const int idAlbum, - const CStdString& strTitle, const CStdString& strMusicBrainzTrackID, - const CStdString& strPathAndFileName, const CStdString& strComment, const CStdString& strThumb, + const std::string& strTitle, const std::string& strMusicBrainzTrackID, + const std::string& strPathAndFileName, const std::string& strComment, const std::string& strThumb, const std::string &artistString, const std::vector<std::string>& genres, int iTrack, int iDuration, int iYear, const int iTimesPlayed, int iStartOffset, int iEndOffset, const CDateTime& dtLastPlayed, char rating, int iKaraokeNumber) { int idSong = -1; - CStdString strSQL; + std::string strSQL; try { // We need at least the title @@ -518,7 +518,7 @@ int CMusicDatabase::AddSong(const int idAlbum, if (NULL == m_pDB.get()) return -1; if (NULL == m_pDS.get()) return -1; - CStdString strPath, strFileName; + std::string strPath, strFileName; URIUtils::Split(strPathAndFileName, strPath, strFileName); int idPath = AddPath(strPath); @@ -615,7 +615,7 @@ bool CMusicDatabase::GetSong(int idSong, CSong& song) if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL=PrepareSQL("SELECT songview.*,songartistview.* FROM songview " + std::string strSQL=PrepareSQL("SELECT songview.*,songartistview.* FROM songview " " LEFT JOIN songartistview ON songview.idSong = songartistview.idSong " " WHERE songview.idSong = %i", idSong); @@ -677,8 +677,8 @@ int CMusicDatabase::UpdateSong(int idSong, const CSong &song) } int CMusicDatabase::UpdateSong(int idSong, - const CStdString& strTitle, const CStdString& strMusicBrainzTrackID, - const CStdString& strPathAndFileName, const CStdString& strComment, const CStdString& strThumb, + const std::string& strTitle, const std::string& strMusicBrainzTrackID, + const std::string& strPathAndFileName, const std::string& strComment, const std::string& strThumb, const std::string& artistString, const std::vector<std::string>& genres, int iTrack, int iDuration, int iYear, int iTimesPlayed, int iStartOffset, int iEndOffset, @@ -687,8 +687,8 @@ int CMusicDatabase::UpdateSong(int idSong, if (idSong < 0) return -1; - CStdString strSQL; - CStdString strPath, strFileName; + std::string strSQL; + std::string strPath, strFileName; URIUtils::Split(strPathAndFileName, strPath, strFileName); int idPath = AddPath(strPath); @@ -718,10 +718,10 @@ int CMusicDatabase::UpdateSong(int idSong, return idSong; } -int CMusicDatabase::AddAlbum(const CStdString& strAlbum, const CStdString& strMusicBrainzAlbumID, - const CStdString& strArtist, const CStdString& strGenre, int year, bool bCompilation) +int CMusicDatabase::AddAlbum(const std::string& strAlbum, const std::string& strMusicBrainzAlbumID, + const std::string& strArtist, const std::string& strGenre, int year, bool bCompilation) { - CStdString strSQL; + std::string strSQL; try { if (NULL == m_pDB.get()) return -1; @@ -801,18 +801,18 @@ int CMusicDatabase::AddAlbum(const CStdString& strAlbum, const CStdString& strMu } int CMusicDatabase::UpdateAlbum(int idAlbum, - const CStdString& strAlbum, const CStdString& strMusicBrainzAlbumID, - const CStdString& strArtist, const CStdString& strGenre, - const CStdString& strMoods, const CStdString& strStyles, - const CStdString& strThemes, const CStdString& strReview, - const CStdString& strImage, const CStdString& strLabel, - const CStdString& strType, + const std::string& strAlbum, const std::string& strMusicBrainzAlbumID, + const std::string& strArtist, const std::string& strGenre, + const std::string& strMoods, const std::string& strStyles, + const std::string& strThemes, const std::string& strReview, + const std::string& strImage, const std::string& strLabel, + const std::string& strType, int iRating, int iYear, bool bCompilation) { if (idAlbum < 0) return -1; - CStdString strSQL; + std::string strSQL; strSQL = PrepareSQL("UPDATE album SET " " strAlbum = '%s', strArtists = '%s', strGenres = '%s', " " strMoods = '%s', strStyles = '%s', strThemes = '%s', " @@ -848,7 +848,7 @@ bool CMusicDatabase::GetAlbum(int idAlbum, CAlbum& album, bool getSongs /* = tru if (idAlbum == -1) return false; // not in the database - CStdString sql; + std::string sql; if (getSongs) { sql = PrepareSQL("SELECT albumview.*,albumartistview.*,songview.*,songartistview.*,albuminfosong.* " @@ -944,22 +944,22 @@ bool CMusicDatabase::GetAlbum(int idAlbum, CAlbum& album, bool getSongs /* = tru bool CMusicDatabase::ClearAlbumLastScrapedTime(int idAlbum) { - CStdString strSQL = PrepareSQL("UPDATE album SET lastScraped = NULL WHERE idAlbum = %i", idAlbum); + std::string strSQL = PrepareSQL("UPDATE album SET lastScraped = NULL WHERE idAlbum = %i", idAlbum); return ExecuteQuery(strSQL); } bool CMusicDatabase::HasAlbumBeenScraped(int idAlbum) { - CStdString strSQL = PrepareSQL("SELECT idAlbum FROM album WHERE idAlbum = %i AND lastScraped IS NULL", idAlbum); + std::string strSQL = PrepareSQL("SELECT idAlbum FROM album WHERE idAlbum = %i AND lastScraped IS NULL", idAlbum); return GetSingleValue(strSQL).empty(); } -int CMusicDatabase::AddGenre(const CStdString& strGenre1) +int CMusicDatabase::AddGenre(const std::string& strGenre1) { - CStdString strSQL; + std::string strSQL; try { - CStdString strGenre = strGenre1; + std::string strGenre = strGenre1; StringUtils::Trim(strGenre); if (strGenre.empty()) @@ -967,7 +967,7 @@ int CMusicDatabase::AddGenre(const CStdString& strGenre1) if (NULL == m_pDB.get()) return -1; if (NULL == m_pDS.get()) return -1; - map <CStdString, int>::const_iterator it; + map <std::string, int>::const_iterator it; it = m_genreCache.find(strGenre); if (it != m_genreCache.end()) @@ -984,13 +984,13 @@ int CMusicDatabase::AddGenre(const CStdString& strGenre1) m_pDS->exec(strSQL.c_str()); int idGenre = (int)m_pDS->lastinsertid(); - m_genreCache.insert(pair<CStdString, int>(strGenre1, idGenre)); + m_genreCache.insert(pair<std::string, int>(strGenre1, idGenre)); return idGenre; } else { int idGenre = m_pDS->fv("idGenre").get_asInt(); - m_genreCache.insert(pair<CStdString, int>(strGenre1, idGenre)); + m_genreCache.insert(pair<std::string, int>(strGenre1, idGenre)); m_pDS->close(); return idGenre; } @@ -1019,9 +1019,8 @@ bool CMusicDatabase::UpdateArtist(const CArtist& artist) artist.fanart.m_xml.c_str()); DeleteArtistDiscography(artist.idArtist); - for (std::vector<std::pair<CStdString,CStdString> >::const_iterator disc = artist.discography.begin(); - disc != artist.discography.end(); - ++disc) + std::vector<std::pair<std::string,std::string> >::const_iterator disc; + for (disc = artist.discography.begin(); disc != artist.discography.end(); ++disc) { AddArtistDiscography(artist.idArtist, disc->first, disc->second); } @@ -1029,9 +1028,9 @@ bool CMusicDatabase::UpdateArtist(const CArtist& artist) return true; } -int CMusicDatabase::AddArtist(const CStdString& strArtist, const CStdString& strMusicBrainzArtistID) +int CMusicDatabase::AddArtist(const std::string& strArtist, const std::string& strMusicBrainzArtistID) { - CStdString strSQL; + std::string strSQL; try { if (NULL == m_pDB.get()) return -1; @@ -1111,20 +1110,20 @@ int CMusicDatabase::AddArtist(const CStdString& strArtist, const CStdString& str } int CMusicDatabase::UpdateArtist(int idArtist, - const CStdString& strArtist, const CStdString& strMusicBrainzArtistID, - const CStdString& strBorn, const CStdString& strFormed, - const CStdString& strGenres, const CStdString& strMoods, - const CStdString& strStyles, const CStdString& strInstruments, - const CStdString& strBiography, const CStdString& strDied, - const CStdString& strDisbanded, const CStdString& strYearsActive, - const CStdString& strImage, const CStdString& strFanart) + const std::string& strArtist, const std::string& strMusicBrainzArtistID, + const std::string& strBorn, const std::string& strFormed, + const std::string& strGenres, const std::string& strMoods, + const std::string& strStyles, const std::string& strInstruments, + const std::string& strBiography, const std::string& strDied, + const std::string& strDisbanded, const std::string& strYearsActive, + const std::string& strImage, const std::string& strFanart) { CScraperUrl thumbURL; CFanart fanart; if (idArtist < 0) return -1; - CStdString strSQL; + std::string strSQL; strSQL = PrepareSQL("UPDATE artist SET " " strArtist = '%s', " " strBorn = '%s', strFormed = '%s', strGenres = '%s', " @@ -1161,7 +1160,7 @@ bool CMusicDatabase::GetArtist(int idArtist, CArtist &artist, bool fetchAll /* = if (idArtist == -1) return false; // not in the database - CStdString strSQL; + std::string strSQL; if (fetchAll) strSQL = PrepareSQL("SELECT * FROM artistview LEFT JOIN discography ON artistview.idArtist = discography.idArtist WHERE artistview.idArtist = %i", idArtist); else @@ -1201,19 +1200,19 @@ bool CMusicDatabase::GetArtist(int idArtist, CArtist &artist, bool fetchAll /* = bool CMusicDatabase::HasArtistBeenScraped(int idArtist) { - CStdString strSQL = PrepareSQL("SELECT idArtist FROM artist WHERE idArtist = %i AND lastScraped IS NULL", idArtist); + std::string strSQL = PrepareSQL("SELECT idArtist FROM artist WHERE idArtist = %i AND lastScraped IS NULL", idArtist); return GetSingleValue(strSQL).empty(); } bool CMusicDatabase::ClearArtistLastScrapedTime(int idArtist) { - CStdString strSQL = PrepareSQL("UPDATE artist SET lastScraped = NULL WHERE idArtist = %i", idArtist); + std::string strSQL = PrepareSQL("UPDATE artist SET lastScraped = NULL WHERE idArtist = %i", idArtist); return ExecuteQuery(strSQL); } -int CMusicDatabase::AddArtistDiscography(int idArtist, const CStdString& strAlbum, const CStdString& strYear) +int CMusicDatabase::AddArtistDiscography(int idArtist, const std::string& strAlbum, const std::string& strYear) { - CStdString strSQL=PrepareSQL("INSERT INTO discography (idArtist, strAlbum, strYear) values(%i, '%s', '%s')", + std::string strSQL=PrepareSQL("INSERT INTO discography (idArtist, strAlbum, strYear) values(%i, '%s', '%s')", idArtist, strAlbum.c_str(), strYear.c_str()); @@ -1222,13 +1221,13 @@ int CMusicDatabase::AddArtistDiscography(int idArtist, const CStdString& strAlbu bool CMusicDatabase::DeleteArtistDiscography(int idArtist) { - CStdString strSQL = PrepareSQL("DELETE FROM discography WHERE idArtist = %i", idArtist); + std::string strSQL = PrepareSQL("DELETE FROM discography WHERE idArtist = %i", idArtist); return ExecuteQuery(strSQL); } bool CMusicDatabase::AddSongArtist(int idArtist, int idSong, std::string strArtist, std::string joinPhrase, bool featured, int iOrder) { - CStdString strSQL; + std::string strSQL; strSQL=PrepareSQL("replace into song_artist (idArtist, idSong, strArtist, strJoinPhrase, boolFeatured, iOrder) values(%i,%i,'%s','%s',%i,%i)", idArtist, idSong, strArtist.c_str(), joinPhrase.c_str(), featured == true ? 1 : 0, iOrder); return ExecuteQuery(strSQL); @@ -1241,7 +1240,7 @@ bool CMusicDatabase::DeleteSongArtistsBySong(int idSong) bool CMusicDatabase::AddAlbumArtist(int idArtist, int idAlbum, std::string strArtist, std::string joinPhrase, bool featured, int iOrder) { - CStdString strSQL; + std::string strSQL; strSQL=PrepareSQL("replace into album_artist (idArtist, idAlbum, strArtist, strJoinPhrase, boolFeatured, iOrder) values(%i,%i,'%s','%s',%i,%i)", idArtist, idAlbum, strArtist.c_str(), joinPhrase.c_str(), featured == true ? 1 : 0, iOrder); return ExecuteQuery(strSQL); @@ -1257,7 +1256,7 @@ bool CMusicDatabase::AddSongGenre(int idGenre, int idSong, int iOrder) if (idGenre == -1 || idSong == -1) return true; - CStdString strSQL; + std::string strSQL; strSQL=PrepareSQL("replace into song_genre (idGenre, idSong, iOrder) values(%i,%i,%i)", idGenre, idSong, iOrder); return ExecuteQuery(strSQL); @@ -1273,7 +1272,7 @@ bool CMusicDatabase::AddAlbumGenre(int idGenre, int idAlbum, int iOrder) if (idGenre == -1 || idAlbum == -1) return true; - CStdString strSQL; + std::string strSQL; strSQL=PrepareSQL("replace into album_genre (idGenre, idAlbum, iOrder) values(%i,%i,%i)", idGenre, idAlbum, iOrder); return ExecuteQuery(strSQL); @@ -1288,7 +1287,7 @@ bool CMusicDatabase::GetAlbumsByArtist(int idArtist, bool includeFeatured, std:: { try { - CStdString strSQL, strPrepSQL; + std::string strSQL, strPrepSQL; strPrepSQL = "select idAlbum from album_artist where idArtist=%i"; if (includeFeatured == false) @@ -1322,7 +1321,7 @@ bool CMusicDatabase::GetArtistsByAlbum(int idAlbum, bool includeFeatured, std::v { try { - CStdString strSQL, strPrepSQL; + std::string strSQL, strPrepSQL; strPrepSQL = "select idArtist from album_artist where idAlbum=%i"; if (includeFeatured == false) @@ -1356,7 +1355,7 @@ bool CMusicDatabase::GetSongsByArtist(int idArtist, bool includeFeatured, std::v { try { - CStdString strSQL, strPrepSQL; + std::string strSQL, strPrepSQL; strPrepSQL = "select idSong from song_artist where idArtist=%i"; if (includeFeatured == false) @@ -1390,7 +1389,7 @@ bool CMusicDatabase::GetArtistsBySong(int idSong, bool includeFeatured, std::vec { try { - CStdString strSQL, strPrepSQL; + std::string strSQL, strPrepSQL; strPrepSQL = "select idArtist from song_artist where idSong=%i"; if (includeFeatured == false) @@ -1424,7 +1423,7 @@ bool CMusicDatabase::GetGenresByAlbum(int idAlbum, std::vector<int>& genres) { try { - CStdString strSQL = PrepareSQL("select idGenre from album_genre where idAlbum = %i ORDER BY iOrder ASC", idAlbum); + std::string strSQL = PrepareSQL("select idGenre from album_genre where idAlbum = %i ORDER BY iOrder ASC", idAlbum); if (!m_pDS->query(strSQL.c_str())) return false; if (m_pDS->num_rows() == 0) @@ -1453,7 +1452,7 @@ bool CMusicDatabase::GetGenresBySong(int idSong, std::vector<int>& genres) { try { - CStdString strSQL = PrepareSQL("select idGenre from song_genre where idSong = %i ORDER BY iOrder ASC", idSong); + std::string strSQL = PrepareSQL("select idGenre from song_genre where idSong = %i ORDER BY iOrder ASC", idSong); if (!m_pDS->query(strSQL.c_str())) return false; if (m_pDS->num_rows() == 0) @@ -1478,19 +1477,19 @@ bool CMusicDatabase::GetGenresBySong(int idSong, std::vector<int>& genres) return false; } -int CMusicDatabase::AddPath(const CStdString& strPath1) +int CMusicDatabase::AddPath(const std::string& strPath1) { - CStdString strSQL; + std::string strSQL; try { - CStdString strPath(strPath1); + std::string strPath(strPath1); if (!URIUtils::HasSlashAtEnd(strPath)) URIUtils::AddSlashAtEnd(strPath); if (NULL == m_pDB.get()) return -1; if (NULL == m_pDS.get()) return -1; - map <CStdString, int>::const_iterator it; + map <std::string, int>::const_iterator it; it = m_pathCache.find(strPath); if (it != m_pathCache.end()) @@ -1506,13 +1505,13 @@ int CMusicDatabase::AddPath(const CStdString& strPath1) m_pDS->exec(strSQL.c_str()); int idPath = (int)m_pDS->lastinsertid(); - m_pathCache.insert(pair<CStdString, int>(strPath, idPath)); + m_pathCache.insert(pair<std::string, int>(strPath, idPath)); return idPath; } else { int idPath = m_pDS->fv("idPath").get_asInt(); - m_pathCache.insert(pair<CStdString, int>(strPath, idPath)); + m_pathCache.insert(pair<std::string, int>(strPath, idPath)); m_pDS->close(); return idPath; } @@ -1593,7 +1592,7 @@ void CMusicDatabase::GetFileItemFromDataset(const dbiplus::sql_record* const rec item->GetMusicInfoTag()->SetComment(record->at(song_comment).get_asString()); item->GetMusicInfoTag()->SetPlayCount(record->at(song_iTimesPlayed).get_asInt()); item->GetMusicInfoTag()->SetLastPlayed(record->at(song_lastplayed).get_asString()); - CStdString strRealPath = URIUtils::AddFileToFolder(record->at(song_strPath).get_asString(), record->at(song_strFileName).get_asString()); + std::string strRealPath = URIUtils::AddFileToFolder(record->at(song_strPath).get_asString(), record->at(song_strFileName).get_asString()); item->GetMusicInfoTag()->SetURL(strRealPath); item->GetMusicInfoTag()->SetCompilation(record->at(song_bCompilation).get_asInt() == 1); item->GetMusicInfoTag()->SetAlbumArtist(record->at(song_strAlbumArtists).get_asString()); @@ -1604,9 +1603,9 @@ void CMusicDatabase::GetFileItemFromDataset(const dbiplus::sql_record* const rec else { CMusicDbUrl itemUrl = baseUrl; - CStdString strFileName = record->at(song_strFileName).get_asString(); - CStdString strExt = URIUtils::GetExtension(strFileName); - CStdString path = StringUtils::Format("%i%s", record->at(song_idSong).get_asInt(), strExt.c_str()); + std::string strFileName = record->at(song_strFileName).get_asString(); + std::string strExt = URIUtils::GetExtension(strFileName); + std::string path = StringUtils::Format("%i%s", record->at(song_idSong).get_asInt(), strExt.c_str()); itemUrl.AppendPath(path); item->SetPath(itemUrl.ToString()); } @@ -1695,14 +1694,14 @@ CSong CMusicDatabase::GetAlbumInfoSongFromDataset(const dbiplus::sql_record* con return song; } -bool CMusicDatabase::GetSongByFileName(const CStdString& strFileNameAndPath, CSong& song, int startOffset) +bool CMusicDatabase::GetSongByFileName(const std::string& strFileNameAndPath, CSong& song, int startOffset) { song.Clear(); CURL url(strFileNameAndPath); if (url.IsProtocol("musicdb")) { - CStdString strFile = URIUtils::GetFileName(strFileNameAndPath); + std::string strFile = URIUtils::GetFileName(strFileNameAndPath); URIUtils::RemoveExtension(strFile); return GetSong(atol(strFile.c_str()), song); } @@ -1710,11 +1709,11 @@ bool CMusicDatabase::GetSongByFileName(const CStdString& strFileNameAndPath, CSo if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strPath, strFileName; + std::string strPath, strFileName; URIUtils::Split(strFileNameAndPath, strPath, strFileName); URIUtils::AddSlashAtEnd(strPath); - CStdString strSQL = PrepareSQL("select idSong from songview " + std::string strSQL = PrepareSQL("select idSong from songview " "where strFileName='%s' and strPath='%s'", strFileName.c_str(), strPath.c_str()); if (startOffset) @@ -1727,11 +1726,11 @@ bool CMusicDatabase::GetSongByFileName(const CStdString& strFileNameAndPath, CSo return false; } -int CMusicDatabase::GetAlbumIdByPath(const CStdString& strPath) +int CMusicDatabase::GetAlbumIdByPath(const std::string& strPath) { try { - CStdString strSQL=PrepareSQL("select distinct idAlbum from song join path on song.idPath = path.idPath where path.strPath='%s'", strPath.c_str()); + std::string strSQL=PrepareSQL("select distinct idAlbum from song join path on song.idPath = path.idPath where path.strPath='%s'", strPath.c_str()); m_pDS->query(strSQL.c_str()); if (m_pDS->eof()) return -1; @@ -1749,11 +1748,11 @@ int CMusicDatabase::GetAlbumIdByPath(const CStdString& strPath) return false; } -int CMusicDatabase::GetSongByArtistAndAlbumAndTitle(const CStdString& strArtist, const CStdString& strAlbum, const CStdString& strTitle) +int CMusicDatabase::GetSongByArtistAndAlbumAndTitle(const std::string& strArtist, const std::string& strAlbum, const std::string& strTitle) { try { - CStdString strSQL=PrepareSQL("select idSong from songview " + std::string strSQL=PrepareSQL("select idSong from songview " "where strArtists like '%s' and strAlbum like '%s' and " "strTitle like '%s'",strArtist.c_str(),strAlbum.c_str(),strTitle.c_str()); @@ -1776,15 +1775,15 @@ int CMusicDatabase::GetSongByArtistAndAlbumAndTitle(const CStdString& strArtist, return -1; } -bool CMusicDatabase::SearchArtists(const CStdString& search, CFileItemList &artists) +bool CMusicDatabase::SearchArtists(const std::string& search, CFileItemList &artists) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strVariousArtists = g_localizeStrings.Get(340).c_str(); - CStdString strSQL; + std::string strVariousArtists = g_localizeStrings.Get(340).c_str(); + std::string strSQL; if (search.size() >= MIN_FULL_SEARCH_LENGTH) strSQL=PrepareSQL("select * from artist " "where (strArtist like '%s%%' or strArtist like '%% %s%%') and strArtist <> '%s' " @@ -1801,12 +1800,12 @@ bool CMusicDatabase::SearchArtists(const CStdString& search, CFileItemList &arti return false; } - CStdString artistLabel(g_localizeStrings.Get(557)); // Artist + std::string artistLabel(g_localizeStrings.Get(557)); // Artist while (!m_pDS->eof()) { - CStdString path = StringUtils::Format("musicdb://artists/%i/", m_pDS->fv(0).get_asInt()); + std::string path = StringUtils::Format("musicdb://artists/%i/", m_pDS->fv(0).get_asInt()); CFileItemPtr pItem(new CFileItem(path, true)); - CStdString label = StringUtils::Format("[%s] %s", artistLabel.c_str(), m_pDS->fv(1).get_asString().c_str()); + std::string label = StringUtils::Format("[%s] %s", artistLabel.c_str(), m_pDS->fv(1).get_asString().c_str()); pItem->SetLabel(label); label = StringUtils::Format("A %s", m_pDS->fv(1).get_asString().c_str()); // sort label is stored in the title tag pItem->GetMusicInfoTag()->SetTitle(label); @@ -1826,7 +1825,7 @@ bool CMusicDatabase::SearchArtists(const CStdString& search, CFileItemList &arti return false; } -bool CMusicDatabase::GetTop100(const CStdString& strBaseDir, CFileItemList& items) +bool CMusicDatabase::GetTop100(const std::string& strBaseDir, CFileItemList& items) { try { @@ -1837,7 +1836,7 @@ bool CMusicDatabase::GetTop100(const CStdString& strBaseDir, CFileItemList& item if (!strBaseDir.empty() && !baseUrl.FromString(strBaseDir)) return false; - CStdString strSQL="select * from songview " + std::string strSQL="select * from songview " "where iTimesPlayed>0 " "order by iTimesPlayed desc " "limit 100"; @@ -1880,7 +1879,7 @@ bool CMusicDatabase::GetTop100Albums(VECALBUMS& albums) // NOTE: The song.idAlbum is needed for the group by, as for some reason group by albumview.idAlbum doesn't work // consistently - possibly an SQLite bug, as it works fine in SQLiteSpy (v3.3.17) - CStdString strSQL = "select albumview.* from albumview " + std::string strSQL = "select albumview.* from albumview " "where albumview.iTimesPlayed>0 and albumview.strAlbum != '' " "order by albumview.iTimesPlayed desc " "limit 100 "; @@ -1910,7 +1909,7 @@ bool CMusicDatabase::GetTop100Albums(VECALBUMS& albums) return false; } -bool CMusicDatabase::GetTop100AlbumSongs(const CStdString& strBaseDir, CFileItemList& items) +bool CMusicDatabase::GetTop100AlbumSongs(const std::string& strBaseDir, CFileItemList& items) { try { @@ -1921,7 +1920,7 @@ bool CMusicDatabase::GetTop100AlbumSongs(const CStdString& strBaseDir, CFileItem if (!strBaseDir.empty() && baseUrl.FromString(strBaseDir)) return false; - CStdString strSQL = StringUtils::Format("select * from songview join albumview on (songview.idAlbum = albumview.idAlbum) where albumview.idAlbum in (select song.idAlbum from song where song.iTimesPlayed>0 group by idAlbum order by sum(song.iTimesPlayed) desc limit 100) order by albumview.idAlbum in (select song.idAlbum from song where song.iTimesPlayed>0 group by idAlbum order by sum(song.iTimesPlayed) desc limit 100)"); + std::string strSQL = StringUtils::Format("select * from songview join albumview on (songview.idAlbum = albumview.idAlbum) where albumview.idAlbum in (select song.idAlbum from song where song.iTimesPlayed>0 group by idAlbum order by sum(song.iTimesPlayed) desc limit 100) order by albumview.idAlbum in (select song.idAlbum from song where song.iTimesPlayed>0 group by idAlbum order by sum(song.iTimesPlayed) desc limit 100)"); CLog::Log(LOGDEBUG,"GetTop100AlbumSongs() query: %s", strSQL.c_str()); if (!m_pDS->query(strSQL.c_str())) return false; @@ -1961,7 +1960,7 @@ bool CMusicDatabase::GetRecentlyPlayedAlbums(VECALBUMS& albums) if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL = StringUtils::Format("select distinct albumview.* from song join albumview on albumview.idAlbum=song.idAlbum where song.lastplayed IS NOT NULL order by song.lastplayed desc limit %i", RECENTLY_PLAYED_LIMIT); + std::string strSQL = StringUtils::Format("select distinct albumview.* from song join albumview on albumview.idAlbum=song.idAlbum where song.lastplayed IS NOT NULL order by song.lastplayed desc limit %i", RECENTLY_PLAYED_LIMIT); CLog::Log(LOGDEBUG, "%s query: %s", __FUNCTION__, strSQL.c_str()); if (!m_pDS->query(strSQL.c_str())) return false; int iRowsFound = m_pDS->num_rows(); @@ -1987,7 +1986,7 @@ bool CMusicDatabase::GetRecentlyPlayedAlbums(VECALBUMS& albums) return false; } -bool CMusicDatabase::GetRecentlyPlayedAlbumSongs(const CStdString& strBaseDir, CFileItemList& items) +bool CMusicDatabase::GetRecentlyPlayedAlbumSongs(const std::string& strBaseDir, CFileItemList& items) { try { @@ -1998,7 +1997,7 @@ bool CMusicDatabase::GetRecentlyPlayedAlbumSongs(const CStdString& strBaseDir, C if (!strBaseDir.empty() && !baseUrl.FromString(strBaseDir)) return false; - CStdString strSQL = StringUtils::Format("select * from songview join albumview on (songview.idAlbum = albumview.idAlbum) where albumview.idAlbum in (select distinct albumview.idAlbum from albumview join song on albumview.idAlbum=song.idAlbum where song.lastplayed IS NOT NULL order by song.lastplayed desc limit %i)", g_advancedSettings.m_iMusicLibraryRecentlyAddedItems); + std::string strSQL = StringUtils::Format("select * from songview join albumview on (songview.idAlbum = albumview.idAlbum) where albumview.idAlbum in (select distinct albumview.idAlbum from albumview join song on albumview.idAlbum=song.idAlbum where song.lastplayed IS NOT NULL order by song.lastplayed desc limit %i)", g_advancedSettings.m_iMusicLibraryRecentlyAddedItems); CLog::Log(LOGDEBUG,"GetRecentlyPlayedAlbumSongs() query: %s", strSQL.c_str()); if (!m_pDS->query(strSQL.c_str())) return false; @@ -2038,7 +2037,7 @@ bool CMusicDatabase::GetRecentlyAddedAlbums(VECALBUMS& albums, unsigned int limi if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL = StringUtils::Format("select * from albumview where strAlbum != '' order by idAlbum desc limit %u", limit ? limit : g_advancedSettings.m_iMusicLibraryRecentlyAddedItems); + std::string strSQL = StringUtils::Format("select * from albumview where strAlbum != '' order by idAlbum desc limit %u", limit ? limit : g_advancedSettings.m_iMusicLibraryRecentlyAddedItems); CLog::Log(LOGDEBUG, "%s query: %s", __FUNCTION__, strSQL.c_str()); if (!m_pDS->query(strSQL.c_str())) return false; @@ -2066,7 +2065,7 @@ bool CMusicDatabase::GetRecentlyAddedAlbums(VECALBUMS& albums, unsigned int limi return false; } -bool CMusicDatabase::GetRecentlyAddedAlbumSongs(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit) +bool CMusicDatabase::GetRecentlyAddedAlbumSongs(const std::string& strBaseDir, CFileItemList& items, unsigned int limit) { try { @@ -2077,7 +2076,7 @@ bool CMusicDatabase::GetRecentlyAddedAlbumSongs(const CStdString& strBaseDir, CF if (!strBaseDir.empty() && !baseUrl.FromString(strBaseDir)) return false; - CStdString strSQL; + std::string strSQL; strSQL = PrepareSQL("SELECT songview.* FROM (SELECT idAlbum FROM albumview ORDER BY idAlbum DESC LIMIT %u) AS recentalbums JOIN songview ON songview.idAlbum=recentalbums.idAlbum", limit ? limit : g_advancedSettings.m_iMusicLibraryRecentlyAddedItems); CLog::Log(LOGDEBUG,"GetRecentlyAddedAlbumSongs() query: %s", strSQL.c_str()); if (!m_pDS->query(strSQL.c_str())) return false; @@ -2119,7 +2118,7 @@ void CMusicDatabase::IncrementPlayCount(const CFileItem& item) int idSong = GetSongIDFromPath(item.GetPath()); - CStdString sql=PrepareSQL("UPDATE song SET iTimesPlayed=iTimesPlayed+1, lastplayed=CURRENT_TIMESTAMP where idSong=%i", idSong); + std::string sql=PrepareSQL("UPDATE song SET iTimesPlayed=iTimesPlayed+1, lastplayed=CURRENT_TIMESTAMP where idSong=%i", idSong); m_pDS->exec(sql.c_str()); } catch (...) @@ -2128,9 +2127,9 @@ void CMusicDatabase::IncrementPlayCount(const CFileItem& item) } } -bool CMusicDatabase::GetSongsByPath(const CStdString& strPath1, MAPSONGS& songs, bool bAppendToMap) +bool CMusicDatabase::GetSongsByPath(const std::string& strPath1, MAPSONGS& songs, bool bAppendToMap) { - CStdString strPath(strPath1); + std::string strPath(strPath1); try { if (!URIUtils::HasSlashAtEnd(strPath)) @@ -2142,7 +2141,7 @@ bool CMusicDatabase::GetSongsByPath(const CStdString& strPath1, MAPSONGS& songs, if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL=PrepareSQL("select * from songview where strPath='%s'", strPath.c_str() ); + std::string strSQL=PrepareSQL("select * from songview where strPath='%s'", strPath.c_str() ); if (!m_pDS->query(strSQL.c_str())) return false; int iRowsFound = m_pDS->num_rows(); if (iRowsFound == 0) @@ -2177,7 +2176,7 @@ void CMusicDatabase::EmptyCache() m_thumbCache.erase(m_thumbCache.begin(), m_thumbCache.end()); } -bool CMusicDatabase::Search(const CStdString& search, CFileItemList &items) +bool CMusicDatabase::Search(const std::string& search, CFileItemList &items) { unsigned int time = XbmcThreads::SystemClockMillis(); // first grab all the artists that match @@ -2197,7 +2196,7 @@ bool CMusicDatabase::Search(const CStdString& search, CFileItemList &items) return true; } -bool CMusicDatabase::SearchSongs(const CStdString& search, CFileItemList &items) +bool CMusicDatabase::SearchSongs(const std::string& search, CFileItemList &items) { try { @@ -2208,7 +2207,7 @@ bool CMusicDatabase::SearchSongs(const CStdString& search, CFileItemList &items) if (!baseUrl.FromString("musicdb://songs/")) return false; - CStdString strSQL; + std::string strSQL; if (search.size() >= MIN_FULL_SEARCH_LENGTH) strSQL=PrepareSQL("select * from songview where strTitle like '%s%%' or strTitle like '%% %s%%' limit 1000", search.c_str(), search.c_str()); else @@ -2217,7 +2216,7 @@ bool CMusicDatabase::SearchSongs(const CStdString& search, CFileItemList &items) if (!m_pDS->query(strSQL.c_str())) return false; if (m_pDS->num_rows() == 0) return false; - CStdString songLabel = g_localizeStrings.Get(179); // Song + std::string songLabel = g_localizeStrings.Get(179); // Song while (!m_pDS->eof()) { CFileItemPtr item(new CFileItem); @@ -2237,14 +2236,14 @@ bool CMusicDatabase::SearchSongs(const CStdString& search, CFileItemList &items) return false; } -bool CMusicDatabase::SearchAlbums(const CStdString& search, CFileItemList &albums) +bool CMusicDatabase::SearchAlbums(const std::string& search, CFileItemList &albums) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL; + std::string strSQL; if (search.size() >= MIN_FULL_SEARCH_LENGTH) strSQL=PrepareSQL("select * from albumview where strAlbum like '%s%%' or strAlbum like '%% %s%%'", search.c_str(), search.c_str()); else @@ -2252,13 +2251,13 @@ bool CMusicDatabase::SearchAlbums(const CStdString& search, CFileItemList &album if (!m_pDS->query(strSQL.c_str())) return false; - CStdString albumLabel(g_localizeStrings.Get(558)); // Album + std::string albumLabel(g_localizeStrings.Get(558)); // Album while (!m_pDS->eof()) { CAlbum album = GetAlbumFromDataset(m_pDS.get()); - CStdString path = StringUtils::Format("musicdb://albums/%ld/", album.idAlbum); + std::string path = StringUtils::Format("musicdb://albums/%ld/", album.idAlbum); CFileItemPtr pItem(new CFileItem(path, album)); - CStdString label = StringUtils::Format("[%s] %s", albumLabel.c_str(), album.strAlbum.c_str()); + std::string label = StringUtils::Format("[%s] %s", albumLabel.c_str(), album.strAlbum.c_str()); pItem->SetLabel(label); label = StringUtils::Format("B %s", album.strAlbum.c_str()); // sort label is stored in the title tag pItem->GetMusicInfoTag()->SetTitle(label); @@ -2275,14 +2274,14 @@ bool CMusicDatabase::SearchAlbums(const CStdString& search, CFileItemList &album return false; } -bool CMusicDatabase::CleanupSongsByIds(const CStdString &strSongIds) +bool CMusicDatabase::CleanupSongsByIds(const std::string &strSongIds) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; // ok, now find all idSong's - CStdString strSQL=PrepareSQL("select * from song join path on song.idPath = path.idPath where song.idSong in %s", strSongIds.c_str()); + std::string strSQL=PrepareSQL("select * from song join path on song.idPath = path.idPath where song.idSong in %s", strSongIds.c_str()); if (!m_pDS->query(strSQL.c_str())) return false; int iRowsFound = m_pDS->num_rows(); if (iRowsFound == 0) @@ -2293,7 +2292,7 @@ bool CMusicDatabase::CleanupSongsByIds(const CStdString &strSongIds) vector<std::string> songsToDelete; while (!m_pDS->eof()) { // get the full song path - CStdString strFileName = URIUtils::AddFileToFolder(m_pDS->fv("path.strPath").get_asString(), m_pDS->fv("song.strFileName").get_asString()); + std::string strFileName = URIUtils::AddFileToFolder(m_pDS->fv("path.strPath").get_asString(), m_pDS->fv("song.strFileName").get_asString()); // Special case for streams inside an ogg file. (oggstream) // The last dir in the path is the ogg file that @@ -2338,7 +2337,7 @@ bool CMusicDatabase::CleanupSongs() int iLIMIT = 1000; for (int i=0;;i+=iLIMIT) { - CStdString strSQL=PrepareSQL("select song.idSong from song order by song.idSong limit %i offset %i",iLIMIT,i); + std::string strSQL=PrepareSQL("select song.idSong from song order by song.idSong limit %i offset %i",iLIMIT,i); if (!m_pDS->query(strSQL.c_str())) return false; int iRowsFound = m_pDS->num_rows(); // keep going until no rows are left! @@ -2374,7 +2373,7 @@ bool CMusicDatabase::CleanupAlbums() { // This must be run AFTER songs have been cleaned up // delete albums with no reference to songs - CStdString strSQL = "select * from album where album.idAlbum not in (select idAlbum from song)"; + std::string strSQL = "select * from album where album.idAlbum not in (select idAlbum from song)"; if (!m_pDS->query(strSQL.c_str())) return false; int iRowsFound = m_pDS->num_rows(); if (iRowsFound == 0) @@ -2417,7 +2416,7 @@ bool CMusicDatabase::CleanupPaths() m_pDS->exec("INSERT INTO songpaths select idPath,strPath from path where idPath in (select idPath from song)\n"); // grab all paths that aren't immediately connected with a song - CStdString sql = "select * from path where idPath not in (select idPath from song)"; + std::string sql = "select * from path where idPath not in (select idPath from song)"; if (!m_pDS->query(sql.c_str())) return false; int iRowsFound = m_pDS->num_rows(); if (iRowsFound == 0) @@ -2430,8 +2429,8 @@ bool CMusicDatabase::CleanupPaths() while (!m_pDS->eof()) { // anything that isn't a parent path of a song path is to be deleted - CStdString path = m_pDS->fv("strPath").get_asString(); - CStdString sql = PrepareSQL("select count(idPath) from songpaths where SUBSTR(strPath,1,%i)='%s'", StringUtils::utf8_strlen(path.c_str()), path.c_str()); + std::string path = m_pDS->fv("strPath").get_asString(); + std::string sql = PrepareSQL("select count(idPath) from songpaths where SUBSTR(strPath,1,%i)='%s'", StringUtils::utf8_strlen(path.c_str()), path.c_str()); if (m_pDS2->query(sql.c_str()) && m_pDS2->num_rows() == 1 && m_pDS2->fv(0).get_asInt() == 0) pathIds.push_back(m_pDS->fv("idPath").get_asString()); // nothing found, so delete m_pDS2->close(); @@ -2455,9 +2454,9 @@ bool CMusicDatabase::CleanupPaths() return false; } -bool CMusicDatabase::InsideScannedPath(const CStdString& path) +bool CMusicDatabase::InsideScannedPath(const std::string& path) { - CStdString sql = PrepareSQL("select idPath from path where SUBSTR(strPath,1,%i)='%s' LIMIT 1", path.size(), path.c_str()); + std::string sql = PrepareSQL("select idPath from path where SUBSTR(strPath,1,%i)='%s' LIMIT 1", path.size(), path.c_str()); return !GetSingleValue(sql).empty(); } @@ -2491,7 +2490,7 @@ bool CMusicDatabase::CleanupGenres() // Cleanup orphaned genres (ie those that don't belong to a song or an album entry) // (nested queries by Bobbin007) // Must be executed AFTER the song, song_genre, album and album_genre tables have been cleaned. - CStdString strSQL = "delete from genre where idGenre not in (select idGenre from song_genre) and"; + std::string strSQL = "delete from genre where idGenre not in (select idGenre from song_genre) and"; strSQL += " idGenre not in (select idGenre from album_genre)"; m_pDS->exec(strSQL.c_str()); return true; @@ -2651,7 +2650,7 @@ bool CMusicDatabase::LookupCDDBInfo(bool bRequery/*=false*/) // Delete old info if any if (bRequery) { - CStdString strFile = StringUtils::Format("%x.cddb", pCdInfo->GetCddbDiscId()); + std::string strFile = StringUtils::Format("%x.cddb", pCdInfo->GetCddbDiscId()); CFile::Delete(URIUtils::AddFileToFolder(CProfilesManager::Get().GetCDDBFolder(), strFile)); } @@ -2692,10 +2691,10 @@ bool CMusicDatabase::LookupCDDBInfo(bool bRequery/*=false*/) int i = 1; while (1) { - CStdString strTitle = cddb.getInexactTitle(i); + std::string strTitle = cddb.getInexactTitle(i); if (strTitle == "") break; - CStdString strArtist = cddb.getInexactArtist(i); + std::string strArtist = cddb.getInexactArtist(i); if (!strArtist.empty()) strTitle += " - " + strArtist; @@ -2723,7 +2722,7 @@ bool CMusicDatabase::LookupCDDBInfo(bool bRequery/*=false*/) { pCdInfo->SetNoCDDBInfo(); // ..no, an error occured, display it to the user - CStdString strErrorText = StringUtils::Format("[%d] %s", cddb.getLastError(), cddb.getLastErrorText()); + std::string strErrorText = StringUtils::Format("[%d] %s", cddb.getLastError(), cddb.getLastErrorText()); CGUIDialogOK::ShowAndGetInput(255, 257, strErrorText, 0); } } // if ( !cddb.queryCDinfo( pCdInfo ) ) @@ -2755,13 +2754,13 @@ void CMusicDatabase::DeleteCDDBInfo() pDlg->SetHeading(g_localizeStrings.Get(181).c_str()); pDlg->Reset(); - map<ULONG, CStdString> mapCDDBIds; + map<ULONG, std::string> mapCDDBIds; for (int i = 0; i < items.Size(); ++i) { if (items[i]->m_bIsFolder) continue; - CStdString strFile = URIUtils::GetFileName(items[i]->GetPath()); + std::string strFile = URIUtils::GetFileName(items[i]->GetPath()); strFile.erase(strFile.size() - 5, 5); ULONG lDiscId = strtoul(strFile.c_str(), NULL, 16); Xcddb cddb; @@ -2770,18 +2769,18 @@ void CMusicDatabase::DeleteCDDBInfo() if (!cddb.queryCache(lDiscId)) continue; - CStdString strDiskTitle, strDiskArtist; + std::string strDiskTitle, strDiskArtist; cddb.getDiskTitle(strDiskTitle); cddb.getDiskArtist(strDiskArtist); - CStdString str; + std::string str; if (strDiskArtist.empty()) str = strDiskTitle; else str = strDiskTitle + " - " + strDiskArtist; pDlg->Add(str); - mapCDDBIds.insert(pair<ULONG, CStdString>(lDiscId, str)); + mapCDDBIds.insert(pair<ULONG, std::string>(lDiscId, str)); } pDlg->Sort(); @@ -2795,13 +2794,13 @@ void CMusicDatabase::DeleteCDDBInfo() return ; } - CStdString strSelectedAlbum = pDlg->GetSelectedLabelText(); - map<ULONG, CStdString>::iterator it; + std::string strSelectedAlbum = pDlg->GetSelectedLabelText(); + map<ULONG, std::string>::iterator it; for (it = mapCDDBIds.begin();it != mapCDDBIds.end();it++) { if (it->second == strSelectedAlbum) { - CStdString strFile = StringUtils::Format("%x.cddb", (unsigned int) it->first); + std::string strFile = StringUtils::Format("%x.cddb", (unsigned int) it->first); CFile::Delete(URIUtils::AddFileToFolder(CProfilesManager::Get().GetCDDBFolder(), strFile)); break; } @@ -2837,7 +2836,7 @@ void CMusicDatabase::Clean() } } -bool CMusicDatabase::GetGenresNav(const CStdString& strBaseDir, CFileItemList& items, const Filter &filter /* = Filter() */, bool countOnly /* = false */) +bool CMusicDatabase::GetGenresNav(const std::string& strBaseDir, CFileItemList& items, const Filter &filter /* = Filter() */, bool countOnly /* = false */) { try { @@ -2845,7 +2844,7 @@ bool CMusicDatabase::GetGenresNav(const CStdString& strBaseDir, CFileItemList& i if (NULL == m_pDS.get()) return false; // get primary genres for songs - could be simplified to just SELECT * FROM genre? - CStdString strSQL = "SELECT %s FROM genre "; + std::string strSQL = "SELECT %s FROM genre "; Filter extFilter = filter; CMusicDbUrl musicUrl; @@ -2912,7 +2911,7 @@ bool CMusicDatabase::GetGenresNav(const CStdString& strBaseDir, CFileItemList& i pItem->GetMusicInfoTag()->SetDatabaseId(m_pDS->fv("genre.idGenre").get_asInt(), "genre"); CMusicDbUrl itemUrl = musicUrl; - CStdString strDir = StringUtils::Format("%i/", m_pDS->fv("genre.idGenre").get_asInt()); + std::string strDir = StringUtils::Format("%i/", m_pDS->fv("genre.idGenre").get_asInt()); itemUrl.AppendPath(strDir); pItem->SetPath(itemUrl.ToString()); @@ -2934,7 +2933,7 @@ bool CMusicDatabase::GetGenresNav(const CStdString& strBaseDir, CFileItemList& i return false; } -bool CMusicDatabase::GetYearsNav(const CStdString& strBaseDir, CFileItemList& items, const Filter &filter /* = Filter() */) +bool CMusicDatabase::GetYearsNav(const std::string& strBaseDir, CFileItemList& items, const Filter &filter /* = Filter() */) { try { @@ -2948,7 +2947,7 @@ bool CMusicDatabase::GetYearsNav(const CStdString& strBaseDir, CFileItemList& it return false; // get years from album list - CStdString strSQL = "SELECT DISTINCT albumview.iYear FROM albumview "; + std::string strSQL = "SELECT DISTINCT albumview.iYear FROM albumview "; extFilter.AppendWhere("albumview.iYear <> 0"); if (!BuildSQL(strSQL, extFilter, strSQL)) @@ -2974,7 +2973,7 @@ bool CMusicDatabase::GetYearsNav(const CStdString& strBaseDir, CFileItemList& it pItem->GetMusicInfoTag()->SetReleaseDate(stTime); CMusicDbUrl itemUrl = musicUrl; - CStdString strDir = StringUtils::Format("%i/", m_pDS->fv(0).get_asInt()); + std::string strDir = StringUtils::Format("%i/", m_pDS->fv(0).get_asInt()); itemUrl.AppendPath(strDir); pItem->SetPath(itemUrl.ToString()); @@ -2996,7 +2995,7 @@ bool CMusicDatabase::GetYearsNav(const CStdString& strBaseDir, CFileItemList& it return false; } -bool CMusicDatabase::GetAlbumsByYear(const CStdString& strBaseDir, CFileItemList& items, int year) +bool CMusicDatabase::GetAlbumsByYear(const std::string& strBaseDir, CFileItemList& items, int year) { CMusicDbUrl musicUrl; if (!musicUrl.FromString(strBaseDir)) @@ -3009,7 +3008,7 @@ bool CMusicDatabase::GetAlbumsByYear(const CStdString& strBaseDir, CFileItemList return GetAlbumsByWhere(musicUrl.ToString(), filter, items); } -bool CMusicDatabase::GetCommonNav(const CStdString &strBaseDir, const CStdString &table, const CStdString &labelField, CFileItemList &items, const Filter &filter /* = Filter() */, bool countOnly /* = false */) +bool CMusicDatabase::GetCommonNav(const std::string &strBaseDir, const std::string &table, const std::string &labelField, CFileItemList &items, const Filter &filter /* = Filter() */, bool countOnly /* = false */) { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; @@ -3020,7 +3019,7 @@ bool CMusicDatabase::GetCommonNav(const CStdString &strBaseDir, const CStdString try { Filter extFilter = filter; - CStdString strSQL = "SELECT %s FROM " + table + " "; + std::string strSQL = "SELECT %s FROM " + table + " "; extFilter.AppendGroup(labelField); extFilter.AppendWhere(labelField + " != ''"); @@ -3062,11 +3061,11 @@ bool CMusicDatabase::GetCommonNav(const CStdString &strBaseDir, const CStdString // get data from returned rows while (!m_pDS->eof()) { - string labelValue = m_pDS->fv(labelField).get_asString(); + string labelValue = m_pDS->fv(labelField.c_str()).get_asString(); CFileItemPtr pItem(new CFileItem(labelValue)); CMusicDbUrl itemUrl = musicUrl; - CStdString strDir = StringUtils::Format("%s/", labelValue.c_str()); + std::string strDir = StringUtils::Format("%s/", labelValue.c_str()); itemUrl.AppendPath(strDir); pItem->SetPath(itemUrl.ToString()); @@ -3090,17 +3089,17 @@ bool CMusicDatabase::GetCommonNav(const CStdString &strBaseDir, const CStdString return false; } -bool CMusicDatabase::GetAlbumTypesNav(const CStdString &strBaseDir, CFileItemList &items, const Filter &filter /* = Filter() */, bool countOnly /* = false */) +bool CMusicDatabase::GetAlbumTypesNav(const std::string &strBaseDir, CFileItemList &items, const Filter &filter /* = Filter() */, bool countOnly /* = false */) { return GetCommonNav(strBaseDir, "albumview", "albumview.strType", items, filter, countOnly); } -bool CMusicDatabase::GetMusicLabelsNav(const CStdString &strBaseDir, CFileItemList &items, const Filter &filter /* = Filter() */, bool countOnly /* = false */) +bool CMusicDatabase::GetMusicLabelsNav(const std::string &strBaseDir, CFileItemList &items, const Filter &filter /* = Filter() */, bool countOnly /* = false */) { return GetCommonNav(strBaseDir, "albumview", "albumview.strLabel", items, filter, countOnly); } -bool CMusicDatabase::GetArtistsNav(const CStdString& strBaseDir, CFileItemList& items, bool albumArtistsOnly /* = false */, int idGenre /* = -1 */, int idAlbum /* = -1 */, int idSong /* = -1 */, const Filter &filter /* = Filter() */, const SortDescription &sortDescription /* = SortDescription() */, bool countOnly /* = false */) +bool CMusicDatabase::GetArtistsNav(const std::string& strBaseDir, CFileItemList& items, bool albumArtistsOnly /* = false */, int idGenre /* = -1 */, int idAlbum /* = -1 */, int idSong /* = -1 */, const Filter &filter /* = Filter() */, const SortDescription &sortDescription /* = SortDescription() */, bool countOnly /* = false */) { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; @@ -3134,7 +3133,7 @@ bool CMusicDatabase::GetArtistsNav(const CStdString& strBaseDir, CFileItemList& return false; } -bool CMusicDatabase::GetArtistsByWhere(const CStdString& strBaseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription /* = SortDescription() */, bool countOnly /* = false */) +bool CMusicDatabase::GetArtistsByWhere(const std::string& strBaseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription /* = SortDescription() */, bool countOnly /* = false */) { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; @@ -3143,7 +3142,7 @@ bool CMusicDatabase::GetArtistsByWhere(const CStdString& strBaseDir, const Filte { int total = -1; - CStdString strSQL = "SELECT %s FROM artistview "; + std::string strSQL = "SELECT %s FROM artistview "; Filter extFilter = filter; CMusicDbUrl musicUrl; @@ -3237,7 +3236,7 @@ bool CMusicDatabase::GetArtistsByWhere(const CStdString& strBaseDir, const Filte CFileItemPtr pItem(new CFileItem(artist)); CMusicDbUrl itemUrl = musicUrl; - CStdString path = StringUtils::Format("%ld/", artist.idArtist); + std::string path = StringUtils::Format("%ld/", artist.idArtist); itemUrl.AppendPath(path); pItem->SetPath(itemUrl.ToString()); @@ -3274,7 +3273,7 @@ bool CMusicDatabase::GetAlbumFromSong(int idSong, CAlbum &album) if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL = PrepareSQL("select albumview.* from song join albumview on song.idAlbum = albumview.idAlbum where song.idSong='%i'", idSong); + std::string strSQL = PrepareSQL("select albumview.* from song join albumview on song.idAlbum = albumview.idAlbum where song.idSong='%i'", idSong); if (!m_pDS->query(strSQL.c_str())) return false; int iRowsFound = m_pDS->num_rows(); if (iRowsFound != 1) @@ -3296,7 +3295,7 @@ bool CMusicDatabase::GetAlbumFromSong(int idSong, CAlbum &album) return false; } -bool CMusicDatabase::GetAlbumsNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre /* = -1 */, int idArtist /* = -1 */, const Filter &filter /* = Filter() */, const SortDescription &sortDescription /* = SortDescription() */, bool countOnly /* = false */) +bool CMusicDatabase::GetAlbumsNav(const std::string& strBaseDir, CFileItemList& items, int idGenre /* = -1 */, int idArtist /* = -1 */, const Filter &filter /* = Filter() */, const SortDescription &sortDescription /* = SortDescription() */, bool countOnly /* = false */) { CMusicDbUrl musicUrl; if (!musicUrl.FromString(strBaseDir)) @@ -3312,7 +3311,7 @@ bool CMusicDatabase::GetAlbumsNav(const CStdString& strBaseDir, CFileItemList& i return GetAlbumsByWhere(musicUrl.ToString(), filter, items, sortDescription, countOnly); } -bool CMusicDatabase::GetAlbumsByWhere(const CStdString &baseDir, const Filter &filter, CFileItemList &items, const SortDescription &sortDescription /* = SortDescription() */, bool countOnly /* = false */) +bool CMusicDatabase::GetAlbumsByWhere(const std::string &baseDir, const Filter &filter, CFileItemList &items, const SortDescription &sortDescription /* = SortDescription() */, bool countOnly /* = false */) { if (m_pDB.get() == NULL || m_pDS.get() == NULL) return false; @@ -3321,7 +3320,7 @@ bool CMusicDatabase::GetAlbumsByWhere(const CStdString &baseDir, const Filter &f { int total = -1; - CStdString strSQL = "SELECT %s FROM albumview "; + std::string strSQL = "SELECT %s FROM albumview "; Filter extFilter = filter; CMusicDbUrl musicUrl; @@ -3398,7 +3397,7 @@ bool CMusicDatabase::GetAlbumsByWhere(const CStdString &baseDir, const Filter &f try { CMusicDbUrl itemUrl = musicUrl; - CStdString path = StringUtils::Format("%i/", record->at(album_idAlbum).get_asInt()); + std::string path = StringUtils::Format("%i/", record->at(album_idAlbum).get_asInt()); itemUrl.AppendPath(path); CFileItemPtr pItem(new CFileItem(itemUrl.ToString(), GetAlbumFromDataset(record))); @@ -3424,7 +3423,7 @@ bool CMusicDatabase::GetAlbumsByWhere(const CStdString &baseDir, const Filter &f return false; } -bool CMusicDatabase::GetSongsByWhere(const CStdString &baseDir, const Filter &filter, CFileItemList &items, const SortDescription &sortDescription /* = SortDescription() */) +bool CMusicDatabase::GetSongsByWhere(const std::string &baseDir, const Filter &filter, CFileItemList &items, const SortDescription &sortDescription /* = SortDescription() */) { if (m_pDB.get() == NULL || m_pDS.get() == NULL) return false; @@ -3434,7 +3433,7 @@ bool CMusicDatabase::GetSongsByWhere(const CStdString &baseDir, const Filter &fi unsigned int time = XbmcThreads::SystemClockMillis(); int total = -1; - CStdString strSQL = "SELECT %s FROM songview "; + std::string strSQL = "SELECT %s FROM songview "; Filter extFilter = filter; CMusicDbUrl musicUrl; @@ -3526,7 +3525,7 @@ bool CMusicDatabase::GetSongsByWhere(const CStdString &baseDir, const Filter &fi return false; } -bool CMusicDatabase::GetSongsByYear(const CStdString& baseDir, CFileItemList& items, int year) +bool CMusicDatabase::GetSongsByYear(const std::string& baseDir, CFileItemList& items, int year) { CMusicDbUrl musicUrl; if (!musicUrl.FromString(baseDir)) @@ -3538,7 +3537,7 @@ bool CMusicDatabase::GetSongsByYear(const CStdString& baseDir, CFileItemList& it return GetSongsByWhere(baseDir, filter, items); } -bool CMusicDatabase::GetSongsNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre, int idArtist, int idAlbum, const SortDescription &sortDescription /* = SortDescription() */) +bool CMusicDatabase::GetSongsNav(const std::string& strBaseDir, CFileItemList& items, int idGenre, int idArtist, int idAlbum, const SortDescription &sortDescription /* = SortDescription() */) { CMusicDbUrl musicUrl; if (!musicUrl.FromString(strBaseDir)) @@ -3562,7 +3561,7 @@ void CMusicDatabase::UpdateTables(int version) if (version < 19) { int len = g_advancedSettings.m_musicItemSeparator.size() + 1; - CStdString sql = PrepareSQL("UPDATE song SET strExtraArtists=SUBSTR(strExtraArtists,%i), strExtraGenres=SUBSTR(strExtraGenres,%i)", len, len); + std::string sql = PrepareSQL("UPDATE song SET strExtraArtists=SUBSTR(strExtraArtists,%i), strExtraGenres=SUBSTR(strExtraGenres,%i)", len, len); m_pDS->exec(sql.c_str()); sql = PrepareSQL("UPDATE album SET strExtraArtists=SUBSTR(strExtraArtists,%i), strExtraGenres=SUBSTR(strExtraGenres,%i)", len, len); m_pDS->exec(sql.c_str()); @@ -3574,7 +3573,7 @@ void CMusicDatabase::UpdateTables(int version) m_pDS->exec("INSERT INTO album_artist (idArtist, idAlbum, boolFeatured, iOrder) SELECT idArtist, idAlbum, 1, iPosition FROM exartistalbum"); m_pDS->exec("REPLACE INTO album_artist (idArtist, idAlbum, boolFeatured, iOrder) SELECT idArtist, idAlbum, 0, 0 FROM album"); - CStdString strSQL; + std::string strSQL; strSQL=PrepareSQL("SELECT album.idAlbum AS idAlbum, strExtraArtists," " album.idArtist AS idArtist, strArtist FROM album " " LEFT OUTER JOIN artist ON album.idArtist=artist.idArtist"); @@ -3600,7 +3599,7 @@ void CMusicDatabase::UpdateTables(int version) for (VECALBUMS::iterator it = albums.begin(); it != albums.end(); ++it) { - CStdString strSQL; + std::string strSQL; strSQL = PrepareSQL("UPDATE album_new SET strArtists='%s' WHERE idAlbum=%i", StringUtils::Join(it->artist, g_advancedSettings.m_musicItemSeparator).c_str(), it->idAlbum); m_pDS->exec(strSQL); } @@ -3616,7 +3615,7 @@ void CMusicDatabase::UpdateTables(int version) m_pDS->exec("INSERT INTO song_artist (idArtist, idSong, boolFeatured, iOrder) SELECT idArtist, idSong, 1, iPosition FROM exartistsong"); m_pDS->exec("REPLACE INTO song_artist (idArtist, idSong, boolFeatured, iOrder) SELECT idArtist, idSong, 0, 0 FROM song"); - CStdString strSQL; + std::string strSQL; strSQL=PrepareSQL("SELECT song.idSong AS idSong, strExtraArtists," " song.idArtist AS idArtist, strArtist FROM song " " LEFT OUTER JOIN artist ON song.idArtist=artist.idArtist"); @@ -3642,7 +3641,7 @@ void CMusicDatabase::UpdateTables(int version) for (VECSONGS::iterator it = songs.begin(); it != songs.end(); ++it) { - CStdString strSQL; + std::string strSQL; strSQL = PrepareSQL("UPDATE song_new SET strArtists='%s' WHERE idSong=%i", StringUtils::Join(it->artist, g_advancedSettings.m_musicItemSeparator).c_str(), it->idSong); m_pDS->exec(strSQL); } @@ -3658,7 +3657,7 @@ void CMusicDatabase::UpdateTables(int version) m_pDS->exec("INSERT INTO album_genre ( idGenre, idAlbum, iOrder) SELECT idGenre, idAlbum, iPosition FROM exgenrealbum"); m_pDS->exec("REPLACE INTO album_genre ( idGenre, idAlbum, iOrder) SELECT idGenre, idAlbum, 0 FROM album"); - CStdString strSQL; + std::string strSQL; strSQL=PrepareSQL("SELECT album.idAlbum AS idAlbum, strExtraGenres," " album.idGenre AS idGenre, strGenre FROM album " " JOIN genre ON album.idGenre=genre.idGenre"); @@ -3684,7 +3683,7 @@ void CMusicDatabase::UpdateTables(int version) for (VECALBUMS::iterator it = albums.begin(); it != albums.end(); ++it) { - CStdString strSQL; + std::string strSQL; strSQL = PrepareSQL("UPDATE album_new SET strGenres='%s' WHERE idAlbum=%i", StringUtils::Join(it->genre, g_advancedSettings.m_musicItemSeparator).c_str(), it->idAlbum); m_pDS->exec(strSQL); } @@ -3700,7 +3699,7 @@ void CMusicDatabase::UpdateTables(int version) m_pDS->exec("INSERT INTO song_genre ( idGenre, idSong, iOrder) SELECT idGenre, idSong, iPosition FROM exgenresong"); m_pDS->exec("REPLACE INTO song_genre ( idGenre, idSong, iOrder) SELECT idGenre, idSong, 0 FROM song"); - CStdString strSQL; + std::string strSQL; strSQL=PrepareSQL("SELECT song.idSong AS idSong, strExtraGenres," " song.idGenre AS idGenre, strGenre FROM song " " JOIN genre ON song.idGenre=genre.idGenre"); @@ -3726,7 +3725,7 @@ void CMusicDatabase::UpdateTables(int version) for (VECSONGS::iterator it = songs.begin(); it != songs.end(); ++it) { - CStdString strSQL; + std::string strSQL; strSQL = PrepareSQL("UPDATE song_new SET strGenres='%s' WHERE idSong=%i", StringUtils::Join(it->genre, g_advancedSettings.m_musicItemSeparator).c_str(), it->idSong); m_pDS->exec(strSQL); } @@ -3904,7 +3903,7 @@ void CMusicDatabase::UpdateTables(int version) m_pDS->exec("ALTER TABLE album_artist ADD strArtist text\n"); m_pDS->exec("ALTER TABLE song_artist ADD strArtist text\n"); // populate these - CStdString sql = "select idArtist,strArtist from artist"; + std::string sql = "select idArtist,strArtist from artist"; m_pDS->query(sql.c_str()); while (!m_pDS->eof()) { @@ -3936,7 +3935,7 @@ unsigned int CMusicDatabase::GetSongIDs(const Filter &filter, vector<pair<int,in if (NULL == m_pDB.get()) return 0; if (NULL == m_pDS.get()) return 0; - CStdString strSQL = "select idSong from songview "; + std::string strSQL = "select idSong from songview "; if (!CDatabase::BuildSQL(strSQL, filter, strSQL)) return false; @@ -3970,7 +3969,7 @@ int CMusicDatabase::GetSongsCount(const Filter &filter) if (NULL == m_pDB.get()) return 0; if (NULL == m_pDS.get()) return 0; - CStdString strSQL = "select count(idSong) as NumSongs from songview "; + std::string strSQL = "select count(idSong) as NumSongs from songview "; if (!CDatabase::BuildSQL(strSQL, filter, strSQL)) return false; @@ -4026,11 +4025,11 @@ bool CMusicDatabase::GetAlbumPath(int idAlbum, std::string& path) return false; } -bool CMusicDatabase::SaveAlbumThumb(int idAlbum, const CStdString& strThumb) +bool CMusicDatabase::SaveAlbumThumb(int idAlbum, const std::string& strThumb) { SetArtForItem(idAlbum, MediaTypeAlbum, "thumb", strThumb); // TODO: We should prompt the user to update the art for songs - CStdString sql = PrepareSQL("UPDATE art" + std::string sql = PrepareSQL("UPDATE art" " SET url='-'" " WHERE media_type='song'" " AND type='thumb'" @@ -4099,14 +4098,14 @@ bool CMusicDatabase::GetArtistPath(int idArtist, std::string &basePath) return false; } -int CMusicDatabase::GetArtistByName(const CStdString& strArtist) +int CMusicDatabase::GetArtistByName(const std::string& strArtist) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL=PrepareSQL("select idArtist from artist where artist.strArtist like '%s'", strArtist.c_str()); + std::string strSQL=PrepareSQL("select idArtist from artist where artist.strArtist like '%s'", strArtist.c_str()); // run query if (!m_pDS->query(strSQL.c_str())) return false; @@ -4127,14 +4126,14 @@ int CMusicDatabase::GetArtistByName(const CStdString& strArtist) return -1; } -int CMusicDatabase::GetAlbumByName(const CStdString& strAlbum, const CStdString& strArtist) +int CMusicDatabase::GetAlbumByName(const std::string& strAlbum, const std::string& strArtist) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL; + std::string strSQL; if (strArtist.empty()) strSQL=PrepareSQL("SELECT idAlbum FROM album WHERE album.strAlbum LIKE '%s'", strAlbum.c_str()); else @@ -4156,34 +4155,34 @@ int CMusicDatabase::GetAlbumByName(const CStdString& strAlbum, const CStdString& return -1; } -int CMusicDatabase::GetAlbumByName(const CStdString& strAlbum, const std::vector<std::string>& artist) +int CMusicDatabase::GetAlbumByName(const std::string& strAlbum, const std::vector<std::string>& artist) { return GetAlbumByName(strAlbum, StringUtils::Join(artist, g_advancedSettings.m_musicItemSeparator)); } -CStdString CMusicDatabase::GetGenreById(int id) +std::string CMusicDatabase::GetGenreById(int id) { return GetSingleValue("genre", "strGenre", PrepareSQL("idGenre=%i", id)); } -CStdString CMusicDatabase::GetArtistById(int id) +std::string CMusicDatabase::GetArtistById(int id) { return GetSingleValue("artist", "strArtist", PrepareSQL("idArtist=%i", id)); } -CStdString CMusicDatabase::GetAlbumById(int id) +std::string CMusicDatabase::GetAlbumById(int id) { return GetSingleValue("album", "strAlbum", PrepareSQL("idAlbum=%i", id)); } -int CMusicDatabase::GetGenreByName(const CStdString& strGenre) +int CMusicDatabase::GetGenreByName(const std::string& strGenre) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL; + std::string strSQL; strSQL=PrepareSQL("select idGenre from genre where genre.strGenre like '%s'", strGenre.c_str()); // run query if (!m_pDS->query(strSQL.c_str())) return false; @@ -4212,7 +4211,7 @@ bool CMusicDatabase::GetRandomSong(CFileItem* item, int& idSong, const Filter &f if (NULL == m_pDS.get()) return false; // We don't use PrepareSQL here, as the WHERE clause is already formatted - CStdString strSQL = PrepareSQL("select %s from songview ", !filter.fields.empty() ? filter.fields.c_str() : "*"); + std::string strSQL = PrepareSQL("select %s from songview ", !filter.fields.empty() ? filter.fields.c_str() : "*"); Filter extFilter = filter; extFilter.AppendOrder(PrepareSQL("RANDOM()")); extFilter.limit = "1"; @@ -4242,7 +4241,7 @@ bool CMusicDatabase::GetRandomSong(CFileItem* item, int& idSong, const Filter &f return false; } -bool CMusicDatabase::GetCompilationAlbums(const CStdString& strBaseDir, CFileItemList& items) +bool CMusicDatabase::GetCompilationAlbums(const std::string& strBaseDir, CFileItemList& items) { CMusicDbUrl musicUrl; if (!musicUrl.FromString(strBaseDir)) @@ -4254,7 +4253,7 @@ bool CMusicDatabase::GetCompilationAlbums(const CStdString& strBaseDir, CFileIte return GetAlbumsByWhere(musicUrl.ToString(), filter, items); } -bool CMusicDatabase::GetCompilationSongs(const CStdString& strBaseDir, CFileItemList& items) +bool CMusicDatabase::GetCompilationSongs(const std::string& strBaseDir, CFileItemList& items) { CMusicDbUrl musicUrl; if (!musicUrl.FromString(strBaseDir)) @@ -4271,7 +4270,7 @@ int CMusicDatabase::GetCompilationAlbumsCount() return strtol(GetSingleValue("album", "count(idAlbum)", "bCompilation = 1").c_str(), NULL, 10); } -bool CMusicDatabase::SetPathHash(const CStdString &path, const CStdString &hash) +bool CMusicDatabase::SetPathHash(const std::string &path, const std::string &hash) { try { @@ -4287,7 +4286,7 @@ bool CMusicDatabase::SetPathHash(const CStdString &path, const CStdString &hash) int idPath = AddPath(path); if (idPath < 0) return false; - CStdString strSQL=PrepareSQL("update path set strHash='%s' where idPath=%ld", hash.c_str(), idPath); + std::string strSQL=PrepareSQL("update path set strHash='%s' where idPath=%ld", hash.c_str(), idPath); m_pDS->exec(strSQL.c_str()); return true; @@ -4300,14 +4299,14 @@ bool CMusicDatabase::SetPathHash(const CStdString &path, const CStdString &hash) return false; } -bool CMusicDatabase::GetPathHash(const CStdString &path, CStdString &hash) +bool CMusicDatabase::GetPathHash(const std::string &path, std::string &hash) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL=PrepareSQL("select strHash from path where strPath='%s'", path.c_str()); + std::string strSQL=PrepareSQL("select strHash from path where strPath='%s'", path.c_str()); m_pDS->query(strSQL.c_str()); if (m_pDS->num_rows() == 0) return false; @@ -4322,7 +4321,7 @@ bool CMusicDatabase::GetPathHash(const CStdString &path, CStdString &hash) return false; } -bool CMusicDatabase::RemoveSongsFromPath(const CStdString &path1, MAPSONGS& songs, bool exact) +bool CMusicDatabase::RemoveSongsFromPath(const std::string &path1, MAPSONGS& songs, bool exact) { // We need to remove all songs from this path, as their tags are going // to be re-read. We need to remove all songs from the song table + all links to them @@ -4350,7 +4349,7 @@ bool CMusicDatabase::RemoveSongsFromPath(const CStdString &path1, MAPSONGS& song // Note: when used to remove all songs from a path and its subpath (exact=false), this // does miss archived songs. - CStdString path(path1); + std::string path(path1); try { if (!URIUtils::HasSlashAtEnd(path)) @@ -4359,12 +4358,12 @@ bool CMusicDatabase::RemoveSongsFromPath(const CStdString &path1, MAPSONGS& song if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString where; + std::string where; if (exact) where = PrepareSQL(" where strPath='%s'", path.c_str()); else where = PrepareSQL(" where SUBSTR(strPath,1,%i)='%s'", StringUtils::utf8_strlen(path.c_str()), path.c_str()); - CStdString sql = "select * from songview" + where; + std::string sql = "select * from songview" + where; if (!m_pDS->query(sql.c_str())) return false; int iRowsFound = m_pDS->num_rows(); if (iRowsFound > 0) @@ -4432,7 +4431,7 @@ bool CMusicDatabase::GetPaths(set<string> &paths) return false; } -bool CMusicDatabase::SetSongRating(const CStdString &filePath, char rating) +bool CMusicDatabase::SetSongRating(const std::string &filePath, char rating) { try { @@ -4443,7 +4442,7 @@ bool CMusicDatabase::SetSongRating(const CStdString &filePath, char rating) int songID = GetSongIDFromPath(filePath); if (-1 == songID) return false; - CStdString sql = PrepareSQL("update song set rating='%c' where idSong = %i", rating, songID); + std::string sql = PrepareSQL("update song set rating='%c' where idSong = %i", rating, songID); m_pDS->exec(sql.c_str()); return true; } @@ -4454,13 +4453,13 @@ bool CMusicDatabase::SetSongRating(const CStdString &filePath, char rating) return false; } -int CMusicDatabase::GetSongIDFromPath(const CStdString &filePath) +int CMusicDatabase::GetSongIDFromPath(const std::string &filePath) { // grab the where string to identify the song id CURL url(filePath); if (url.IsProtocol("musicdb")) { - CStdString strFile=URIUtils::GetFileName(filePath); + std::string strFile=URIUtils::GetFileName(filePath); URIUtils::RemoveExtension(strFile); return atol(strFile.c_str()); } @@ -4470,11 +4469,11 @@ int CMusicDatabase::GetSongIDFromPath(const CStdString &filePath) if (NULL == m_pDB.get()) return -1; if (NULL == m_pDS.get()) return -1; - CStdString strPath, strFileName; + std::string strPath, strFileName; URIUtils::Split(filePath, strPath, strFileName); URIUtils::AddSlashAtEnd(strPath); - CStdString sql = PrepareSQL("select idSong from song join path on song.idPath = path.idPath where song.strFileName='%s' and path.strPath='%s'", strFileName.c_str(), strPath.c_str()); + std::string sql = PrepareSQL("select idSong from song join path on song.idPath = path.idPath where song.strFileName='%s' and path.strPath='%s'", strFileName.c_str(), strPath.c_str()); if (!m_pDS->query(sql.c_str())) return -1; if (m_pDS->num_rows() == 0) @@ -4504,7 +4503,7 @@ bool CMusicDatabase::CommitTransaction() return false; } -bool CMusicDatabase::SetScraperForPath(const CStdString& strPath, const ADDON::ScraperPtr& scraper) +bool CMusicDatabase::SetScraperForPath(const std::string& strPath, const ADDON::ScraperPtr& scraper) { try { @@ -4512,7 +4511,7 @@ bool CMusicDatabase::SetScraperForPath(const CStdString& strPath, const ADDON::S if (NULL == m_pDS.get()) return false; // wipe old settings - CStdString strSQL = PrepareSQL("delete from content where strPath='%s'",strPath.c_str()); + std::string strSQL = PrepareSQL("delete from content where strPath='%s'",strPath.c_str()); m_pDS->exec(strSQL.c_str()); // insert new settings @@ -4529,14 +4528,14 @@ bool CMusicDatabase::SetScraperForPath(const CStdString& strPath, const ADDON::S return false; } -bool CMusicDatabase::GetScraperForPath(const CStdString& strPath, ADDON::ScraperPtr& info, const ADDON::TYPE &type) +bool CMusicDatabase::GetScraperForPath(const std::string& strPath, ADDON::ScraperPtr& info, const ADDON::TYPE &type) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL = PrepareSQL("select * from content where strPath='%s'",strPath.c_str()); + std::string strSQL = PrepareSQL("select * from content where strPath='%s'",strPath.c_str()); m_pDS->query(strSQL.c_str()); if (m_pDS->eof()) // no info set for path - fallback logic commencing { @@ -4573,7 +4572,7 @@ bool CMusicDatabase::GetScraperForPath(const CStdString& strPath, ADDON::Scraper if (!m_pDS->eof()) { // try and ascertain scraper for this path CONTENT_TYPE content = ADDON::TranslateContent(m_pDS->fv("content.strContent").get_asString()); - CStdString scraperUUID = m_pDS->fv("content.strScraperPath").get_asString(); + std::string scraperUUID = m_pDS->fv("content.strScraperPath").get_asString(); if (content != CONTENT_NONE) { // content set, use pre configured or default scraper @@ -4619,14 +4618,14 @@ bool CMusicDatabase::GetScraperForPath(const CStdString& strPath, ADDON::Scraper return false; } -bool CMusicDatabase::ScraperInUse(const CStdString &scraperID) const +bool CMusicDatabase::ScraperInUse(const std::string &scraperID) const { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString sql = PrepareSQL("select count(1) from content where strScraperPath='%s'",scraperID.c_str()); + std::string sql = PrepareSQL("select count(1) from content where strScraperPath='%s'",scraperID.c_str()); if (!m_pDS->query(sql.c_str()) || m_pDS->num_rows() == 0) return false; bool found = m_pDS->fv(0).get_asInt() > 0; @@ -4640,7 +4639,7 @@ bool CMusicDatabase::ScraperInUse(const CStdString &scraperID) const return false; } -bool CMusicDatabase::GetItems(const CStdString &strBaseDir, CFileItemList &items, const Filter &filter /* = Filter() */, const SortDescription &sortDescription /* = SortDescription() */) +bool CMusicDatabase::GetItems(const std::string &strBaseDir, CFileItemList &items, const Filter &filter /* = Filter() */, const SortDescription &sortDescription /* = SortDescription() */) { CMusicDbUrl musicUrl; if (!musicUrl.FromString(strBaseDir)) @@ -4649,37 +4648,37 @@ bool CMusicDatabase::GetItems(const CStdString &strBaseDir, CFileItemList &items return GetItems(strBaseDir, musicUrl.GetType(), items, filter, sortDescription); } -bool CMusicDatabase::GetItems(const CStdString &strBaseDir, const CStdString &itemType, CFileItemList &items, const Filter &filter /* = Filter() */, const SortDescription &sortDescription /* = SortDescription() */) +bool CMusicDatabase::GetItems(const std::string &strBaseDir, const std::string &itemType, CFileItemList &items, const Filter &filter /* = Filter() */, const SortDescription &sortDescription /* = SortDescription() */) { - if (itemType.Equals("genres")) + if (StringUtils::EqualsNoCase(itemType, "genres")) return GetGenresNav(strBaseDir, items, filter); - else if (itemType.Equals("years")) + else if (StringUtils::EqualsNoCase(itemType, "years")) return GetYearsNav(strBaseDir, items, filter); - else if (itemType.Equals("artists")) + else if (StringUtils::EqualsNoCase(itemType, "artists")) return GetArtistsNav(strBaseDir, items, !CSettings::Get().GetBool("musiclibrary.showcompilationartists"), -1, -1, -1, filter, sortDescription); - else if (itemType.Equals("albums")) + else if (StringUtils::EqualsNoCase(itemType, "albums")) return GetAlbumsByWhere(strBaseDir, filter, items, sortDescription); - else if (itemType.Equals("songs")) + else if (StringUtils::EqualsNoCase(itemType, "songs")) return GetSongsByWhere(strBaseDir, filter, items, sortDescription); return false; } -CStdString CMusicDatabase::GetItemById(const CStdString &itemType, int id) +std::string CMusicDatabase::GetItemById(const std::string &itemType, int id) { - if (itemType.Equals("genres")) + if (StringUtils::EqualsNoCase(itemType, "genres")) return GetGenreById(id); - else if (itemType.Equals("years")) + else if (StringUtils::EqualsNoCase(itemType, "years")) return StringUtils::Format("%d", id); - else if (itemType.Equals("artists")) + else if (StringUtils::EqualsNoCase(itemType, "artists")) return GetArtistById(id); - else if (itemType.Equals("albums")) + else if (StringUtils::EqualsNoCase(itemType, "albums")) return GetAlbumById(id); return ""; } -void CMusicDatabase::ExportToXML(const CStdString &xmlFile, bool singleFiles, bool images, bool overwrite) +void CMusicDatabase::ExportToXML(const std::string &xmlFile, bool singleFiles, bool images, bool overwrite) { try { @@ -4689,7 +4688,7 @@ void CMusicDatabase::ExportToXML(const CStdString &xmlFile, bool singleFiles, bo // find all albums vector<int> albumIds; - CStdString sql = "select idAlbum FROM album WHERE lastScraped IS NOT NULL"; + std::string sql = "select idAlbum FROM album WHERE lastScraped IS NOT NULL"; m_pDS->query(sql.c_str()); int total = m_pDS->num_rows(); @@ -4731,7 +4730,7 @@ void CMusicDatabase::ExportToXML(const CStdString &xmlFile, bool singleFiles, bo { CAlbum album; GetAlbum(*albumId, album); - CStdString strPath; + std::string strPath; GetAlbumPath(*albumId, strPath); album.Save(pMain, "album", strPath); if (singleFiles) @@ -4740,7 +4739,7 @@ void CMusicDatabase::ExportToXML(const CStdString &xmlFile, bool singleFiles, bo CLog::Log(LOGDEBUG, "%s - Not exporting item %s as it does not exist", __FUNCTION__, strPath.c_str()); else { - CStdString nfoFile = URIUtils::AddFileToFolder(strPath, "album.nfo"); + std::string nfoFile = URIUtils::AddFileToFolder(strPath, "album.nfo"); if (overwrite || !CFile::Exists(nfoFile)) { if (!xmlDoc.SaveFile(nfoFile)) @@ -4776,7 +4775,7 @@ void CMusicDatabase::ExportToXML(const CStdString &xmlFile, bool singleFiles, bo // find all artists vector<int> artistIds; - CStdString artistSQL = "SELECT idArtist FROM artist where lastScraped IS NOT NULL"; + std::string artistSQL = "SELECT idArtist FROM artist where lastScraped IS NOT NULL"; m_pDS->query(artistSQL.c_str()); total = m_pDS->num_rows(); current = 0; @@ -4792,7 +4791,7 @@ void CMusicDatabase::ExportToXML(const CStdString &xmlFile, bool singleFiles, bo { CArtist artist; GetArtist(*artistId, artist); - CStdString strPath; + std::string strPath; GetArtistPath(artist.idArtist,strPath); artist.Save(pMain, "artist", strPath); @@ -4810,7 +4809,7 @@ void CMusicDatabase::ExportToXML(const CStdString &xmlFile, bool singleFiles, bo CLog::Log(LOGDEBUG, "%s - Not exporting item %s as it does not exist", __FUNCTION__, strPath.c_str()); else { - CStdString nfoFile = URIUtils::AddFileToFolder(strPath, "artist.nfo"); + std::string nfoFile = URIUtils::AddFileToFolder(strPath, "artist.nfo"); if (overwrite || !CFile::Exists(nfoFile)) { if (!xmlDoc.SaveFile(nfoFile)) @@ -4819,8 +4818,8 @@ void CMusicDatabase::ExportToXML(const CStdString &xmlFile, bool singleFiles, bo if (images && !artwork.empty()) { - CStdString savedThumb = URIUtils::AddFileToFolder(strPath,"folder.jpg"); - CStdString savedFanart = URIUtils::AddFileToFolder(strPath,"fanart.jpg"); + std::string savedThumb = URIUtils::AddFileToFolder(strPath,"folder.jpg"); + std::string savedFanart = URIUtils::AddFileToFolder(strPath,"fanart.jpg"); if (artwork.find("thumb") != artwork.end() && (overwrite || !CFile::Exists(savedThumb))) CTextureCache::Get().Export(artwork["thumb"], savedThumb); if (artwork.find("fanart") != artwork.end() && (overwrite || !CFile::Exists(savedFanart))) @@ -4858,7 +4857,7 @@ void CMusicDatabase::ExportToXML(const CStdString &xmlFile, bool singleFiles, bo } } -void CMusicDatabase::ImportFromXML(const CStdString &xmlFile) +void CMusicDatabase::ImportFromXML(const std::string &xmlFile) { CGUIDialogProgress *progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); try @@ -4900,7 +4899,7 @@ void CMusicDatabase::ImportFromXML(const CStdString &xmlFile) entry = root->FirstChildElement(); while (entry) { - CStdString strTitle; + std::string strTitle; if (strnicmp(entry->Value(), "artist", 6) == 0) { CArtist importedArtist; @@ -4964,12 +4963,12 @@ void CMusicDatabase::AddKaraokeData(int idSong, int iKaraokeNumber) { try { - CStdString strSQL; + std::string strSQL; // If song.iKaraokeNumber is non-zero, we already have it in the database. Just replace the song ID. if (iKaraokeNumber > 0) { - CStdString strSQL = PrepareSQL("UPDATE karaokedata SET idSong=%i WHERE iKaraNumber=%i", idSong, iKaraokeNumber); + std::string strSQL = PrepareSQL("UPDATE karaokedata SET idSong=%i WHERE iKaraNumber=%i", idSong, iKaraokeNumber); m_pDS->exec(strSQL.c_str()); return; } @@ -5003,7 +5002,7 @@ bool CMusicDatabase::GetSongByKaraokeNumber(int number, CSong & song) if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL=PrepareSQL("SELECT * FROM karaokedata where iKaraNumber=%ld", number); + std::string strSQL=PrepareSQL("SELECT * FROM karaokedata where iKaraNumber=%ld", number); if (!m_pDS->query(strSQL.c_str())) return false; if (m_pDS->num_rows() == 0) @@ -5025,7 +5024,7 @@ bool CMusicDatabase::GetSongByKaraokeNumber(int number, CSong & song) return false; } -void CMusicDatabase::ExportKaraokeInfo(const CStdString & outFile, bool asHTML) +void CMusicDatabase::ExportKaraokeInfo(const std::string & outFile, bool asHTML) { try { @@ -5033,7 +5032,7 @@ void CMusicDatabase::ExportKaraokeInfo(const CStdString & outFile, bool asHTML) if (NULL == m_pDS.get()) return; // find all karaoke songs - CStdString sql = "SELECT * FROM songview WHERE iKaraNumber > 0 ORDER BY strFileName"; + std::string sql = "SELECT * FROM songview WHERE iKaraNumber > 0 ORDER BY strFileName"; m_pDS->query(sql.c_str()); @@ -5064,27 +5063,27 @@ void CMusicDatabase::ExportKaraokeInfo(const CStdString & outFile, bool asHTML) progress->ShowProgressBar(true); } - CStdString outdoc; + std::string outdoc; if ( asHTML ) { outdoc = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></meta></head>\n" "<body>\n<table>\n"; - if (file.Write(outdoc, outdoc.size()) != outdoc.size()) + if (file.Write(outdoc.c_str(), outdoc.size()) != outdoc.size()) return; // error } while (!m_pDS->eof()) { CSong song = GetSongFromDataset(); - CStdString songnum = StringUtils::Format("%06ld", song.iKaraokeNumber); + std::string songnum = StringUtils::Format("%06ld", song.iKaraokeNumber); if ( asHTML ) - outdoc = "<tr><td>" + songnum + "</td><td>" + (CStdString)StringUtils::Join(song.artist, g_advancedSettings.m_musicItemSeparator) + "</td><td>" + song.strTitle + "</td></tr>\r\n"; + outdoc = "<tr><td>" + songnum + "</td><td>" + StringUtils::Join(song.artist, g_advancedSettings.m_musicItemSeparator) + "</td><td>" + song.strTitle + "</td></tr>\r\n"; else - outdoc = songnum + '\t' + (CStdString)StringUtils::Join(song.artist, g_advancedSettings.m_musicItemSeparator) + '\t' + song.strTitle + '\t' + song.strFileName + "\r\n"; + outdoc = songnum + '\t' + StringUtils::Join(song.artist, g_advancedSettings.m_musicItemSeparator) + '\t' + song.strTitle + '\t' + song.strFileName + "\r\n"; - if (file.Write(outdoc, outdoc.size()) != outdoc.size()) + if (file.Write(outdoc.c_str(), outdoc.size()) != outdoc.size()) return; // error if ((current % 50) == 0 && progress) @@ -5107,7 +5106,7 @@ void CMusicDatabase::ExportKaraokeInfo(const CStdString & outFile, bool asHTML) if ( asHTML ) { outdoc = "</table>\n</body>\n</html>\n"; - if (file.Write(outdoc, outdoc.size()) != outdoc.size()) + if (file.Write(outdoc.c_str(), outdoc.size()) != outdoc.size()) return; // error } @@ -5122,7 +5121,7 @@ void CMusicDatabase::ExportKaraokeInfo(const CStdString & outFile, bool asHTML) } } -void CMusicDatabase::ImportKaraokeInfo(const CStdString & inputFile) +void CMusicDatabase::ImportKaraokeInfo(const std::string & inputFile) { CGUIDialogProgress *progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); @@ -5213,7 +5212,7 @@ void CMusicDatabase::ImportKaraokeInfo(const CStdString & inputFile) } linestart = p + 1; - CStdString strSQL=PrepareSQL("select idSong from songview " + std::string strSQL=PrepareSQL("select idSong from songview " "where strArtists like '%s' and strTitle like '%s'", artist, title ); if ( !m_pDS->query(strSQL.c_str()) ) @@ -5273,7 +5272,7 @@ bool CMusicDatabase::SetKaraokeSongDelay(int idSong, int delay) if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL = PrepareSQL("UPDATE karaokedata SET iKaraDelay=%i WHERE idSong=%i", delay, idSong); + std::string strSQL = PrepareSQL("UPDATE karaokedata SET iKaraDelay=%i WHERE idSong=%i", delay, idSong); m_pDS->exec(strSQL.c_str()); return true; @@ -5391,7 +5390,7 @@ void CMusicDatabase::SetArtForItem(int mediaId, const string &mediaType, const s if (artType.find('.') != string::npos) return; - CStdString sql = PrepareSQL("SELECT art_id FROM art WHERE media_id=%i AND media_type='%s' AND type='%s'", mediaId, mediaType.c_str(), artType.c_str()); + std::string sql = PrepareSQL("SELECT art_id FROM art WHERE media_id=%i AND media_type='%s' AND type='%s'", mediaId, mediaType.c_str(), artType.c_str()); m_pDS->query(sql.c_str()); if (!m_pDS->eof()) { // update @@ -5420,7 +5419,7 @@ bool CMusicDatabase::GetArtForItem(int mediaId, const string &mediaType, map<str if (NULL == m_pDB.get()) return false; if (NULL == m_pDS2.get()) return false; // using dataset 2 as we're likely called in loops on dataset 1 - CStdString sql = PrepareSQL("SELECT type,url FROM art WHERE media_id=%i AND media_type='%s'", mediaId, mediaType.c_str()); + std::string sql = PrepareSQL("SELECT type,url FROM art WHERE media_id=%i AND media_type='%s'", mediaId, mediaType.c_str()); m_pDS2->query(sql.c_str()); while (!m_pDS2->eof()) { @@ -5450,7 +5449,7 @@ bool CMusicDatabase::GetArtistArtForItem(int mediaId, const std::string &mediaTy if (NULL == m_pDB.get()) return false; if (NULL == m_pDS2.get()) return false; // using dataset 2 as we're likely called in loops on dataset 1 - CStdString sql = PrepareSQL("SELECT type,url FROM art WHERE media_id=(SELECT idArtist from %s_artist WHERE id%s=%i AND iOrder=0) AND media_type='artist'", mediaType.c_str(), mediaType.c_str(), mediaId); + std::string sql = PrepareSQL("SELECT type,url FROM art WHERE media_id=(SELECT idArtist from %s_artist WHERE id%s=%i AND iOrder=0) AND media_type='artist'", mediaType.c_str(), mediaType.c_str(), mediaId); m_pDS2->query(sql.c_str()); while (!m_pDS2->eof()) { @@ -5519,7 +5518,7 @@ bool CMusicDatabase::GetFilter(CDbUrl &musicUrl, Filter &filter, SortDescription if (option != options.end()) albumArtistsOnly = option->second.asBoolean(); - CStdString strSQL = "(artistview.idArtist IN "; + std::string strSQL = "(artistview.idArtist IN "; if (idArtist > 0) strSQL += PrepareSQL("(%d)", idArtist); else if (idAlbum > 0) @@ -5558,7 +5557,7 @@ bool CMusicDatabase::GetFilter(CDbUrl &musicUrl, Filter &filter, SortDescription // and the various artist entry if applicable if (!albumArtistsOnly) { - CStdString strVariousArtists = g_localizeStrings.Get(340); + std::string strVariousArtists = g_localizeStrings.Get(340); strSQL += PrepareSQL(" and artistview.strArtist <> '%s'", strVariousArtists.c_str()); } diff --git a/xbmc/music/MusicDatabase.h b/xbmc/music/MusicDatabase.h index 3f68055155..52d08b69e7 100644 --- a/xbmc/music/MusicDatabase.h +++ b/xbmc/music/MusicDatabase.h @@ -38,6 +38,7 @@ namespace dbiplus } #include <set> +#include <string> // return codes of Cleaning up the Database // numbers are strings from strings.xml @@ -56,17 +57,17 @@ namespace dbiplus /*! \ingroup music - \brief A set of CStdString objects, used for CMusicDatabase + \brief A set of std::string objects, used for CMusicDatabase \sa ISETPATHES, CMusicDatabase */ -typedef std::set<CStdString> SETPATHES; +typedef std::set<std::string> SETPATHES; /*! \ingroup music \brief The SETPATHES iterator \sa SETPATHES, CMusicDatabase */ -typedef std::set<CStdString>::iterator ISETPATHES; +typedef std::set<std::string>::iterator ISETPATHES; class CGUIDialogProgress; class CFileItemList; @@ -125,11 +126,11 @@ public: \return the id of the song */ int AddSong(const int idAlbum, - const CStdString& strTitle, - const CStdString& strMusicBrainzTrackID, - const CStdString& strPathAndFileName, - const CStdString& strComment, - const CStdString& strThumb, + const std::string& strTitle, + const std::string& strMusicBrainzTrackID, + const std::string& strPathAndFileName, + const std::string& strComment, + const std::string& strThumb, const std::string &artistString, const std::vector<std::string>& genres, int iTrack, int iDuration, int iYear, const int iTimesPlayed, int iStartOffset, int iEndOffset, @@ -171,9 +172,9 @@ public: \return the id of the song */ int UpdateSong(int idSong, - const CStdString& strTitle, const CStdString& strMusicBrainzTrackID, - const CStdString& strPathAndFileName, const CStdString& strComment, - const CStdString& strThumb, + const std::string& strTitle, const std::string& strMusicBrainzTrackID, + const std::string& strPathAndFileName, const std::string& strComment, + const std::string& strThumb, const std::string& artistString, const std::vector<std::string>& genres, int iTrack, int iDuration, int iYear, int iTimesPlayed, int iStartOffset, int iEndOffset, @@ -181,12 +182,12 @@ public: char rating, int iKaraokeNumber); //// Misc Song - bool GetSongByFileName(const CStdString& strFileName, CSong& song, int startOffset = 0); - bool GetSongsByPath(const CStdString& strPath, MAPSONGS& songs, bool bAppendToMap = false); - bool Search(const CStdString& search, CFileItemList &items); - bool RemoveSongsFromPath(const CStdString &path, MAPSONGS& songs, bool exact=true); - bool SetSongRating(const CStdString &filePath, char rating); - int GetSongByArtistAndAlbumAndTitle(const CStdString& strArtist, const CStdString& strAlbum, const CStdString& strTitle); + bool GetSongByFileName(const std::string& strFileName, CSong& song, int startOffset = 0); + bool GetSongsByPath(const std::string& strPath, MAPSONGS& songs, bool bAppendToMap = false); + bool Search(const std::string& search, CFileItemList &items); + bool RemoveSongsFromPath(const std::string &path, MAPSONGS& songs, bool exact=true); + bool SetSongRating(const std::string &filePath, char rating); + int GetSongByArtistAndAlbumAndTitle(const std::string& strArtist, const std::string& strAlbum, const std::string& strTitle); ///////////////////////////////////////////////// // Album @@ -203,8 +204,8 @@ public: \param songIDs [out] the ids of the added songs \return the id of the album */ - int AddAlbum(const CStdString& strAlbum, const CStdString& strMusicBrainzAlbumID, - const CStdString& strArtist, const CStdString& strGenre, + int AddAlbum(const std::string& strAlbum, const std::string& strMusicBrainzAlbumID, + const std::string& strArtist, const std::string& strGenre, int year, bool bCompilation); /*! \brief retrieve an album, optionally with all songs. \param idAlbum the database id of the album. @@ -215,12 +216,12 @@ public: bool GetAlbum(int idAlbum, CAlbum& album, bool getSongs = true); int UpdateAlbum(int idAlbum, const CAlbum &album); int UpdateAlbum(int idAlbum, - const CStdString& strAlbum, const CStdString& strMusicBrainzAlbumID, - const CStdString& strArtist, const CStdString& strGenre, - const CStdString& strMoods, const CStdString& strStyles, - const CStdString& strThemes, const CStdString& strReview, - const CStdString& strImage, const CStdString& strLabel, - const CStdString& strType, + const std::string& strAlbum, const std::string& strMusicBrainzAlbumID, + const std::string& strArtist, const std::string& strGenre, + const std::string& strMoods, const std::string& strStyles, + const std::string& strThemes, const std::string& strReview, + const std::string& strImage, const std::string& strLabel, + const std::string& strType, int iRating, int iYear, bool bCompilation); bool ClearAlbumLastScrapedTime(int idAlbum); bool HasAlbumBeenScraped(int idAlbum); @@ -229,55 +230,55 @@ public: /*! \brief Checks if the given path is inside a folder that has already been scanned into the library \param path the path we want to check */ - bool InsideScannedPath(const CStdString& path); + bool InsideScannedPath(const std::string& path); //// Misc Album - int GetAlbumIdByPath(const CStdString& path); + int GetAlbumIdByPath(const std::string& path); bool GetAlbumFromSong(int idSong, CAlbum &album); - int GetAlbumByName(const CStdString& strAlbum, const CStdString& strArtist=""); - int GetAlbumByName(const CStdString& strAlbum, const std::vector<std::string>& artist); - CStdString GetAlbumById(int id); + int GetAlbumByName(const std::string& strAlbum, const std::string& strArtist=""); + int GetAlbumByName(const std::string& strAlbum, const std::vector<std::string>& artist); + std::string GetAlbumById(int id); ///////////////////////////////////////////////// // Artist CRUD ///////////////////////////////////////////////// bool UpdateArtist(const CArtist& artist); - int AddArtist(const CStdString& strArtist, const CStdString& strMusicBrainzArtistID); + int AddArtist(const std::string& strArtist, const std::string& strMusicBrainzArtistID); bool GetArtist(int idArtist, CArtist& artist, bool fetchAll = true); int UpdateArtist(int idArtist, - const CStdString& strArtist, const CStdString& strMusicBrainzArtistID, - const CStdString& strBorn, const CStdString& strFormed, - const CStdString& strGenres, const CStdString& strMoods, - const CStdString& strStyles, const CStdString& strInstruments, - const CStdString& strBiography, const CStdString& strDied, - const CStdString& strDisbanded, const CStdString& strYearsActive, - const CStdString& strImage, const CStdString& strFanart); + const std::string& strArtist, const std::string& strMusicBrainzArtistID, + const std::string& strBorn, const std::string& strFormed, + const std::string& strGenres, const std::string& strMoods, + const std::string& strStyles, const std::string& strInstruments, + const std::string& strBiography, const std::string& strDied, + const std::string& strDisbanded, const std::string& strYearsActive, + const std::string& strImage, const std::string& strFanart); bool HasArtistBeenScraped(int idArtist); bool ClearArtistLastScrapedTime(int idArtist); - int AddArtistDiscography(int idArtist, const CStdString& strAlbum, const CStdString& strYear); + int AddArtistDiscography(int idArtist, const std::string& strAlbum, const std::string& strYear); bool DeleteArtistDiscography(int idArtist); - CStdString GetArtistById(int id); - int GetArtistByName(const CStdString& strArtist); + std::string GetArtistById(int id); + int GetArtistByName(const std::string& strArtist); ///////////////////////////////////////////////// // Paths ///////////////////////////////////////////////// - int AddPath(const CStdString& strPath); + int AddPath(const std::string& strPath); bool GetPaths(std::set<std::string> &paths); - bool SetPathHash(const CStdString &path, const CStdString &hash); - bool GetPathHash(const CStdString &path, CStdString &hash); + bool SetPathHash(const std::string &path, const std::string &hash); + bool GetPathHash(const std::string &path, std::string &hash); bool GetAlbumPath(int idAlbum, std::string &path); bool GetArtistPath(int idArtist, std::string &path); ///////////////////////////////////////////////// // Genres ///////////////////////////////////////////////// - int AddGenre(const CStdString& strGenre); - CStdString GetGenreById(int id); - int GetGenreByName(const CStdString& strGenre); + int AddGenre(const std::string& strGenre); + std::string GetGenreById(int id); + int GetGenreByName(const std::string& strGenre); ///////////////////////////////////////////////// // Link tables @@ -303,26 +304,26 @@ public: ///////////////////////////////////////////////// // Top 100 ///////////////////////////////////////////////// - bool GetTop100(const CStdString& strBaseDir, CFileItemList& items); + bool GetTop100(const std::string& strBaseDir, CFileItemList& items); bool GetTop100Albums(VECALBUMS& albums); - bool GetTop100AlbumSongs(const CStdString& strBaseDir, CFileItemList& item); + bool GetTop100AlbumSongs(const std::string& strBaseDir, CFileItemList& item); ///////////////////////////////////////////////// // Recently added ///////////////////////////////////////////////// bool GetRecentlyAddedAlbums(VECALBUMS& albums, unsigned int limit=0); - bool GetRecentlyAddedAlbumSongs(const CStdString& strBaseDir, CFileItemList& item, unsigned int limit=0); + bool GetRecentlyAddedAlbumSongs(const std::string& strBaseDir, CFileItemList& item, unsigned int limit=0); bool GetRecentlyPlayedAlbums(VECALBUMS& albums); - bool GetRecentlyPlayedAlbumSongs(const CStdString& strBaseDir, CFileItemList& item); + bool GetRecentlyPlayedAlbumSongs(const std::string& strBaseDir, CFileItemList& item); ///////////////////////////////////////////////// // Compilations ///////////////////////////////////////////////// - bool GetCompilationAlbums(const CStdString& strBaseDir, CFileItemList& items); - bool GetCompilationSongs(const CStdString& strBaseDir, CFileItemList& items); + bool GetCompilationAlbums(const std::string& strBaseDir, CFileItemList& items); + bool GetCompilationSongs(const std::string& strBaseDir, CFileItemList& items); int GetCompilationAlbumsCount(); - bool GetVariousArtistsAlbums(const CStdString& strBaseDir, CFileItemList& items); - bool GetVariousArtistsAlbumsSongs(const CStdString& strBaseDir, CFileItemList& items); + bool GetVariousArtistsAlbums(const std::string& strBaseDir, CFileItemList& items); + bool GetVariousArtistsAlbumsSongs(const std::string& strBaseDir, CFileItemList& items); int GetVariousArtistsAlbumsCount(); /*! \brief Increment the playcount of an item @@ -335,19 +336,19 @@ public: ///////////////////////////////////////////////// // VIEWS ///////////////////////////////////////////////// - bool GetGenresNav(const CStdString& strBaseDir, CFileItemList& items, const Filter &filter = Filter(), bool countOnly = false); - bool GetYearsNav(const CStdString& strBaseDir, CFileItemList& items, const Filter &filter = Filter()); - bool GetArtistsNav(const CStdString& strBaseDir, CFileItemList& items, bool albumArtistsOnly = false, int idGenre = -1, int idAlbum = -1, int idSong = -1, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription(), bool countOnly = false); - bool GetCommonNav(const CStdString &strBaseDir, const CStdString &table, const CStdString &labelField, CFileItemList &items, const Filter &filter /* = Filter() */, bool countOnly /* = false */); - bool GetAlbumTypesNav(const CStdString &strBaseDir, CFileItemList &items, const Filter &filter = Filter(), bool countOnly = false); - bool GetMusicLabelsNav(const CStdString &strBaseDir, CFileItemList &items, const Filter &filter = Filter(), bool countOnly = false); - bool GetAlbumsNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre = -1, int idArtist = -1, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription(), bool countOnly = false); - bool GetAlbumsByYear(const CStdString &strBaseDir, CFileItemList& items, int year); - bool GetSongsNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre, int idArtist,int idAlbum, const SortDescription &sortDescription = SortDescription()); - bool GetSongsByYear(const CStdString& baseDir, CFileItemList& items, int year); - bool GetSongsByWhere(const CStdString &baseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription = SortDescription()); - bool GetAlbumsByWhere(const CStdString &baseDir, const Filter &filter, CFileItemList &items, const SortDescription &sortDescription = SortDescription(), bool countOnly = false); - bool GetArtistsByWhere(const CStdString& strBaseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription = SortDescription(), bool countOnly = false); + bool GetGenresNav(const std::string& strBaseDir, CFileItemList& items, const Filter &filter = Filter(), bool countOnly = false); + bool GetYearsNav(const std::string& strBaseDir, CFileItemList& items, const Filter &filter = Filter()); + bool GetArtistsNav(const std::string& strBaseDir, CFileItemList& items, bool albumArtistsOnly = false, int idGenre = -1, int idAlbum = -1, int idSong = -1, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription(), bool countOnly = false); + bool GetCommonNav(const std::string &strBaseDir, const std::string &table, const std::string &labelField, CFileItemList &items, const Filter &filter /* = Filter() */, bool countOnly /* = false */); + bool GetAlbumTypesNav(const std::string &strBaseDir, CFileItemList &items, const Filter &filter = Filter(), bool countOnly = false); + bool GetMusicLabelsNav(const std::string &strBaseDir, CFileItemList &items, const Filter &filter = Filter(), bool countOnly = false); + bool GetAlbumsNav(const std::string& strBaseDir, CFileItemList& items, int idGenre = -1, int idArtist = -1, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription(), bool countOnly = false); + bool GetAlbumsByYear(const std::string &strBaseDir, CFileItemList& items, int year); + bool GetSongsNav(const std::string& strBaseDir, CFileItemList& items, int idGenre, int idArtist,int idAlbum, const SortDescription &sortDescription = SortDescription()); + bool GetSongsByYear(const std::string& baseDir, CFileItemList& items, int year); + bool GetSongsByWhere(const std::string &baseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription = SortDescription()); + bool GetAlbumsByWhere(const std::string &baseDir, const Filter &filter, CFileItemList &items, const SortDescription &sortDescription = SortDescription(), bool countOnly = false); + bool GetArtistsByWhere(const std::string& strBaseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription = SortDescription(), bool countOnly = false); bool GetRandomSong(CFileItem* item, int& idSong, const Filter &filter); int GetSongsCount(const Filter &filter = Filter()); unsigned int GetSongIDs(const Filter &filter, std::vector<std::pair<int,int> > &songIDs); @@ -356,14 +357,14 @@ public: ///////////////////////////////////////////////// // Scraper ///////////////////////////////////////////////// - bool SetScraperForPath(const CStdString& strPath, const ADDON::ScraperPtr& info); - bool GetScraperForPath(const CStdString& strPath, ADDON::ScraperPtr& info, const ADDON::TYPE &type); + bool SetScraperForPath(const std::string& strPath, const ADDON::ScraperPtr& info); + bool GetScraperForPath(const std::string& strPath, ADDON::ScraperPtr& info, const ADDON::TYPE &type); /*! \brief Check whether a given scraper is in use. \param scraperID the scraper to check for. \return true if the scraper is in use, false otherwise. */ - bool ScraperInUse(const CStdString &scraperID) const; + bool ScraperInUse(const std::string &scraperID) const; ///////////////////////////////////////////////// // Karaoke @@ -372,21 +373,21 @@ public: bool GetSongByKaraokeNumber( int number, CSong& song ); bool SetKaraokeSongDelay( int idSong, int delay ); int GetKaraokeSongsCount(); - void ExportKaraokeInfo(const CStdString &outFile, bool asHTML ); - void ImportKaraokeInfo(const CStdString &inputFile ); + void ExportKaraokeInfo(const std::string &outFile, bool asHTML ); + void ImportKaraokeInfo(const std::string &inputFile ); ///////////////////////////////////////////////// // Filters ///////////////////////////////////////////////// - bool GetItems(const CStdString &strBaseDir, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription()); - bool GetItems(const CStdString &strBaseDir, const CStdString &itemType, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription()); - CStdString GetItemById(const CStdString &itemType, int id); + bool GetItems(const std::string &strBaseDir, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription()); + bool GetItems(const std::string &strBaseDir, const std::string &itemType, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription()); + std::string GetItemById(const std::string &itemType, int id); ///////////////////////////////////////////////// // XML ///////////////////////////////////////////////// - void ExportToXML(const CStdString &xmlFile, bool singleFiles = false, bool images=false, bool overwrite=false); - void ImportFromXML(const CStdString &xmlFile); + void ExportToXML(const std::string &xmlFile, bool singleFiles = false, bool images=false, bool overwrite=false); + void ImportFromXML(const std::string &xmlFile); ///////////////////////////////////////////////// // Properties @@ -398,7 +399,7 @@ public: ///////////////////////////////////////////////// // Art ///////////////////////////////////////////////// - bool SaveAlbumThumb(int idAlbum, const CStdString &thumb); + bool SaveAlbumThumb(int idAlbum, const std::string &thumb); /*! \brief Sets art for a database item. Sets a single piece of art for a database item. \param mediaId the id in the media (song/artist/album) table. @@ -459,11 +460,11 @@ public: std::string GetArtistArtForItem(int mediaId, const std::string &mediaType, const std::string &artType); protected: - std::map<CStdString, int> m_artistCache; - std::map<CStdString, int> m_genreCache; - std::map<CStdString, int> m_pathCache; - std::map<CStdString, int> m_thumbCache; - std::map<CStdString, CAlbum> m_albumCache; + std::map<std::string, int> m_artistCache; + std::map<std::string, int> m_genreCache; + std::map<std::string, int> m_pathCache; + std::map<std::string, int> m_thumbCache; + std::map<std::string, CAlbum> m_albumCache; virtual void CreateTables(); virtual void CreateAnalytics(); @@ -489,16 +490,16 @@ private: void GetFileItemFromDataset(const dbiplus::sql_record* const record, CFileItem* item, const CMusicDbUrl &baseUrl); CSong GetAlbumInfoSongFromDataset(const dbiplus::sql_record* const record, int offset = 0); bool CleanupSongs(); - bool CleanupSongsByIds(const CStdString &strSongIds); + bool CleanupSongsByIds(const std::string &strSongIds); bool CleanupPaths(); bool CleanupAlbums(); bool CleanupArtists(); bool CleanupGenres(); virtual void UpdateTables(int version); - bool SearchArtists(const CStdString& search, CFileItemList &artists); - bool SearchAlbums(const CStdString& search, CFileItemList &albums); - bool SearchSongs(const CStdString& strSearch, CFileItemList &songs); - int GetSongIDFromPath(const CStdString &filePath); + bool SearchArtists(const std::string& search, CFileItemList &artists); + bool SearchAlbums(const std::string& search, CFileItemList &albums); + bool SearchSongs(const std::string& strSearch, CFileItemList &songs); + int GetSongIDFromPath(const std::string &filePath); // Fields should be ordered as they // appear in the songview diff --git a/xbmc/music/MusicDbUrl.cpp b/xbmc/music/MusicDbUrl.cpp index 9fd509aca9..48612c2679 100644 --- a/xbmc/music/MusicDbUrl.cpp +++ b/xbmc/music/MusicDbUrl.cpp @@ -41,7 +41,7 @@ bool CMusicDbUrl::parse() if (!m_url.IsProtocol("musicdb") || m_url.GetFileName().empty()) return false; - CStdString path = m_url.Get(); + std::string path = m_url.Get(); NODE_TYPE dirType = CMusicDatabaseDirectory::GetDirectoryType(path); NODE_TYPE childType = CMusicDatabaseDirectory::GetDirectoryChildType(path); diff --git a/xbmc/music/MusicInfoLoader.cpp b/xbmc/music/MusicInfoLoader.cpp index a5705f5506..00834c087f 100644 --- a/xbmc/music/MusicInfoLoader.cpp +++ b/xbmc/music/MusicInfoLoader.cpp @@ -89,7 +89,7 @@ bool CMusicInfoLoader::LoadAdditionalTagInfo(CFileItem* pItem) if (pItem->GetProperty("hasfullmusictag") == "true") return false; // already have the information - CStdString path(pItem->GetPath()); + std::string path(pItem->GetPath()); if (pItem->IsMusicDb()) { // set the artist / album properties @@ -163,7 +163,7 @@ bool CMusicInfoLoader::LoadItemLookup(CFileItem* pItem) } else { - CStdString strPath = URIUtils::GetDirectory(pItem->GetPath()); + std::string strPath = URIUtils::GetDirectory(pItem->GetPath()); URIUtils::AddSlashAtEnd(strPath); if (strPath!=m_strPrevPath) { @@ -230,12 +230,12 @@ void CMusicInfoLoader::OnLoaderFinish() m_thumbLoader->OnLoaderFinish(); } -void CMusicInfoLoader::UseCacheOnHD(const CStdString& strFileName) +void CMusicInfoLoader::UseCacheOnHD(const std::string& strFileName) { m_strCacheFileName = strFileName; } -void CMusicInfoLoader::LoadCache(const CStdString& strFileName, CFileItemList& items) +void CMusicInfoLoader::LoadCache(const std::string& strFileName, CFileItemList& items) { CFile file; @@ -256,7 +256,7 @@ void CMusicInfoLoader::LoadCache(const CStdString& strFileName, CFileItemList& i } } -void CMusicInfoLoader::SaveCache(const CStdString& strFileName, CFileItemList& items) +void CMusicInfoLoader::SaveCache(const std::string& strFileName, CFileItemList& items) { int iSize = items.Size(); diff --git a/xbmc/music/MusicInfoLoader.h b/xbmc/music/MusicInfoLoader.h index 4d822571c8..e0e4eed6a7 100644 --- a/xbmc/music/MusicInfoLoader.h +++ b/xbmc/music/MusicInfoLoader.h @@ -32,7 +32,7 @@ public: CMusicInfoLoader(); virtual ~CMusicInfoLoader(); - void UseCacheOnHD(const CStdString& strFileName); + void UseCacheOnHD(const std::string& strFileName); virtual bool LoadItem(CFileItem* pItem); virtual bool LoadItemCached(CFileItem* pItem); virtual bool LoadItemLookup(CFileItem* pItem); @@ -41,13 +41,13 @@ public: protected: virtual void OnLoaderStart(); virtual void OnLoaderFinish(); - void LoadCache(const CStdString& strFileName, CFileItemList& items); - void SaveCache(const CStdString& strFileName, CFileItemList& items); + void LoadCache(const std::string& strFileName, CFileItemList& items); + void SaveCache(const std::string& strFileName, CFileItemList& items); protected: - CStdString m_strCacheFileName; + std::string m_strCacheFileName; CFileItemList* m_mapFileItems; MAPSONGS m_songsMap; - CStdString m_strPrevPath; + std::string m_strPrevPath; CMusicDatabase m_musicDatabase; unsigned int m_databaseHits; unsigned int m_tagReads; diff --git a/xbmc/music/MusicThumbLoader.cpp b/xbmc/music/MusicThumbLoader.cpp index d1fea25aba..8354497469 100644 --- a/xbmc/music/MusicThumbLoader.cpp +++ b/xbmc/music/MusicThumbLoader.cpp @@ -159,7 +159,7 @@ bool CMusicThumbLoader::LoadItemLookup(CFileItem* pItem) if (!FillThumb(*pItem, false)) // Check for user thumbs but ignore folder thumbs { // No user thumb, use embedded art - CStdString thumb = CTextureUtils::GetWrappedImageURL(pItem->GetPath(), "music"); + std::string thumb = CTextureUtils::GetWrappedImageURL(pItem->GetPath(), "music"); pItem->SetArt("thumb", thumb); } } @@ -177,7 +177,7 @@ bool CMusicThumbLoader::FillThumb(CFileItem &item, bool folderThumbs /* = true * { if (item.HasArt("thumb")) return true; - CStdString thumb = GetCachedImage(item, "thumb"); + std::string thumb = GetCachedImage(item, "thumb"); if (thumb.empty()) { thumb = item.GetUserMusicThumb(false, folderThumbs); diff --git a/xbmc/music/Song.cpp b/xbmc/music/Song.cpp index 670fa3d325..fe88466e1d 100644 --- a/xbmc/music/Song.cpp +++ b/xbmc/music/Song.cpp @@ -40,8 +40,8 @@ CSong::CSong(CFileItem& item) { // have musicbrainz artist info, so use it for (size_t i = 0; i < tag.GetMusicBrainzArtistID().size(); i++) { - CStdString artistId = tag.GetMusicBrainzArtistID()[i]; - CStdString artistName; + std::string artistId = tag.GetMusicBrainzArtistID()[i]; + std::string artistName; /* We try and get the corresponding artist name from the album artist tag. We match on the same index, and if that fails just use the first name we have. @@ -50,7 +50,7 @@ CSong::CSong(CFileItem& item) artistName = (i < artist.size()) ? artist[i] : artist[0]; if (artistName.empty()) artistName = artistId; - CStdString strJoinPhrase = (i == tag.GetMusicBrainzArtistID().size()-1) ? "" : g_advancedSettings.m_musicItemSeparator; + std::string strJoinPhrase = (i == tag.GetMusicBrainzArtistID().size()-1) ? "" : g_advancedSettings.m_musicItemSeparator; CArtistCredit artistCredit(artistName, artistId, strJoinPhrase); artistCredits.push_back(artistCredit); } @@ -59,7 +59,7 @@ CSong::CSong(CFileItem& item) { // no musicbrainz info, so fill in directly for (vector<string>::const_iterator it = tag.GetArtist().begin(); it != tag.GetArtist().end(); ++it) { - CStdString strJoinPhrase = (it == --tag.GetArtist().end() ? "" : g_advancedSettings.m_musicItemSeparator); + std::string strJoinPhrase = (it == --tag.GetArtist().end() ? "" : g_advancedSettings.m_musicItemSeparator); CArtistCredit artistCredit(*it, "", strJoinPhrase); artistCredits.push_back(artistCredit); } diff --git a/xbmc/music/Song.h b/xbmc/music/Song.h index 4c7e6e2a1d..594af187e0 100644 --- a/xbmc/music/Song.h +++ b/xbmc/music/Song.h @@ -23,12 +23,12 @@ */ #pragma once -#include "utils/StdString.h" #include "utils/ISerializable.h" #include "XBDateTime.h" #include "music/tags/MusicInfoTag.h" // for EmbeddedArt #include "Artist.h" #include <map> +#include <string> #include <vector> /*! @@ -41,7 +41,7 @@ class CGenre { public: long idGenre; - CStdString strGenre; + std::string strGenre; }; class CFileItem; @@ -81,17 +81,17 @@ public: long idSong; int idAlbum; - CStdString strFileName; - CStdString strTitle; + std::string strFileName; + std::string strTitle; std::vector<std::string> artist; VECARTISTCREDITS artistCredits; - CStdString strAlbum; + std::string strAlbum; std::vector<std::string> albumArtist; std::vector<std::string> genre; - CStdString strThumb; + std::string strThumb; MUSIC_INFO::EmbeddedArtInfo embeddedArt; - CStdString strMusicBrainzTrackID; - CStdString strComment; + std::string strMusicBrainzTrackID; + std::string strComment; char rating; int iTrack; int iDuration; @@ -104,7 +104,7 @@ public: // Karaoke-specific information long iKaraokeNumber; //! Karaoke song number to "select by number". 0 for non-karaoke - CStdString strKaraokeLyrEncoding; //! Karaoke song lyrics encoding if known. Empty if unknown. + std::string strKaraokeLyrEncoding; //! Karaoke song lyrics encoding if known. Empty if unknown. int iKaraokeDelay; //! Karaoke song lyrics-music delay in 1/10 seconds. }; @@ -123,7 +123,7 @@ typedef std::vector<CSong> VECSONGS; /*! \ingroup music - \brief A vector of CStdString objects, used for CMusicDatabase + \brief A vector of std::string objects, used for CMusicDatabase \sa CMusicDatabase */ typedef std::vector<CGenre> VECGENRES; diff --git a/xbmc/music/dialogs/GUIDialogMusicInfo.cpp b/xbmc/music/dialogs/GUIDialogMusicInfo.cpp index 08264c76fc..6480f5e440 100644 --- a/xbmc/music/dialogs/GUIDialogMusicInfo.cpp +++ b/xbmc/music/dialogs/GUIDialogMusicInfo.cpp @@ -147,7 +147,7 @@ bool CGUIDialogMusicInfo::OnAction(const CAction &action) return CGUIDialog::OnAction(action); } -void CGUIDialogMusicInfo::SetAlbum(const CAlbum& album, const CStdString &path) +void CGUIDialogMusicInfo::SetAlbum(const CAlbum& album, const std::string &path) { m_album = album; SetSongs(m_album.infoSongs); @@ -184,7 +184,7 @@ void CGUIDialogMusicInfo::SetAlbum(const CAlbum& album, const CStdString &path) m_albumSongs->SetContent("albums"); } -void CGUIDialogMusicInfo::SetArtist(const CArtist& artist, const CStdString &path) +void CGUIDialogMusicInfo::SetArtist(const CArtist& artist, const std::string &path) { m_artist = artist; SetDiscography(); @@ -233,7 +233,7 @@ void CGUIDialogMusicInfo::SetDiscography() int idAlbum = -1; for (vector<int>::const_iterator album = albumsByArtist.begin(); album != albumsByArtist.end(); ++album) { - if (database.GetAlbumById(*album).Equals((CStdString)item->GetLabel())) + if (StringUtils::EqualsNoCase(database.GetAlbumById(*album), item->GetLabel())) { idAlbum = *album; item->GetMusicInfoTag()->SetDatabaseId(idAlbum, "album"); @@ -313,7 +313,7 @@ void CGUIDialogMusicInfo::Update() CONTROL_ENABLE_ON_CONDITION(CONTROL_BTN_GET_THUMB, CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser); } -void CGUIDialogMusicInfo::SetLabel(int iControl, const CStdString& strLabel) +void CGUIDialogMusicInfo::SetLabel(int iControl, const std::string& strLabel) { if (strLabel.empty()) { @@ -366,7 +366,7 @@ void CGUIDialogMusicInfo::OnGetThumb() for (unsigned int i = 0; i < thumbs.size(); ++i) { - CStdString strItemPath; + std::string strItemPath; strItemPath = StringUtils::Format("thumb://Remote%i", i); CFileItemPtr item(new CFileItem(strItemPath, false)); item->SetArt("thumb", thumbs[i]); @@ -379,12 +379,12 @@ void CGUIDialogMusicInfo::OnGetThumb() } // local thumb - CStdString localThumb; + std::string localThumb; if (m_bArtistInfo) { CMusicDatabase database; database.Open(); - CStdString strArtistPath; + std::string strArtistPath; if (database.GetArtistPath(m_artist.idArtist,strArtistPath)) localThumb = URIUtils::AddFileToFolder(strArtistPath, "folder.jpg"); } @@ -408,7 +408,7 @@ void CGUIDialogMusicInfo::OnGetThumb() items.Add(item); } - CStdString result; + std::string result; bool flip=false; VECSOURCES sources(*CMediaSourceSettings::Get().GetSources("music")); AddItemPathToFileBrowserSources(sources, *m_albumItem); @@ -419,7 +419,7 @@ void CGUIDialogMusicInfo::OnGetThumb() if (result == "thumb://Current") return; // user chose the one they have - CStdString newThumb; + std::string newThumb; if (StringUtils::StartsWith(result, "thumb://Remote")) { int number = atoi(result.substr(14).c_str()); @@ -468,9 +468,9 @@ void CGUIDialogMusicInfo::OnGetFanart() // Grab the thumbnails from the web for (unsigned int i = 0; i < m_artist.fanart.GetNumFanarts(); i++) { - CStdString strItemPath = StringUtils::Format("fanart://Remote%i",i); + std::string strItemPath = StringUtils::Format("fanart://Remote%i",i); CFileItemPtr item(new CFileItem(strItemPath, false)); - CStdString thumb = m_artist.fanart.GetPreviewURL(i); + std::string thumb = m_artist.fanart.GetPreviewURL(i); item->SetArt("thumb", CTextureUtils::GetWrappedThumbURL(thumb)); item->SetIconImage("DefaultPicture.png"); item->SetLabel(g_localizeStrings.Get(20441)); @@ -483,10 +483,10 @@ void CGUIDialogMusicInfo::OnGetFanart() // Grab a local thumb CMusicDatabase database; database.Open(); - CStdString strArtistPath; + std::string strArtistPath; database.GetArtistPath(m_artist.idArtist,strArtistPath); CFileItem item(strArtistPath,true); - CStdString strLocal = item.GetLocalFanart(); + std::string strLocal = item.GetLocalFanart(); if (!strLocal.empty()) { CFileItemPtr itemLocal(new CFileItem("fanart://Local",false)); @@ -505,7 +505,7 @@ void CGUIDialogMusicInfo::OnGetFanart() items.Add(itemNone); } - CStdString result; + std::string result; VECSOURCES sources = *CMediaSourceSettings::Get().GetSources("music"); g_mediaManager.GetLocalDrives(sources); bool flip=false; @@ -514,10 +514,10 @@ void CGUIDialogMusicInfo::OnGetFanart() // delete the thumbnail if that's what the user wants, else overwrite with the // new thumbnail - if (result.Equals("fanart://Current")) + if (StringUtils::EqualsNoCase(result, "fanart://Current")) return; - if (result.Equals("fanart://Local")) + if (StringUtils::EqualsNoCase(result, "fanart://Local")) result = strLocal; if (StringUtils::StartsWith(result, "fanart://Remote")) @@ -526,7 +526,7 @@ void CGUIDialogMusicInfo::OnGetFanart() m_artist.fanart.SetPrimaryFanart(iFanart); result = m_artist.fanart.GetImageURL(); } - else if (result.Equals("fanart://None") || !CFile::Exists(result)) + else if (StringUtils::EqualsNoCase(result, "fanart://None") || !CFile::Exists(result)) result.clear(); if (flip && !result.empty()) @@ -560,7 +560,7 @@ void CGUIDialogMusicInfo::OnSearch(const CFileItem* pItem) CAlbum album; if (database.GetAlbum(pItem->GetMusicInfoTag()->GetDatabaseId(), album)) { - CStdString strPath; + std::string strPath; database.GetAlbumPath(pItem->GetMusicInfoTag()->GetDatabaseId(), strPath); SetAlbum(album,strPath); Update(); @@ -575,7 +575,7 @@ CFileItemPtr CGUIDialogMusicInfo::GetCurrentListItem(int offset) void CGUIDialogMusicInfo::AddItemPathToFileBrowserSources(VECSOURCES &sources, const CFileItem &item) { - CStdString itemDir; + std::string itemDir; if (item.HasMusicInfoTag() && item.GetMusicInfoTag()->GetType() == MediaTypeSong) itemDir = URIUtils::GetParentPath(item.GetMusicInfoTag()->GetURL()); diff --git a/xbmc/music/dialogs/GUIDialogMusicInfo.h b/xbmc/music/dialogs/GUIDialogMusicInfo.h index ecb10d6f08..f6ffd8a60b 100644 --- a/xbmc/music/dialogs/GUIDialogMusicInfo.h +++ b/xbmc/music/dialogs/GUIDialogMusicInfo.h @@ -37,8 +37,8 @@ public: virtual ~CGUIDialogMusicInfo(void); virtual bool OnMessage(CGUIMessage& message); virtual bool OnAction(const CAction &action); - void SetAlbum(const CAlbum& album, const CStdString &path); - void SetArtist(const CArtist& artist, const CStdString &path); + void SetAlbum(const CAlbum& album, const std::string &path); + void SetArtist(const CArtist& artist, const std::string &path); bool NeedRefresh() const; bool HasUpdatedThumb() const { return m_hasUpdatedThumb; }; @@ -49,7 +49,7 @@ public: protected: virtual void OnInitWindow(); void Update(); - void SetLabel(int iControl, const CStdString& strLabel); + void SetLabel(int iControl, const std::string& strLabel); void OnGetThumb(); void OnGetFanart(); void SetSongs(const VECSONGS &songs); diff --git a/xbmc/music/dialogs/GUIDialogMusicOSD.cpp b/xbmc/music/dialogs/GUIDialogMusicOSD.cpp index 31b3bc8df0..922651230a 100644 --- a/xbmc/music/dialogs/GUIDialogMusicOSD.cpp +++ b/xbmc/music/dialogs/GUIDialogMusicOSD.cpp @@ -48,7 +48,7 @@ bool CGUIDialogMusicOSD::OnMessage(CGUIMessage &message) unsigned int iControl = message.GetSenderId(); if (iControl == CONTROL_VIS_BUTTON) { - CStdString addonID; + std::string addonID; if (CGUIWindowAddonBrowser::SelectAddonID(ADDON::ADDON_VIZ, addonID, true) == 1) { CSettings::Get().SetString("musicplayer.visualisation", addonID); diff --git a/xbmc/music/dialogs/GUIDialogSongInfo.cpp b/xbmc/music/dialogs/GUIDialogSongInfo.cpp index 4af0af4e6d..906488ab51 100644 --- a/xbmc/music/dialogs/GUIDialogSongInfo.cpp +++ b/xbmc/music/dialogs/GUIDialogSongInfo.cpp @@ -110,7 +110,7 @@ bool CGUIDialogSongInfo::OnMessage(CGUIMessage& message) if (window) { CFileItem item(*m_song); - CStdString path = StringUtils::Format("musicdb://albums/%li",m_albumId); + std::string path = StringUtils::Format("musicdb://albums/%li",m_albumId); item.SetPath(path); item.m_bIsFolder = true; window->OnInfo(&item, true); @@ -166,7 +166,7 @@ void CGUIDialogSongInfo::OnInitWindow() // no known db info - check if parent dir is an album if (m_song->GetMusicInfoTag()->GetDatabaseId() == -1) { - CStdString path = URIUtils::GetDirectory(m_song->GetPath()); + std::string path = URIUtils::GetDirectory(m_song->GetPath()); m_albumId = db.GetAlbumIdByPath(path); } else @@ -234,10 +234,10 @@ CFileItemPtr CGUIDialogSongInfo::GetCurrentListItem(int offset) return m_song; } -bool CGUIDialogSongInfo::DownloadThumbnail(const CStdString &thumbFile) +bool CGUIDialogSongInfo::DownloadThumbnail(const std::string &thumbFile) { // TODO: Obtain the source... - CStdString source; + std::string source; CCurlFile http; http.Download(source, thumbFile); return true; @@ -259,7 +259,7 @@ void CGUIDialogSongInfo::OnGetThumb() // Grab the thumbnail from the web /* - CStdString thumbFromWeb; + std::string thumbFromWeb; thumbFromWeb = URIUtils::AddFileToFolder(g_advancedSettings.m_cachePath, "allmusicThumb.jpg"); if (DownloadThumbnail(thumbFromWeb)) { @@ -279,8 +279,8 @@ void CGUIDialogSongInfo::OnGetThumb() } // local thumb - CStdString cachedLocalThumb; - CStdString localThumb(m_song->GetUserMusicThumb(true)); + std::string cachedLocalThumb; + std::string localThumb(m_song->GetUserMusicThumb(true)); if (m_song->IsMusicDb()) { CFileItem item(m_song->GetMusicInfoTag()->GetURL(), false); @@ -303,7 +303,7 @@ void CGUIDialogSongInfo::OnGetThumb() items.Add(item); } - CStdString result; + std::string result; VECSOURCES sources(*CMediaSourceSettings::Get().GetSources("music")); CGUIDialogMusicInfo::AddItemPathToFileBrowserSources(sources, *m_song); g_mediaManager.GetLocalDrives(sources); @@ -316,7 +316,7 @@ void CGUIDialogSongInfo::OnGetThumb() // delete the thumbnail if that's what the user wants, else overwrite with the // new thumbnail - CStdString newThumb; + std::string newThumb; if (result == "thumb://None") newThumb = "-"; else if (result == "thumb://allmusic.com") diff --git a/xbmc/music/dialogs/GUIDialogSongInfo.h b/xbmc/music/dialogs/GUIDialogSongInfo.h index caa146a390..01e7529cb1 100644 --- a/xbmc/music/dialogs/GUIDialogSongInfo.h +++ b/xbmc/music/dialogs/GUIDialogSongInfo.h @@ -40,7 +40,7 @@ public: virtual CFileItemPtr GetCurrentListItem(int offset = 0); protected: virtual void OnInitWindow(); - bool DownloadThumbnail(const CStdString &thumbFile); + bool DownloadThumbnail(const std::string &thumbFile); void OnGetThumb(); void SetRating(char rating); diff --git a/xbmc/music/dialogs/GUIDialogVisualisationPresetList.cpp b/xbmc/music/dialogs/GUIDialogVisualisationPresetList.cpp index 95bf003121..18225edb9a 100644 --- a/xbmc/music/dialogs/GUIDialogVisualisationPresetList.cpp +++ b/xbmc/music/dialogs/GUIDialogVisualisationPresetList.cpp @@ -130,7 +130,7 @@ void CGUIDialogVisualisationPresetList::OnDeinitWindow(int nextWindowID) void CGUIDialogVisualisationPresetList::Update() { m_vecPresets->Clear(); - CStdString strHeading; + std::string strHeading; if (m_viz) { strHeading = StringUtils::Format(g_localizeStrings.Get(13407).c_str(), m_viz->Name().c_str()); diff --git a/xbmc/music/infoscanner/MusicAlbumInfo.cpp b/xbmc/music/infoscanner/MusicAlbumInfo.cpp index 68da249ec4..f9dc7f7a77 100644 --- a/xbmc/music/infoscanner/MusicAlbumInfo.cpp +++ b/xbmc/music/infoscanner/MusicAlbumInfo.cpp @@ -27,7 +27,7 @@ using namespace std; using namespace MUSIC_GRABBER; -CMusicAlbumInfo::CMusicAlbumInfo(const CStdString& strAlbumInfo, const CScraperUrl& strAlbumURL) +CMusicAlbumInfo::CMusicAlbumInfo(const std::string& strAlbumInfo, const CScraperUrl& strAlbumURL) { m_strTitle2 = strAlbumInfo; m_albumURL = strAlbumURL; @@ -35,8 +35,8 @@ CMusicAlbumInfo::CMusicAlbumInfo(const CStdString& strAlbumInfo, const CScraperU m_bLoaded = false; } -CMusicAlbumInfo::CMusicAlbumInfo(const CStdString& strAlbum, const CStdString& strArtist, - const CStdString& strAlbumInfo, const CScraperUrl& strAlbumURL) +CMusicAlbumInfo::CMusicAlbumInfo(const std::string& strAlbum, const std::string& strArtist, + const std::string& strAlbumInfo, const CScraperUrl& strAlbumURL) { m_album.strAlbum = strAlbum; m_album.artist = StringUtils::Split(strArtist, g_advancedSettings.m_musicItemSeparator); diff --git a/xbmc/music/infoscanner/MusicAlbumInfo.h b/xbmc/music/infoscanner/MusicAlbumInfo.h index e764a233c2..316e8915ab 100644 --- a/xbmc/music/infoscanner/MusicAlbumInfo.h +++ b/xbmc/music/infoscanner/MusicAlbumInfo.h @@ -35,8 +35,8 @@ class CMusicAlbumInfo { public: CMusicAlbumInfo() : m_bLoaded(false), m_relevance(-1) {} - CMusicAlbumInfo(const CStdString& strAlbumInfo, const CScraperUrl& strAlbumURL); - CMusicAlbumInfo(const CStdString& strAlbum, const CStdString& strArtist, const CStdString& strAlbumInfo, const CScraperUrl& strAlbumURL); + CMusicAlbumInfo(const std::string& strAlbumInfo, const CScraperUrl& strAlbumURL); + CMusicAlbumInfo(const std::string& strAlbum, const std::string& strArtist, const std::string& strAlbumInfo, const CScraperUrl& strAlbumURL); virtual ~CMusicAlbumInfo() {} bool Loaded() const { return m_bLoaded; } @@ -45,8 +45,8 @@ public: CAlbum& GetAlbum() { return m_album; } void SetAlbum(CAlbum& album); const VECSONGS &GetSongs() const { return m_album.infoSongs; } - const CStdString& GetTitle2() const { return m_strTitle2; } - void SetTitle(const CStdString& strTitle) { m_album.strAlbum = strTitle; } + const std::string& GetTitle2() const { return m_strTitle2; } + void SetTitle(const std::string& strTitle) { m_album.strAlbum = strTitle; } const CScraperUrl& GetAlbumURL() const { return m_albumURL; } float GetRelevance() const { return m_relevance; } void SetRelevance(float relevance) { m_relevance = relevance; } @@ -57,7 +57,7 @@ protected: bool m_bLoaded; CAlbum m_album; float m_relevance; - CStdString m_strTitle2; + std::string m_strTitle2; CScraperUrl m_albumURL; }; diff --git a/xbmc/music/infoscanner/MusicArtistInfo.cpp b/xbmc/music/infoscanner/MusicArtistInfo.cpp index 22bbb62fd7..5e6aba82e4 100644 --- a/xbmc/music/infoscanner/MusicArtistInfo.cpp +++ b/xbmc/music/infoscanner/MusicArtistInfo.cpp @@ -26,7 +26,7 @@ using namespace std; using namespace XFILE; using namespace MUSIC_GRABBER; -CMusicArtistInfo::CMusicArtistInfo(const CStdString& strArtist, const CScraperUrl& strArtistURL) +CMusicArtistInfo::CMusicArtistInfo(const std::string& strArtist, const CScraperUrl& strArtistURL) { m_artist.strArtist = strArtist; m_artistURL = strArtistURL; @@ -40,7 +40,7 @@ void CMusicArtistInfo::SetArtist(const CArtist& artist) } bool CMusicArtistInfo::Load(CCurlFile& http, const ADDON::ScraperPtr& scraper, - const CStdString &strSearch) + const std::string &strSearch) { return m_bLoaded = scraper->GetArtistDetails(http, m_artistURL, strSearch, m_artist); } diff --git a/xbmc/music/infoscanner/MusicArtistInfo.h b/xbmc/music/infoscanner/MusicArtistInfo.h index 5a544ebe50..6d015f2026 100644 --- a/xbmc/music/infoscanner/MusicArtistInfo.h +++ b/xbmc/music/infoscanner/MusicArtistInfo.h @@ -33,7 +33,7 @@ class CMusicArtistInfo { public: CMusicArtistInfo() : m_bLoaded(false) {} - CMusicArtistInfo(const CStdString& strArtist, const CScraperUrl& strArtistURL); + CMusicArtistInfo(const std::string& strArtist, const CScraperUrl& strArtistURL); virtual ~CMusicArtistInfo() {} bool Loaded() const { return m_bLoaded; } void SetLoaded() { m_bLoaded = true; } @@ -42,7 +42,7 @@ public: CArtist& GetArtist() { return m_artist; } const CScraperUrl& GetArtistURL() const { return m_artistURL; } bool Load(XFILE::CCurlFile& http, const ADDON::ScraperPtr& scraper, - const CStdString &strSearch); + const std::string &strSearch); protected: CArtist m_artist; diff --git a/xbmc/music/infoscanner/MusicInfoScanner.cpp b/xbmc/music/infoscanner/MusicInfoScanner.cpp index 38fe5653d8..18806a4150 100644 --- a/xbmc/music/infoscanner/MusicInfoScanner.cpp +++ b/xbmc/music/infoscanner/MusicInfoScanner.cpp @@ -192,7 +192,7 @@ void CMusicInfoScanner::Process() if (m_handle) { float percentage = (float) std::distance(it, m_pathsToScan.end()) / m_pathsToScan.size(); - m_handle->SetText((CStdString)StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator) + " - " + album.strAlbum); + m_handle->SetText(StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator) + " - " + album.strAlbum); m_handle->SetPercentage(percentage); } @@ -260,7 +260,7 @@ void CMusicInfoScanner::Process() m_handle = NULL; } -void CMusicInfoScanner::Start(const CStdString& strDirectory, int flags) +void CMusicInfoScanner::Start(const std::string& strDirectory, int flags) { m_fileCountReader.StopThread(); StopThread(); @@ -298,7 +298,7 @@ void CMusicInfoScanner::StartCleanDatabase() m_bRunning = true; } -void CMusicInfoScanner::FetchAlbumInfo(const CStdString& strDirectory, +void CMusicInfoScanner::FetchAlbumInfo(const std::string& strDirectory, bool refresh) { m_fileCountReader.StopThread(); @@ -342,7 +342,7 @@ void CMusicInfoScanner::FetchAlbumInfo(const CStdString& strDirectory, m_bRunning = true; } -void CMusicInfoScanner::FetchArtistInfo(const CStdString& strDirectory, +void CMusicInfoScanner::FetchArtistInfo(const std::string& strDirectory, bool refresh) { m_fileCountReader.StopThread(); @@ -411,21 +411,21 @@ void CMusicInfoScanner::CleanDatabase(bool showProgress /* = true */) CUtil::DeleteMusicDatabaseDirectoryCache(); } -static void OnDirectoryScanned(const CStdString& strDirectory) +static void OnDirectoryScanned(const std::string& strDirectory) { CGUIMessage msg(GUI_MSG_DIRECTORY_SCANNED, 0, 0, 0); msg.SetStringParam(strDirectory); g_windowManager.SendThreadMessage(msg); } -static CStdString Prettify(const CStdString& strDirectory) +static std::string Prettify(const std::string& strDirectory) { CURL url(strDirectory); return CURL::Decode(url.GetWithoutUserDetails()); } -bool CMusicInfoScanner::DoScan(const CStdString& strDirectory) +bool CMusicInfoScanner::DoScan(const std::string& strDirectory) { if (m_handle) m_handle->SetText(Prettify(strDirectory)); @@ -449,11 +449,11 @@ bool CMusicInfoScanner::DoScan(const CStdString& strDirectory) // to detect changes in the .cue sheet as well. The .cue sheet items only need filtering // if we have a changed hash. items.Sort(SortByLabel, SortOrderAscending); - CStdString hash; + std::string hash; GetPathHash(items, hash); // check whether we need to rescan or not - CStdString dbHash; + std::string dbHash; if ((m_flags & SCAN_RESCAN) || !m_musicDatabase.GetPathHash(strDirectory, dbHash) || dbHash != hash) { // path has changed - rescan if (dbHash.empty()) @@ -499,7 +499,7 @@ bool CMusicInfoScanner::DoScan(const CStdString& strDirectory) // if we have a directory item (non-playlist) we then recurse into that folder if (pItem->m_bIsFolder && !pItem->IsParentFolder() && !pItem->IsPlayList()) { - CStdString strPath=pItem->GetPath(); + std::string strPath=pItem->GetPath(); if (!DoScan(strPath)) { m_bStop = true; @@ -586,7 +586,7 @@ void CMusicInfoScanner::FileItemsToAlbums(CFileItemList& items, VECALBUMS& album { VECALBUMS::iterator it; for (it = albums.begin(); it != albums.end(); ++it) - if (it->strMusicBrainzAlbumID.Equals(tag.GetMusicBrainzAlbumID())) + if (it->strMusicBrainzAlbumID == tag.GetMusicBrainzAlbumID()) break; if (it == albums.end()) @@ -704,7 +704,7 @@ void CMusicInfoScanner::FileItemsToAlbums(CFileItemList& items, VECALBUMS& album album.artist = common; for (vector<string>::iterator it = common.begin(); it != common.end(); ++it) { - CStdString strJoinPhrase = (it == --common.end() ? "" : g_advancedSettings.m_musicItemSeparator); + std::string strJoinPhrase = (it == --common.end() ? "" : g_advancedSettings.m_musicItemSeparator); CArtistCredit artistCredit(*it, strJoinPhrase); album.artistCredits.push_back(artistCredit); } @@ -724,7 +724,7 @@ void CMusicInfoScanner::FileItemsToAlbums(CFileItemList& items, VECALBUMS& album } } -int CMusicInfoScanner::RetrieveMusicInfo(const CStdString& strDirectory, CFileItemList& items) +int CMusicInfoScanner::RetrieveMusicInfo(const std::string& strDirectory, CFileItemList& items) { MAPSONGS songsMap; @@ -836,7 +836,7 @@ int CMusicInfoScanner::RetrieveMusicInfo(const CStdString& strDirectory, CFileIt return numAdded; } -void CMusicInfoScanner::FindArtForAlbums(VECALBUMS &albums, const CStdString &path) +void CMusicInfoScanner::FindArtForAlbums(VECALBUMS &albums, const std::string &path) { /* If there's a single album in the folder, then art can be taken from @@ -918,7 +918,7 @@ void CMusicInfoScanner::FindArtForAlbums(VECALBUMS &albums, const CStdString &pa } } -int CMusicInfoScanner::GetPathHash(const CFileItemList &items, CStdString &hash) +int CMusicInfoScanner::GetPathHash(const CFileItemList &items, std::string &hash) { // Create a hash based on the filenames, filesize and filedate. Also count the number of files if (0 == items.Size()) return 0; @@ -955,7 +955,7 @@ loop: if (!CGUIKeyboardFactory::ShowAndGetInput(album.strAlbum, g_localizeStrings.Get(16011), false)) return INFO_CANCELLED; - CStdString strTempArtist(StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator)); + std::string strTempArtist(StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator)); if (!CGUIKeyboardFactory::ShowAndGetInput(strTempArtist, g_localizeStrings.Get(16025), false)) return INFO_CANCELLED; @@ -1014,7 +1014,7 @@ INFO_RET CMusicInfoScanner::DownloadAlbumInfo(const CAlbum& album, const ADDON:: if (m_handle) { m_handle->SetTitle(StringUtils::Format(g_localizeStrings.Get(20321).c_str(), info->Name().c_str())); - m_handle->SetText((CStdString)StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator) + " - " + album.strAlbum); + m_handle->SetText(StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator) + " - " + album.strAlbum); } // clear our scraper cache @@ -1035,11 +1035,11 @@ INFO_RET CMusicInfoScanner::DownloadAlbumInfo(const CAlbum& album, const ADDON:: } // handle nfo files - CStdString path = album.strPath; + std::string path = album.strPath; if (path.empty()) m_musicDatabase.GetAlbumPath(album.idAlbum, path); - CStdString strNfo = URIUtils::AddFileToFolder(path, "album.nfo"); + std::string strNfo = URIUtils::AddFileToFolder(path, "album.nfo"); CNfoFile::NFOResult result = CNfoFile::NO_NFO; CNfoFile nfoReader; if (XFILE::CFile::Exists(strNfo)) @@ -1125,7 +1125,7 @@ INFO_RET CMusicInfoScanner::DownloadAlbumInfo(const CAlbum& album, const ADDON:: if (pDialog) { // set the label to [relevance] album - artist - CStdString strTemp = StringUtils::Format("[%0.2f] %s", relevance, info.GetTitle2().c_str()); + std::string strTemp = StringUtils::Format("[%0.2f] %s", relevance, info.GetTitle2().c_str()); CFileItem item(strTemp); item.m_idepth = i; // use this to hold the index of the album in the scraper pDlg->Add(&item); @@ -1146,11 +1146,11 @@ INFO_RET CMusicInfoScanner::DownloadAlbumInfo(const CAlbum& album, const ADDON:: return INFO_CANCELLED; // manual button pressed - CStdString strNewAlbum = album.strAlbum; + std::string strNewAlbum = album.strAlbum; if (!CGUIKeyboardFactory::ShowAndGetInput(strNewAlbum, g_localizeStrings.Get(16011), false)) return INFO_CANCELLED; if (strNewAlbum == "") return INFO_CANCELLED; - CStdString strNewArtist = StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator); + std::string strNewArtist = StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator); if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return INFO_CANCELLED; pDialog->SetLine(0, strNewAlbum); @@ -1251,11 +1251,11 @@ INFO_RET CMusicInfoScanner::DownloadArtistInfo(const CArtist& artist, const ADDO } // handle nfo files - CStdString path = artist.strPath; + std::string path = artist.strPath; if (path.empty()) m_musicDatabase.GetArtistPath(artist.idArtist, path); - CStdString strNfo = URIUtils::AddFileToFolder(path, "artist.nfo"); + std::string strNfo = URIUtils::AddFileToFolder(path, "artist.nfo"); CNfoFile::NFOResult result=CNfoFile::NO_NFO; CNfoFile nfoReader; if (XFILE::CFile::Exists(strNfo)) @@ -1317,12 +1317,12 @@ INFO_RET CMusicInfoScanner::DownloadArtistInfo(const CArtist& artist, const ADDO { // set the label to artist CFileItem item(scraper.GetArtist(i).GetArtist()); - CStdString strTemp=scraper.GetArtist(i).GetArtist().strArtist; + std::string strTemp=scraper.GetArtist(i).GetArtist().strArtist; if (!scraper.GetArtist(i).GetArtist().strBorn.empty()) strTemp += " ("+scraper.GetArtist(i).GetArtist().strBorn+")"; if (!scraper.GetArtist(i).GetArtist().genre.empty()) { - CStdString genres = StringUtils::Join(scraper.GetArtist(i).GetArtist().genre, g_advancedSettings.m_musicItemSeparator); + std::string genres = StringUtils::Join(scraper.GetArtist(i).GetArtist().genre, g_advancedSettings.m_musicItemSeparator); if (!genres.empty()) strTemp = StringUtils::Format("[%s] %s", genres.c_str(), strTemp.c_str()); } @@ -1339,7 +1339,7 @@ INFO_RET CMusicInfoScanner::DownloadArtistInfo(const CArtist& artist, const ADDO return INFO_CANCELLED; // manual button pressed - CStdString strNewArtist = artist.strArtist; + std::string strNewArtist = artist.strArtist; if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return INFO_CANCELLED; if (pDialog) @@ -1382,7 +1382,7 @@ INFO_RET CMusicInfoScanner::DownloadArtistInfo(const CArtist& artist, const ADDO return INFO_ADDED; } -bool CMusicInfoScanner::ResolveMusicBrainz(const CStdString &strMusicBrainzID, const ScraperPtr &preferredScraper, CScraperUrl &musicBrainzURL) +bool CMusicInfoScanner::ResolveMusicBrainz(const std::string &strMusicBrainzID, const ScraperPtr &preferredScraper, CScraperUrl &musicBrainzURL) { // We have a MusicBrainz ID // Get a scraper that can resolve it to a MusicBrainz URL & force our @@ -1417,8 +1417,8 @@ map<string, string> CMusicInfoScanner::GetArtistArtwork(const CArtist& artist) map<string, string> artwork; // check thumb - CStdString strFolder; - CStdString thumb; + std::string strFolder; + std::string thumb; if (!artist.strPath.empty()) { strFolder = artist.strPath; @@ -1438,7 +1438,7 @@ map<string, string> CMusicInfoScanner::GetArtistArtwork(const CArtist& artist) } // check fanart - CStdString fanart; + std::string fanart; if (!artist.strPath.empty()) { strFolder = artist.strPath; @@ -1473,7 +1473,7 @@ void CMusicInfoScanner::Run() } // Recurse through all folders we scan and count files -int CMusicInfoScanner::CountFilesRecursively(const CStdString& strPath) +int CMusicInfoScanner::CountFilesRecursively(const std::string& strPath) { // load subfolder CFileItemList items; diff --git a/xbmc/music/infoscanner/MusicInfoScanner.h b/xbmc/music/infoscanner/MusicInfoScanner.h index 658d01cd42..b26be2011b 100644 --- a/xbmc/music/infoscanner/MusicInfoScanner.h +++ b/xbmc/music/infoscanner/MusicInfoScanner.h @@ -54,10 +54,10 @@ public: CMusicInfoScanner(); virtual ~CMusicInfoScanner(); - void Start(const CStdString& strDirectory, int flags); + void Start(const std::string& strDirectory, int flags); void StartCleanDatabase(); - void FetchAlbumInfo(const CStdString& strDirectory, bool refresh=false); - void FetchArtistInfo(const CStdString& strDirectory, bool refresh=false); + void FetchAlbumInfo(const std::string& strDirectory, bool refresh = false); + void FetchArtistInfo(const std::string& strDirectory, bool refresh = false); bool IsScanning(); void Stop(); @@ -111,7 +111,7 @@ public: \param albums [in/out] list of albums to categorise - art field may be altered. \param path [in] path containing albums. */ - static void FindArtForAlbums(VECALBUMS &albums, const CStdString &path); + static void FindArtForAlbums(VECALBUMS &albums, const std::string &path); /*! \brief Update the database information for a MusicDB album Given an album, search and update its info with the given scraper. @@ -175,7 +175,7 @@ protected: \param items [in] list of FileItems to scan \param scannedItems [in] list to populate with the scannedItems */ - int RetrieveMusicInfo(const CStdString& strDirectory, CFileItemList& items); + int RetrieveMusicInfo(const std::string& strDirectory, CFileItemList& items); /*! \brief Scan in the ID3/Ogg/FLAC tags for a bunch of FileItems Given a list of FileItems, scan in the tags for those FileItems @@ -185,14 +185,14 @@ protected: \param scannedItems [in] list to populate with the scannedItems */ INFO_RET ScanTags(const CFileItemList& items, CFileItemList& scannedItems); - int GetPathHash(const CFileItemList &items, CStdString &hash); + int GetPathHash(const CFileItemList &items, std::string &hash); void GetAlbumArtwork(long id, const CAlbum &artist); - bool DoScan(const CStdString& strDirectory); + bool DoScan(const std::string& strDirectory); virtual void Run(); int CountFiles(const CFileItemList& items, bool recursive); - int CountFilesRecursively(const CStdString& strPath); + int CountFilesRecursively(const std::string& strPath); /*! \brief Resolve a MusicBrainzID to a URL If we have a MusicBrainz ID for an artist or album, @@ -201,7 +201,7 @@ protected: \param preferredScraper [in] A ScraperPtr to the preferred album/artist scraper. \param musicBrainzURL [out] will be populated with the MB URL for the artist/album. */ - bool ResolveMusicBrainz(const CStdString &strMusicBrainzID, const ADDON::ScraperPtr &preferredScraper, CScraperUrl &musicBrainzURL); + bool ResolveMusicBrainz(const std::string &strMusicBrainzID, const ADDON::ScraperPtr &preferredScraper, CScraperUrl &musicBrainzURL); protected: bool m_showDialog; diff --git a/xbmc/music/infoscanner/MusicInfoScraper.cpp b/xbmc/music/infoscanner/MusicInfoScraper.cpp index 7a541a52d7..5aa87380ea 100644 --- a/xbmc/music/infoscanner/MusicInfoScraper.cpp +++ b/xbmc/music/infoscanner/MusicInfoScraper.cpp @@ -62,7 +62,7 @@ CMusicArtistInfo& CMusicInfoScraper::GetArtist(int iArtist) return m_vecArtists[iArtist]; } -void CMusicInfoScraper::FindAlbumInfo(const CStdString& strAlbum, const CStdString& strArtist /* = "" */) +void CMusicInfoScraper::FindAlbumInfo(const std::string& strAlbum, const std::string& strArtist /* = "" */) { m_strAlbum=strAlbum; m_strArtist=strArtist; @@ -71,7 +71,7 @@ void CMusicInfoScraper::FindAlbumInfo(const CStdString& strAlbum, const CStdStri Create(); } -void CMusicInfoScraper::FindArtistInfo(const CStdString& strArtist) +void CMusicInfoScraper::FindArtistInfo(const std::string& strArtist) { m_strArtist=strArtist; m_bSucceeded=false; @@ -99,7 +99,7 @@ void CMusicInfoScraper::LoadAlbumInfo(int iAlbum) Create(); } -void CMusicInfoScraper::LoadArtistInfo(int iArtist, const CStdString &strSearch) +void CMusicInfoScraper::LoadArtistInfo(int iArtist, const std::string &strSearch) { m_iAlbum=-1; m_iArtist=iArtist; @@ -190,7 +190,7 @@ void CMusicInfoScraper::Process() } } -bool CMusicInfoScraper::CheckValidOrFallback(const CStdString &fallbackScraper) +bool CMusicInfoScraper::CheckValidOrFallback(const std::string &fallbackScraper) { return true; /* diff --git a/xbmc/music/infoscanner/MusicInfoScraper.h b/xbmc/music/infoscanner/MusicInfoScraper.h index 627210fab6..fa9a977f8b 100644 --- a/xbmc/music/infoscanner/MusicInfoScraper.h +++ b/xbmc/music/infoscanner/MusicInfoScraper.h @@ -37,10 +37,10 @@ class CMusicInfoScraper : public CThread public: CMusicInfoScraper(const ADDON::ScraperPtr &scraper); virtual ~CMusicInfoScraper(void); - void FindAlbumInfo(const CStdString& strAlbum, const CStdString& strArtist = ""); + void FindAlbumInfo(const std::string& strAlbum, const std::string& strArtist = ""); void LoadAlbumInfo(int iAlbum); - void FindArtistInfo(const CStdString& strArtist); - void LoadArtistInfo(int iArtist, const CStdString &strSearch); + void FindArtistInfo(const std::string& strArtist); + void LoadArtistInfo(int iArtist, const std::string &strSearch); bool Completed(); bool Succeeded(); void Cancel(); @@ -68,7 +68,7 @@ public: \param fallbackScraper name of scraper to use as a fallback \return true if we have a valid scraper (or the default is valid). */ - bool CheckValidOrFallback(const CStdString &fallbackScraper); + bool CheckValidOrFallback(const std::string &fallbackScraper); protected: void FindAlbumInfo(); void LoadAlbumInfo(); @@ -78,9 +78,9 @@ protected: virtual void Process(); std::vector<CMusicAlbumInfo> m_vecAlbums; std::vector<CMusicArtistInfo> m_vecArtists; - CStdString m_strAlbum; - CStdString m_strArtist; - CStdString m_strSearch; + std::string m_strAlbum; + std::string m_strArtist; + std::string m_strSearch; int m_iAlbum; int m_iArtist; bool m_bSucceeded; diff --git a/xbmc/music/karaoke/GUIDialogKaraokeSongSelector.cpp b/xbmc/music/karaoke/GUIDialogKaraokeSongSelector.cpp index 74082b1c95..2c962ec0ed 100644 --- a/xbmc/music/karaoke/GUIDialogKaraokeSongSelector.cpp +++ b/xbmc/music/karaoke/GUIDialogKaraokeSongSelector.cpp @@ -67,7 +67,7 @@ void CGUIDialogKaraokeSongSelector::OnButtonSelect() // We only handle "select" if a song is selected if ( m_songSelected ) { - CStdString path = m_karaokeSong.strFileName; + std::string path = m_karaokeSong.strFileName; CFileItemPtr pItem( new CFileItem( path, false) ); m_songSelected = false; @@ -250,7 +250,7 @@ void CGUIDialogKaraokeSongSelector::OnDeinitWindow(int nextWindowID) } -void CGUIDialogKaraokeSongSelectorSmall::DoModal(unsigned int startcode, int iWindowID, const CStdString & param) +void CGUIDialogKaraokeSongSelectorSmall::DoModal(unsigned int startcode, int iWindowID, const std::string & param) { m_songSelected = false; m_selectedNumber = 0; @@ -260,7 +260,7 @@ void CGUIDialogKaraokeSongSelectorSmall::DoModal(unsigned int startcode, int iWi } -void CGUIDialogKaraokeSongSelectorLarge::DoModal(int iWindowID, const CStdString & param) +void CGUIDialogKaraokeSongSelectorLarge::DoModal(int iWindowID, const std::string & param) { m_songSelected = false; m_selectedNumber = 0; diff --git a/xbmc/music/karaoke/GUIDialogKaraokeSongSelector.h b/xbmc/music/karaoke/GUIDialogKaraokeSongSelector.h index 7c50173479..2987ac83ae 100644 --- a/xbmc/music/karaoke/GUIDialogKaraokeSongSelector.h +++ b/xbmc/music/karaoke/GUIDialogKaraokeSongSelector.h @@ -74,7 +74,7 @@ class CGUIDialogKaraokeSongSelectorSmall : public CGUIDialogKaraokeSongSelector { public: CGUIDialogKaraokeSongSelectorSmall(); - void DoModal(unsigned int startcode, int iWindowID = WINDOW_INVALID, const CStdString ¶m = ""); + void DoModal(unsigned int startcode, int iWindowID = WINDOW_INVALID, const std::string ¶m = ""); }; @@ -83,5 +83,5 @@ class CGUIDialogKaraokeSongSelectorLarge : public CGUIDialogKaraokeSongSelector { public: CGUIDialogKaraokeSongSelectorLarge(); - void DoModal(int iWindowID = WINDOW_INVALID, const CStdString ¶m = ""); + void DoModal(int iWindowID = WINDOW_INVALID, const std::string ¶m = ""); }; diff --git a/xbmc/music/karaoke/GUIWindowKaraokeLyrics.cpp b/xbmc/music/karaoke/GUIWindowKaraokeLyrics.cpp index 2a6caa232d..9ac4c0c768 100644 --- a/xbmc/music/karaoke/GUIWindowKaraokeLyrics.cpp +++ b/xbmc/music/karaoke/GUIWindowKaraokeLyrics.cpp @@ -141,7 +141,7 @@ void CGUIWindowKaraokeLyrics::newSong(CKaraokeLyrics * lyrics) // Set up current background mode if ( m_Lyrics->HasVideo() ) { - CStdString path; + std::string path; int64_t offset; // Start the required video diff --git a/xbmc/music/karaoke/karaokelyrics.cpp b/xbmc/music/karaoke/karaokelyrics.cpp index ed5c860f4d..c61908aad4 100644 --- a/xbmc/music/karaoke/karaokelyrics.cpp +++ b/xbmc/music/karaoke/karaokelyrics.cpp @@ -67,7 +67,7 @@ bool CKaraokeLyrics::InitGraphics() return true; } -void CKaraokeLyrics::initData( const CStdString & songPath ) +void CKaraokeLyrics::initData( const std::string & songPath ) { m_songPath = songPath; @@ -113,7 +113,7 @@ double CKaraokeLyrics::getSongTime() const return songtime >= 0 ? songtime : 0.0; } -CStdString CKaraokeLyrics::getSongFile() const +std::string CKaraokeLyrics::getSongFile() const { return m_songPath; } diff --git a/xbmc/music/karaoke/karaokelyrics.h b/xbmc/music/karaoke/karaokelyrics.h index b5eebb8a42..cf8f6aa638 100644 --- a/xbmc/music/karaoke/karaokelyrics.h +++ b/xbmc/music/karaoke/karaokelyrics.h @@ -21,7 +21,7 @@ * */ -#include "utils/StdString.h" +#include <string> // C++ Interface: karaokelyrics @@ -45,7 +45,7 @@ class CKaraokeLyrics virtual bool HasVideo() = 0; //! Should return video parameters if HasVideo() returned true - virtual void GetVideoParameters( CStdString& path, int64_t& offset ) = 0; + virtual void GetVideoParameters( std::string& path, int64_t& offset ) = 0; //! This function is called when the karoke visualisation window created. It may //! be called after Start(), but is guaranteed to be called before Render() @@ -68,10 +68,10 @@ class CKaraokeLyrics //! This function gets 'real' time since the moment song begins, corrected by using remote control //! to increase/decrease lyrics delays. All lyric show functions must use it to properly calculate //! the offset. - CStdString getSongFile() const; + std::string getSongFile() const; //! Sets the path to the lyrics file, and restores musicdb values - void initData( const CStdString& songPath ); + void initData( const std::string& songPath ); //! Adjusts lyrics delay void lyricsDelayIncrease(); @@ -85,7 +85,7 @@ class CKaraokeLyrics double m_avOrigDelay; //! Current playing song - CStdString m_songPath; + std::string m_songPath; long m_idSong; }; diff --git a/xbmc/music/karaoke/karaokelyricscdg.cpp b/xbmc/music/karaoke/karaokelyricscdg.cpp index 8566f47c35..32122222b8 100644 --- a/xbmc/music/karaoke/karaokelyricscdg.cpp +++ b/xbmc/music/karaoke/karaokelyricscdg.cpp @@ -31,7 +31,7 @@ #include "karaokelyricscdg.h" -CKaraokeLyricsCDG::CKaraokeLyricsCDG( const CStdString& cdgFile ) +CKaraokeLyricsCDG::CKaraokeLyricsCDG( const std::string& cdgFile ) : CKaraokeLyrics() { m_cdgFile = cdgFile; @@ -65,7 +65,7 @@ bool CKaraokeLyricsCDG::HasVideo() return false; } -void CKaraokeLyricsCDG::GetVideoParameters(CStdString & path, int64_t & offset) +void CKaraokeLyricsCDG::GetVideoParameters(std::string& path, int64_t & offset) { // no bg video } diff --git a/xbmc/music/karaoke/karaokelyricscdg.h b/xbmc/music/karaoke/karaokelyricscdg.h index b3f8d02abd..2b3b5bbc48 100644 --- a/xbmc/music/karaoke/karaokelyricscdg.h +++ b/xbmc/music/karaoke/karaokelyricscdg.h @@ -32,7 +32,7 @@ typedef uint32_t color_t; class CKaraokeLyricsCDG : public CKaraokeLyrics { public: - CKaraokeLyricsCDG( const CStdString& cdgFile ); + CKaraokeLyricsCDG( const std::string& cdgFile ); ~CKaraokeLyricsCDG(); //! Parses the lyrics or song file, and loads the lyrics into memory. Returns true if the @@ -46,7 +46,7 @@ class CKaraokeLyricsCDG : public CKaraokeLyrics virtual bool HasVideo(); //! Should return video parameters if HasVideo() returned true - virtual void GetVideoParameters( CStdString& path, int64_t& offset ); + virtual void GetVideoParameters(std::string& path, int64_t& offset); //! This function is called when the karoke visualisation window created. It may //! be called after Start(), but is guaranteed to be called before Render() @@ -82,7 +82,7 @@ class CKaraokeLyricsCDG : public CKaraokeLyrics void setPixel( int x, int y, BYTE color ); //! CDG file name - CStdString m_cdgFile; + std::string m_cdgFile; typedef struct { diff --git a/xbmc/music/karaoke/karaokelyricsfactory.cpp b/xbmc/music/karaoke/karaokelyricsfactory.cpp index bb7ff000df..bd44d55f04 100644 --- a/xbmc/music/karaoke/karaokelyricsfactory.cpp +++ b/xbmc/music/karaoke/karaokelyricsfactory.cpp @@ -32,11 +32,11 @@ // A helper function to have all the checks in a single place -bool CheckAndCreateLyrics( const CStdString & songName, CKaraokeLyrics ** lyricptr ) +bool CheckAndCreateLyrics( const std::string & songName, CKaraokeLyrics ** lyricptr ) { - CStdString filename = songName; + std::string filename = songName; URIUtils::RemoveExtension( filename ); - CStdString ext = URIUtils::GetExtension(songName); + std::string ext = URIUtils::GetExtension(songName); // LRC lyrics have .lrc extension if ( XFILE::CFile::Exists( filename + ".lrc" ) ) @@ -82,7 +82,7 @@ bool CheckAndCreateLyrics( const CStdString & songName, CKaraokeLyrics ** lyricp } -CKaraokeLyrics * CKaraokeLyricsFactory::CreateLyrics( const CStdString & songName ) +CKaraokeLyrics * CKaraokeLyricsFactory::CreateLyrics( const std::string & songName ) { CKaraokeLyrics * lyricptr = 0; @@ -91,7 +91,7 @@ CKaraokeLyrics * CKaraokeLyricsFactory::CreateLyrics( const CStdString & songNam } -bool CKaraokeLyricsFactory::HasLyrics(const CStdString & songName) +bool CKaraokeLyricsFactory::HasLyrics(const std::string & songName) { return CheckAndCreateLyrics( songName, 0 ); } diff --git a/xbmc/music/karaoke/karaokelyricsfactory.h b/xbmc/music/karaoke/karaokelyricsfactory.h index 27677d98b2..658f5bc00e 100644 --- a/xbmc/music/karaoke/karaokelyricsfactory.h +++ b/xbmc/music/karaoke/karaokelyricsfactory.h @@ -36,10 +36,10 @@ class CKaraokeLyricsFactory //! should be limited to simple checks like whether the specific filename exists. //! If the loader needs more than that to make sure lyrics are there, it must create this //! loader, which should handle the processing in load(). - static CKaraokeLyrics * CreateLyrics( const CStdString& songName ); + static CKaraokeLyrics * CreateLyrics( const std::string& songName ); //! This function returns true if the lyrics are (or might be) available for this song. - static bool HasLyrics( const CStdString& songName ); + static bool HasLyrics( const std::string& songName ); }; #endif diff --git a/xbmc/music/karaoke/karaokelyricsmanager.cpp b/xbmc/music/karaoke/karaokelyricsmanager.cpp index 639162e52f..818f3e4436 100644 --- a/xbmc/music/karaoke/karaokelyricsmanager.cpp +++ b/xbmc/music/karaoke/karaokelyricsmanager.cpp @@ -52,7 +52,7 @@ CKaraokeLyricsManager::~ CKaraokeLyricsManager() } } -bool CKaraokeLyricsManager::Start(const CStdString & strSongPath) +bool CKaraokeLyricsManager::Start(const std::string & strSongPath) { CSingleLock lock (m_CritSection); diff --git a/xbmc/music/karaoke/karaokelyricsmanager.h b/xbmc/music/karaoke/karaokelyricsmanager.h index 3883d30808..68d06a4ca9 100644 --- a/xbmc/music/karaoke/karaokelyricsmanager.h +++ b/xbmc/music/karaoke/karaokelyricsmanager.h @@ -22,6 +22,8 @@ */ // C++ Interface: karaokelyricsmanager +// +#include <string> class CKaraokeLyrics; class CGUIDialogKaraokeSongSelectorSmall; @@ -37,7 +39,7 @@ class CKaraokeLyricsManager ~CKaraokeLyricsManager(); //! A new song is started playing - bool Start( const CStdString& strSongPath ); + bool Start( const std::string& strSongPath ); //! Called when the current song is being paused or unpaused void SetPaused( bool now_paused ); diff --git a/xbmc/music/karaoke/karaokelyricstext.cpp b/xbmc/music/karaoke/karaokelyricstext.cpp index 5ecaa532f0..ca988afcb3 100644 --- a/xbmc/music/karaoke/karaokelyricstext.cpp +++ b/xbmc/music/karaoke/karaokelyricstext.cpp @@ -104,7 +104,7 @@ void CKaraokeLyricsText::clearLyrics() } -void CKaraokeLyricsText::addLyrics(const CStdString & text, unsigned int timing, unsigned int flags, unsigned int pitch) +void CKaraokeLyricsText::addLyrics(const std::string & text, unsigned int timing, unsigned int flags, unsigned int pitch) { Lyric line; @@ -140,7 +140,7 @@ bool CKaraokeLyricsText::InitGraphics() if ( m_lyrics.empty() ) return false; - CStdString fontPath = URIUtils::AddFileToFolder("special://home/media/Fonts/", CSettings::Get().GetString("karaoke.font")); + std::string fontPath = URIUtils::AddFileToFolder("special://home/media/Fonts/", CSettings::Get().GetString("karaoke.font")); if (!XFILE::CFile::Exists(fontPath)) fontPath = URIUtils::AddFileToFolder("special://xbmc/media/Fonts/", CSettings::Get().GetString("karaoke.font")); m_karaokeFont = g_fontManager.LoadTTF("__karaoke__", fontPath, @@ -468,7 +468,7 @@ void CKaraokeLyricsText::rescanLyrics() const RESOLUTION_INFO info = g_graphicsContext.GetResInfo(); float maxWidth = (float) info.Overscan.right - info.Overscan.left; - CStdString line_text; + std::string line_text; int prev_line_idx = -1; int prev_line_timediff = -1; @@ -495,7 +495,7 @@ void CKaraokeLyricsText::rescanLyrics() ld.offset_start = prev_line_idx; // This piece extracts the first character of a new string and makes it uppercase in Unicode way - CStdStringW temptext; + std::wstring temptext; g_charsetConverter.utf8ToW( line_text, temptext ); // This is pretty ugly upper/lowercase for Russian unicode character set @@ -503,7 +503,7 @@ void CKaraokeLyricsText::rescanLyrics() ld.upper_start = temptext[0] <= 0x42F; else { - CStdString lower = m_lyrics[i].text; + std::string lower = m_lyrics[i].text; StringUtils::ToLower(lower); ld.upper_start = (m_lyrics[i].text == lower); } @@ -608,7 +608,7 @@ void CKaraokeLyricsText::rescanLyrics() bool invalid_timing_reported = false; for ( unsigned int i = 0; i < m_lyrics.size(); i++ ) { - CStdStringW utf16; + std::wstring utf16; g_charsetConverter.utf8ToW( m_lyrics[i].text, utf16 ); // Skip empty lyrics @@ -686,9 +686,9 @@ void CKaraokeLyricsText::rescanLyrics() } -float CKaraokeLyricsText::getStringWidth(const CStdString & text) +float CKaraokeLyricsText::getStringWidth(const std::string & text) { - CStdStringW utf16; + std::wstring utf16; vecText utf32; g_charsetConverter.utf8ToW(text, utf16); @@ -704,11 +704,11 @@ void CKaraokeLyricsText::saveLyrics() { XFILE::CFile file; - CStdString out; + std::string out; for ( unsigned int i = 0; i < m_lyrics.size(); i++ ) { - CStdString timing = StringUtils::Format("%02d:%02d.%d", + std::string timing = StringUtils::Format("%02d:%02d.%d", m_lyrics[i].timing / 600, (m_lyrics[i].timing % 600) / 10, (m_lyrics[i].timing % 10)); @@ -727,7 +727,7 @@ void CKaraokeLyricsText::saveLyrics() if ( !file.OpenForWrite( "special://temp/tmp.lrc", true ) ) return; - file.Write( out, out.size() ); + file.Write( out.c_str(), out.size() ); } @@ -741,7 +741,7 @@ bool CKaraokeLyricsText::HasVideo() return m_videoFile.empty() ? false : true; } -void CKaraokeLyricsText::GetVideoParameters(CStdString & path, int64_t & offset) +void CKaraokeLyricsText::GetVideoParameters(std::string& path, int64_t& offset) { path = m_videoFile; offset = m_videoOffset; diff --git a/xbmc/music/karaoke/karaokelyricstext.h b/xbmc/music/karaoke/karaokelyricstext.h index e8a3cc75c2..015a120412 100644 --- a/xbmc/music/karaoke/karaokelyricstext.h +++ b/xbmc/music/karaoke/karaokelyricstext.h @@ -56,7 +56,7 @@ class CKaraokeLyricsText : public CKaraokeLyrics //! UStar lyrics might have video virtual bool HasVideo(); - virtual void GetVideoParameters( CStdString& path, int64_t& offset ); + virtual void GetVideoParameters(std::string& path, int64_t& offset ); protected: enum @@ -86,7 +86,7 @@ class CKaraokeLyricsText : public CKaraokeLyrics //! flags could be 0 (regular), LYRICS_NEW_LINE (this syllable should start on a new line), //! and LYRICS_NEW_PARAGRAPH (this syllable should start on a new paragraph). //! If the lyrics support pitch (i.e. Ultrastar), it also should be specified. - void addLyrics( const CStdString& text, unsigned int timing, unsigned int flags = 0, unsigned int pitch = LYRICS_INVALID_PITCH ); + void addLyrics( const std::string& text, unsigned int timing, unsigned int flags = 0, unsigned int pitch = LYRICS_INVALID_PITCH ); //! This function clears the lyrics array and resets song information void clearLyrics(); @@ -98,7 +98,7 @@ class CKaraokeLyricsText : public CKaraokeLyrics void rescanLyrics(); //! Returns string width if rendered using current font - float getStringWidth( const CStdString& text ); + float getStringWidth( const std::string& text ); //! Saves parsed lyrics into a temporary file for debugging void saveLyrics(); @@ -106,10 +106,10 @@ class CKaraokeLyricsText : public CKaraokeLyrics //! Those variables keep the song information if available, parsed from the lyrics file. //! It should not be based on filename, as this case will be handled internally. //! Should be set to "" if no information available. - CStdString m_songName; - CStdString m_artist; + std::string m_songName; + std::string m_artist; bool m_hasPitch; - CStdString m_videoFile; + std::string m_videoFile; int64_t m_videoOffset; private: @@ -142,7 +142,7 @@ class CKaraokeLyricsText : public CKaraokeLyrics typedef struct { - CStdString text; + std::string text; unsigned int timing; unsigned int flags; unsigned int pitch; @@ -163,7 +163,7 @@ class CKaraokeLyricsText : public CKaraokeLyrics //! Lyrics colors unsigned int m_colorLyrics; unsigned int m_colorLyricsOutline; - CStdString m_colorSinging; + std::string m_colorSinging; //! This is index in m_lyrics pointing to current paragraph first, last and current elements unsigned int m_indexEndPara; @@ -181,10 +181,10 @@ class CKaraokeLyricsText : public CKaraokeLyrics unsigned int m_lyricsState; //! Lyrics text on screen - CStdString m_currentLyrics; + std::string m_currentLyrics; //! Preamble text on screen - CStdString m_currentPreamble; + std::string m_currentPreamble; // // Configuration settings diff --git a/xbmc/music/karaoke/karaokelyricstextkar.cpp b/xbmc/music/karaoke/karaokelyricstextkar.cpp index 6e3a16eafb..604f00048e 100644 --- a/xbmc/music/karaoke/karaokelyricstextkar.cpp +++ b/xbmc/music/karaoke/karaokelyricstextkar.cpp @@ -35,7 +35,7 @@ typedef struct { unsigned int clocks; unsigned int track; - CStdString text; + std::string text; unsigned int flags; } MidiLyrics; @@ -133,7 +133,7 @@ class MidiTimestamp -CKaraokeLyricsTextKAR::CKaraokeLyricsTextKAR( const CStdString & midiFile ) +CKaraokeLyricsTextKAR::CKaraokeLyricsTextKAR( const std::string & midiFile ) : CKaraokeLyricsText() { m_midiFile = midiFile; @@ -580,9 +580,9 @@ void CKaraokeLyricsTextKAR::readData(void * buf, unsigned int length) *((char*)buf + i) = readByte(); } -CStdString CKaraokeLyricsTextKAR::convertText( const char * data ) +std::string CKaraokeLyricsTextKAR::convertText( const char * data ) { - CStdString strUTF8; + std::string strUTF8; // Use some heuristics; need to replace by real detection stuff later if (CUtf8Utils::isValidUtf8(data) || CSettings::Get().GetString("karaoke.charset") == "DEFAULT") diff --git a/xbmc/music/karaoke/karaokelyricstextkar.h b/xbmc/music/karaoke/karaokelyricstextkar.h index 94efd2b88b..8301e8b725 100644 --- a/xbmc/music/karaoke/karaokelyricstextkar.h +++ b/xbmc/music/karaoke/karaokelyricstextkar.h @@ -26,12 +26,11 @@ #include "karaokelyricstext.h" #include "utils/auto_buffer.h" - //! This class loads MIDI/KAR format lyrics class CKaraokeLyricsTextKAR : public CKaraokeLyricsText { public: - CKaraokeLyricsTextKAR( const CStdString & midiFile ); + CKaraokeLyricsTextKAR( const std::string & midiFile ); ~CKaraokeLyricsTextKAR(); //! Parses the lyrics or song file, and loads the lyrics into memory. @@ -40,7 +39,7 @@ class CKaraokeLyricsTextKAR : public CKaraokeLyricsText private: void parseMIDI(); - CStdString convertText( const char * data ); + std::string convertText( const char * data ); unsigned char readByte(); unsigned short readWord(); @@ -52,7 +51,7 @@ class CKaraokeLyricsTextKAR : public CKaraokeLyricsText void setPos( unsigned int offset ); // MIDI file name - CStdString m_midiFile; + std::string m_midiFile; // MIDI in-memory information XUTILS::auto_buffer m_midiData; diff --git a/xbmc/music/karaoke/karaokelyricstextlrc.cpp b/xbmc/music/karaoke/karaokelyricstextlrc.cpp index ba1780434c..3dbb94bdae 100644 --- a/xbmc/music/karaoke/karaokelyricstextlrc.cpp +++ b/xbmc/music/karaoke/karaokelyricstextlrc.cpp @@ -40,12 +40,12 @@ enum ParserState // Used in multi-time lyric loader typedef struct { - CStdString text; + std::string text; unsigned int timing; unsigned int flags; } MtLyric; -CKaraokeLyricsTextLRC::CKaraokeLyricsTextLRC( const CStdString & lyricsFile ) +CKaraokeLyricsTextLRC::CKaraokeLyricsTextLRC( const std::string & lyricsFile ) : CKaraokeLyricsText() { m_lyricsFile = lyricsFile; @@ -77,7 +77,7 @@ bool CKaraokeLyricsTextLRC::Load() unsigned int offset = 0; - CStdString songfilename = getSongFile(); + std::string songfilename = getSongFile(); // Skip windoze UTF8 file prefix, if any, and reject UTF16 files if (buf.size() > 3) @@ -173,7 +173,7 @@ bool CKaraokeLyricsTextLRC::ParserNormal(char *lyricData, unsigned int lyricSize // Add existing lyrics char current = *p; - CStdString text; + std::string text; if ( offset > state_offset ) { @@ -239,7 +239,7 @@ bool CKaraokeLyricsTextLRC::ParserNormal(char *lyricData, unsigned int lyricSize m_artist += fieldptr; else if ( !strcmp( timestr, "sr" ) ) { - // m_artist += "[CR]" + CStdString( fieldptr ); // Add source to the artist name as a separate line + // m_artist += "[CR]" + std::string( fieldptr ); // Add source to the artist name as a separate line } else if ( !strcmp( timestr, "ti" ) ) m_songName = fieldptr; @@ -348,7 +348,7 @@ bool CKaraokeLyricsTextLRC::ParserMultiTime(char *lyricData, unsigned int lyricS // Add existing lyrics char current = *p; - CStdString text; + std::string text; if ( offset > state_offset ) { @@ -428,7 +428,7 @@ bool CKaraokeLyricsTextLRC::ParserMultiTime(char *lyricData, unsigned int lyricS m_artist += fieldptr; else if ( !strcmp( timestr, "sr" ) ) { - // m_artist += "[CR]" + CStdString( fieldptr ); // Add source to the artist name as a separate line + // m_artist += "[CR]" + std::string( fieldptr ); // Add source to the artist name as a separate line } else if ( !strcmp( timestr, "ti" ) ) m_songName = fieldptr; diff --git a/xbmc/music/karaoke/karaokelyricstextlrc.h b/xbmc/music/karaoke/karaokelyricstextlrc.h index cb7ee8b079..07f8e855fd 100644 --- a/xbmc/music/karaoke/karaokelyricstextlrc.h +++ b/xbmc/music/karaoke/karaokelyricstextlrc.h @@ -30,7 +30,7 @@ class CKaraokeLyricsTextLRC : public CKaraokeLyricsText { public: - CKaraokeLyricsTextLRC( const CStdString & lyricsFile ); + CKaraokeLyricsTextLRC( const std::string & lyricsFile ); ~CKaraokeLyricsTextLRC(); //! Parses the lyrics or song file, and loads the lyrics into memory. Returns true if the @@ -42,7 +42,7 @@ class CKaraokeLyricsTextLRC : public CKaraokeLyricsText bool ParserNormal(char *lyricData, unsigned int lyricSize, int timing_correction); bool ParserMultiTime(char *lyricData, unsigned int lyricSize, int timing_correction); - CStdString m_lyricsFile; + std::string m_lyricsFile; }; #endif diff --git a/xbmc/music/karaoke/karaokelyricstextustar.cpp b/xbmc/music/karaoke/karaokelyricstextustar.cpp index 51e485e3e3..58f51292dd 100644 --- a/xbmc/music/karaoke/karaokelyricstextustar.cpp +++ b/xbmc/music/karaoke/karaokelyricstextustar.cpp @@ -29,7 +29,7 @@ #include "karaokelyricstextustar.h" -CKaraokeLyricsTextUStar::CKaraokeLyricsTextUStar( const CStdString & lyricsFile ) +CKaraokeLyricsTextUStar::CKaraokeLyricsTextUStar( const std::string & lyricsFile ) : CKaraokeLyricsText() { m_lyricsFile = lyricsFile; @@ -41,9 +41,9 @@ CKaraokeLyricsTextUStar::~CKaraokeLyricsTextUStar() } -std::vector< CStdString > CKaraokeLyricsTextUStar::readFile(const CStdString & lyricsFile, bool report_errors ) +std::vector< std::string > CKaraokeLyricsTextUStar::readFile(const std::string & lyricsFile, bool report_errors ) { - std::vector< CStdString > lines; + std::vector< std::string > lines; XFILE::CFile file; XFILE::auto_buffer buf; @@ -53,7 +53,7 @@ std::vector< CStdString > CKaraokeLyricsTextUStar::readFile(const CStdString & l if (report_errors) CLog::Log(LOGERROR, "%s: can't load \"%s\" file", __FUNCTION__, lyricsFile.c_str()); - return std::vector< CStdString >(); + return std::vector< std::string >(); } file.Close(); @@ -87,9 +87,9 @@ std::vector< CStdString > CKaraokeLyricsTextUStar::readFile(const CStdString & l } -bool CKaraokeLyricsTextUStar::isValidFile(const CStdString & lyricsFile) +bool CKaraokeLyricsTextUStar::isValidFile(const std::string & lyricsFile) { - std::vector< CStdString > lines = readFile( lyricsFile, false ); + std::vector< std::string > lines = readFile( lyricsFile, false ); if ( lines.size() == 0 ) return false; @@ -102,12 +102,12 @@ bool CKaraokeLyricsTextUStar::isValidFile(const CStdString & lyricsFile) bool CKaraokeLyricsTextUStar::Load() { // Header parameters - CStdString coverimage, bgimage; + std::string coverimage, bgimage; int bpm = 0, startoffsetms = 0; bool relative = false; // Read the text file - std::vector< CStdString > lines = readFile( m_lyricsFile, true ); + std::vector< std::string > lines = readFile( m_lyricsFile, true ); if ( lines.size() == 0 ) return false; @@ -129,8 +129,8 @@ bool CKaraokeLyricsTextUStar::Load() return false; } - CStdString key = lines[idx].substr(1, offset - 1); - CStdString value = lines[idx].substr(offset + 1); + std::string key = lines[idx].substr(1, offset - 1); + std::string value = lines[idx].substr(offset + 1); if ( key == "TITLE" ) m_songName = value; diff --git a/xbmc/music/karaoke/karaokelyricstextustar.h b/xbmc/music/karaoke/karaokelyricstextustar.h index 826630046e..8e2aced3e8 100644 --- a/xbmc/music/karaoke/karaokelyricstextustar.h +++ b/xbmc/music/karaoke/karaokelyricstextustar.h @@ -30,20 +30,20 @@ class CKaraokeLyricsTextUStar : public CKaraokeLyricsText { public: - CKaraokeLyricsTextUStar( const CStdString & lyricsFile ); + CKaraokeLyricsTextUStar( const std::string & lyricsFile ); ~CKaraokeLyricsTextUStar(); //! Parses the lyrics or song file, and loads the lyrics into memory. Returns true if the //! lyrics are successfully loaded, false otherwise. bool Load(); - static bool isValidFile( const CStdString & lyricsFile ); + static bool isValidFile( const std::string & lyricsFile ); private: - static std::vector<CStdString> readFile( const CStdString & lyricsFile, bool report_errors ); + static std::vector<std::string> readFile( const std::string & lyricsFile, bool report_errors ); private: - CStdString m_lyricsFile; + std::string m_lyricsFile; }; #endif diff --git a/xbmc/music/karaoke/karaokevideobackground.cpp b/xbmc/music/karaoke/karaokevideobackground.cpp index ef08896c7f..4e83398ec5 100644 --- a/xbmc/music/karaoke/karaokevideobackground.cpp +++ b/xbmc/music/karaoke/karaokevideobackground.cpp @@ -51,9 +51,9 @@ KaraokeVideoBackground::~KaraokeVideoBackground() delete m_texture; } -bool KaraokeVideoBackground::openVideoFile( const CStdString& filename ) +bool KaraokeVideoBackground::openVideoFile( const std::string& filename ) { - CStdString realPath = CSpecialProtocol::TranslatePath( filename ); + std::string realPath = CSpecialProtocol::TranslatePath( filename ); if ( !m_decoder->open( realPath ) ) { @@ -154,7 +154,7 @@ void KaraokeVideoBackground::Render() CGUITexture::DrawQuad(vertCoords, 0xffffffff, m_texture ); } -bool KaraokeVideoBackground::Start( const CStdString& filename ) +bool KaraokeVideoBackground::Start( const std::string& filename ) { if ( !filename.empty() ) { diff --git a/xbmc/music/karaoke/karaokevideobackground.h b/xbmc/music/karaoke/karaokevideobackground.h index 49816a5cbf..146cdaae43 100644 --- a/xbmc/music/karaoke/karaokevideobackground.h +++ b/xbmc/music/karaoke/karaokevideobackground.h @@ -21,7 +21,7 @@ * */ -#include "utils/StdString.h" +#include <string> class CBaseTexture; class FFmpegVideoDecoder; @@ -47,7 +47,7 @@ public: // Start playing the video. It is called each time a new song is being played. Should continue playing existing // video from the position it was paused. If it returns false, the video rendering is disabled and // KaraokeVideoFFMpeg object is deleted. Must write the reason for failure into the log file. - bool Start( const CStdString& filename = "" ); + bool Start( const std::string& filename = "" ); // Render the current frame into the screen. This function also must handle video loops and // switching to the next video when necessary. Hence it shouldn't take too long. @@ -65,13 +65,13 @@ private: // Dismisses the object, freeing all the memory and unloading the libraries. The object must be inited before using again. void Dismiss(); - bool openVideoFile( const CStdString& filename ); + bool openVideoFile( const std::string& filename ); void closeVideoFile(); // FFMpeg objects FFmpegVideoDecoder * m_decoder; - CStdString m_curVideoFile; + std::string m_curVideoFile; int m_videoWidth; // shown video width, i.e. upscaled or downscaled as necessary int m_videoHeight; // shown video height, i.e. upscaled or downscaled as necessary int m_displayLeft, m_displayRight, m_displayTop, m_displayBottom; // Video as shown at the display diff --git a/xbmc/music/karaoke/karaokewindowbackground.cpp b/xbmc/music/karaoke/karaokewindowbackground.cpp index d861e7ad1c..4af54822c2 100644 --- a/xbmc/music/karaoke/karaokewindowbackground.cpp +++ b/xbmc/music/karaoke/karaokewindowbackground.cpp @@ -66,7 +66,7 @@ void CKaraokeWindowBackground::Init(CGUIWindow * wnd) m_ImgControl = (CGUIImage*) wnd->GetControl( CONTROL_ID_IMG ); // Init visialisation variables - CStdString defBkgType = g_advancedSettings.m_karaokeDefaultBackgroundType; + std::string defBkgType = g_advancedSettings.m_karaokeDefaultBackgroundType; if ( defBkgType.empty() || defBkgType == "none" ) { @@ -166,7 +166,7 @@ void CKaraokeWindowBackground::StartVisualisation() } -void CKaraokeWindowBackground::StartImage( const CStdString& path ) +void CKaraokeWindowBackground::StartImage( const std::string& path ) { // Showing controls m_ImgControl->SetVisible( true ); @@ -179,7 +179,7 @@ void CKaraokeWindowBackground::StartImage( const CStdString& path ) } -void CKaraokeWindowBackground::StartVideo( const CStdString& path ) +void CKaraokeWindowBackground::StartVideo( const std::string& path ) { if ( !m_videoPlayer ) m_videoPlayer = new KaraokeVideoBackground(); diff --git a/xbmc/music/karaoke/karaokewindowbackground.h b/xbmc/music/karaoke/karaokewindowbackground.h index 3a849e5348..e799716af9 100644 --- a/xbmc/music/karaoke/karaokewindowbackground.h +++ b/xbmc/music/karaoke/karaokewindowbackground.h @@ -45,10 +45,10 @@ public: virtual void StartVisualisation(); // Start with song-specific still image background - virtual void StartImage( const CStdString& path ); + virtual void StartImage( const std::string& path ); // Start with song-specific video background - virtual void StartVideo( const CStdString& path = "" ); + virtual void StartVideo( const std::string& path = "" ); // Start with default (setting-specific) background virtual void StartDefault(); @@ -96,7 +96,7 @@ private: // For default visualisation mode BackgroundMode m_defaultMode; - CStdString m_path; // image + std::string m_path; // image }; #endif diff --git a/xbmc/music/tags/ImusicInfoTagLoader.h b/xbmc/music/tags/ImusicInfoTagLoader.h index 15ae1e7230..775f2dde98 100644 --- a/xbmc/music/tags/ImusicInfoTagLoader.h +++ b/xbmc/music/tags/ImusicInfoTagLoader.h @@ -19,7 +19,7 @@ * */ -#include "utils/StdString.h" +#include <string> namespace MUSIC_INFO { @@ -31,6 +31,6 @@ namespace MUSIC_INFO IMusicInfoTagLoader(void){}; virtual ~IMusicInfoTagLoader(){}; - virtual bool Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art = NULL) = 0; + virtual bool Load(const std::string& strFileName, CMusicInfoTag& tag, EmbeddedArt *art = NULL) = 0; }; } diff --git a/xbmc/music/tags/MusicInfoTag.cpp b/xbmc/music/tags/MusicInfoTag.cpp index e0d7d5bd1f..1b4f19f7eb 100644 --- a/xbmc/music/tags/MusicInfoTag.cpp +++ b/xbmc/music/tags/MusicInfoTag.cpp @@ -168,12 +168,12 @@ int CMusicInfoTag::GetDuration() const return m_iDuration; } -const CStdString& CMusicInfoTag::GetTitle() const +const std::string& CMusicInfoTag::GetTitle() const { return m_strTitle; } -const CStdString& CMusicInfoTag::GetURL() const +const std::string& CMusicInfoTag::GetURL() const { return m_strURL; } @@ -183,7 +183,7 @@ const std::vector<std::string>& CMusicInfoTag::GetArtist() const return m_artist; } -const CStdString& CMusicInfoTag::GetAlbum() const +const std::string& CMusicInfoTag::GetAlbum() const { return m_strAlbum; } @@ -223,17 +223,17 @@ const std::string &CMusicInfoTag::GetType() const return m_type; } -CStdString CMusicInfoTag::GetYearString() const +std::string CMusicInfoTag::GetYearString() const { return m_dwReleaseDate.wYear ? StringUtils::Format("%i", m_dwReleaseDate.wYear) : StringUtils::Empty; } -const CStdString &CMusicInfoTag::GetComment() const +const std::string &CMusicInfoTag::GetComment() const { return m_strComment; } -const CStdString &CMusicInfoTag::GetLyrics() const +const std::string &CMusicInfoTag::GetLyrics() const { return m_strLyrics; } @@ -293,17 +293,17 @@ int CMusicInfoTag::HasReplayGainInfo() const return m_iHasGainInfo; } -void CMusicInfoTag::SetURL(const CStdString& strURL) +void CMusicInfoTag::SetURL(const std::string& strURL) { m_strURL = strURL; } -void CMusicInfoTag::SetTitle(const CStdString& strTitle) +void CMusicInfoTag::SetTitle(const std::string& strTitle) { m_strTitle = Trim(strTitle); } -void CMusicInfoTag::SetArtist(const CStdString& strArtist) +void CMusicInfoTag::SetArtist(const std::string& strArtist) { if (!strArtist.empty()) SetArtist(StringUtils::Split(strArtist, g_advancedSettings.m_musicItemSeparator)); @@ -316,7 +316,7 @@ void CMusicInfoTag::SetArtist(const std::vector<std::string>& artists) m_artist = artists; } -void CMusicInfoTag::SetAlbum(const CStdString& strAlbum) +void CMusicInfoTag::SetAlbum(const std::string& strAlbum) { m_strAlbum = Trim(strAlbum); } @@ -326,7 +326,7 @@ void CMusicInfoTag::SetAlbumId(const int iAlbumId) m_iAlbumId = iAlbumId; } -void CMusicInfoTag::SetAlbumArtist(const CStdString& strAlbumArtist) +void CMusicInfoTag::SetAlbumArtist(const std::string& strAlbumArtist) { if (!strAlbumArtist.empty()) SetAlbumArtist(StringUtils::Split(strAlbumArtist, g_advancedSettings.m_musicItemSeparator)); @@ -339,7 +339,7 @@ void CMusicInfoTag::SetAlbumArtist(const std::vector<std::string>& albumArtists) m_albumArtist = albumArtists; } -void CMusicInfoTag::SetGenre(const CStdString& strGenre) +void CMusicInfoTag::SetGenre(const std::string& strGenre) { if (!strGenre.empty()) SetGenre(StringUtils::Split(strGenre, g_advancedSettings.m_musicItemSeparator)); @@ -389,12 +389,12 @@ void CMusicInfoTag::SetDuration(int iSec) m_iDuration = iSec; } -void CMusicInfoTag::SetComment(const CStdString& comment) +void CMusicInfoTag::SetComment(const std::string& comment) { m_strComment = comment; } -void CMusicInfoTag::SetLyrics(const CStdString& lyrics) +void CMusicInfoTag::SetLyrics(const std::string& lyrics) { m_strLyrics = lyrics; } @@ -414,7 +414,7 @@ void CMusicInfoTag::SetPlayCount(int playcount) m_iTimesPlayed = playcount; } -void CMusicInfoTag::SetLastPlayed(const CStdString& lastplayed) +void CMusicInfoTag::SetLastPlayed(const std::string& lastplayed) { m_lastPlayed.SetFromDBDateTime(lastplayed); } @@ -439,7 +439,7 @@ bool CMusicInfoTag::Loaded() const return m_bLoaded; } -const CStdString& CMusicInfoTag::GetMusicBrainzTrackID() const +const std::string& CMusicInfoTag::GetMusicBrainzTrackID() const { return m_strMusicBrainzTrackID; } @@ -449,7 +449,7 @@ const std::vector<std::string>& CMusicInfoTag::GetMusicBrainzArtistID() const return m_musicBrainzArtistID; } -const CStdString& CMusicInfoTag::GetMusicBrainzAlbumID() const +const std::string& CMusicInfoTag::GetMusicBrainzAlbumID() const { return m_strMusicBrainzAlbumID; } @@ -459,12 +459,12 @@ const std::vector<std::string>& CMusicInfoTag::GetMusicBrainzAlbumArtistID() con return m_musicBrainzAlbumArtistID; } -const CStdString& CMusicInfoTag::GetMusicBrainzTRMID() const +const std::string& CMusicInfoTag::GetMusicBrainzTRMID() const { return m_strMusicBrainzTRMID; } -void CMusicInfoTag::SetMusicBrainzTrackID(const CStdString& strTrackID) +void CMusicInfoTag::SetMusicBrainzTrackID(const std::string& strTrackID) { m_strMusicBrainzTrackID=strTrackID; } @@ -474,7 +474,7 @@ void CMusicInfoTag::SetMusicBrainzArtistID(const std::vector<std::string>& music m_musicBrainzArtistID = musicBrainzArtistId; } -void CMusicInfoTag::SetMusicBrainzAlbumID(const CStdString& strAlbumID) +void CMusicInfoTag::SetMusicBrainzAlbumID(const std::string& strAlbumID) { m_strMusicBrainzAlbumID=strAlbumID; } @@ -484,7 +484,7 @@ void CMusicInfoTag::SetMusicBrainzAlbumArtistID(const std::vector<std::string>& m_musicBrainzAlbumArtistID = musicBrainzAlbumArtistId; } -void CMusicInfoTag::SetMusicBrainzTRMID(const CStdString& strTRMID) +void CMusicInfoTag::SetMusicBrainzTRMID(const std::string& strTRMID) { m_strMusicBrainzTRMID=strTRMID; } @@ -728,42 +728,42 @@ void CMusicInfoTag::Clear() m_iHasGainInfo = 0; } -void CMusicInfoTag::AppendArtist(const CStdString &artist) +void CMusicInfoTag::AppendArtist(const std::string &artist) { for (unsigned int index = 0; index < m_artist.size(); index++) { - if (artist.Equals(m_artist.at(index).c_str())) + if (StringUtils::EqualsNoCase(artist, m_artist.at(index))) return; } m_artist.push_back(artist); } -void CMusicInfoTag::AppendAlbumArtist(const CStdString &albumArtist) +void CMusicInfoTag::AppendAlbumArtist(const std::string &albumArtist) { for (unsigned int index = 0; index < m_albumArtist.size(); index++) { - if (albumArtist.Equals(m_albumArtist.at(index).c_str())) + if (StringUtils::EqualsNoCase(albumArtist, m_albumArtist.at(index))) return; } m_albumArtist.push_back(albumArtist); } -void CMusicInfoTag::AppendGenre(const CStdString &genre) +void CMusicInfoTag::AppendGenre(const std::string &genre) { for (unsigned int index = 0; index < m_genre.size(); index++) { - if (genre.Equals(m_genre.at(index).c_str())) + if (StringUtils::EqualsNoCase(genre, m_genre.at(index))) return; } m_genre.push_back(genre); } -CStdString CMusicInfoTag::Trim(const CStdString &value) const +std::string CMusicInfoTag::Trim(const std::string &value) const { - CStdString trimmedValue(value); + std::string trimmedValue(value); StringUtils::TrimLeft(trimmedValue, " "); StringUtils::TrimRight(trimmedValue, " \n\r"); return trimmedValue; diff --git a/xbmc/music/tags/MusicInfoTag.h b/xbmc/music/tags/MusicInfoTag.h index c1e13a04c4..c2ff04b38e 100644 --- a/xbmc/music/tags/MusicInfoTag.h +++ b/xbmc/music/tags/MusicInfoTag.h @@ -30,7 +30,6 @@ class CArtist; #include "utils/IArchivable.h" #include "utils/ISerializable.h" #include "utils/ISortable.h" -#include "utils/StdString.h" #include "XBDateTime.h" #define REPLAY_GAIN_HAS_TRACK_INFO 1 @@ -79,10 +78,10 @@ public: const CMusicInfoTag& operator =(const CMusicInfoTag& tag); bool operator !=(const CMusicInfoTag& tag) const; bool Loaded() const; - const CStdString& GetTitle() const; - const CStdString& GetURL() const; + const std::string& GetTitle() const; + const std::string& GetURL() const; const std::vector<std::string>& GetArtist() const; - const CStdString& GetAlbum() const; + const std::string& GetAlbum() const; int GetAlbumId() const; const std::vector<std::string>& GetAlbumArtist() const; const std::vector<std::string>& GetGenre() const; @@ -95,14 +94,14 @@ public: const std::string &GetType() const; void GetReleaseDate(SYSTEMTIME& dateTime) const; - CStdString GetYearString() const; - const CStdString& GetMusicBrainzTrackID() const; + std::string GetYearString() const; + const std::string& GetMusicBrainzTrackID() const; const std::vector<std::string>& GetMusicBrainzArtistID() const; - const CStdString& GetMusicBrainzAlbumID() const; + const std::string& GetMusicBrainzAlbumID() const; const std::vector<std::string>& GetMusicBrainzAlbumArtistID() const; - const CStdString& GetMusicBrainzTRMID() const; - const CStdString& GetComment() const; - const CStdString& GetLyrics() const; + const std::string& GetMusicBrainzTRMID() const; + const std::string& GetComment() const; + const std::string& GetLyrics() const; const CDateTime& GetLastPlayed() const; bool GetCompilation() const; char GetRating() const; @@ -115,15 +114,15 @@ public: float GetReplayGainAlbumPeak() const; int HasReplayGainInfo() const; - void SetURL(const CStdString& strURL); - void SetTitle(const CStdString& strTitle); - void SetArtist(const CStdString& strArtist); + void SetURL(const std::string& strURL); + void SetTitle(const std::string& strTitle); + void SetArtist(const std::string& strArtist); void SetArtist(const std::vector<std::string>& artists); - void SetAlbum(const CStdString& strAlbum); + void SetAlbum(const std::string& strAlbum); void SetAlbumId(const int iAlbumId); - void SetAlbumArtist(const CStdString& strAlbumArtist); + void SetAlbumArtist(const std::string& strAlbumArtist); void SetAlbumArtist(const std::vector<std::string>& albumArtists); - void SetGenre(const CStdString& strGenre); + void SetGenre(const std::string& strGenre); void SetGenre(const std::vector<std::string>& genres); void SetYear(int year); void SetDatabaseId(long id, const std::string &type); @@ -136,17 +135,17 @@ public: void SetArtist(const CArtist& artist); void SetAlbum(const CAlbum& album); void SetSong(const CSong& song); - void SetMusicBrainzTrackID(const CStdString& strTrackID); + void SetMusicBrainzTrackID(const std::string& strTrackID); void SetMusicBrainzArtistID(const std::vector<std::string>& musicBrainzArtistId); - void SetMusicBrainzAlbumID(const CStdString& strAlbumID); + void SetMusicBrainzAlbumID(const std::string& strAlbumID); void SetMusicBrainzAlbumArtistID(const std::vector<std::string>& musicBrainzAlbumArtistId); - void SetMusicBrainzTRMID(const CStdString& strTRMID); - void SetComment(const CStdString& comment); - void SetLyrics(const CStdString& lyrics); + void SetMusicBrainzTRMID(const std::string& strTRMID); + void SetComment(const std::string& comment); + void SetLyrics(const std::string& lyrics); void SetRating(char rating); void SetListeners(int listeners); void SetPlayCount(int playcount); - void SetLastPlayed(const CStdString& strLastPlayed); + void SetLastPlayed(const std::string& strLastPlayed); void SetLastPlayed(const CDateTime& strLastPlayed); void SetCompilation(bool compilation); void SetCoverArtInfo(size_t size, const std::string &mimeType); @@ -159,19 +158,19 @@ public: Checks if we have this artist already added, and if not adds it to the songs artist list. \param value artist to add. */ - void AppendArtist(const CStdString &artist); + void AppendArtist(const std::string &artist); /*! \brief Append a unique album artist to the artist list Checks if we have this album artist already added, and if not adds it to the songs album artist list. \param albumArtist album artist to add. */ - void AppendAlbumArtist(const CStdString &albumArtist); + void AppendAlbumArtist(const std::string &albumArtist); /*! \brief Append a unique genre to the genre list Checks if we have this genre already added, and if not adds it to the songs genre list. \param genre genre to add. */ - void AppendGenre(const CStdString &genre); + void AppendGenre(const std::string &genre); virtual void Archive(CArchive& ar); virtual void Serialize(CVariant& ar) const; @@ -183,21 +182,21 @@ protected: \param value string to trim \return trimmed value, with spaces removed from left and right, as well as carriage returns from the right. */ - CStdString Trim(const CStdString &value) const; + std::string Trim(const std::string &value) const; - CStdString m_strURL; - CStdString m_strTitle; + std::string m_strURL; + std::string m_strTitle; std::vector<std::string> m_artist; - CStdString m_strAlbum; + std::string m_strAlbum; std::vector<std::string> m_albumArtist; std::vector<std::string> m_genre; - CStdString m_strMusicBrainzTrackID; + std::string m_strMusicBrainzTrackID; std::vector<std::string> m_musicBrainzArtistID; - CStdString m_strMusicBrainzAlbumID; + std::string m_strMusicBrainzAlbumID; std::vector<std::string> m_musicBrainzAlbumArtistID; - CStdString m_strMusicBrainzTRMID; - CStdString m_strComment; - CStdString m_strLyrics; + std::string m_strMusicBrainzTRMID; + std::string m_strComment; + std::string m_strLyrics; CDateTime m_lastPlayed; bool m_bCompilation; int m_iDuration; diff --git a/xbmc/music/tags/MusicInfoTagLoaderASAP.cpp b/xbmc/music/tags/MusicInfoTagLoaderASAP.cpp index 2f6e24646f..5bb44936d7 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderASAP.cpp +++ b/xbmc/music/tags/MusicInfoTagLoaderASAP.cpp @@ -33,19 +33,19 @@ CMusicInfoTagLoaderASAP::~CMusicInfoTagLoaderASAP() { } -bool CMusicInfoTagLoaderASAP::Load(const CStdString &strFile, CMusicInfoTag &tag, EmbeddedArt *art) +bool CMusicInfoTagLoaderASAP::Load(const std::string &strFile, CMusicInfoTag &tag, EmbeddedArt *art) { tag.SetLoaded(false); if (!m_dll.Load()) return false; - CStdString strFileToLoad = strFile; + std::string strFileToLoad = strFile; int song = -1; - CStdString strExtension = URIUtils::GetExtension(strFile); + std::string strExtension = URIUtils::GetExtension(strFile); if (StringUtils::EqualsNoCase(strExtension, ".asapstream")) { - CStdString strFileName = URIUtils::GetFileName(strFile); + std::string strFileName = URIUtils::GetFileName(strFile); size_t iStart = strFileName.rfind('-') + 1; song = atoi(strFileName.substr(iStart, strFileName.size() - iStart - 11).c_str()) - 1; strFileToLoad = URIUtils::GetDirectory(strFile); diff --git a/xbmc/music/tags/MusicInfoTagLoaderASAP.h b/xbmc/music/tags/MusicInfoTagLoaderASAP.h index adb4d574f1..ead7b49562 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderASAP.h +++ b/xbmc/music/tags/MusicInfoTagLoaderASAP.h @@ -30,7 +30,7 @@ namespace MUSIC_INFO CMusicInfoTagLoaderASAP(void); virtual ~CMusicInfoTagLoaderASAP(); - virtual bool Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art = NULL); + virtual bool Load(const std::string& strFileName, CMusicInfoTag& tag, EmbeddedArt *art = NULL); private: DllASAP m_dll; }; diff --git a/xbmc/music/tags/MusicInfoTagLoaderCDDA.cpp b/xbmc/music/tags/MusicInfoTagLoaderCDDA.cpp index eb27ffcce6..160511ebca 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderCDDA.cpp +++ b/xbmc/music/tags/MusicInfoTagLoaderCDDA.cpp @@ -47,7 +47,7 @@ CMusicInfoTagLoaderCDDA::~CMusicInfoTagLoaderCDDA() { } -bool CMusicInfoTagLoaderCDDA::Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art) +bool CMusicInfoTagLoaderCDDA::Load(const std::string& strFileName, CMusicInfoTag& tag, EmbeddedArt *art) { #ifdef HAS_DVD_DRIVE try @@ -77,7 +77,7 @@ bool CMusicInfoTagLoaderCDDA::Load(const CStdString& strFileName, CMusicInfoTag& if (cddb.queryCDinfo(pCdInfo)) { // Fill the fileitems music tag with cddb information, if available - CStdString strTitle = cddb.getTrackTitle(iTrack); + std::string strTitle = cddb.getTrackTitle(iTrack); if (strTitle.size() > 0) { // Tracknumber @@ -87,18 +87,18 @@ bool CMusicInfoTagLoaderCDDA::Load(const CStdString& strFileName, CMusicInfoTag& tag.SetTitle(strTitle); // Artist: Use track artist or disc artist - CStdString strArtist = cddb.getTrackArtist(iTrack); + std::string strArtist = cddb.getTrackArtist(iTrack); if (strArtist.empty()) cddb.getDiskArtist(strArtist); tag.SetArtist(strArtist); // Album - CStdString strAlbum; + std::string strAlbum; cddb.getDiskTitle( strAlbum ); tag.SetAlbum(strAlbum); // Album Artist - CStdString strAlbumArtist; + std::string strAlbumArtist; cddb.getDiskArtist(strAlbumArtist); tag.SetAlbumArtist(strAlbumArtist); @@ -121,7 +121,7 @@ bool CMusicInfoTagLoaderCDDA::Load(const CStdString& strFileName, CMusicInfoTag& trackinfo ti = pCdInfo->GetTrackInformation(iTrack); // Fill the fileitems music tag with CD-Text information, if available - CStdString strTitle = ti.cdtext[CDTEXT_TITLE]; + std::string strTitle = ti.cdtext[CDTEXT_TITLE]; if (strTitle.size() > 0) { // Tracknumber @@ -134,18 +134,18 @@ bool CMusicInfoTagLoaderCDDA::Load(const CStdString& strFileName, CMusicInfoTag& xbmc_cdtext_t discCDText = pCdInfo->GetDiscCDTextInformation(); // Artist: Use track artist or disc artist - CStdString strArtist = ti.cdtext[CDTEXT_PERFORMER]; + std::string strArtist = ti.cdtext[CDTEXT_PERFORMER]; if (strArtist.empty()) strArtist = discCDText[CDTEXT_PERFORMER]; tag.SetArtist(strArtist); // Album - CStdString strAlbum; + std::string strAlbum; strAlbum = discCDText[CDTEXT_TITLE]; tag.SetAlbum(strAlbum); // Genre: use track or disc genre - CStdString strGenre = ti.cdtext[CDTEXT_GENRE]; + std::string strGenre = ti.cdtext[CDTEXT_GENRE]; if (strGenre.empty()) strGenre = discCDText[CDTEXT_GENRE]; tag.SetGenre( strGenre ); diff --git a/xbmc/music/tags/MusicInfoTagLoaderCDDA.h b/xbmc/music/tags/MusicInfoTagLoaderCDDA.h index 8d3b18f980..96b4e591cd 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderCDDA.h +++ b/xbmc/music/tags/MusicInfoTagLoaderCDDA.h @@ -29,6 +29,6 @@ namespace MUSIC_INFO CMusicInfoTagLoaderCDDA(void); virtual ~CMusicInfoTagLoaderCDDA(); - virtual bool Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art = NULL); + virtual bool Load(const std::string& strFileName, CMusicInfoTag& tag, EmbeddedArt *art = NULL); }; } diff --git a/xbmc/music/tags/MusicInfoTagLoaderDatabase.cpp b/xbmc/music/tags/MusicInfoTagLoaderDatabase.cpp index eafe21a7f3..72225c965f 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderDatabase.cpp +++ b/xbmc/music/tags/MusicInfoTagLoaderDatabase.cpp @@ -34,7 +34,7 @@ CMusicInfoTagLoaderDatabase::~CMusicInfoTagLoaderDatabase() { } -bool CMusicInfoTagLoaderDatabase::Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art) +bool CMusicInfoTagLoaderDatabase::Load(const std::string& strFileName, CMusicInfoTag& tag, EmbeddedArt *art) { tag.SetLoaded(false); CMusicDatabase database; diff --git a/xbmc/music/tags/MusicInfoTagLoaderDatabase.h b/xbmc/music/tags/MusicInfoTagLoaderDatabase.h index 8762105b82..0ca5dad87a 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderDatabase.h +++ b/xbmc/music/tags/MusicInfoTagLoaderDatabase.h @@ -29,7 +29,7 @@ namespace MUSIC_INFO CMusicInfoTagLoaderDatabase(void); virtual ~CMusicInfoTagLoaderDatabase(); - virtual bool Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art = NULL); + virtual bool Load(const std::string& strFileName, CMusicInfoTag& tag, EmbeddedArt *art = NULL); }; } diff --git a/xbmc/music/tags/MusicInfoTagLoaderFactory.cpp b/xbmc/music/tags/MusicInfoTagLoaderFactory.cpp index 2e53851f41..7d51837fc8 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderFactory.cpp +++ b/xbmc/music/tags/MusicInfoTagLoaderFactory.cpp @@ -48,7 +48,7 @@ CMusicInfoTagLoaderFactory::CMusicInfoTagLoaderFactory() CMusicInfoTagLoaderFactory::~CMusicInfoTagLoaderFactory() {} -IMusicInfoTagLoader* CMusicInfoTagLoaderFactory::CreateLoader(const CStdString& strFileName) +IMusicInfoTagLoader* CMusicInfoTagLoaderFactory::CreateLoader(const std::string& strFileName) { // dont try to read the tags for streams & shoutcast CFileItem item(strFileName, false); @@ -58,7 +58,7 @@ IMusicInfoTagLoader* CMusicInfoTagLoaderFactory::CreateLoader(const CStdString& if (item.IsMusicDb()) return new CMusicInfoTagLoaderDatabase(); - CStdString strExtension = URIUtils::GetExtension(strFileName); + std::string strExtension = URIUtils::GetExtension(strFileName); StringUtils::ToLower(strExtension); StringUtils::TrimLeft(strExtension, "."); diff --git a/xbmc/music/tags/MusicInfoTagLoaderFactory.h b/xbmc/music/tags/MusicInfoTagLoaderFactory.h index 1184f46102..39c5859301 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderFactory.h +++ b/xbmc/music/tags/MusicInfoTagLoaderFactory.h @@ -29,7 +29,7 @@ namespace MUSIC_INFO CMusicInfoTagLoaderFactory(void); virtual ~CMusicInfoTagLoaderFactory(); - static IMusicInfoTagLoader* CreateLoader(const CStdString& strFileName); + static IMusicInfoTagLoader* CreateLoader(const std::string& strFileName); }; } diff --git a/xbmc/music/tags/MusicInfoTagLoaderMidi.cpp b/xbmc/music/tags/MusicInfoTagLoaderMidi.cpp index 56c48c6ba4..ae41501771 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderMidi.cpp +++ b/xbmc/music/tags/MusicInfoTagLoaderMidi.cpp @@ -43,11 +43,11 @@ CMusicInfoTagLoaderMidi::~CMusicInfoTagLoaderMidi() // A good intention of creating a pattern-based artist/song recognition engine failed greatly. Simple formats // like %A-%T fail greatly with artists like A-HA and songs like "Ob-la-Di ob-la-Da.mid". So if anyone has // a good idea which would include cases from above, I'd be happy to hear about it. -bool CMusicInfoTagLoaderMidi::Load(const CStdString & strFileName, CMusicInfoTag & tag, EmbeddedArt *art) +bool CMusicInfoTagLoaderMidi::Load(const std::string & strFileName, CMusicInfoTag & tag, EmbeddedArt *art) { tag.SetURL(strFileName); - CStdString path, title; + std::string path, title; URIUtils::Split( strFileName, path, title); URIUtils::RemoveExtension( title ); @@ -57,7 +57,7 @@ bool CMusicInfoTagLoaderMidi::Load(const CStdString & strFileName, CMusicInfoTag if ( !path.empty() ) { - CStdString artist = URIUtils::GetFileName( path ); + std::string artist = URIUtils::GetFileName( path ); if ( !artist.empty() ) tag.SetArtist( artist ); } diff --git a/xbmc/music/tags/MusicInfoTagLoaderMidi.h b/xbmc/music/tags/MusicInfoTagLoaderMidi.h index b7be0ad60d..7c91adb3f2 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderMidi.h +++ b/xbmc/music/tags/MusicInfoTagLoaderMidi.h @@ -29,7 +29,7 @@ namespace MUSIC_INFO public: CMusicInfoTagLoaderMidi(); virtual ~CMusicInfoTagLoaderMidi(); - virtual bool Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art = NULL); + virtual bool Load(const std::string& strFileName, CMusicInfoTag& tag, EmbeddedArt *art = NULL); }; } diff --git a/xbmc/music/tags/MusicInfoTagLoaderNSF.cpp b/xbmc/music/tags/MusicInfoTagLoaderNSF.cpp index 1374f7ffbd..8f9f9d5df0 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderNSF.cpp +++ b/xbmc/music/tags/MusicInfoTagLoaderNSF.cpp @@ -35,7 +35,7 @@ CMusicInfoTagLoaderNSF::~CMusicInfoTagLoaderNSF() { } -int CMusicInfoTagLoaderNSF::GetStreamCount(const CStdString& strFileName) +int CMusicInfoTagLoaderNSF::GetStreamCount(const std::string& strFileName) { if (!m_dll.Load()) return 0; @@ -52,7 +52,7 @@ int CMusicInfoTagLoaderNSF::GetStreamCount(const CStdString& strFileName) return result; } -bool CMusicInfoTagLoaderNSF::Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art) +bool CMusicInfoTagLoaderNSF::Load(const std::string& strFileName, CMusicInfoTag& tag, EmbeddedArt *art) { tag.SetLoaded(false); diff --git a/xbmc/music/tags/MusicInfoTagLoaderNSF.h b/xbmc/music/tags/MusicInfoTagLoaderNSF.h index 55e8902604..f018422643 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderNSF.h +++ b/xbmc/music/tags/MusicInfoTagLoaderNSF.h @@ -30,12 +30,10 @@ namespace MUSIC_INFO CMusicInfoTagLoaderNSF(void); virtual ~CMusicInfoTagLoaderNSF(); - virtual bool Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art = NULL); - virtual int GetStreamCount(const CStdString& strFileName); + virtual bool Load(const std::string& strFileName, CMusicInfoTag& tag, EmbeddedArt *art = NULL); + virtual int GetStreamCount(const std::string& strFileName); private: void* m_nsf; DllNosefart m_dll; }; } - -extern CStdString strNSFDLL; diff --git a/xbmc/music/tags/MusicInfoTagLoaderSPC.cpp b/xbmc/music/tags/MusicInfoTagLoaderSPC.cpp index 90e1718dab..11e9563095 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderSPC.cpp +++ b/xbmc/music/tags/MusicInfoTagLoaderSPC.cpp @@ -118,7 +118,7 @@ CMusicInfoTagLoaderSPC::~CMusicInfoTagLoaderSPC() { } -bool CMusicInfoTagLoaderSPC::Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art) +bool CMusicInfoTagLoaderSPC::Load(const std::string& strFileName, CMusicInfoTag& tag, EmbeddedArt *art) { tag.SetLoaded(false); diff --git a/xbmc/music/tags/MusicInfoTagLoaderSPC.h b/xbmc/music/tags/MusicInfoTagLoaderSPC.h index 1c441321f5..ac05370de4 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderSPC.h +++ b/xbmc/music/tags/MusicInfoTagLoaderSPC.h @@ -29,7 +29,7 @@ namespace MUSIC_INFO CMusicInfoTagLoaderSPC(void); virtual ~CMusicInfoTagLoaderSPC(); - virtual bool Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art = NULL); + virtual bool Load(const std::string& strFileName, CMusicInfoTag& tag, EmbeddedArt *art = NULL); }; } diff --git a/xbmc/music/tags/MusicInfoTagLoaderShn.cpp b/xbmc/music/tags/MusicInfoTagLoaderShn.cpp index f6d1253641..b2d25fda7f 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderShn.cpp +++ b/xbmc/music/tags/MusicInfoTagLoaderShn.cpp @@ -30,7 +30,7 @@ CMusicInfoTagLoaderSHN::CMusicInfoTagLoaderSHN(void) CMusicInfoTagLoaderSHN::~CMusicInfoTagLoaderSHN() {} -bool CMusicInfoTagLoaderSHN::Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art) +bool CMusicInfoTagLoaderSHN::Load(const std::string& strFileName, CMusicInfoTag& tag, EmbeddedArt *art) { try { diff --git a/xbmc/music/tags/MusicInfoTagLoaderShn.h b/xbmc/music/tags/MusicInfoTagLoaderShn.h index acb37f0d76..8d61ac68b2 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderShn.h +++ b/xbmc/music/tags/MusicInfoTagLoaderShn.h @@ -30,6 +30,6 @@ public: CMusicInfoTagLoaderSHN(void); virtual ~CMusicInfoTagLoaderSHN(); - virtual bool Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art = NULL); + virtual bool Load(const std::string& strFileName, CMusicInfoTag& tag, EmbeddedArt *art = NULL); }; } diff --git a/xbmc/music/tags/MusicInfoTagLoaderYM.cpp b/xbmc/music/tags/MusicInfoTagLoaderYM.cpp index d96af1a851..39970cd0c7 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderYM.cpp +++ b/xbmc/music/tags/MusicInfoTagLoaderYM.cpp @@ -33,7 +33,7 @@ CMusicInfoTagLoaderYM::~CMusicInfoTagLoaderYM() { } -bool CMusicInfoTagLoaderYM::Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art) +bool CMusicInfoTagLoaderYM::Load(const std::string& strFileName, CMusicInfoTag& tag, EmbeddedArt *art) { tag.SetLoaded(false); diff --git a/xbmc/music/tags/MusicInfoTagLoaderYM.h b/xbmc/music/tags/MusicInfoTagLoaderYM.h index e57b76fb80..059c5b3ed4 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderYM.h +++ b/xbmc/music/tags/MusicInfoTagLoaderYM.h @@ -30,7 +30,7 @@ namespace MUSIC_INFO CMusicInfoTagLoaderYM(void); virtual ~CMusicInfoTagLoaderYM(); - virtual bool Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art = NULL); + virtual bool Load(const std::string& strFileName, CMusicInfoTag& tag, EmbeddedArt *art = NULL); private: void* m_ym; DllStSound m_dll; diff --git a/xbmc/music/tags/TagLibVFSStream.cpp b/xbmc/music/tags/TagLibVFSStream.cpp index db4499942a..0daae77c17 100644 --- a/xbmc/music/tags/TagLibVFSStream.cpp +++ b/xbmc/music/tags/TagLibVFSStream.cpp @@ -20,7 +20,6 @@ #include "limits.h" #include "TagLibVFSStream.h" #include "filesystem/File.h" -#include "utils/StdString.h" #include "utils/log.h" #include <taglib/tiostream.h> diff --git a/xbmc/music/tags/TagLibVFSStream.h b/xbmc/music/tags/TagLibVFSStream.h index 6a0b2a6213..f0c81c5229 100644 --- a/xbmc/music/tags/TagLibVFSStream.h +++ b/xbmc/music/tags/TagLibVFSStream.h @@ -19,7 +19,6 @@ * */ #include "filesystem/File.h" -#include "utils/StdString.h" #include <taglib/tiostream.h> namespace MUSIC_INFO diff --git a/xbmc/music/tags/TagLoaderTagLib.cpp b/xbmc/music/tags/TagLoaderTagLib.cpp index 937f782283..b780c23416 100644 --- a/xbmc/music/tags/TagLoaderTagLib.cpp +++ b/xbmc/music/tags/TagLoaderTagLib.cpp @@ -60,8 +60,8 @@ public: virtual ~TagStringHandler() {} virtual String parse(const ByteVector &data) const { - CStdString strSource(data.data(), data.size()); - CStdString strUTF8; + std::string strSource(data.data(), data.size()); + std::string strUTF8; g_charsetConverter.unknownToUTF8(strSource, strUTF8); return String(strUTF8, String::UTF8); } @@ -87,14 +87,14 @@ static const vector<string> StringListToVectorString(const StringList& stringLis return values; } -bool CTagLoaderTagLib::Load(const CStdString& strFileName, MUSIC_INFO::CMusicInfoTag& tag, MUSIC_INFO::EmbeddedArt *art /* = NULL */) +bool CTagLoaderTagLib::Load(const std::string& strFileName, MUSIC_INFO::CMusicInfoTag& tag, MUSIC_INFO::EmbeddedArt *art /* = NULL */) { return Load(strFileName, tag, "", art); } -bool CTagLoaderTagLib::Load(const CStdString& strFileName, CMusicInfoTag& tag, const CStdString& fallbackFileExtension, MUSIC_INFO::EmbeddedArt *art /* = NULL */) +bool CTagLoaderTagLib::Load(const std::string& strFileName, CMusicInfoTag& tag, const std::string& fallbackFileExtension, MUSIC_INFO::EmbeddedArt *art /* = NULL */) { - CStdString strExtension = URIUtils::GetExtension(strFileName); + std::string strExtension = URIUtils::GetExtension(strFileName); StringUtils::ToLower(strExtension); StringUtils::TrimLeft(strExtension, "."); diff --git a/xbmc/music/tags/TagLoaderTagLib.h b/xbmc/music/tags/TagLoaderTagLib.h index e8ff6d8a86..e7b6da5b15 100644 --- a/xbmc/music/tags/TagLoaderTagLib.h +++ b/xbmc/music/tags/TagLoaderTagLib.h @@ -56,9 +56,9 @@ class CTagLoaderTagLib : public MUSIC_INFO::IMusicInfoTagLoader public: CTagLoaderTagLib(); virtual ~CTagLoaderTagLib(); - virtual bool Load(const CStdString& strFileName, MUSIC_INFO::CMusicInfoTag& tag, MUSIC_INFO::EmbeddedArt *art = NULL); + virtual bool Load(const std::string& strFileName, MUSIC_INFO::CMusicInfoTag& tag, MUSIC_INFO::EmbeddedArt *art = NULL); - bool Load(const CStdString& strFileName, MUSIC_INFO::CMusicInfoTag& tag, const CStdString& fallbackFileExtension, MUSIC_INFO::EmbeddedArt *art = NULL); + bool Load(const std::string& strFileName, MUSIC_INFO::CMusicInfoTag& tag, const std::string& fallbackFileExtension, MUSIC_INFO::EmbeddedArt *art = NULL); const std::vector<std::string> SplitMBID(const std::vector<std::string> &values); private: diff --git a/xbmc/music/windows/GUIWindowMusicBase.cpp b/xbmc/music/windows/GUIWindowMusicBase.cpp index 963df6371e..b635f746c6 100644 --- a/xbmc/music/windows/GUIWindowMusicBase.cpp +++ b/xbmc/music/windows/GUIWindowMusicBase.cpp @@ -80,8 +80,8 @@ using namespace MUSIC_INFO; #define CONTROL_BTNSORTASC 4 #define CONTROL_BTNTYPE 5 -CGUIWindowMusicBase::CGUIWindowMusicBase(int id, const CStdString &xmlFile) - : CGUIMediaWindow(id, xmlFile) +CGUIWindowMusicBase::CGUIWindowMusicBase(int id, const std::string &xmlFile) + : CGUIMediaWindow(id, xmlFile.c_str()) { m_dlgProgress = NULL; } @@ -256,7 +256,7 @@ bool CGUIWindowMusicBase::OnAction(const CAction &action) void CGUIWindowMusicBase::OnInfoAll(int iItem, bool bCurrent /* = false */, bool refresh /* = false */) { CMusicDatabaseDirectory dir; - CStdString strPath = m_vecItems->GetPath(); + std::string strPath = m_vecItems->GetPath(); if (bCurrent) strPath = m_vecItems->Get(iItem)->GetPath(); @@ -756,7 +756,7 @@ bool CGUIWindowMusicBase::OnContextButton(int itemNumber, CONTEXT_BUTTON button) case CONTEXT_BUTTON_EDIT: { - CStdString playlist = item->IsPlayList() ? item->GetPath() : m_vecItems->GetPath(); // save path as activatewindow will destroy our items + std::string playlist = item->IsPlayList() ? item->GetPath() : m_vecItems->GetPath(); // save path as activatewindow will destroy our items g_windowManager.ActivateWindow(WINDOW_MUSIC_PLAYLIST_EDITOR, playlist); // need to update m_vecItems->RemoveDiscCache(GetID()); @@ -765,7 +765,7 @@ bool CGUIWindowMusicBase::OnContextButton(int itemNumber, CONTEXT_BUTTON button) case CONTEXT_BUTTON_EDIT_SMART_PLAYLIST: { - CStdString playlist = item->IsSmartPlayList() ? item->GetPath() : m_vecItems->GetPath(); // save path as activatewindow will destroy our items + std::string playlist = item->IsSmartPlayList() ? item->GetPath() : m_vecItems->GetPath(); // save path as activatewindow will destroy our items if (CGUIDialogSmartPlaylistEditor::EditPlaylist(playlist, "music")) Refresh(true); // need to update return true; @@ -882,7 +882,7 @@ void CGUIWindowMusicBase::PlayItem(int iItem) } /* - CStdString strPlayListDirectory = m_vecItems->GetPath(); + std::string strPlayListDirectory = m_vecItems->GetPath(); URIUtils::RemoveSlashAtEnd(strPlayListDirectory); */ @@ -977,7 +977,7 @@ bool CGUIWindowMusicBase::OnPlayMedia(int iItem) return CGUIMediaWindow::OnPlayMedia(iItem); } -void CGUIWindowMusicBase::UpdateThumb(const CAlbum &album, const CStdString &path) +void CGUIWindowMusicBase::UpdateThumb(const CAlbum &album, const std::string &path) { // check user permissions bool saveDb = album.idAlbum != -1; @@ -988,10 +988,10 @@ void CGUIWindowMusicBase::UpdateThumb(const CAlbum &album, const CStdString &pat saveDirThumb = false; } - CStdString albumThumb = m_musicdatabase.GetArtForItem(album.idAlbum, MediaTypeAlbum, "thumb"); + std::string albumThumb = m_musicdatabase.GetArtForItem(album.idAlbum, MediaTypeAlbum, "thumb"); // Update the thumb in the music database (songs + albums) - CStdString albumPath(path); + std::string albumPath(path); if (saveDb && CFile::Exists(albumThumb)) m_musicdatabase.SaveAlbumThumb(album.idAlbum, albumThumb); @@ -1067,7 +1067,7 @@ void CGUIWindowMusicBase::OnRetrieveMusicInfo(CFileItemList& items) if (!bProgressVisible && elapsed>1500 && m_dlgProgress) { // tag loading takes more then 1.5 secs, show a progress dialog CURL url(items.GetPath()); - CStdString strStrippedPath = url.GetWithoutUserDetails(); + std::string strStrippedPath = url.GetWithoutUserDetails(); m_dlgProgress->SetHeading(189); m_dlgProgress->SetLine(0, 505); m_dlgProgress->SetLine(1, ""); @@ -1106,7 +1106,7 @@ bool CGUIWindowMusicBase::GetDirectory(const std::string &strDirectory, CFileIte if (params.GetAlbumId() && m_musicdatabase.GetArtistArtForItem(params.GetAlbumId(), MediaTypeAlbum, art)) items.AppendArt(art, MediaTypeAlbum); - if (params.GetArtistId() && m_musicdatabase.GetArtForItem(params.GetArtistId(), MediaTypeArtist, art)); + if (params.GetArtistId() && m_musicdatabase.GetArtForItem(params.GetArtistId(), MediaTypeArtist, art)) items.AppendArt(art, MediaTypeArtist); // add in the "New Playlist" item if we're in the playlists folder @@ -1138,9 +1138,11 @@ bool CGUIWindowMusicBase::GetDirectory(const std::string &strDirectory, CFileIte bool CGUIWindowMusicBase::CheckFilterAdvanced(CFileItemList &items) const { - CStdString content = items.GetContent(); + std::string content = items.GetContent(); if ((items.IsMusicDb() || CanContainFilter(m_strFilterPath)) && - (content.Equals("artists") || content.Equals("albums") || content.Equals("songs"))) + (StringUtils::EqualsNoCase(content, "artists") || + StringUtils::EqualsNoCase(content, "albums") || + StringUtils::EqualsNoCase(content, "songs"))) return true; return false; diff --git a/xbmc/music/windows/GUIWindowMusicBase.h b/xbmc/music/windows/GUIWindowMusicBase.h index 1d962509d2..83d5464dbf 100644 --- a/xbmc/music/windows/GUIWindowMusicBase.h +++ b/xbmc/music/windows/GUIWindowMusicBase.h @@ -41,7 +41,7 @@ class CGUIWindowMusicBase : public CGUIMediaWindow { public: - CGUIWindowMusicBase(int id, const CStdString &xmlFile); + CGUIWindowMusicBase(int id, const std::string &xmlFile); virtual ~CGUIWindowMusicBase(void); virtual bool OnMessage(CGUIMessage& message); virtual bool OnAction(const CAction &action); @@ -88,7 +88,7 @@ protected: bool ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo = true); void ShowArtistInfo(const CFileItem *pItem, bool bShowInfo = true); void ShowSongInfo(CFileItem* pItem); - void UpdateThumb(const CAlbum &album, const CStdString &path); + void UpdateThumb(const CAlbum &album, const std::string &path); void OnRipTrack(int iItem); void OnSearch(); diff --git a/xbmc/music/windows/GUIWindowMusicNav.cpp b/xbmc/music/windows/GUIWindowMusicNav.cpp index 74d0d48521..e9dd128483 100644 --- a/xbmc/music/windows/GUIWindowMusicNav.cpp +++ b/xbmc/music/windows/GUIWindowMusicNav.cpp @@ -164,7 +164,7 @@ bool CGUIWindowMusicNav::OnMessage(CGUIMessage& message) SetProperty("search", selected.GetLabel()); return true; } - CStdString search(GetProperty("search").asString()); + std::string search(GetProperty("search").asString()); CGUIKeyboardFactory::ShowAndGetFilter(search, true); SetProperty("search", search); return true; @@ -217,34 +217,35 @@ bool CGUIWindowMusicNav::OnAction(const CAction& action) return CGUIWindowMusicBase::OnAction(action); } -CStdString CGUIWindowMusicNav::GetQuickpathName(const CStdString& strPath) const +std::string CGUIWindowMusicNav::GetQuickpathName(const std::string& strPath) const { - CStdString path = CLegacyPathTranslation::TranslateMusicDbPath(strPath); - if (path.Equals("musicdb://genres/")) + std::string path = CLegacyPathTranslation::TranslateMusicDbPath(strPath); + StringUtils::ToLower(path); + if (path == "musicdb://genres/") return "Genres"; - else if (path.Equals("musicdb://artists/")) + else if (path == "musicdb://artists/") return "Artists"; - else if (path.Equals("musicdb://albums/")) + else if (path == "musicdb://albums/") return "Albums"; - else if (path.Equals("musicdb://songs/")) + else if (path == "musicdb://songs/") return "Songs"; - else if (path.Equals("musicdb://top100/")) + else if (path == "musicdb://top100/") return "Top100"; - else if (path.Equals("musicdb://top100/songs/")) + else if (path == "musicdb://top100/songs/") return "Top100Songs"; - else if (path.Equals("musicdb://top100/albums/")) + else if (path == "musicdb://top100/albums/") return "Top100Albums"; - else if (path.Equals("musicdb://recentlyaddedalbums/")) + else if (path == "musicdb://recentlyaddedalbums/") return "RecentlyAddedAlbums"; - else if (path.Equals("musicdb://recentlyplayedalbums/")) + else if (path == "musicdb://recentlyplayedalbums/") return "RecentlyPlayedAlbums"; - else if (path.Equals("musicdb://compilations/")) + else if (path == "musicdb://compilations/") return "Compilations"; - else if (path.Equals("musicdb://years/")) + else if (path == "musicdb://years/") return "Years"; - else if (path.Equals("musicdb://singles/")) + else if (path == "musicdb://singles/") return "Singles"; - else if (path.Equals("special://musicplaylists/")) + else if (path == "special://musicplaylists/") return "Playlists"; else { @@ -264,7 +265,7 @@ bool CGUIWindowMusicNav::OnClick(int iItem) OnSearchUpdate(); else { - CStdString search(GetProperty("search").asString()); + std::string search(GetProperty("search").asString()); CGUIKeyboardFactory::ShowAndGetFilter(search, true); SetProperty("search", search); } @@ -388,11 +389,11 @@ void CGUIWindowMusicNav::UpdateButtons() StringUtils::StartsWith(m_vecItems->Get(m_vecItems->Size()-1)->GetPath(), "/-1/")) iItems--; } - CStdString items = StringUtils::Format("%i %s", iItems, g_localizeStrings.Get(127).c_str()); + std::string items = StringUtils::Format("%i %s", iItems, g_localizeStrings.Get(127).c_str()); SET_CONTROL_LABEL(CONTROL_LABELFILES, items); // set the filter label - CStdString strLabel; + std::string strLabel; // "Playlists" if (m_vecItems->IsPath("special://musicplaylists/")) @@ -401,7 +402,7 @@ void CGUIWindowMusicNav::UpdateButtons() else if (m_vecItems->IsPlayList()) { // get playlist name from path - CStdString strDummy; + std::string strDummy; URIUtils::Split(m_vecItems->GetPath(), strDummy, strLabel); } // everything else is from a musicdb:// path @@ -561,7 +562,7 @@ void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &butt buttons.Add(CONTEXT_BUTTON_DELETE, 646); } } - if (inPlaylists && !URIUtils::GetFileName(item->GetPath()).Equals("PartyMode.xsp") + if (inPlaylists && URIUtils::GetFileName(item->GetPath()) != "PartyMode.xsp" && (item->IsPlayList() || item->IsSmartPlayList())) buttons.Add(CONTEXT_BUTTON_DELETE, 117); @@ -592,7 +593,7 @@ bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) long idArtist = m_musicdatabase.GetArtistByName(item->GetLabel()); if (idArtist == -1) return false; - CStdString path = StringUtils::Format("musicdb://artists/%ld/", idArtist); + std::string path = StringUtils::Format("musicdb://artists/%ld/", idArtist); CArtist artist; m_musicdatabase.GetArtist(idArtist, artist, false); *item = CFileItem(artist); @@ -609,7 +610,7 @@ bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) long idAlbum = m_musicdatabase.GetAlbumByName(item->GetLabel()); if (idAlbum == -1) return false; - CStdString path = StringUtils::Format("musicdb://albums/%ld/", idAlbum); + std::string path = StringUtils::Format("musicdb://albums/%ld/", idAlbum); CAlbum album; m_musicdatabase.GetAlbum(idAlbum, album, false); *item = CFileItem(path,album); @@ -649,7 +650,7 @@ bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) case CONTEXT_BUTTON_GO_TO_ARTIST: { - CStdString strPath; + std::string strPath; CVideoDatabase database; database.Open(); strPath = StringUtils::Format("videodb://musicvideos/artists/%i/", @@ -691,7 +692,7 @@ bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) case CONTEXT_BUTTON_SET_CONTENT: { ADDON::ScraperPtr scraper; - CStdString path(item->GetPath()); + std::string path(item->GetPath()); CQueryParams params; CDirectoryNode::GetDatabaseInfo(item->GetPath(), params); CONTENT_TYPE content = CONTENT_ALBUMS; @@ -738,7 +739,7 @@ bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) bool CGUIWindowMusicNav::GetSongsFromPlayList(const std::string& strPlayList, CFileItemList &items) { - CStdString strParentPath=m_history.GetParentPath(); + std::string strParentPath=m_history.GetParentPath(); if (m_guiState.get() && !m_guiState->HideParentDirItems()) { @@ -777,10 +778,10 @@ void CGUIWindowMusicNav::DisplayEmptyDatabaseMessage(bool bDisplay) void CGUIWindowMusicNav::OnSearchUpdate() { - CStdString search(CURL::Encode(GetProperty("search").asString())); + std::string search(CURL::Encode(GetProperty("search").asString())); if (!search.empty()) { - CStdString path = "musicsearch://" + search + "/"; + std::string path = "musicsearch://" + search + "/"; m_history.ClearSearchHistory(); Update(path); } diff --git a/xbmc/music/windows/GUIWindowMusicNav.h b/xbmc/music/windows/GUIWindowMusicNav.h index d7709da0f9..d020b1d68b 100644 --- a/xbmc/music/windows/GUIWindowMusicNav.h +++ b/xbmc/music/windows/GUIWindowMusicNav.h @@ -51,7 +51,7 @@ protected: bool GetSongsFromPlayList(const std::string& strPlayList, CFileItemList &items); void DisplayEmptyDatabaseMessage(bool bDisplay); - CStdString GetQuickpathName(const CStdString& strPath) const; + std::string GetQuickpathName(const std::string& strPath) const; VECSOURCES m_shares; diff --git a/xbmc/music/windows/GUIWindowMusicPlaylist.cpp b/xbmc/music/windows/GUIWindowMusicPlaylist.cpp index 45c873c1b0..59086022a9 100644 --- a/xbmc/music/windows/GUIWindowMusicPlaylist.cpp +++ b/xbmc/music/windows/GUIWindowMusicPlaylist.cpp @@ -280,18 +280,18 @@ bool CGUIWindowMusicPlayList::MoveCurrentPlayListItem(int iItem, int iAction, bo void CGUIWindowMusicPlayList::SavePlayList() { - CStdString strNewFileName; + std::string strNewFileName; if (CGUIKeyboardFactory::ShowAndGetInput(strNewFileName, g_localizeStrings.Get(16012), false)) { // need 2 rename it - CStdString strFolder = URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "music"); + std::string strFolder = URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "music"); strNewFileName = CUtil::MakeLegalFileName(strNewFileName); strNewFileName += ".m3u"; - CStdString strPath = URIUtils::AddFileToFolder(strFolder, strNewFileName); + std::string strPath = URIUtils::AddFileToFolder(strFolder, strNewFileName); // get selected item int iItem = m_viewControl.GetSelectedItem(); - CStdString strSelectedItem = ""; + std::string strSelectedItem = ""; if (iItem >= 0 && iItem < m_vecItems->Size()) { CFileItemPtr pItem = m_vecItems->Get(iItem); @@ -301,7 +301,7 @@ void CGUIWindowMusicPlayList::SavePlayList() } } - CStdString strOldDirectory = m_vecItems->GetPath(); + std::string strOldDirectory = m_vecItems->GetPath(); m_history.SetSelectedItem(strSelectedItem, strOldDirectory); CPlayListM3U playlist; @@ -406,7 +406,7 @@ void CGUIWindowMusicPlayList::UpdateButtons() SET_CONTROL_LABEL(CONTROL_BTNREPEAT, g_localizeStrings.Get(iRepeat)); // Update object count label - CStdString items = StringUtils::Format("%i %s", m_vecItems->GetObjectCount(), g_localizeStrings.Get(127).c_str()); + std::string items = StringUtils::Format("%i %s", m_vecItems->GetObjectCount(), g_localizeStrings.Get(127).c_str()); SET_CONTROL_LABEL(CONTROL_LABELFILES, items); MarkPlaying(); @@ -446,10 +446,10 @@ void CGUIWindowMusicPlayList::OnItemLoaded(CFileItem* pItem) if (pItem->HasMusicInfoTag() && pItem->GetMusicInfoTag()->Loaded()) { // set label 1+2 from tags if (m_guiState.get()) m_hideExtensions = m_guiState->HideExtensions(); - CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.nowplayingtrackformat"); + std::string strTrackLeft=CSettings::Get().GetString("musicfiles.nowplayingtrackformat"); if (strTrackLeft.empty()) strTrackLeft = CSettings::Get().GetString("musicfiles.trackformat"); - CStdString strTrackRight=CSettings::Get().GetString("musicfiles.nowplayingtrackformatright"); + std::string strTrackRight=CSettings::Get().GetString("musicfiles.nowplayingtrackformatright"); if (strTrackRight.empty()) strTrackRight = CSettings::Get().GetString("musicfiles.trackformatright"); CLabelFormatter formatter(strTrackLeft, strTrackRight); @@ -470,7 +470,7 @@ void CGUIWindowMusicPlayList::OnItemLoaded(CFileItem* pItem) // currently it is hacked into m_iprogramCount // No music info and it's not CDDA so we'll just show the filename - CStdString str; + std::string str; str = CUtil::GetTitleFromPath(pItem->GetPath()); str = StringUtils::Format("%02.2i. %s ", pItem->m_iprogramCount, str.c_str()); pItem->SetLabel(str); @@ -599,7 +599,7 @@ bool CGUIWindowMusicPlayList::OnContextButton(int itemNumber, CONTEXT_BUTTON but case CONTEXT_BUTTON_EDIT_PARTYMODE: { - CStdString playlist = CProfilesManager::Get().GetUserDataItem("PartyMode.xsp"); + std::string playlist = CProfilesManager::Get().GetUserDataItem("PartyMode.xsp"); if (CGUIDialogSmartPlaylistEditor::EditPlaylist(playlist)) { // apply new rules diff --git a/xbmc/music/windows/GUIWindowMusicPlaylistEditor.cpp b/xbmc/music/windows/GUIWindowMusicPlaylistEditor.cpp index 96d182847b..98a2c24a42 100644 --- a/xbmc/music/windows/GUIWindowMusicPlaylistEditor.cpp +++ b/xbmc/music/windows/GUIWindowMusicPlaylistEditor.cpp @@ -178,7 +178,7 @@ void CGUIWindowMusicPlaylistEditor::UpdateButtons() CGUIWindowMusicBase::UpdateButtons(); // Update object count label - CStdString items = StringUtils::Format("%i %s", m_vecItems->GetObjectCount(), g_localizeStrings.Get(127).c_str()); // " 14 Objects" + std::string items = StringUtils::Format("%i %s", m_vecItems->GetObjectCount(), g_localizeStrings.Get(127).c_str()); // " 14 Objects" SET_CONTROL_LABEL(CONTROL_LABELFILES, items); } @@ -256,7 +256,7 @@ void CGUIWindowMusicPlaylistEditor::UpdatePlaylist() OnMessage(msg); // indicate how many songs we have - CStdString items = StringUtils::Format("%i %s", m_playlist->Size(), g_localizeStrings.Get(134).c_str()); // "123 Songs" + std::string items = StringUtils::Format("%i %s", m_playlist->Size(), g_localizeStrings.Get(134).c_str()); // "123 Songs" SET_CONTROL_LABEL(CONTROL_LABEL_PLAYLIST, items); m_playlistThumbLoader.Load(*m_playlist); @@ -355,7 +355,7 @@ bool CGUIWindowMusicPlaylistEditor::OnContextButton(int itemNumber, CONTEXT_BUTT void CGUIWindowMusicPlaylistEditor::OnLoadPlaylist() { // prompt user for file to load - CStdString playlist; + std::string playlist; VECSOURCES shares; m_rootDir.GetSources(shares); // add the playlist share @@ -391,15 +391,15 @@ void CGUIWindowMusicPlaylistEditor::LoadPlaylist(const std::string &playlist) void CGUIWindowMusicPlaylistEditor::OnSavePlaylist() { // saves playlist to the playlist folder - CStdString name = URIUtils::GetFileName(m_strLoadedPlaylist); + std::string name = URIUtils::GetFileName(m_strLoadedPlaylist); URIUtils::RemoveExtension(name); if (CGUIKeyboardFactory::ShowAndGetInput(name, g_localizeStrings.Get(16012), false)) { // save playlist as an .m3u PLAYLIST::CPlayListM3U playlist; playlist.Add(*m_playlist); - CStdString strBase = URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "music"); - CStdString path = URIUtils::AddFileToFolder(strBase, name + ".m3u"); + std::string strBase = URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "music"); + std::string path = URIUtils::AddFileToFolder(strBase, name + ".m3u"); playlist.Save(path); m_strLoadedPlaylist = name; } diff --git a/xbmc/music/windows/GUIWindowMusicPlaylistEditor.h b/xbmc/music/windows/GUIWindowMusicPlaylistEditor.h index ff5efdae94..7e7e1bb690 100644 --- a/xbmc/music/windows/GUIWindowMusicPlaylistEditor.h +++ b/xbmc/music/windows/GUIWindowMusicPlaylistEditor.h @@ -65,5 +65,5 @@ protected: CMusicThumbLoader m_playlistThumbLoader; CFileItemList* m_playlist; - CStdString m_strLoadedPlaylist; + std::string m_strLoadedPlaylist; }; diff --git a/xbmc/music/windows/GUIWindowMusicSongs.cpp b/xbmc/music/windows/GUIWindowMusicSongs.cpp index 865dbcfdfa..10225a1883 100644 --- a/xbmc/music/windows/GUIWindowMusicSongs.cpp +++ b/xbmc/music/windows/GUIWindowMusicSongs.cpp @@ -100,7 +100,7 @@ bool CGUIWindowMusicSongs::OnMessage(CGUIMessage& message) // Only update thumb on a local drive if (directory.IsHD()) { - CStdString strParent; + std::string strParent; URIUtils::GetParentPath(directory.GetPath(), strParent); if (directory.GetPath() == m_vecItems->GetPath() || strParent == m_vecItems->GetPath()) Refresh(); @@ -167,7 +167,7 @@ bool CGUIWindowMusicSongs::OnAction(const CAction& action) void CGUIWindowMusicSongs::OnScan(int iItem) { - CStdString strPath; + std::string strPath; if (iItem < 0 || iItem >= m_vecItems->Size()) strPath = m_vecItems->GetPath(); else if (m_vecItems->Get(iItem)->m_bIsFolder) @@ -180,7 +180,7 @@ void CGUIWindowMusicSongs::OnScan(int iItem) DoScan(strPath); } -void CGUIWindowMusicSongs::DoScan(const CStdString &strPath) +void CGUIWindowMusicSongs::DoScan(const std::string &strPath) { if (g_application.IsMusicScanning()) { @@ -205,7 +205,7 @@ bool CGUIWindowMusicSongs::GetDirectory(const std::string &strDirectory, CFileIt // check for .CUE files here. items.FilterCueItems(); - CStdString label; + std::string label; if (items.GetLabel().empty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::Get().GetSources("music"), &label)) items.SetLabel(label); @@ -283,7 +283,7 @@ void CGUIWindowMusicSongs::UpdateButtons() } // Update object count label - CStdString items = StringUtils::Format("%i %s", m_vecItems->GetObjectCount(), g_localizeStrings.Get(127).c_str()); + std::string items = StringUtils::Format("%i %s", m_vecItems->GetObjectCount(), g_localizeStrings.Get(127).c_str()); SET_CONTROL_LABEL(CONTROL_LABELFILES, items); } diff --git a/xbmc/music/windows/GUIWindowMusicSongs.h b/xbmc/music/windows/GUIWindowMusicSongs.h index a4dd14b157..13424b6186 100644 --- a/xbmc/music/windows/GUIWindowMusicSongs.h +++ b/xbmc/music/windows/GUIWindowMusicSongs.h @@ -30,7 +30,7 @@ public: virtual bool OnMessage(CGUIMessage& message); virtual bool OnAction(const CAction& action); - void DoScan(const CStdString &strPath); + void DoScan(const std::string &strPath); protected: virtual void OnItemLoaded(CFileItem* pItem) {}; virtual bool GetDirectory(const std::string &strDirectory, CFileItemList &items); diff --git a/xbmc/network/AirPlayServer.cpp b/xbmc/network/AirPlayServer.cpp index ee0a1a7d5b..96aebfce74 100644 --- a/xbmc/network/AirPlayServer.cpp +++ b/xbmc/network/AirPlayServer.cpp @@ -273,7 +273,7 @@ void CAirPlayServer::AnnounceToClients(int state) CSingleLock lock (m_connectionLock); std::vector<CTCPClient>::iterator it; - for (it = m_connections.begin(); it != m_connections.end(); it++) + for (it = m_connections.begin(); it != m_connections.end(); ++it) { std::string reverseHeader; std::string reverseBody; diff --git a/xbmc/network/AirTunesServer.cpp b/xbmc/network/AirTunesServer.cpp index e38a2d415f..8c456ab255 100644 --- a/xbmc/network/AirTunesServer.cpp +++ b/xbmc/network/AirTunesServer.cpp @@ -262,21 +262,8 @@ void CAirTunesServer::AudioOutputFunctions::audio_set_volume(void *cls, void *s void CAirTunesServer::AudioOutputFunctions::audio_process(void *cls, void *session, const void *buffer, int buflen) { - #define NUM_OF_BYTES 64 XFILE::CPipeFile *pipe=(XFILE::CPipeFile *)cls; - int sentBytes = 0; - unsigned char buf[NUM_OF_BYTES]; - - while (sentBytes < buflen) - { - int n = (buflen - sentBytes < NUM_OF_BYTES ? buflen - sentBytes : NUM_OF_BYTES); - memcpy(buf, (char*) buffer + sentBytes, n); - - if (pipe->Write(buf, n) == 0) - return; - - sentBytes += n; - } + pipe->Write(buffer, buflen); } void CAirTunesServer::AudioOutputFunctions::audio_destroy(void *cls, void *session) diff --git a/xbmc/network/EventClient.cpp b/xbmc/network/EventClient.cpp index 85b291495b..d81a56fce1 100644 --- a/xbmc/network/EventClient.cpp +++ b/xbmc/network/EventClient.cpp @@ -187,7 +187,7 @@ bool CEventClient::AddPacket(CEventPacket *packet) void CEventClient::ProcessEvents() { - if (m_readyPackets.size() > 0) + if (!m_readyPackets.empty()) { while ( ! m_readyPackets.empty() ) { @@ -204,7 +204,7 @@ void CEventClient::ProcessEvents() bool CEventClient::GetNextAction(CEventAction &action) { CSingleLock lock(m_critSection); - if (m_actionQueue.size() > 0) + if (!m_actionQueue.empty()) { // grab the next action in line action = m_actionQueue.front(); @@ -722,7 +722,7 @@ void CEventClient::FreePacketQueues() { delete iter->second; } - iter++; + ++iter; } m_seqPackets.clear(); } @@ -755,7 +755,7 @@ unsigned int CEventClient::GetButtonCode(string& joystickName, bool& isAxis, flo list<CEventButtonState> repeat; list<CEventButtonState>::iterator it; - for(it = m_buttonQueue.begin(); bcode == 0 && it != m_buttonQueue.end(); it++) + for(it = m_buttonQueue.begin(); bcode == 0 && it != m_buttonQueue.end(); ++it) { bcode = it->KeyCode(); joystickName = it->JoystickName(); diff --git a/xbmc/network/EventClient.h b/xbmc/network/EventClient.h index 339ea7cc55..5450a45350 100644 --- a/xbmc/network/EventClient.h +++ b/xbmc/network/EventClient.h @@ -43,9 +43,9 @@ namespace EVENTCLIENT { actionType = 0; } - CEventAction(const char* action, unsigned char type) + CEventAction(const char* action, unsigned char type): + actionName(action) { - actionName = action; actionType = type; } @@ -59,8 +59,6 @@ namespace EVENTCLIENT CEventButtonState() { m_iKeyCode = 0; - m_mapName = ""; - m_buttonName = ""; m_fAmount = 0.0f; m_bUseAmount = false; m_bRepeat = false; @@ -76,12 +74,11 @@ namespace EVENTCLIENT float fAmount, bool isAxis, bool bRepeat, - bool bUseAmount - ) + bool bUseAmount): + m_buttonName(buttonName), + m_mapName(mapName) { m_iKeyCode = iKeyCode; - m_buttonName = buttonName; - m_mapName = mapName; m_fAmount = fAmount; m_bUseAmount = bUseAmount; m_bRepeat = bRepeat; @@ -131,9 +128,9 @@ namespace EVENTCLIENT Initialize(); } - CEventClient(SOCKETS::CAddress& addr) + CEventClient(SOCKETS::CAddress& addr): + m_remoteAddr(addr) { - m_remoteAddr = addr; Initialize(); } diff --git a/xbmc/network/EventServer.cpp b/xbmc/network/EventServer.cpp index 14b35b1509..d76fbc4785 100644 --- a/xbmc/network/EventServer.cpp +++ b/xbmc/network/EventServer.cpp @@ -307,7 +307,7 @@ void CEventServer::RefreshClients() { iter->second->RefreshSettings(); } - iter++; + ++iter; } } m_bRefreshSettings = false; @@ -321,7 +321,7 @@ void CEventServer::ProcessEvents() while (iter != m_clients.end()) { iter->second->ProcessEvents(); - iter++; + ++iter; } } @@ -356,7 +356,7 @@ bool CEventServer::ExecuteNextAction() } return true; } - iter++; + ++iter; } return false; @@ -373,7 +373,7 @@ unsigned int CEventServer::GetButtonCode(std::string& strMapName, bool& isAxis, bcode = iter->second->GetButtonCode(strMapName, isAxis, fAmount); if (bcode) return bcode; - iter++; + ++iter; } return bcode; } @@ -387,7 +387,7 @@ bool CEventServer::GetMousePos(float &x, float &y) { if (iter->second->GetMousePos(x, y)) return true; - iter++; + ++iter; } return false; } diff --git a/xbmc/network/Network.cpp b/xbmc/network/Network.cpp index d0c80c0f5e..ed4c5d741c 100644 --- a/xbmc/network/Network.cpp +++ b/xbmc/network/Network.cpp @@ -159,19 +159,49 @@ int CNetwork::ParseHex(char *str, unsigned char *addr) return len; } -std::string CNetwork::GetHostName(void) +bool CNetwork::GetHostName(std::string& hostname) { char hostName[128]; if (gethostname(hostName, sizeof(hostName))) - return "unknown"; + return false; - std::string hostStr; #ifdef TARGET_WINDOWS + std::string hostStr; g_charsetConverter.systemToUtf8(hostName, hostStr); + hostname = hostStr; #else - hostStr = hostName; + hostname = hostName; #endif - return hostStr; + return true; +} + +bool CNetwork::IsLocalHost(const std::string& hostname) +{ + if (hostname.empty()) + return false; + + if (StringUtils::StartsWith(hostname, "127.") + || (hostname == "::1") + || StringUtils::EqualsNoCase(hostname, "localhost")) + return true; + + std::string myhostname; + if (GetHostName(myhostname) + && StringUtils::EqualsNoCase(hostname, myhostname)) + return true; + + std::vector<CNetworkInterface*>& ifaces = GetInterfaceList(); + std::vector<CNetworkInterface*>::const_iterator iter = ifaces.begin(); + while (iter != ifaces.end()) + { + CNetworkInterface* iface = *iter; + if (iface && iface->GetCurrentIPAddress() == hostname) + return true; + + ++iter; + } + + return false; } CNetworkInterface* CNetwork::GetFirstConnectedInterface() diff --git a/xbmc/network/Network.h b/xbmc/network/Network.h index 7d0629588c..2bd8369be7 100644 --- a/xbmc/network/Network.h +++ b/xbmc/network/Network.h @@ -32,10 +32,10 @@ enum NetworkAssignment { NETWORK_DASH = 0, NETWORK_DHCP = 1, NETWORK_STATIC = 2, class NetworkAccessPoint { public: - NetworkAccessPoint(const std::string &essId, const std::string &macAddress, int signalStrength, EncMode encryption, int channel = 0) - { - m_essId = essId; - m_macAddress = macAddress; + NetworkAccessPoint(const std::string &essId, const std::string &macAddress, int signalStrength, EncMode encryption, int channel = 0): + m_essId(essId), + m_macAddress(macAddress) + { m_dBm = signalStrength; m_encryptionMode = encryption; m_channel = channel; @@ -110,7 +110,7 @@ public: virtual ~CNetwork(); // Return our hostname - virtual std::string GetHostName(void); + virtual bool GetHostName(std::string& hostname); // Return the list of interfaces virtual std::vector<CNetworkInterface*>& GetInterfaceList(void) = 0; @@ -146,6 +146,9 @@ public: void StopServices(bool bWait); static int ParseHex(char *str, unsigned char *addr); + + // Return true if given name or ip address corresponds to localhost + bool IsLocalHost(const std::string& hostname); }; #ifdef HAS_LINUX_NETWORK diff --git a/xbmc/network/TCPServer.cpp b/xbmc/network/TCPServer.cpp index bf54e4b4a9..bf39c58af8 100644 --- a/xbmc/network/TCPServer.cpp +++ b/xbmc/network/TCPServer.cpp @@ -112,7 +112,7 @@ void CTCPServer::Process() struct timeval to = {1, 0}; FD_ZERO(&rfds); - for (std::vector<SOCKET>::iterator it = m_servers.begin(); it != m_servers.end(); it++) + for (std::vector<SOCKET>::iterator it = m_servers.begin(); it != m_servers.end(); ++it) { FD_SET(*it, &rfds); if ((intptr_t)*it > (intptr_t)max_fd) @@ -182,7 +182,7 @@ void CTCPServer::Process() } } - for (std::vector<SOCKET>::iterator it = m_servers.begin(); it != m_servers.end(); it++) + for (std::vector<SOCKET>::iterator it = m_servers.begin(); it != m_servers.end(); ++it) { if (FD_ISSET(*it, &rfds)) { diff --git a/xbmc/network/WakeOnAccess.cpp b/xbmc/network/WakeOnAccess.cpp index 45d4c507c8..c7fb7a4c07 100644 --- a/xbmc/network/WakeOnAccess.cpp +++ b/xbmc/network/WakeOnAccess.cpp @@ -498,7 +498,7 @@ static void AddHost (const std::string& host, vector<string>& hosts) static void AddHostFromDatabase(const DatabaseSettings& setting, vector<string>& hosts) { - if (setting.type.Equals("mysql")) + if (StringUtils::EqualsNoCase(setting.type, "mysql")) AddHost(setting.host, hosts); } @@ -515,7 +515,7 @@ void CWakeOnAccess::QueueMACDiscoveryForHost(const std::string& host) static void AddHostsFromMediaSource(const CMediaSource& source, std::vector<std::string>& hosts) { - for (vector<string>::const_iterator it = source.vecPaths.begin() ; it != source.vecPaths.end(); it++) + for (vector<string>::const_iterator it = source.vecPaths.begin() ; it != source.vecPaths.end(); ++it) { CURL url(*it); @@ -525,7 +525,7 @@ static void AddHostsFromMediaSource(const CMediaSource& source, std::vector<std: static void AddHostsFromVecSource(const VECSOURCES& sources, vector<string>& hosts) { - for (VECSOURCES::const_iterator it = sources.begin(); it != sources.end(); it++) + for (VECSOURCES::const_iterator it = sources.begin(); it != sources.end(); ++it) AddHostsFromMediaSource(*it, hosts); } @@ -562,7 +562,7 @@ void CWakeOnAccess::QueueMACDiscoveryForAllRemotes() AddHost (url.GetHostName(), hosts); } - for (vector<string>::const_iterator it = hosts.begin(); it != hosts.end(); it++) + for (vector<string>::const_iterator it = hosts.begin(); it != hosts.end(); ++it) QueueMACDiscoveryForHost(*it); } diff --git a/xbmc/network/WebServer.cpp b/xbmc/network/WebServer.cpp index 282a13484e..0c607e5dce 100644 --- a/xbmc/network/WebServer.cpp +++ b/xbmc/network/WebServer.cpp @@ -172,7 +172,7 @@ int CWebServer::AnswerToConnection(void *cls, struct MHD_Connection *connection, { // Look for a IHTTPRequestHandler which can // take care of the current request - for (vector<IHTTPRequestHandler *>::const_iterator it = m_requestHandlers.begin(); it != m_requestHandlers.end(); it++) + for (vector<IHTTPRequestHandler *>::const_iterator it = m_requestHandlers.begin(); it != m_requestHandlers.end(); ++it) { IHTTPRequestHandler *requestHandler = *it; if (requestHandler->CheckHTTPRequest(request)) @@ -269,7 +269,7 @@ int CWebServer::AnswerToConnection(void *cls, struct MHD_Connection *connection, // requests, but let's handle it anyway else { - for (vector<IHTTPRequestHandler *>::const_iterator it = m_requestHandlers.begin(); it != m_requestHandlers.end(); it++) + for (vector<IHTTPRequestHandler *>::const_iterator it = m_requestHandlers.begin(); it != m_requestHandlers.end(); ++it) { IHTTPRequestHandler *requestHandler = *it; if (requestHandler->CheckHTTPRequest(request)) @@ -362,7 +362,7 @@ int CWebServer::HandleRequest(IHTTPRequestHandler *handler, const HTTPRequest &r } multimap<string, string> header = handler->GetHTTPResponseHeaderFields(); - for (multimap<string, string>::const_iterator it = header.begin(); it != header.end(); it++) + for (multimap<string, string>::const_iterator it = header.begin(); it != header.end(); ++it) AddHeader(response, it->first, it->second); MHD_queue_response(request.connection, responseCode, response); @@ -403,7 +403,7 @@ int CWebServer::CreateFileDownloadResponse(struct MHD_Connection *connection, co multimap<string, string> headers; if (GetRequestHeaderValues(connection, MHD_HEADER_KIND, headers) > 0) { - for (multimap<string, string>::const_iterator header = headers.begin(); header != headers.end(); header++) + for (multimap<string, string>::const_iterator header = headers.begin(); header != headers.end(); ++header) CLog::Log(LOGDEBUG, "webserver [IN] %s: %s", header->first.c_str(), header->second.c_str()); } #endif @@ -556,7 +556,7 @@ int CWebServer::CreateFileDownloadResponse(struct MHD_Connection *connection, co context->boundaryWithHeader += MHD_HTTP_HEADER_CONTENT_TYPE ": " + context->contentType + HEADER_NEWLINE; // for every range, we need to add a boundary with header - for (HttpRanges::const_iterator range = context->ranges.begin(); range != context->ranges.end(); range++) + for (HttpRanges::const_iterator range = context->ranges.begin(); range != context->ranges.end(); ++range) { // we need to temporarily add the Content-Range header to the // boundary to be able to determine the length @@ -907,7 +907,7 @@ void CWebServer::RegisterRequestHandler(IHTTPRequestHandler *handler) if (handler == NULL) return; - for (vector<IHTTPRequestHandler *>::iterator it = m_requestHandlers.begin(); it != m_requestHandlers.end(); it++) + for (vector<IHTTPRequestHandler *>::iterator it = m_requestHandlers.begin(); it != m_requestHandlers.end(); ++it) { if (*it == handler) return; @@ -927,7 +927,7 @@ void CWebServer::UnregisterRequestHandler(IHTTPRequestHandler *handler) if (handler == NULL) return; - for (vector<IHTTPRequestHandler *>::iterator it = m_requestHandlers.begin(); it != m_requestHandlers.end(); it++) + for (vector<IHTTPRequestHandler *>::iterator it = m_requestHandlers.begin(); it != m_requestHandlers.end(); ++it) { if (*it == handler) { @@ -1012,7 +1012,7 @@ int64_t CWebServer::ParseRangeHeader(const std::string &rangeHeaderValue, int64_ string rangesValue = rangeHeaderValue.substr(6); // split the value of the "Range" header by "," vector<string> rangeValues = StringUtils::Split(rangesValue, ","); - for (vector<string>::const_iterator range = rangeValues.begin(); range != rangeValues.end(); range++) + for (vector<string>::const_iterator range = rangeValues.begin(); range != rangeValues.end(); ++range) { // there must be a "-" in the range definition if (range->find("-") == string::npos) diff --git a/xbmc/network/WebServer.h b/xbmc/network/WebServer.h index 6beef62c19..24748acd46 100644 --- a/xbmc/network/WebServer.h +++ b/xbmc/network/WebServer.h @@ -22,13 +22,6 @@ #include "system.h" #ifdef HAS_WEB_SERVER -#include <sys/types.h> -#include <sys/select.h> -#include <sys/socket.h> -#include <stdlib.h> -#include <string.h> -#include <stdio.h> -#include <stdint.h> #include <vector> #include "interfaces/json-rpc/ITransportLayer.h" diff --git a/xbmc/network/cddb.cpp b/xbmc/network/cddb.cpp index 133ecc9e26..b3e045b603 100644 --- a/xbmc/network/cddb.cpp +++ b/xbmc/network/cddb.cpp @@ -215,7 +215,7 @@ bool Xcddb::queryCDinfo(CCdInfo* pInfo, int inexact_list_select) //########################################################## // Compose the cddb query string - CStdString read_buffer = getInexactCommand(inexact_list_select); + std::string read_buffer = getInexactCommand(inexact_list_select); if (read_buffer.size() == 0) { CLog::Log(LOGERROR, "Xcddb::queryCDinfo_inexaxt_list_select Size of inexaxt_list_select are 0"); @@ -227,14 +227,14 @@ bool Xcddb::queryCDinfo(CCdInfo* pInfo, int inexact_list_select) //########################################################## // Read the data from cddb Recv(false); //erstmal den Müll abholen - if ( !Send(read_buffer) ) + if ( !Send(read_buffer.c_str()) ) { CLog::Log(LOGERROR, "Xcddb::queryCDinfo_inexaxt_list_select Error sending \"%s\"", read_buffer.c_str()); CLog::Log(LOGERROR, "Xcddb::queryCDinfo_inexaxt_list_select pInfo == NULL"); m_lastError = E_NETWORK_ERROR_SEND; return false; } - CStdString recv_buffer = Recv(true); + std::string recv_buffer = Recv(true); m_lastError = atoi(recv_buffer.c_str()); switch(m_lastError) { @@ -414,9 +414,9 @@ void Xcddb::addTitle(const char *buffer) } //------------------------------------------------------------------------------------------------------------------- -const CStdString& Xcddb::getInexactCommand(int select) const +const std::string& Xcddb::getInexactCommand(int select) const { - typedef map<int, CStdString>::const_iterator iter; + typedef map<int, std::string>::const_iterator iter; iter i = m_mapInexact_cddb_command_list.find(select); if (i == m_mapInexact_cddb_command_list.end()) return m_strNull; @@ -424,9 +424,9 @@ const CStdString& Xcddb::getInexactCommand(int select) const } //------------------------------------------------------------------------------------------------------------------- -const CStdString& Xcddb::getInexactArtist(int select) const +const std::string& Xcddb::getInexactArtist(int select) const { - typedef map<int, CStdString>::const_iterator iter; + typedef map<int, std::string>::const_iterator iter; iter i = m_mapInexact_artist_list.find(select); if (i == m_mapInexact_artist_list.end()) return m_strNull; @@ -434,9 +434,9 @@ const CStdString& Xcddb::getInexactArtist(int select) const } //------------------------------------------------------------------------------------------------------------------- -const CStdString& Xcddb::getInexactTitle(int select) const +const std::string& Xcddb::getInexactTitle(int select) const { - typedef map<int, CStdString>::const_iterator iter; + typedef map<int, std::string>::const_iterator iter; iter i = m_mapInexact_title_list.find(select); if (i == m_mapInexact_title_list.end()) return m_strNull; @@ -444,9 +444,9 @@ const CStdString& Xcddb::getInexactTitle(int select) const } //------------------------------------------------------------------------------------------------------------------- -const CStdString& Xcddb::getTrackArtist(int track) const +const std::string& Xcddb::getTrackArtist(int track) const { - typedef map<int, CStdString>::const_iterator iter; + typedef map<int, std::string>::const_iterator iter; iter i = m_mapArtists.find(track); if (i == m_mapArtists.end()) return m_strNull; @@ -454,9 +454,9 @@ const CStdString& Xcddb::getTrackArtist(int track) const } //------------------------------------------------------------------------------------------------------------------- -const CStdString& Xcddb::getTrackTitle(int track) const +const std::string& Xcddb::getTrackTitle(int track) const { - typedef map<int, CStdString>::const_iterator iter; + typedef map<int, std::string>::const_iterator iter; iter i = m_mapTitles.find(track); if (i == m_mapTitles.end()) return m_strNull; @@ -464,13 +464,13 @@ const CStdString& Xcddb::getTrackTitle(int track) const } //------------------------------------------------------------------------------------------------------------------- -void Xcddb::getDiskTitle(CStdString& strdisk_title) const +void Xcddb::getDiskTitle(std::string& strdisk_title) const { strdisk_title = m_strDisk_title; } //------------------------------------------------------------------------------------------------------------------- -void Xcddb::getDiskArtist(CStdString& strdisk_artist) const +void Xcddb::getDiskArtist(std::string& strdisk_artist) const { strdisk_artist = m_strDisk_artist; } @@ -480,8 +480,8 @@ void Xcddb::parseData(const char *buffer) { //writeLog("parseData Start"); - std::map<CStdString, CStdString> keywords; - std::list<CStdString> keywordsOrder; // remember order of keywords as it appears in data received from CDDB + std::map<std::string, std::string> keywords; + std::list<std::string> keywordsOrder; // remember order of keywords as it appears in data received from CDDB // Collect all the keywords and put them in map. // Multiple occurrences of the same keyword indicate that @@ -497,15 +497,15 @@ void Xcddb::parseData(const char *buffer) char *s = strstr(line, "="); if (s != NULL) { - CStdString strKeyword(line, s - line); + std::string strKeyword(line, s - line); StringUtils::TrimRight(strKeyword); - CStdString strValue(s+1); + std::string strValue(s+1); StringUtils::Replace(strValue, "\\n", "\n"); StringUtils::Replace(strValue, "\\t", "\t"); StringUtils::Replace(strValue, "\\\\", "\\"); - std::map<CStdString, CStdString>::const_iterator it = keywords.find(strKeyword); + std::map<std::string, std::string>::const_iterator it = keywords.find(strKeyword); if (it != keywords.end()) strValue = it->second + strValue; // keyword occured before, concatenate else @@ -517,10 +517,10 @@ void Xcddb::parseData(const char *buffer) } // parse keywords - for (std::list<CStdString>::const_iterator it = keywordsOrder.begin(); it != keywordsOrder.end(); ++it) + for (std::list<std::string>::const_iterator it = keywordsOrder.begin(); it != keywordsOrder.end(); ++it) { - CStdString strKeyword = *it; - CStdString strValue = keywords[strKeyword]; + std::string strKeyword = *it; + std::string strValue = keywords[strKeyword]; /* TODO:STRING_CLEANUP */ if (strKeyword == "DTITLE") @@ -547,10 +547,10 @@ void Xcddb::parseData(const char *buffer) else if (strKeyword== "DGENRE") m_strGenre = TrimToUTF8(strValue); else if (StringUtils::StartsWith(strKeyword, "TTITLE")) - addTitle(strKeyword + "=" + strValue); + addTitle((strKeyword + "=" + strValue).c_str()); else if (strKeyword == "EXTD") { - CStdString strExtd(strValue); + std::string strExtd(strValue); if (m_strYear.empty()) { @@ -568,18 +568,18 @@ void Xcddb::parseData(const char *buffer) size_t iPos = strExtd.find("ID3G: "); if (iPos != std::string::npos) { - CStdString strGenre = strExtd.substr(iPos + 5, 4); + std::string strGenre = strExtd.substr(iPos + 5, 4); StringUtils::TrimLeft(strGenre); if (StringUtils::IsNaturalNumber(strGenre)) { - int iGenre = strtol(strGenre, NULL, 10); + int iGenre = strtol(strGenre.c_str(), NULL, 10); m_strGenre = TagLib::ID3v1::genre(iGenre).to8Bit(true); } } } } else if (StringUtils::StartsWith(strKeyword, "EXTT")) - addExtended(strKeyword + "=" + strValue); + addExtended((strKeyword + "=" + strValue).c_str()); } //writeLog("parseData Ende"); @@ -611,17 +611,17 @@ void Xcddb::addExtended(const char *buffer) return ; } - CStdString strValue; - CStdString strValueUtf8=value; + std::string strValue; + std::string strValueUtf8=value; // You never know if you really get UTF-8 strings from cddb g_charsetConverter.unknownToUTF8(strValueUtf8, strValue); m_mapExtended_track[trk_nr] = strValue; } //------------------------------------------------------------------------------------------------------------------- -const CStdString& Xcddb::getTrackExtended(int track) const +const std::string& Xcddb::getTrackExtended(int track) const { - typedef map<int, CStdString>::const_iterator iter; + typedef map<int, std::string>::const_iterator iter; iter i = m_mapExtended_track.find(track); if (i == m_mapExtended_track.end()) return m_strNull; @@ -721,12 +721,12 @@ void Xcddb::addInexactListLine(int line_cnt, const char *line, int len) m_mapInexact_cddb_command_list[line_cnt] = cddb_command; - CStdString strArtist=artist; + std::string strArtist=artist; // You never know if you really get UTF-8 strings from cddb g_charsetConverter.unknownToUTF8(artist, strArtist); m_mapInexact_artist_list[line_cnt] = strArtist; - CStdString strTitle=title; + std::string strTitle=title; // You never know if you really get UTF-8 strings from cddb g_charsetConverter.unknownToUTF8(title, strTitle); m_mapInexact_title_list[line_cnt] = strTitle; @@ -737,13 +737,13 @@ void Xcddb::addInexactListLine(int line_cnt, const char *line, int len) } //------------------------------------------------------------------------------------------------------------------- -void Xcddb::setCDDBIpAdress(const CStdString& ip_adress) +void Xcddb::setCDDBIpAdress(const std::string& ip_adress) { m_cddb_ip_adress = ip_adress; } //------------------------------------------------------------------------------------------------------------------- -void Xcddb::setCacheDir(const CStdString& pCacheDir ) +void Xcddb::setCacheDir(const std::string& pCacheDir ) { cCacheDir = pCacheDir; } @@ -795,13 +795,13 @@ bool Xcddb::isCDCached( int nr_of_tracks, toc cdtoc[] ) } //------------------------------------------------------------------------------------------------------------------- -const CStdString& Xcddb::getYear() const +const std::string& Xcddb::getYear() const { return m_strYear; } //------------------------------------------------------------------------------------------------------------------- -const CStdString& Xcddb::getGenre() const +const std::string& Xcddb::getGenre() const { return m_strGenre; } @@ -853,7 +853,7 @@ bool Xcddb::queryCDinfo(CCdInfo* pInfo) m_lastError = E_NETWORK_ERROR_OPEN_SOCKET; return false; } - CStdString recv_buffer = Recv(false); + std::string recv_buffer = Recv(false); m_lastError = atoi(recv_buffer.c_str()); switch(m_lastError) { @@ -960,7 +960,7 @@ bool Xcddb::queryCDinfo(CCdInfo* pInfo) return false; } // 200 rock d012180e Soundtrack / Hackers - CStdString read_buffer; + std::string read_buffer; recv_buffer = Recv(false); m_lastError = atoi(recv_buffer.c_str()); switch(m_lastError) @@ -997,7 +997,7 @@ bool Xcddb::queryCDinfo(CCdInfo* pInfo) //########################################################## // Read the data from cddb - if ( !Send(read_buffer) ) + if ( !Send(read_buffer.c_str()) ) { CLog::Log(LOGERROR, "Xcddb::queryCDinfo Error sending \"%s\"", read_buffer.c_str()); m_lastError = E_NETWORK_ERROR_SEND; @@ -1068,16 +1068,16 @@ bool Xcddb::isCDCached( CCdInfo* pInfo ) return XFILE::CFile::Exists(GetCacheFile(pInfo->GetCddbDiscId())); } -CStdString Xcddb::GetCacheFile(uint32_t disc_id) const +std::string Xcddb::GetCacheFile(uint32_t disc_id) const { - CStdString strFileName; + std::string strFileName; strFileName = StringUtils::Format("%x.cddb", disc_id); return URIUtils::AddFileToFolder(cCacheDir, strFileName); } -CStdString Xcddb::TrimToUTF8(const CStdString &untrimmedText) +std::string Xcddb::TrimToUTF8(const std::string &untrimmedText) { - CStdString text(untrimmedText); + std::string text(untrimmedText); StringUtils::Trim(text); // You never know if you really get UTF-8 strings from cddb g_charsetConverter.unknownToUTF8(text); diff --git a/xbmc/network/cddb.h b/xbmc/network/cddb.h index 198ea33b94..4b6fc4f050 100644 --- a/xbmc/network/cddb.h +++ b/xbmc/network/cddb.h @@ -23,6 +23,7 @@ #ifdef HAS_DVD_DRIVE +#include <string> #include <sstream> #include <iostream> #include <map> @@ -32,7 +33,6 @@ #include "storage/cdioSupport.h" #include "utils/AutoPtrHandle.h" -#include "utils/StdString.h" namespace CDDB { @@ -67,47 +67,47 @@ class Xcddb public: Xcddb(); virtual ~Xcddb(); - void setCDDBIpAdress(const CStdString& ip_adress); - void setCacheDir(const CStdString& pCacheDir ); + void setCDDBIpAdress(const std::string& ip_adress); + void setCacheDir(const std::string& pCacheDir ); // int queryCDinfo(int real_track_count, toc cdtoc[]); bool queryCDinfo(MEDIA_DETECT::CCdInfo* pInfo, int inexact_list_select); bool queryCDinfo(MEDIA_DETECT::CCdInfo* pInfo); int getLastError() const; const char * getLastErrorText() const; - const CStdString& getYear() const; - const CStdString& getGenre() const; - const CStdString& getTrackArtist(int track) const; - const CStdString& getTrackTitle(int track) const; - void getDiskArtist(CStdString& strdisk_artist) const; - void getDiskTitle(CStdString& strdisk_title) const; - const CStdString& getTrackExtended(int track) const; + const std::string& getYear() const; + const std::string& getGenre() const; + const std::string& getTrackArtist(int track) const; + const std::string& getTrackTitle(int track) const; + void getDiskArtist(std::string& strdisk_artist) const; + void getDiskTitle(std::string& strdisk_title) const; + const std::string& getTrackExtended(int track) const; uint32_t calc_disc_id(int nr_of_tracks, toc cdtoc[]); - const CStdString& getInexactArtist(int select) const; - const CStdString& getInexactTitle(int select) const; + const std::string& getInexactArtist(int select) const; + const std::string& getInexactTitle(int select) const; bool queryCache( uint32_t discid ); bool writeCacheFile( const char* pBuffer, uint32_t discid ); bool isCDCached( int nr_of_tracks, toc cdtoc[] ); bool isCDCached( MEDIA_DETECT::CCdInfo* pInfo ); protected: - CStdString m_strNull; + std::string m_strNull; AUTOPTR::CAutoPtrSocket m_cddb_socket; const static int recv_buffer = 4096; int m_lastError; - std::map<int, CStdString> m_mapTitles; - std::map<int, CStdString> m_mapArtists; - std::map<int, CStdString> m_mapExtended_track; + std::map<int, std::string> m_mapTitles; + std::map<int, std::string> m_mapArtists; + std::map<int, std::string> m_mapExtended_track; - std::map<int, CStdString> m_mapInexact_cddb_command_list; - std::map<int, CStdString> m_mapInexact_artist_list; - std::map<int, CStdString> m_mapInexact_title_list; + std::map<int, std::string> m_mapInexact_cddb_command_list; + std::map<int, std::string> m_mapInexact_artist_list; + std::map<int, std::string> m_mapInexact_title_list; - CStdString m_strDisk_artist; - CStdString m_strDisk_title; - CStdString m_strYear; - CStdString m_strGenre; + std::string m_strDisk_artist; + std::string m_strDisk_title; + std::string m_strYear; + std::string m_strGenre; void addTitle(const char *buffer); void addExtended(const char *buffer); @@ -121,16 +121,16 @@ protected: int cddb_sum(int n); void addInexactList(const char *list); void addInexactListLine(int line_cnt, const char *line, int len); - const CStdString& getInexactCommand(int select) const; - CStdString GetCacheFile(uint32_t disc_id) const; + const std::string& getInexactCommand(int select) const; + std::string GetCacheFile(uint32_t disc_id) const; /*! \brief Trim and convert some text to UTF8 \param untrimmedText original text to trim and convert \return a utf8 version of the trimmed text */ - CStdString TrimToUTF8(const CStdString &untrimmed); + std::string TrimToUTF8(const std::string &untrimmed); - CStdString m_cddb_ip_adress; - CStdString cCacheDir; + std::string m_cddb_ip_adress; + std::string cCacheDir; }; } diff --git a/xbmc/network/httprequesthandler/HTTPImageHandler.h b/xbmc/network/httprequesthandler/HTTPImageHandler.h index 6565da0b8d..b8dce76ca4 100644 --- a/xbmc/network/httprequesthandler/HTTPImageHandler.h +++ b/xbmc/network/httprequesthandler/HTTPImageHandler.h @@ -25,7 +25,8 @@ class CHTTPImageHandler : public IHTTPRequestHandler { public: - CHTTPImageHandler() { }; + CHTTPImageHandler() { } + virtual ~CHTTPImageHandler() { } virtual IHTTPRequestHandler* GetInstance() { return new CHTTPImageHandler(); } virtual bool CheckHTTPRequest(const HTTPRequest &request); diff --git a/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.h b/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.h index ee947d8fff..35481c281a 100644 --- a/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.h +++ b/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.h @@ -25,7 +25,8 @@ class CHTTPJsonRpcHandler : public IHTTPRequestHandler { public: - CHTTPJsonRpcHandler() { }; + CHTTPJsonRpcHandler() { } + virtual ~CHTTPJsonRpcHandler() { } virtual IHTTPRequestHandler* GetInstance() { return new CHTTPJsonRpcHandler(); } virtual bool CheckHTTPRequest(const HTTPRequest &request); diff --git a/xbmc/network/httprequesthandler/HTTPVfsHandler.cpp b/xbmc/network/httprequesthandler/HTTPVfsHandler.cpp index d0297d9859..c6fd01e370 100644 --- a/xbmc/network/httprequesthandler/HTTPVfsHandler.cpp +++ b/xbmc/network/httprequesthandler/HTTPVfsHandler.cpp @@ -62,13 +62,13 @@ int CHTTPVfsHandler::HandleHTTPRequest(const HTTPRequest &request) if (sources == NULL) continue; - for (VECSOURCES::const_iterator source = sources->begin(); source != sources->end() && !accessible; source++) + for (VECSOURCES::const_iterator source = sources->begin(); source != sources->end() && !accessible; ++source) { // don't allow access to locked / disabled sharing sources if (source->m_iHasLock == 2 || !source->m_allowSharing) continue; - for (vector<string>::const_iterator path = source->vecPaths.begin(); path != source->vecPaths.end(); path++) + for (vector<string>::const_iterator path = source->vecPaths.begin(); path != source->vecPaths.end(); ++path) { string realSourcePath = URIUtils::GetRealPath(*path); if (URIUtils::IsInPath(realPath, realSourcePath)) diff --git a/xbmc/network/httprequesthandler/HTTPVfsHandler.h b/xbmc/network/httprequesthandler/HTTPVfsHandler.h index 93e5602e17..033a4039b6 100644 --- a/xbmc/network/httprequesthandler/HTTPVfsHandler.h +++ b/xbmc/network/httprequesthandler/HTTPVfsHandler.h @@ -25,7 +25,8 @@ class CHTTPVfsHandler : public IHTTPRequestHandler { public: - CHTTPVfsHandler() { }; + CHTTPVfsHandler() { } + virtual ~CHTTPVfsHandler() { } virtual IHTTPRequestHandler* GetInstance() { return new CHTTPVfsHandler(); } virtual bool CheckHTTPRequest(const HTTPRequest &request); diff --git a/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.h b/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.h index b4b2904c2b..dcdccb8588 100644 --- a/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.h +++ b/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.h @@ -24,7 +24,8 @@ class CHTTPWebinterfaceAddonsHandler : public IHTTPRequestHandler { public: - CHTTPWebinterfaceAddonsHandler() { }; + CHTTPWebinterfaceAddonsHandler() { } + virtual ~CHTTPWebinterfaceAddonsHandler() { } virtual IHTTPRequestHandler* GetInstance() { return new CHTTPWebinterfaceAddonsHandler(); } virtual bool CheckHTTPRequest(const HTTPRequest &request); diff --git a/xbmc/network/httprequesthandler/HTTPWebinterfaceHandler.h b/xbmc/network/httprequesthandler/HTTPWebinterfaceHandler.h index b3fb5a6cfd..ea45a9f3cc 100644 --- a/xbmc/network/httprequesthandler/HTTPWebinterfaceHandler.h +++ b/xbmc/network/httprequesthandler/HTTPWebinterfaceHandler.h @@ -25,7 +25,8 @@ class CHTTPWebinterfaceHandler : public IHTTPRequestHandler { public: - CHTTPWebinterfaceHandler() { }; + CHTTPWebinterfaceHandler() { } + virtual ~CHTTPWebinterfaceHandler() { } virtual IHTTPRequestHandler* GetInstance() { return new CHTTPWebinterfaceHandler(); } virtual bool CheckHTTPRequest(const HTTPRequest &request); diff --git a/xbmc/network/linux/NetworkLinux.cpp b/xbmc/network/linux/NetworkLinux.cpp index 13b5ad0822..cea86e5ac0 100644 --- a/xbmc/network/linux/NetworkLinux.cpp +++ b/xbmc/network/linux/NetworkLinux.cpp @@ -67,18 +67,17 @@ using namespace std; -CNetworkInterfaceLinux::CNetworkInterfaceLinux(CNetworkLinux* network, std::string interfaceName, char interfaceMacAddrRaw[6]) - +CNetworkInterfaceLinux::CNetworkInterfaceLinux(CNetworkLinux* network, std::string interfaceName, char interfaceMacAddrRaw[6]): + m_interfaceName(interfaceName), + m_interfaceMacAdr(StringUtils::Format("%02X:%02X:%02X:%02X:%02X:%02X", + (uint8_t)interfaceMacAddrRaw[0], + (uint8_t)interfaceMacAddrRaw[1], + (uint8_t)interfaceMacAddrRaw[2], + (uint8_t)interfaceMacAddrRaw[3], + (uint8_t)interfaceMacAddrRaw[4], + (uint8_t)interfaceMacAddrRaw[5])) { m_network = network; - m_interfaceName = interfaceName; - m_interfaceMacAdr = StringUtils::Format("%02X:%02X:%02X:%02X:%02X:%02X", - (uint8_t)interfaceMacAddrRaw[0], - (uint8_t)interfaceMacAddrRaw[1], - (uint8_t)interfaceMacAddrRaw[2], - (uint8_t)interfaceMacAddrRaw[3], - (uint8_t)interfaceMacAddrRaw[4], - (uint8_t)interfaceMacAddrRaw[5]); memcpy(m_interfaceMacAddrRaw, interfaceMacAddrRaw, sizeof(m_interfaceMacAddrRaw)); } diff --git a/xbmc/network/linux/ZeroconfAvahi.cpp b/xbmc/network/linux/ZeroconfAvahi.cpp index 78d5eae060..746275aeea 100644 --- a/xbmc/network/linux/ZeroconfAvahi.cpp +++ b/xbmc/network/linux/ZeroconfAvahi.cpp @@ -145,7 +145,7 @@ bool CZeroconfAvahi::doPublishService(const std::string& fcr_identifier, //txt records to AvahiStringList AvahiStringList *txtList = NULL; - for(std::vector<std::pair<std::string, std::string> >::const_iterator it=txt.begin(); it!=txt.end(); it++) + for(std::vector<std::pair<std::string, std::string> >::const_iterator it=txt.begin(); it!=txt.end(); ++it) { txtList = avahi_string_list_add_pair(txtList, it->first.c_str(), it->second.c_str()); } diff --git a/xbmc/network/upnp/UPnP.cpp b/xbmc/network/upnp/UPnP.cpp index 4c34e6050f..52580577a1 100644 --- a/xbmc/network/upnp/UPnP.cpp +++ b/xbmc/network/upnp/UPnP.cpp @@ -208,7 +208,7 @@ public: { NPT_String path = "upnp://"+device->GetUUID()+"/"; if (!NPT_StringsEqual(item_id, "0")) { - CStdString id(CURL::Encode(item_id)); + std::string id(CURL::Encode(item_id)); URIUtils::AddSlashAtEnd(id); path += id.c_str(); } @@ -577,14 +577,14 @@ CUPnPServer* CUPnP::CreateServer(int port /* = 0 */) { CUPnPServer* device = - new CUPnPServer(g_infoManager.GetLabel(SYSTEM_FRIENDLY_NAME), + new CUPnPServer(g_infoManager.GetLabel(SYSTEM_FRIENDLY_NAME).c_str(), CUPnPSettings::Get().GetServerUUID().length() ? CUPnPSettings::Get().GetServerUUID().c_str() : NULL, port); // trying to set optional upnp values for XP UPnP UI Icons to detect us // but it doesn't work anyways as it requires multicast for XP to detect us device->m_PresentationURL = - NPT_HttpUrl(m_IP, + NPT_HttpUrl(m_IP.c_str(), CSettings::Get().GetInt("services.webserverport"), "/").ToString(); @@ -608,7 +608,7 @@ CUPnP::StartServer() if (!m_ServerHolder->m_Device.IsNull()) return false; // load upnpserver.xml - CStdString filename = URIUtils::AddFileToFolder(CProfilesManager::Get().GetUserDataFolder(), "upnpserver.xml"); + std::string filename = URIUtils::AddFileToFolder(CProfilesManager::Get().GetUserDataFolder(), "upnpserver.xml"); CUPnPSettings::Get().Load(filename); // create the server with a XBox compatible friendlyname and UUID from upnpserver.xml if found @@ -661,13 +661,13 @@ CUPnPRenderer* CUPnP::CreateRenderer(int port /* = 0 */) { CUPnPRenderer* device = - new CUPnPRenderer(g_infoManager.GetLabel(SYSTEM_FRIENDLY_NAME), + new CUPnPRenderer(g_infoManager.GetLabel(SYSTEM_FRIENDLY_NAME).c_str(), false, (CUPnPSettings::Get().GetRendererUUID().length() ? CUPnPSettings::Get().GetRendererUUID().c_str() : NULL), port); device->m_PresentationURL = - NPT_HttpUrl(m_IP, + NPT_HttpUrl(m_IP.c_str(), CSettings::Get().GetInt("services.webserverport"), "/").ToString(); device->m_ModelName = "Kodi"; @@ -687,7 +687,7 @@ bool CUPnP::StartRenderer() { if (!m_RendererHolder->m_Device.IsNull()) return false; - CStdString filename = URIUtils::AddFileToFolder(CProfilesManager::Get().GetUserDataFolder(), "upnpserver.xml"); + std::string filename = URIUtils::AddFileToFolder(CProfilesManager::Get().GetUserDataFolder(), "upnpserver.xml"); CUPnPSettings::Get().Load(filename); m_RendererHolder->m_Device = CreateRenderer(CUPnPSettings::Get().GetRendererPort()); diff --git a/xbmc/network/upnp/UPnP.h b/xbmc/network/upnp/UPnP.h index 96194e6ac8..56c91b0a7b 100644 --- a/xbmc/network/upnp/UPnP.h +++ b/xbmc/network/upnp/UPnP.h @@ -23,7 +23,7 @@ */ #pragma once -#include "utils/StdString.h" +#include <string> class NPT_LogHandler; class PLT_UPnP; @@ -88,7 +88,7 @@ public: PLT_MediaController* m_MediaController; private: - CStdString m_IP; + std::string m_IP; PLT_UPnP* m_UPnP; NPT_LogHandler* m_LogHandler; CDeviceHostReferenceHolder* m_ServerHolder; diff --git a/xbmc/network/upnp/UPnPInternal.cpp b/xbmc/network/upnp/UPnPInternal.cpp index e7d13b9f49..2b1d6b16d6 100644 --- a/xbmc/network/upnp/UPnPInternal.cpp +++ b/xbmc/network/upnp/UPnPInternal.cpp @@ -113,7 +113,7 @@ NPT_String GetMimeType(const CFileItem& item, const PLT_HttpRequestContext* context /* = NULL */) { - CStdString path = item.GetPath(); + std::string path = item.GetPath(); if (item.HasVideoInfoTag() && !item.GetVideoInfoTag()->GetPath().empty()) { path = item.GetVideoInfoTag()->GetPath(); } else if (item.HasMusicInfoTag() && !item.GetMusicInfoTag()->GetURL().empty()) { @@ -221,13 +221,13 @@ PopulateObjectFromTag(CMusicInfoTag& tag, EClientQuirks quirks) { if (!tag.GetURL().empty() && file_path) - *file_path = tag.GetURL(); + *file_path = tag.GetURL().c_str(); std::vector<std::string> genres = tag.GetGenre(); for (unsigned int index = 0; index < genres.size(); index++) object.m_Affiliation.genres.Add(genres.at(index).c_str()); - object.m_Title = tag.GetTitle(); - object.m_Affiliation.album = tag.GetAlbum(); + object.m_Title = tag.GetTitle().c_str(); + object.m_Affiliation.album = tag.GetAlbum().c_str(); for (unsigned int index = 0; index < tag.GetArtist().size(); index++) { object.m_People.artists.Add(tag.GetArtist().at(index).c_str()); @@ -264,7 +264,7 @@ PopulateObjectFromTag(CVideoInfoTag& tag, EClientQuirks quirks) { if (!tag.m_strFileNameAndPath.empty() && file_path) - *file_path = tag.m_strFileNameAndPath; + *file_path = tag.m_strFileNameAndPath.c_str(); if (tag.m_iDbId != -1 ) { if (tag.m_type == MediaTypeMusicVideo) { @@ -272,21 +272,21 @@ PopulateObjectFromTag(CVideoInfoTag& tag, object.m_Creator = StringUtils::Join(tag.m_artist, g_advancedSettings.m_videoItemSeparator).c_str(); for (std::vector<std::string>::const_iterator itArtist = tag.m_artist.begin(); itArtist != tag.m_artist.end(); ++itArtist) object.m_People.artists.Add(itArtist->c_str()); - object.m_Affiliation.album = tag.m_strAlbum; - object.m_Title = tag.m_strTitle; + object.m_Affiliation.album = tag.m_strAlbum.c_str(); + object.m_Title = tag.m_strTitle.c_str(); object.m_Date = CDateTime(tag.m_iYear, 1, 1, 0, 0, 0).GetAsW3CDate().c_str(); object.m_ReferenceID = NPT_String::Format("videodb://musicvideos/titles/%i", tag.m_iDbId); } else if (tag.m_type == MediaTypeMovie) { object.m_ObjectClass.type = "object.item.videoItem.movie"; - object.m_Title = tag.m_strTitle; + object.m_Title = tag.m_strTitle.c_str(); object.m_Date = CDateTime(tag.m_iYear, 1, 1, 0, 0, 0).GetAsW3CDate().c_str(); object.m_ReferenceID = NPT_String::Format("videodb://movies/titles/%i", tag.m_iDbId); } else { object.m_ObjectClass.type = "object.item.videoItem.videoBroadcast"; object.m_Recorded.program_title = "S" + ("0" + NPT_String::FromInteger(tag.m_iSeason)).Right(2); object.m_Recorded.program_title += "E" + ("0" + NPT_String::FromInteger(tag.m_iEpisode)).Right(2); - object.m_Recorded.program_title += " : " + tag.m_strTitle; - object.m_Recorded.series_title = tag.m_strShowTitle; + object.m_Recorded.program_title += (" : " + tag.m_strTitle).c_str(); + object.m_Recorded.series_title = tag.m_strShowTitle.c_str(); int season = tag.m_iSeason > 1 ? tag.m_iSeason : 1; object.m_Recorded.episode_number = season * 100 + tag.m_iEpisode; object.m_Title = object.m_Recorded.series_title + " - " + object.m_Recorded.program_title; @@ -307,7 +307,8 @@ PopulateObjectFromTag(CVideoInfoTag& tag, object.m_XbmcInfo.date_added = tag.m_dateAdded.GetAsW3CDate().c_str(); object.m_XbmcInfo.rating = tag.m_fRating; - object.m_XbmcInfo.votes = tag.m_strVotes; + object.m_XbmcInfo.votes = tag.m_strVotes.c_str(); + object.m_XbmcInfo.unique_identifier = tag.m_strIMDBNumber.c_str(); for (unsigned int index = 0; index < tag.m_genre.size(); index++) object.m_Affiliation.genres.Add(tag.m_genre.at(index).c_str()); @@ -322,9 +323,9 @@ PopulateObjectFromTag(CVideoInfoTag& tag, for (unsigned int index = 0; index < tag.m_writingCredits.size(); index++) object.m_People.authors.Add(tag.m_writingCredits[index].c_str()); - object.m_Description.description = tag.m_strTagLine; - object.m_Description.long_description = tag.m_strPlot; - object.m_Description.rating = tag.m_strMPAARating; + object.m_Description.description = tag.m_strTagLine.c_str(); + object.m_Description.long_description = tag.m_strPlot.c_str(); + object.m_Description.rating = tag.m_strMPAARating.c_str(); object.m_MiscInfo.last_position = (NPT_UInt32)tag.m_resumePoint.timeInSeconds; object.m_MiscInfo.last_time = tag.m_lastPlayed.GetAsW3CDateTime().c_str(); object.m_MiscInfo.play_count = tag.m_playCount; @@ -508,15 +509,15 @@ BuildObject(CFileItem& item, case VIDEODATABASEDIRECTORY::NODE_TYPE_ACTOR: container->m_ObjectClass.type += ".person.videoArtist"; container->m_Creator = StringUtils::Join(tag.m_artist, g_advancedSettings.m_videoItemSeparator).c_str(); - container->m_Title = tag.m_strTitle; + container->m_Title = tag.m_strTitle.c_str(); break; case VIDEODATABASEDIRECTORY::NODE_TYPE_SEASONS: case VIDEODATABASEDIRECTORY::NODE_TYPE_TITLE_TVSHOWS: container->m_ObjectClass.type += ".album.videoAlbum"; - container->m_Recorded.series_title = tag.m_strShowTitle; + container->m_Recorded.series_title = tag.m_strShowTitle.c_str(); container->m_Recorded.episode_number = tag.m_iEpisode; container->m_MiscInfo.play_count = tag.m_playCount; - container->m_Title = tag.m_strTitle; + container->m_Title = tag.m_strTitle.c_str(); if (!tag.m_premiered.IsValid() && tag.m_iYear) container->m_Date = CDateTime(tag.m_iYear, 1, 1, 0, 0, 0).GetAsW3CDateTime().c_str(); else @@ -534,8 +535,8 @@ BuildObject(CFileItem& item, for (unsigned int index = 0; index < tag.m_writingCredits.size(); index++) container->m_People.authors.Add(tag.m_writingCredits[index].c_str()); - container->m_Description.description = tag.m_strTagLine; - container->m_Description.long_description = tag.m_strPlot; + container->m_Description.description = tag.m_strTagLine.c_str(); + container->m_Description.long_description = tag.m_strPlot.c_str(); break; default: @@ -566,9 +567,9 @@ BuildObject(CFileItem& item, // set a title for the object if (object->m_Title.IsEmpty()) { if (!item.GetLabel().empty()) { - CStdString title = item.GetLabel(); + std::string title = item.GetLabel(); if (item.IsPlayList() || !item.m_bIsFolder) URIUtils::RemoveExtension(title); - object->m_Title = title; + object->m_Title = title.c_str(); } } @@ -615,15 +616,15 @@ failure: /*---------------------------------------------------------------------- | CUPnPServer::CorrectAllItemsSortHack +---------------------------------------------------------------------*/ -const CStdString& -CorrectAllItemsSortHack(const CStdString &item) +const std::string& +CorrectAllItemsSortHack(const std::string &item) { // This is required as in order for the "* All Albums" etc. items to sort // correctly, they must have fake artist/album etc. information generated. // This looks nasty if we attempt to render it to the GUI, thus this (further) // workaround if ((item.size() == 1 && item[0] == 0x01) || (item.size() > 1 && ((unsigned char) item[1]) == 0xff)) - return StringUtils::EmptyString; + return StringUtils::Empty; return item; } @@ -716,6 +717,7 @@ PopulateTagFromObject(CVideoInfoTag& tag, tag.m_dateAdded.SetFromW3CDate((const char*)object.m_XbmcInfo.date_added); tag.m_fRating = object.m_XbmcInfo.rating; tag.m_strVotes = object.m_XbmcInfo.votes; + tag.m_strIMDBNumber = object.m_XbmcInfo.unique_identifier; for (unsigned int index = 0; index < object.m_Affiliation.genres.GetItemCount(); index++) { @@ -982,7 +984,7 @@ bool GetResource(const PLT_MediaObject* entry, CFileItem& item) { if(info.Match(PLT_ProtocolInfo("*", "*", allowed[type], "*"))) { - CStdString prop = StringUtils::Format("subtitle:%d", ++subs); + std::string prop = StringUtils::Format("subtitle:%d", ++subs); item.SetProperty(prop, (const char*)res.m_Uri); break; } diff --git a/xbmc/network/upnp/UPnPInternal.h b/xbmc/network/upnp/UPnPInternal.h index f0bbf991a5..a76f904d74 100644 --- a/xbmc/network/upnp/UPnPInternal.h +++ b/xbmc/network/upnp/UPnPInternal.h @@ -23,8 +23,8 @@ #include <Neptune/Source/Core/NptStrings.h> #include "system.h" -#include "utils/StdString.h" #include "FileItem.h" +#include <string> class CUPnPServer; class CFileItem; @@ -82,7 +82,7 @@ namespace UPNP const NPT_String GetProtocolInfo(const CFileItem& item, const char* protocol, const PLT_HttpRequestContext* context = NULL); - const CStdString& CorrectAllItemsSortHack(const CStdString &item); + const std::string& CorrectAllItemsSortHack(const std::string &item); NPT_Result PopulateTagFromObject(MUSIC_INFO::CMusicInfoTag& tag, PLT_MediaObject& object, diff --git a/xbmc/network/upnp/UPnPPlayer.h b/xbmc/network/upnp/UPnPPlayer.h index 7e20b86c4c..c10b5d5dff 100644 --- a/xbmc/network/upnp/UPnPPlayer.h +++ b/xbmc/network/upnp/UPnPPlayer.h @@ -20,6 +20,7 @@ */ #include "cores/IPlayer.h" +#include <string> class PLT_MediaController; class CGUIDialogBusy; diff --git a/xbmc/network/upnp/UPnPRenderer.cpp b/xbmc/network/upnp/UPnPRenderer.cpp index 7aeb034ead..2c84a46d4e 100644 --- a/xbmc/network/upnp/UPnPRenderer.cpp +++ b/xbmc/network/upnp/UPnPRenderer.cpp @@ -214,7 +214,7 @@ CUPnPRenderer::ProcessHttpGetRequest(NPT_HttpRequest& request, } // open the file - CStdString path (CURL::Decode((const char*) filepath)); + std::string path (CURL::Decode((const char*) filepath)); NPT_File file(path.c_str()); NPT_Result result = file.Open(NPT_FILE_OPEN_MODE_READ); if (NPT_FAILED(result)) { @@ -277,7 +277,7 @@ CUPnPRenderer::Announce(AnnouncementFlag flag, const char *sender, const char *m if (NPT_FAILED(FindServiceByType("urn:schemas-upnp-org:service:RenderingControl:1", rct))) return; - CStdString buffer; + std::string buffer; buffer = StringUtils::Format("%" PRId64, data["volume"].asInteger()); rct->SetStateVariable("Volume", buffer.c_str()); @@ -314,7 +314,7 @@ CUPnPRenderer::UpdateState() avt->SetStateVariable("NumberOfTracks", "1"); avt->SetStateVariable("CurrentTrack", "1"); - CStdString buffer = g_infoManager.GetCurrentPlayTime(TIME_FORMAT_HH_MM_SS); + std::string buffer = g_infoManager.GetCurrentPlayTime(TIME_FORMAT_HH_MM_SS); avt->SetStateVariable("RelativeTimePosition", buffer.c_str()); avt->SetStateVariable("AbsoluteTimePosition", buffer.c_str()); @@ -330,14 +330,14 @@ CUPnPRenderer::UpdateState() } else if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW) { avt->SetStateVariable("TransportState", "PLAYING"); - avt->SetStateVariable("AVTransportURI" , g_infoManager.GetPictureLabel(SLIDE_FILE_PATH)); - avt->SetStateVariable("CurrentTrackURI", g_infoManager.GetPictureLabel(SLIDE_FILE_PATH)); + avt->SetStateVariable("AVTransportURI" , g_infoManager.GetPictureLabel(SLIDE_FILE_PATH).c_str()); + avt->SetStateVariable("CurrentTrackURI", g_infoManager.GetPictureLabel(SLIDE_FILE_PATH).c_str()); avt->SetStateVariable("TransportPlaySpeed", "1"); CGUIWindowSlideShow *slideshow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW); if (slideshow) { - CStdString index; + std::string index; index = StringUtils::Format("%d", slideshow->NumSlides()); avt->SetStateVariable("NumberOfTracks", index.c_str()); index = StringUtils::Format("%d", slideshow->CurrentSlide()); @@ -403,7 +403,7 @@ CUPnPRenderer::GetMetadata(NPT_String& meta) PLT_MediaObject* object = BuildObject(item, file_path, false, thumb_loader); if (object) { // fetch the item's artwork - CStdString thumb; + std::string thumb; if (object->m_ObjectClass.type == "object.item.audioItem.musicTrack") thumb = g_infoManager.GetImage(MUSICPLAYER_COVER, -1); else @@ -625,7 +625,7 @@ CUPnPRenderer::PlayMedia(const NPT_String& uri, const NPT_String& meta, PLT_Acti if (item->IsPicture()) { CApplicationMessenger::Get().PictureShow(item->GetPath()); } else { - CApplicationMessenger::Get().MediaPlay(*item); + CApplicationMessenger::Get().MediaPlay(*item, false); } if (g_application.m_pPlayer->IsPlaying() || g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW) { diff --git a/xbmc/network/upnp/UPnPServer.cpp b/xbmc/network/upnp/UPnPServer.cpp index 20e3bf5ab2..df79d3f2bd 100644 --- a/xbmc/network/upnp/UPnPServer.cpp +++ b/xbmc/network/upnp/UPnPServer.cpp @@ -230,10 +230,10 @@ NPT_String CUPnPServer::BuildSafeResourceUri(const NPT_HttpUrl &rooturi, const char* file_path) { CURL url(file_path); - CStdString md5; + std::string md5; // determine the filename to provide context to md5'd urls - CStdString filename; + std::string filename; if (url.IsProtocol("image")) filename = URIUtils::GetFileName(url.GetHostName()); else @@ -323,7 +323,7 @@ CUPnPServer::Build(CFileItemPtr item, if (item->GetLabel().empty()) { /* if no label try to grab it from node type */ - CStdString label; + std::string label; if (CMusicDatabaseDirectory::GetLabel((const char*)path, label)) { item->SetLabel(label); item->SetLabelPreformated(true); @@ -367,7 +367,7 @@ CUPnPServer::Build(CFileItemPtr item, // try to grab it from the folder if (item->GetLabel().empty()) { - CStdString label; + std::string label; if (CVideoDatabaseDirectory::GetLabel((const char*)path, label)) { item->SetLabel(label); item->SetLabelPreformated(true); @@ -559,7 +559,7 @@ CUPnPServer::OnBrowseMetadata(PLT_ActionReference& action, item.reset(new CFileItem((const char*)id, CDirectory::Exists((const char*)id))); // attempt to determine the parent of this item - CStdString parent; + std::string parent; if (URIUtils::IsVideoDb((const char*)id) || URIUtils::IsMusicDb((const char*)id) || StringUtils::StartsWithNoCase((const char*)id, "library://video/")) { if (!URIUtils::GetParentPath((const char*)id, parent)) { parent = "0"; @@ -572,7 +572,7 @@ CUPnPServer::OnBrowseMetadata(PLT_ActionReference& action, // or could handle this in URIUtils::GetParentPath() possibly, // however this is quicker to implement and subsequently purge when a // better solution presents itself - CStdString child_id((const char*)id); + std::string child_id((const char*)id); if (StringUtils::StartsWithNoCase(child_id, "special://musicplaylists/")) parent = "musicdb://"; else if (StringUtils::StartsWithNoCase(child_id, "special://videoplaylists/")) parent = "library://video/"; else if (StringUtils::StartsWithNoCase(child_id, "sources://video/")) parent = "library://video/"; @@ -640,7 +640,7 @@ CUPnPServer::OnBrowseDirectChildren(PLT_ActionReference& action, return NPT_FAILURE; } - items.SetPath(CStdString(parent_id)); + items.SetPath(std::string(parent_id)); // guard against loading while saving to the same cache file // as CArchive currently performs no locking itself @@ -894,8 +894,7 @@ CUPnPServer::OnSearchContainer(PLT_ActionReference& action, if (genre.GetLength() > 0) { // all tracks by genre filtered by artist and/or album - CStdString strPath; - strPath = StringUtils::Format("musicdb://genres/%i/%i/%i/", + std::string strPath = StringUtils::Format("musicdb://genres/%i/%i/%i/", database.GetGenreByName((const char*)genre), database.GetArtistByName((const char*)artist), // will return -1 if no artist database.GetAlbumByName((const char*)album)); // will return -1 if no album @@ -903,15 +902,14 @@ CUPnPServer::OnSearchContainer(PLT_ActionReference& action, return OnBrowseDirectChildren(action, strPath.c_str(), filter, starting_index, requested_count, sort_criteria, context); } else if (artist.GetLength() > 0) { // all tracks by artist name filtered by album if passed - CStdString strPath; - strPath = StringUtils::Format("musicdb://artists/%i/%i/", + std::string strPath = StringUtils::Format("musicdb://artists/%i/%i/", database.GetArtistByName((const char*)artist), database.GetAlbumByName((const char*)album)); // will return -1 if no album return OnBrowseDirectChildren(action, strPath.c_str(), filter, starting_index, requested_count, sort_criteria, context); } else if (album.GetLength() > 0) { // all tracks by album name - CStdString strPath = StringUtils::Format("musicdb://albums/%i/", + std::string strPath = StringUtils::Format("musicdb://albums/%i/", database.GetAlbumByName((const char*)album)); return OnBrowseDirectChildren(action, strPath.c_str(), filter, starting_index, requested_count, sort_criteria, context); @@ -934,12 +932,12 @@ CUPnPServer::OnSearchContainer(PLT_ActionReference& action, database.Open(); if (genre.GetLength() > 0) { - CStdString strPath = StringUtils::Format("musicdb://genres/%i/%i/", + std::string strPath = StringUtils::Format("musicdb://genres/%i/%i/", database.GetGenreByName((const char*)genre), database.GetArtistByName((const char*)artist)); // no artist should return -1 return OnBrowseDirectChildren(action, strPath.c_str(), filter, starting_index, requested_count, sort_criteria, context); } else if (artist.GetLength() > 0) { - CStdString strPath = StringUtils::Format("musicdb://artists/%i/", + std::string strPath = StringUtils::Format("musicdb://artists/%i/", database.GetArtistByName((const char*)artist)); return OnBrowseDirectChildren(action, strPath.c_str(), filter, starting_index, requested_count, sort_criteria, context); } @@ -952,7 +950,7 @@ CUPnPServer::OnSearchContainer(PLT_ActionReference& action, if (genre.GetLength() > 0) { CMusicDatabase database; database.Open(); - CStdString strPath = StringUtils::Format("musicdb://genres/%i/", database.GetGenreByName((const char*)genre)); + std::string strPath = StringUtils::Format("musicdb://genres/%i/", database.GetGenreByName((const char*)genre)); return OnBrowseDirectChildren(action, strPath.c_str(), filter, starting_index, requested_count, sort_criteria, context); } return OnBrowseDirectChildren(action, "musicdb://artists/", filter, starting_index, requested_count, sort_criteria, context); @@ -1009,7 +1007,7 @@ CUPnPServer::OnUpdateObject(PLT_ActionReference& action, NPT_Map<NPT_String,NPT_String>& new_vals, const PLT_HttpRequestContext& context) { - CStdString path(CURL::Decode(object_id)); + std::string path(CURL::Decode(object_id)); CFileItem updated; updated.SetPath(path); CLog::Log(LOGINFO, "UPnP: OnUpdateObject: %s from %s", path.c_str(), @@ -1047,7 +1045,7 @@ CUPnPServer::OnUpdateObject(PLT_ActionReference& action, goto failure; } - CStdString file_path; + std::string file_path; db.GetFilePathById(id, file_path, content_type); CVideoInfoTag tag; db.LoadVideoInfo(file_path, tag); @@ -1174,7 +1172,7 @@ CUPnPServer::ServeFile(const NPT_HttpRequest& request, NPT_List<NPT_String>::Iterator url = files.GetFirstItem(); for (;url;url++) { - output += "#EXTINF:-1," + URIUtils::GetFileName((const char*)*url); + output += ("#EXTINF:-1," + URIUtils::GetFileName((const char*)*url)).c_str(); output += "\r\n"; output += BuildSafeResourceUri( rooturi, @@ -1190,7 +1188,7 @@ CUPnPServer::ServeFile(const NPT_HttpRequest& request, if(URIUtils::IsURL((const char*)file_path)) { - CStdString disp = "inline; filename=\"" + URIUtils::GetFileName((const char*)file_path) + "\""; + std::string disp = "inline; filename=\"" + URIUtils::GetFileName((const char*)file_path) + "\""; response.GetHeaders().SetHeader("Content-Disposition", disp.c_str()); } @@ -1212,58 +1210,59 @@ CUPnPServer::ServeFile(const NPT_HttpRequest& request, bool CUPnPServer::SortItems(CFileItemList& items, const char* sort_criteria) { - CStdString criteria(sort_criteria); + std::string criteria(sort_criteria); if (criteria.empty()) { return false; } bool sorted = false; vector<string> tokens = StringUtils::Split(criteria, ","); - for (vector<string>::reverse_iterator itr = tokens.rbegin(); itr != tokens.rend(); itr++) { + for (vector<string>::reverse_iterator itr = tokens.rbegin(); itr != tokens.rend(); ++itr) { SortDescription sorting; /* Platinum guarantees 1st char is - or + */ sorting.sortOrder = StringUtils::StartsWith(*itr, "+") ? SortOrderAscending : SortOrderDescending; - CStdString method = itr->substr(1); + std::string method = itr->substr(1); /* resource specific */ - if (method.Equals("res@duration")) + if (StringUtils::EqualsNoCase(method, "res@duration")) sorting.sortBy = SortByTime; - else if (method.Equals("res@size")) + else if (StringUtils::EqualsNoCase(method, "res@size")) sorting.sortBy = SortBySize; - else if (method.Equals("res@bitrate")) + else if (StringUtils::EqualsNoCase(method, "res@bitrate")) sorting.sortBy = SortByBitrate; /* dc: */ - else if (method.Equals("dc:date")) + else if (StringUtils::EqualsNoCase(method, "dc:date")) sorting.sortBy = SortByDate; - else if (method.Equals("dc:title")) + else if (StringUtils::EqualsNoCase(method, "dc:title")) { sorting.sortBy = SortByTitle; sorting.sortAttributes = SortAttributeIgnoreArticle; } /* upnp: */ - else if (method.Equals("upnp:album")) + else if (StringUtils::EqualsNoCase(method, "upnp:album")) sorting.sortBy = SortByAlbum; - else if (method.Equals("upnp:artist") || method.Equals("upnp:albumArtist")) + else if (StringUtils::EqualsNoCase(method, "upnp:artist") || + StringUtils::EqualsNoCase(method, "upnp:albumArtist")) sorting.sortBy = SortByArtist; - else if (method.Equals("upnp:episodeNumber")) + else if (StringUtils::EqualsNoCase(method, "upnp:episodeNumber")) sorting.sortBy = SortByEpisodeNumber; - else if (method.Equals("upnp:episodeCount")) + else if (StringUtils::EqualsNoCase(method, "upnp:episodeCount")) sorting.sortBy = SortByNumberOfEpisodes; - else if (method.Equals("upnp:episodeSeason")) + else if (StringUtils::EqualsNoCase(method, "upnp:episodeSeason")) sorting.sortBy = SortBySeason; - else if (method.Equals("upnp:genre")) + else if (StringUtils::EqualsNoCase(method, "upnp:genre")) sorting.sortBy = SortByGenre; - else if (method.Equals("upnp:originalTrackNumber")) + else if (StringUtils::EqualsNoCase(method, "upnp:originalTrackNumber")) sorting.sortBy = SortByTrackNumber; - else if(method.Equals("upnp:rating")) + else if(StringUtils::EqualsNoCase(method, "upnp:rating")) sorting.sortBy = SortByMPAA; - else if (method.Equals("xbmc:rating")) + else if (StringUtils::EqualsNoCase(method, "xbmc:rating")) sorting.sortBy = SortByRating; - else if (method.Equals("xbmc:dateadded")) + else if (StringUtils::EqualsNoCase(method, "xbmc:dateadded")) sorting.sortBy = SortByDateAdded; - else if (method.Equals("xbmc:votes")) + else if (StringUtils::EqualsNoCase(method, "xbmc:votes")) sorting.sortBy = SortByVotes; else { CLog::Log(LOGINFO, "UPnP: unsupported sort criteria '%s' passed", method.c_str()); diff --git a/xbmc/network/windows/NetworkWin32.cpp b/xbmc/network/windows/NetworkWin32.cpp index 759e406e3d..922c88b799 100644 --- a/xbmc/network/windows/NetworkWin32.cpp +++ b/xbmc/network/windows/NetworkWin32.cpp @@ -41,12 +41,11 @@ using namespace std; -CNetworkInterfaceWin32::CNetworkInterfaceWin32(CNetworkWin32* network, IP_ADAPTER_INFO adapter) - +CNetworkInterfaceWin32::CNetworkInterfaceWin32(CNetworkWin32* network, IP_ADAPTER_INFO adapter): + m_adaptername(adapter.Description) { m_network = network; m_adapter = adapter; - m_adaptername = adapter.Description; } CNetworkInterfaceWin32::~CNetworkInterfaceWin32(void) diff --git a/xbmc/osx/CocoaInterface.h b/xbmc/osx/CocoaInterface.h index 9987243541..e7953fccff 100644 --- a/xbmc/osx/CocoaInterface.h +++ b/xbmc/osx/CocoaInterface.h @@ -21,7 +21,6 @@ #define _OSX_INTERFACE_H_ #include <string> -#include "utils/StdString.h" #include "AutoPool.h" #ifdef __cplusplus @@ -47,7 +46,7 @@ extern "C" // Devices // char* Cocoa_MountPoint2DeviceName(char *path); - bool Cocoa_GetVolumeNameFromMountPoint(const char *mountPoint, CStdString &volumeName); + bool Cocoa_GetVolumeNameFromMountPoint(const std::string &mountPoint, std::string &volumeName); // Mouse. // diff --git a/xbmc/osx/CocoaInterface.mm b/xbmc/osx/CocoaInterface.mm index b500c7ce32..424fa0ac80 100644 --- a/xbmc/osx/CocoaInterface.mm +++ b/xbmc/osx/CocoaInterface.mm @@ -277,12 +277,12 @@ char* Cocoa_MountPoint2DeviceName(char *path) return path; } -bool Cocoa_GetVolumeNameFromMountPoint(const char *mountPoint, CStdString &volumeName) +bool Cocoa_GetVolumeNameFromMountPoint(const std::string &mountPoint, std::string &volumeName) { CCocoaAutoPool pool; unsigned i, count = 0; struct statfs *buf = NULL; - CStdString mountpoint, devicepath; + std::string mountpoint, devicepath; count = getmntinfo(&buf, 0); for (i=0; i<count; i++) diff --git a/xbmc/osx/IOSExternalTouchController.mm b/xbmc/osx/IOSExternalTouchController.mm index c528eb8c65..25475983f3 100644 --- a/xbmc/osx/IOSExternalTouchController.mm +++ b/xbmc/osx/IOSExternalTouchController.mm @@ -75,13 +75,13 @@ const CGFloat timeFadeSecs = 2.0; [descriptionLabel setLineBreakMode:UILineBreakModeTailTruncation]; [descriptionLabel setNumberOfLines:5]; - CStdString descText = g_localizeStrings.Get(34404) + "\n"; + std::string descText = g_localizeStrings.Get(34404) + "\n"; descText += g_localizeStrings.Get(34405) + "\n"; descText += g_localizeStrings.Get(34406) + "\n"; descText += g_localizeStrings.Get(34407) + "\n"; descText += g_localizeStrings.Get(34408) + "\n"; - NSString *stringFromUTFString = [[NSString alloc] initWithUTF8String:descText]; + NSString *stringFromUTFString = [[NSString alloc] initWithUTF8String:descText.c_str()]; [descriptionLabel setText:stringFromUTFString]; [stringFromUTFString release]; @@ -93,7 +93,7 @@ const CGFloat timeFadeSecs = 2.0; [descriptionLabel release]; //load the splash image - CStdString strUserSplash = CSpecialProtocol::TranslatePath("special://xbmc/media/Splash.png"); + std::string strUserSplash = CSpecialProtocol::TranslatePath("special://xbmc/media/Splash.png"); xbmcLogo = [UIImage imageWithContentsOfFile:[NSString stringWithUTF8String:strUserSplash.c_str()]]; //make a view with the image diff --git a/xbmc/osx/OSXTextInputResponder.mm b/xbmc/osx/OSXTextInputResponder.mm index 49e9030d26..b77e56834e 100644 --- a/xbmc/osx/OSXTextInputResponder.mm +++ b/xbmc/osx/OSXTextInputResponder.mm @@ -27,6 +27,8 @@ #include "guilib/GUIWindowManager.h" #include "GUIUserMessages.h" #include "utils/log.h" +#include "ApplicationMessenger.h" +#include "guilib/key.h" #undef BOOL void SendKeyboardText(const char *text) @@ -37,9 +39,12 @@ void SendKeyboardText(const char *text) if ((unsigned char)*text < ' ' || *text == 127) return; - CGUIMessage msg(GUI_MSG_INPUT_TEXT, 0, 0); - msg.SetLabel(text); - g_windowManager.SendThreadMessage(msg, g_windowManager.GetFocusedWindow()); + ThreadMessage tMsg = {TMSG_GUI_ACTION}; + tMsg.param1 = WINDOW_INVALID; + CAction *action = new CAction(ACTION_INPUT_TEXT); + action->SetText(text); + tMsg.lpVoid = action; + CApplicationMessenger::Get().SendMessage(tMsg, false); } void SendEditingText(const char *text, unsigned int location, unsigned int length) diff --git a/xbmc/osx/XBMCHelper.cpp b/xbmc/osx/XBMCHelper.cpp index 00564bffaf..cafa73d3ae 100644 --- a/xbmc/osx/XBMCHelper.cpp +++ b/xbmc/osx/XBMCHelper.cpp @@ -68,7 +68,7 @@ XBMCHelper::XBMCHelper() , m_errorStarting(false) { // Compute the KODI_HOME path. - CStdString homePath; + std::string homePath; CUtil::GetHomePath(homePath); m_homepath = homePath; diff --git a/xbmc/osx/ios/XBMCController.mm b/xbmc/osx/ios/XBMCController.mm index 9b6c943049..3e52de3ad6 100644 --- a/xbmc/osx/ios/XBMCController.mm +++ b/xbmc/osx/ios/XBMCController.mm @@ -147,11 +147,11 @@ void AnnounceBridge(ANNOUNCEMENT::AnnouncementFlag flag, const char *sender, con if (!thumb.empty()) { bool needsRecaching; - CStdString cachedThumb(CTextureCache::Get().CheckCachedImage(thumb, false, needsRecaching)); + std::string cachedThumb(CTextureCache::Get().CheckCachedImage(thumb, false, needsRecaching)); LOG("thumb: %s, %s", thumb.c_str(), cachedThumb.c_str()); if (!cachedThumb.empty()) { - CStdString thumbRealPath = CSpecialProtocol::TranslatePath(cachedThumb); + std::string thumbRealPath = CSpecialProtocol::TranslatePath(cachedThumb); [item setValue:[NSString stringWithUTF8String:thumbRealPath.c_str()] forKey:@"thumb"]; } } diff --git a/xbmc/osx/smc.c b/xbmc/osx/smc.c index a3bc3bd09c..00b74ed485 100644 --- a/xbmc/osx/smc.c +++ b/xbmc/osx/smc.c @@ -52,12 +52,11 @@ void _ultostr(char *str, UInt32 val) kern_return_t SMCOpen(void) { - kern_return_t result; mach_port_t masterPort; io_iterator_t iterator; io_object_t device; - result = IOMasterPort(MACH_PORT_NULL, &masterPort); + kern_return_t result = IOMasterPort(MACH_PORT_NULL, &masterPort); CFMutableDictionaryRef matchingDictionary = IOServiceMatching("AppleSMC"); result = IOServiceGetMatchingServices(masterPort, matchingDictionary, &iterator); diff --git a/xbmc/peripherals/PeripheralTypes.h b/xbmc/peripherals/PeripheralTypes.h index e92fd41140..699e1b2caa 100644 --- a/xbmc/peripherals/PeripheralTypes.h +++ b/xbmc/peripherals/PeripheralTypes.h @@ -19,12 +19,13 @@ * */ +#include <algorithm> #include <map> +#include <string> #include <stdio.h> #ifdef TARGET_WINDOWS #include "PlatformDefs.h" #endif -#include "utils/StdString.h" #include "utils/StringUtils.h" class CSetting; @@ -83,9 +84,9 @@ namespace PERIPHERALS std::vector<PeripheralID> m_PeripheralID; PeripheralBusType m_busType; PeripheralType m_class; - CStdString m_strDeviceName; + std::string m_strDeviceName; PeripheralType m_mappedTo; - std::map<CStdString, PeripheralDeviceSetting> m_settings; + std::map<std::string, PeripheralDeviceSetting> m_settings; }; class PeripheralTypeTranslator @@ -116,26 +117,26 @@ namespace PERIPHERALS } }; - static PeripheralType GetTypeFromString(const CStdString &strType) + static PeripheralType GetTypeFromString(const std::string &strType) { - CStdString strTypeLowerCase(strType); + std::string strTypeLowerCase(strType); StringUtils::ToLower(strTypeLowerCase); - if (strTypeLowerCase.Equals("bluetooth")) + if (strTypeLowerCase == "bluetooth") return PERIPHERAL_BLUETOOTH; - else if (strTypeLowerCase.Equals("cec")) + else if (strTypeLowerCase == "cec") return PERIPHERAL_CEC; - else if (strTypeLowerCase.Equals("disk")) + else if (strTypeLowerCase == "disk") return PERIPHERAL_DISK; - else if (strTypeLowerCase.Equals("hid")) + else if (strTypeLowerCase == "hid") return PERIPHERAL_HID; - else if (strTypeLowerCase.Equals("nic")) + else if (strTypeLowerCase == "nic") return PERIPHERAL_NIC; - else if (strTypeLowerCase.Equals("nyxboard")) + else if (strTypeLowerCase == "nyxboard") return PERIPHERAL_NYXBOARD; - else if (strTypeLowerCase.Equals("tuner")) + else if (strTypeLowerCase == "tuner") return PERIPHERAL_TUNER; - else if (strTypeLowerCase.Equals("imon")) + else if (strTypeLowerCase == "imon") return PERIPHERAL_IMON; return PERIPHERAL_UNKNOWN; @@ -158,18 +159,18 @@ namespace PERIPHERALS } }; - static PeripheralBusType GetBusTypeFromString(const CStdString &strType) + static PeripheralBusType GetBusTypeFromString(const std::string &strType) { - CStdString strTypeLowerCase(strType); + std::string strTypeLowerCase(strType); StringUtils::ToLower(strTypeLowerCase); - if (strTypeLowerCase.Equals("usb")) + if (strTypeLowerCase == "usb") return PERIPHERAL_BUS_USB; - else if (strTypeLowerCase.Equals("pci")) + else if (strTypeLowerCase == "pci") return PERIPHERAL_BUS_PCI; - else if (strTypeLowerCase.Equals("rpi")) + else if (strTypeLowerCase == "rpi") return PERIPHERAL_BUS_RPI; - else if (strTypeLowerCase.Equals("cec")) + else if (strTypeLowerCase == "cec") return PERIPHERAL_BUS_CEC; return PERIPHERAL_BUS_UNKNOWN; @@ -182,7 +183,7 @@ namespace PERIPHERALS return iVal; }; - static void FormatHexString(int iVal, CStdString &strHexString) + static void FormatHexString(int iVal, std::string &strHexString) { if (iVal < 0) iVal = 0; @@ -220,7 +221,7 @@ namespace PERIPHERALS m_iProductId == right.m_iProductId && m_type == right.m_type && m_busType == right.m_busType && - m_strLocation.Equals(right.m_strLocation); + StringUtils::EqualsNoCase(m_strLocation, right.m_strLocation); } bool operator !=(const PeripheralScanResult& right) const @@ -229,11 +230,11 @@ namespace PERIPHERALS } PeripheralType m_type; - CStdString m_strLocation; + std::string m_strLocation; int m_iVendorId; int m_iProductId; PeripheralType m_mappedType; - CStdString m_strDeviceName; + std::string m_strDeviceName; PeripheralBusType m_busType; PeripheralBusType m_mappedBusType; unsigned int m_iSequence; // when more than one adapter of the same type is found @@ -241,7 +242,7 @@ namespace PERIPHERALS struct PeripheralScanResults { - bool GetDeviceOnLocation(const CStdString& strLocation, PeripheralScanResult* result) const + bool GetDeviceOnLocation(const std::string& strLocation, PeripheralScanResult* result) const { for (std::vector<PeripheralScanResult>::const_iterator it = m_results.begin(); it != m_results.end(); it++) { diff --git a/xbmc/peripherals/Peripherals.cpp b/xbmc/peripherals/Peripherals.cpp index 557ee351f4..cf5e7c1d60 100644 --- a/xbmc/peripherals/Peripherals.cpp +++ b/xbmc/peripherals/Peripherals.cpp @@ -114,8 +114,8 @@ void CPeripherals::Clear(void) /* delete mappings */ for (unsigned int iMappingPtr = 0; iMappingPtr < m_mappings.size(); iMappingPtr++) { - map<CStdString, PeripheralDeviceSetting> settings = m_mappings.at(iMappingPtr).m_settings; - for (map<CStdString, PeripheralDeviceSetting>::iterator itr = settings.begin(); itr != settings.end(); ++itr) + map<std::string, PeripheralDeviceSetting> settings = m_mappings.at(iMappingPtr).m_settings; + for (map<std::string, PeripheralDeviceSetting>::iterator itr = settings.begin(); itr != settings.end(); ++itr) delete itr->second.m_setting; m_mappings.at(iMappingPtr).m_settings.clear(); } @@ -159,7 +159,7 @@ CPeripheralBus *CPeripherals::GetBusByType(const PeripheralBusType type) const return bus; } -CPeripheral *CPeripherals::GetPeripheralAtLocation(const CStdString &strLocation, PeripheralBusType busType /* = PERIPHERAL_BUS_UNKNOWN */) const +CPeripheral *CPeripherals::GetPeripheralAtLocation(const std::string &strLocation, PeripheralBusType busType /* = PERIPHERAL_BUS_UNKNOWN */) const { CSingleLock lock(m_critSection); CPeripheral *peripheral(NULL); @@ -177,12 +177,12 @@ CPeripheral *CPeripherals::GetPeripheralAtLocation(const CStdString &strLocation return peripheral; } -bool CPeripherals::HasPeripheralAtLocation(const CStdString &strLocation, PeripheralBusType busType /* = PERIPHERAL_BUS_UNKNOWN */) const +bool CPeripherals::HasPeripheralAtLocation(const std::string &strLocation, PeripheralBusType busType /* = PERIPHERAL_BUS_UNKNOWN */) const { return (GetPeripheralAtLocation(strLocation, busType) != NULL); } -CPeripheralBus *CPeripherals::GetBusWithDevice(const CStdString &strLocation) const +CPeripheralBus *CPeripherals::GetBusWithDevice(const std::string &strLocation) const { CSingleLock lock(m_critSection); for (unsigned int iBusPtr = 0; iBusPtr < m_busses.size(); iBusPtr++) @@ -366,7 +366,7 @@ bool CPeripherals::GetMappingForDevice(const CPeripheralBus &bus, PeripheralScan if (bProductMatch && bBusMatch && bClassMatch) { - CStdString strVendorId, strProductId; + std::string strVendorId, strProductId; PeripheralTypeTranslator::FormatHexString(result.m_iVendorId, strVendorId); PeripheralTypeTranslator::FormatHexString(result.m_iProductId, strProductId); CLog::Log(LOGDEBUG, "%s - device (%s:%s) mapped to %s (type = %s)", __FUNCTION__, strVendorId.c_str(), strProductId.c_str(), mapping.m_strDeviceName.c_str(), PeripheralTypeTranslator::TypeToString(mapping.m_mappedTo)); @@ -403,12 +403,13 @@ void CPeripherals::GetSettingsFromMapping(CPeripheral &peripheral) const if (bBusMatch && bProductMatch && bClassMatch) { - for (map<CStdString, PeripheralDeviceSetting>::const_iterator itr = mapping->m_settings.begin(); itr != mapping->m_settings.end(); ++itr) + for (map<std::string, PeripheralDeviceSetting>::const_iterator itr = mapping->m_settings.begin(); itr != mapping->m_settings.end(); ++itr) peripheral.AddSetting((*itr).first, (*itr).second.m_setting, (*itr).second.m_order); } } } +#define SS(x) ((x) ? x : "") bool CPeripherals::LoadMappings(void) { CXBMCTinyXML xmlDoc; @@ -419,7 +420,7 @@ bool CPeripherals::LoadMappings(void) } TiXmlElement *pRootElement = xmlDoc.RootElement(); - if (strcmpi(pRootElement->Value(), "peripherals") != 0) + if (!pRootElement || strcmpi(pRootElement->Value(), "peripherals") != 0) { CLog::Log(LOGERROR, "%s - peripherals.xml does not contain <peripherals>", __FUNCTION__); return false; @@ -464,7 +465,7 @@ bool CPeripherals::LoadMappings(void) return true; } -void CPeripherals::GetSettingsFromMappingsFile(TiXmlElement *xmlNode, map<CStdString, PeripheralDeviceSetting> &settings) +void CPeripherals::GetSettingsFromMappingsFile(TiXmlElement *xmlNode, map<std::string, PeripheralDeviceSetting> &settings) { TiXmlElement *currentNode = xmlNode->FirstChildElement("setting"); int iMaxOrder = 0; @@ -472,21 +473,21 @@ void CPeripherals::GetSettingsFromMappingsFile(TiXmlElement *xmlNode, map<CStdSt while (currentNode) { CSetting *setting = NULL; - CStdString strKey = XMLUtils::GetAttribute(currentNode, "key"); + std::string strKey = XMLUtils::GetAttribute(currentNode, "key"); if (strKey.empty()) continue; - CStdString strSettingsType = XMLUtils::GetAttribute(currentNode, "type"); + std::string strSettingsType = XMLUtils::GetAttribute(currentNode, "type"); int iLabelId = currentNode->Attribute("label") ? atoi(currentNode->Attribute("label")) : -1; const std::string config = XMLUtils::GetAttribute(currentNode, "configurable"); bool bConfigurable = (config.empty() || (config != "no" && config != "false" && config != "0")); - if (strSettingsType.Equals("bool")) + if (strSettingsType == "bool") { const std::string value = XMLUtils::GetAttribute(currentNode, "value"); bool bValue = (value != "no" && value != "false" && value != "0"); setting = new CSettingBool(strKey, iLabelId, bValue); } - else if (strSettingsType.Equals("int")) + else if (strSettingsType == "int") { int iValue = currentNode->Attribute("value") ? atoi(currentNode->Attribute("value")) : 0; int iMin = currentNode->Attribute("min") ? atoi(currentNode->Attribute("min")) : 0; @@ -494,7 +495,7 @@ void CPeripherals::GetSettingsFromMappingsFile(TiXmlElement *xmlNode, map<CStdSt int iMax = currentNode->Attribute("max") ? atoi(currentNode->Attribute("max")) : 255; setting = new CSettingInt(strKey, iLabelId, iValue, iMin, iStep, iMax); } - else if (strSettingsType.Equals("float")) + else if (strSettingsType == "float") { float fValue = currentNode->Attribute("value") ? (float) atof(currentNode->Attribute("value")) : 0; float fMin = currentNode->Attribute("min") ? (float) atof(currentNode->Attribute("min")) : 0; @@ -502,9 +503,9 @@ void CPeripherals::GetSettingsFromMappingsFile(TiXmlElement *xmlNode, map<CStdSt float fMax = currentNode->Attribute("max") ? (float) atof(currentNode->Attribute("max")) : 0; setting = new CSettingNumber(strKey, iLabelId, fValue, fMin, fStep, fMax); } - else if (strSettingsType.Equals("enum")) + else if (StringUtils::EqualsNoCase(strSettingsType, "enum")) { - CStdString strEnums = XMLUtils::GetAttribute(currentNode, "lvalues"); + std::string strEnums = XMLUtils::GetAttribute(currentNode, "lvalues"); if (!strEnums.empty()) { vector< pair<int,int> > enums; @@ -518,7 +519,7 @@ void CPeripherals::GetSettingsFromMappingsFile(TiXmlElement *xmlNode, map<CStdSt } else { - CStdString strValue = XMLUtils::GetAttribute(currentNode, "value"); + std::string strValue = XMLUtils::GetAttribute(currentNode, "value"); setting = new CSettingString(strKey, iLabelId, strValue); } @@ -547,41 +548,42 @@ void CPeripherals::GetSettingsFromMappingsFile(TiXmlElement *xmlNode, map<CStdSt } /* add the settings without an order attribute or an invalid order attribute set at the end */ - for (map<CStdString, PeripheralDeviceSetting>::iterator it = settings.begin(); it != settings.end(); ++it) + for (map<std::string, PeripheralDeviceSetting>::iterator it = settings.begin(); it != settings.end(); ++it) { if (it->second.m_order == 0) it->second.m_order = ++iMaxOrder; } } -void CPeripherals::GetDirectory(const CStdString &strPath, CFileItemList &items) const +void CPeripherals::GetDirectory(const std::string &strPath, CFileItemList &items) const { if (!StringUtils::StartsWithNoCase(strPath, "peripherals://")) return; - CStdString strPathCut = strPath.substr(14); - CStdString strBus = strPathCut.substr(0, strPathCut.find('/')); + std::string strPathCut = strPath.substr(14); + std::string strBus = strPathCut.substr(0, strPathCut.find('/')); CSingleLock lock(m_critSection); for (unsigned int iBusPtr = 0; iBusPtr < m_busses.size(); iBusPtr++) { - if (strBus.Equals("all") || strBus.Equals(PeripheralTypeTranslator::BusTypeToString(m_busses.at(iBusPtr)->Type()))) + if (StringUtils::EqualsNoCase(strBus, "all") || + StringUtils::EqualsNoCase(strBus, PeripheralTypeTranslator::BusTypeToString(m_busses.at(iBusPtr)->Type()))) m_busses.at(iBusPtr)->GetDirectory(strPath, items); } } -CPeripheral *CPeripherals::GetByPath(const CStdString &strPath) const +CPeripheral *CPeripherals::GetByPath(const std::string &strPath) const { if (!StringUtils::StartsWithNoCase(strPath, "peripherals://")) return NULL; - CStdString strPathCut = strPath.substr(14); - CStdString strBus = strPathCut.substr(0, strPathCut.find('/')); + std::string strPathCut = strPath.substr(14); + std::string strBus = strPathCut.substr(0, strPathCut.find('/')); CSingleLock lock(m_critSection); for (unsigned int iBusPtr = 0; iBusPtr < m_busses.size(); iBusPtr++) { - if (strBus.Equals(PeripheralTypeTranslator::BusTypeToString(m_busses.at(iBusPtr)->Type()))) + if (StringUtils::EqualsNoCase(strBus, PeripheralTypeTranslator::BusTypeToString(m_busses.at(iBusPtr)->Type()))) return m_busses.at(iBusPtr)->GetByPath(strPath); } diff --git a/xbmc/peripherals/Peripherals.h b/xbmc/peripherals/Peripherals.h index fcef6cad11..c33b7a52af 100644 --- a/xbmc/peripherals/Peripherals.h +++ b/xbmc/peripherals/Peripherals.h @@ -61,7 +61,7 @@ namespace PERIPHERALS * @param busType The bus to query. Default (PERIPHERAL_BUS_UNKNOWN) searches all busses. * @return The peripheral or NULL if it wasn't found. */ - virtual CPeripheral *GetPeripheralAtLocation(const CStdString &strLocation, PeripheralBusType busType = PERIPHERAL_BUS_UNKNOWN) const; + virtual CPeripheral *GetPeripheralAtLocation(const std::string &strLocation, PeripheralBusType busType = PERIPHERAL_BUS_UNKNOWN) const; /*! * @brief Check whether a peripheral is present at the given location. @@ -69,14 +69,14 @@ namespace PERIPHERALS * @param busType The bus to query. Default (PERIPHERAL_BUS_UNKNOWN) searches all busses. * @return True when a peripheral was found, false otherwise. */ - virtual bool HasPeripheralAtLocation(const CStdString &strLocation, PeripheralBusType busType = PERIPHERAL_BUS_UNKNOWN) const; + virtual bool HasPeripheralAtLocation(const std::string &strLocation, PeripheralBusType busType = PERIPHERAL_BUS_UNKNOWN) const; /*! * @brief Get the bus that holds the device with the given location. * @param strLocation The location. * @return The bus or NULL if no device was found. */ - virtual CPeripheralBus *GetBusWithDevice(const CStdString &strLocation) const; + virtual CPeripheralBus *GetBusWithDevice(const std::string &strLocation) const; /*! * @brief Get all peripheral instances that have the given feature. @@ -142,14 +142,14 @@ namespace PERIPHERALS * @param strPath The path to the directory to get the items from. * @param items The item list. */ - virtual void GetDirectory(const CStdString &strPath, CFileItemList &items) const; + virtual void GetDirectory(const std::string &strPath, CFileItemList &items) const; /*! * @brief Get the instance of a peripheral given it's path. * @param strPath The path to the peripheral. * @return The peripheral or NULL if it wasn't found. */ - virtual CPeripheral *GetByPath(const CStdString &strPath) const; + virtual CPeripheral *GetByPath(const std::string &strPath) const; /*! * @brief Try to let one of the peripherals handle an action. @@ -214,7 +214,7 @@ namespace PERIPHERALS CPeripherals(void); bool LoadMappings(void); bool GetMappingForDevice(const CPeripheralBus &bus, PeripheralScanResult& result) const; - static void GetSettingsFromMappingsFile(TiXmlElement *xmlNode, std::map<CStdString, PeripheralDeviceSetting> &m_settings); + static void GetSettingsFromMappingsFile(TiXmlElement *xmlNode, std::map<std::string, PeripheralDeviceSetting> &m_settings); bool m_bInitialised; bool m_bIsStarted; diff --git a/xbmc/peripherals/bus/PeripheralBus.cpp b/xbmc/peripherals/bus/PeripheralBus.cpp index 7f1191b845..a59c49ac2b 100644 --- a/xbmc/peripherals/bus/PeripheralBus.cpp +++ b/xbmc/peripherals/bus/PeripheralBus.cpp @@ -29,8 +29,8 @@ using namespace PERIPHERALS; #define PERIPHERAL_DEFAULT_RESCAN_INTERVAL 5000 -CPeripheralBus::CPeripheralBus(const CStdString &threadname, CPeripherals *manager, PeripheralBusType type) : - CThread(threadname), +CPeripheralBus::CPeripheralBus(const std::string &threadname, CPeripherals *manager, PeripheralBusType type) : + CThread(threadname.c_str()), m_iRescanTime(PERIPHERAL_DEFAULT_RESCAN_INTERVAL), m_bInitialised(false), m_bIsStarted(false), @@ -41,17 +41,17 @@ CPeripheralBus::CPeripheralBus(const CStdString &threadname, CPeripherals *manag { } -void CPeripheralBus::OnDeviceAdded(const CStdString &strLocation) +void CPeripheralBus::OnDeviceAdded(const std::string &strLocation) { ScanForDevices(); } -void CPeripheralBus::OnDeviceChanged(const CStdString &strLocation) +void CPeripheralBus::OnDeviceChanged(const std::string &strLocation) { ScanForDevices(); } -void CPeripheralBus::OnDeviceRemoved(const CStdString &strLocation) +void CPeripheralBus::OnDeviceRemoved(const std::string &strLocation) { ScanForDevices(); } @@ -158,7 +158,7 @@ void CPeripheralBus::GetFeatures(std::vector<PeripheralFeature> &features) const m_peripherals.at(iPeripheralPtr)->GetFeatures(features); } -CPeripheral *CPeripheralBus::GetPeripheral(const CStdString &strLocation) const +CPeripheral *CPeripheralBus::GetPeripheral(const std::string &strLocation) const { CPeripheral *peripheral(NULL); CSingleLock lock(m_critSection); @@ -270,14 +270,14 @@ void CPeripheralBus::TriggerDeviceScan(void) } } -bool CPeripheralBus::HasPeripheral(const CStdString &strLocation) const +bool CPeripheralBus::HasPeripheral(const std::string &strLocation) const { return (GetPeripheral(strLocation) != NULL); } -void CPeripheralBus::GetDirectory(const CStdString &strPath, CFileItemList &items) const +void CPeripheralBus::GetDirectory(const std::string &strPath, CFileItemList &items) const { - CStdString strDevPath; + std::string strDevPath; CSingleLock lock(m_critSection); for (unsigned int iDevicePtr = 0; iDevicePtr < m_peripherals.size(); iDevicePtr++) { @@ -297,13 +297,13 @@ void CPeripheralBus::GetDirectory(const CStdString &strPath, CFileItemList &item } } -CPeripheral *CPeripheralBus::GetByPath(const CStdString &strPath) const +CPeripheral *CPeripheralBus::GetByPath(const std::string &strPath) const { - CStdString strDevPath; + std::string strDevPath; CSingleLock lock(m_critSection); for (unsigned int iDevicePtr = 0; iDevicePtr < m_peripherals.size(); iDevicePtr++) { - if (strPath.Equals(m_peripherals.at(iDevicePtr)->FileLocation())) + if (StringUtils::EqualsNoCase(strPath, m_peripherals.at(iDevicePtr)->FileLocation())) return m_peripherals.at(iDevicePtr); } diff --git a/xbmc/peripherals/bus/PeripheralBus.h b/xbmc/peripherals/bus/PeripheralBus.h index 795f88b6a4..6dff42ccb1 100644 --- a/xbmc/peripherals/bus/PeripheralBus.h +++ b/xbmc/peripherals/bus/PeripheralBus.h @@ -20,7 +20,6 @@ */ #include <vector> -#include "utils/StdString.h" #include "threads/Thread.h" #include "peripherals/PeripheralTypes.h" #include "peripherals/devices/Peripheral.h" @@ -42,7 +41,7 @@ namespace PERIPHERALS class CPeripheralBus : protected CThread { public: - CPeripheralBus(const CStdString &threadname, CPeripherals *manager, PeripheralBusType type); + CPeripheralBus(const std::string &threadname, CPeripherals *manager, PeripheralBusType type); virtual ~CPeripheralBus(void) { Clear(); } /*! @@ -60,14 +59,14 @@ namespace PERIPHERALS * @param strLocation The location. * @return The peripheral or NULL if it wasn't found. */ - virtual CPeripheral *GetPeripheral(const CStdString &strLocation) const; + virtual CPeripheral *GetPeripheral(const std::string &strLocation) const; /*! * @brief Check whether a peripheral is present at the given location. * @param strLocation The location. * @return True when a peripheral was found, false otherwise. */ - virtual bool HasPeripheral(const CStdString &strLocation) const; + virtual bool HasPeripheral(const std::string &strLocation) const; /*! * @brief Get all peripheral instances that have the given feature. @@ -97,19 +96,19 @@ namespace PERIPHERALS * @brief Callback method for when a device has been added. Will perform a device scan. * @param strLocation The location of the device that has been added. */ - virtual void OnDeviceAdded(const CStdString &strLocation); + virtual void OnDeviceAdded(const std::string &strLocation); /*! * @brief Callback method for when a device has been changed. Will perform a device scan. * @param strLocation The location of the device that has been changed. */ - virtual void OnDeviceChanged(const CStdString &strLocation); + virtual void OnDeviceChanged(const std::string &strLocation); /*! * @brief Callback method for when a device has been removed. Will perform a device scan. * @param strLocation The location of the device that has been removed. */ - virtual void OnDeviceRemoved(const CStdString &strLocation); + virtual void OnDeviceRemoved(const std::string &strLocation); /*! * @brief Initialise this bus and start a polling thread if this bus needs polling. @@ -131,14 +130,14 @@ namespace PERIPHERALS * @param strPath The path to the directory to get the items from. * @param items The item list. */ - virtual void GetDirectory(const CStdString &strPath, CFileItemList &items) const; + virtual void GetDirectory(const std::string &strPath, CFileItemList &items) const; /*! * @brief Get the instance of a peripheral given it's path. * @param strPath The path to the peripheral. * @return The peripheral or NULL if it wasn't found. */ - virtual CPeripheral *GetByPath(const CStdString &strPath) const; + virtual CPeripheral *GetByPath(const std::string &strPath) const; /*! * @brief Register a new peripheral on this bus. @@ -146,7 +145,7 @@ namespace PERIPHERALS */ virtual void Register(CPeripheral *peripheral); - virtual bool FindComPort(CStdString &strLocation) { return false; } + virtual bool FindComPort(std::string &strLocation) { return false; } virtual bool IsInitialised(void) const { return m_bInitialised; } diff --git a/xbmc/peripherals/bus/linux/PeripheralBusUSBLibUdev.cpp b/xbmc/peripherals/bus/linux/PeripheralBusUSBLibUdev.cpp index 461a4fc7f6..85da3823b5 100644 --- a/xbmc/peripherals/bus/linux/PeripheralBusUSBLibUdev.cpp +++ b/xbmc/peripherals/bus/linux/PeripheralBusUSBLibUdev.cpp @@ -115,7 +115,7 @@ bool CPeripheralBusUSB::PerformDeviceScan(PeripheralScanResults &results) devices = udev_enumerate_get_list_entry(enumerate); bool bContinue(true); - CStdString strPath, strClass; + std::string strPath, strClass; udev_list_entry_foreach(dev_list_entry, devices) { strPath = udev_list_entry_get_name(dev_list_entry); @@ -124,7 +124,7 @@ bool CPeripheralBusUSB::PerformDeviceScan(PeripheralScanResults &results) if (bContinue) { - if (!(parent = udev_device_new_from_syspath(m_udev, strPath))) + if (!(parent = udev_device_new_from_syspath(m_udev, strPath.c_str()))) bContinue = false; } diff --git a/xbmc/peripherals/bus/osx/PeripheralBusUSB.cpp b/xbmc/peripherals/bus/osx/PeripheralBusUSB.cpp index 641ed65ef7..0ab954807a 100644 --- a/xbmc/peripherals/bus/osx/PeripheralBusUSB.cpp +++ b/xbmc/peripherals/bus/osx/PeripheralBusUSB.cpp @@ -36,7 +36,7 @@ using namespace PERIPHERALS; typedef struct USBDevicePrivateData { CPeripheralBusUSB *refCon; - CStdString deviceName; + std::string deviceName; io_object_t notification; PeripheralScanResult result; } USBDevicePrivateData; @@ -121,8 +121,6 @@ void CPeripheralBusUSB::DeviceDetachCallback(void *refCon, io_service_t service, { if (messageType == kIOMessageServiceIsTerminated) { - IOReturn result; - USBDevicePrivateData *privateDataRef = (USBDevicePrivateData*)refCon; std::vector<PeripheralScanResult>::iterator it = privateDataRef->refCon->m_scan_results.m_results.begin(); @@ -137,10 +135,10 @@ void CPeripheralBusUSB::DeviceDetachCallback(void *refCon, io_service_t service, CLog::Log(LOGDEBUG, "USB Device Detach:%s, %s\n", privateDataRef->deviceName.c_str(), privateDataRef->result.m_strLocation.c_str()); - result = IOObjectRelease(privateDataRef->notification); + IOObjectRelease(privateDataRef->notification); delete privateDataRef; //release the service - result = IOObjectRelease(service); + IOObjectRelease(service); } } @@ -183,10 +181,10 @@ void CPeripheralBusUSB::DeviceAttachCallback(CPeripheralBusUSB* refCon, io_itera UInt32 locationId; UInt8 bDeviceClass; - result = (*deviceInterface)->GetDeviceVendor( deviceInterface, &vendorId); - result = (*deviceInterface)->GetDeviceProduct(deviceInterface, &productId); - result = (*deviceInterface)->GetLocationID( deviceInterface, &locationId); - result = (*deviceInterface)->GetDeviceClass( deviceInterface, &bDeviceClass); + (*deviceInterface)->GetDeviceVendor( deviceInterface, &vendorId); + (*deviceInterface)->GetDeviceProduct(deviceInterface, &productId); + (*deviceInterface)->GetLocationID( deviceInterface, &locationId); + (*deviceInterface)->GetDeviceClass( deviceInterface, &bDeviceClass); io_service_t usbInterface; io_iterator_t interface_iterator; diff --git a/xbmc/peripherals/bus/win32/PeripheralBusUSB.h b/xbmc/peripherals/bus/win32/PeripheralBusUSB.h index 92c51d3a08..3a54f925ef 100644 --- a/xbmc/peripherals/bus/win32/PeripheralBusUSB.h +++ b/xbmc/peripherals/bus/win32/PeripheralBusUSB.h @@ -39,6 +39,6 @@ namespace PERIPHERALS private: bool PerformDeviceScan(const GUID *guid, const PeripheralType defaultType, PeripheralScanResults &results); - bool GetProductAndVendorId(const PeripheralType type, const CStdString &strDeviceLocation, int *iVendorId, int *iProductId); + bool GetProductAndVendorId(const PeripheralType type, const std::string &strDeviceLocation, int *iVendorId, int *iProductId); }; } diff --git a/xbmc/peripherals/devices/Peripheral.cpp b/xbmc/peripherals/devices/Peripheral.cpp index b1eaa1fa27..b1c9b76ec4 100644 --- a/xbmc/peripherals/devices/Peripheral.cpp +++ b/xbmc/peripherals/devices/Peripheral.cpp @@ -45,7 +45,6 @@ CPeripheral::CPeripheral(const PeripheralScanResult& scanResult) : m_mappedBusType(scanResult.m_mappedBusType), m_strLocation(scanResult.m_strLocation), m_strDeviceName(scanResult.m_strDeviceName), - m_strFileLocation(StringUtils::EmptyString), m_iVendorId(scanResult.m_iVendorId), m_iProductId(scanResult.m_iProductId), m_strVersionInfo(g_localizeStrings.Get(13205)), // "unknown" @@ -173,7 +172,7 @@ bool CPeripheral::IsMultiFunctional(void) const vector<CSetting *> CPeripheral::GetSettings(void) const { vector<PeripheralDeviceSetting> tmpSettings; - for (map<CStdString, PeripheralDeviceSetting>::const_iterator it = m_settings.begin(); it != m_settings.end(); ++it) + for (map<std::string, PeripheralDeviceSetting>::const_iterator it = m_settings.begin(); it != m_settings.end(); ++it) tmpSettings.push_back(it->second); sort(tmpSettings.begin(), tmpSettings.end(), SortBySettingsOrder()); @@ -183,7 +182,7 @@ vector<CSetting *> CPeripheral::GetSettings(void) const return settings; } -void CPeripheral::AddSetting(const CStdString &strKey, const CSetting *setting, int order) +void CPeripheral::AddSetting(const std::string &strKey, const CSetting *setting, int order) { if (!setting) { @@ -250,9 +249,9 @@ void CPeripheral::AddSetting(const CStdString &strKey, const CSetting *setting, } } -bool CPeripheral::HasSetting(const CStdString &strKey) const +bool CPeripheral::HasSetting(const std::string &strKey) const { - map<CStdString, PeripheralDeviceSetting>:: const_iterator it = m_settings.find(strKey); + map<std::string, PeripheralDeviceSetting>:: const_iterator it = m_settings.find(strKey); return it != m_settings.end(); } @@ -264,7 +263,7 @@ bool CPeripheral::HasSettings(void) const bool CPeripheral::HasConfigurableSettings(void) const { bool bReturn(false); - map<CStdString, PeripheralDeviceSetting>::const_iterator it = m_settings.begin(); + map<std::string, PeripheralDeviceSetting>::const_iterator it = m_settings.begin(); while (it != m_settings.end() && !bReturn) { if ((*it).second.m_setting->IsVisible()) @@ -279,9 +278,9 @@ bool CPeripheral::HasConfigurableSettings(void) const return bReturn; } -bool CPeripheral::GetSettingBool(const CStdString &strKey) const +bool CPeripheral::GetSettingBool(const std::string &strKey) const { - map<CStdString, PeripheralDeviceSetting>::const_iterator it = m_settings.find(strKey); + map<std::string, PeripheralDeviceSetting>::const_iterator it = m_settings.find(strKey); if (it != m_settings.end() && (*it).second.m_setting->GetType() == SettingTypeBool) { CSettingBool *boolSetting = (CSettingBool *) (*it).second.m_setting; @@ -292,9 +291,9 @@ bool CPeripheral::GetSettingBool(const CStdString &strKey) const return false; } -int CPeripheral::GetSettingInt(const CStdString &strKey) const +int CPeripheral::GetSettingInt(const std::string &strKey) const { - map<CStdString, PeripheralDeviceSetting>::const_iterator it = m_settings.find(strKey); + map<std::string, PeripheralDeviceSetting>::const_iterator it = m_settings.find(strKey); if (it != m_settings.end() && (*it).second.m_setting->GetType() == SettingTypeInteger) { CSettingInt *intSetting = (CSettingInt *) (*it).second.m_setting; @@ -305,9 +304,9 @@ int CPeripheral::GetSettingInt(const CStdString &strKey) const return 0; } -float CPeripheral::GetSettingFloat(const CStdString &strKey) const +float CPeripheral::GetSettingFloat(const std::string &strKey) const { - map<CStdString, PeripheralDeviceSetting>::const_iterator it = m_settings.find(strKey); + map<std::string, PeripheralDeviceSetting>::const_iterator it = m_settings.find(strKey); if (it != m_settings.end() && (*it).second.m_setting->GetType() == SettingTypeNumber) { CSettingNumber *floatSetting = (CSettingNumber *) (*it).second.m_setting; @@ -318,9 +317,9 @@ float CPeripheral::GetSettingFloat(const CStdString &strKey) const return 0; } -const CStdString CPeripheral::GetSettingString(const CStdString &strKey) const +const std::string CPeripheral::GetSettingString(const std::string &strKey) const { - map<CStdString, PeripheralDeviceSetting>::const_iterator it = m_settings.find(strKey); + map<std::string, PeripheralDeviceSetting>::const_iterator it = m_settings.find(strKey); if (it != m_settings.end() && (*it).second.m_setting->GetType() == SettingTypeString) { CSettingString *stringSetting = (CSettingString *) (*it).second.m_setting; @@ -328,13 +327,13 @@ const CStdString CPeripheral::GetSettingString(const CStdString &strKey) const return stringSetting->GetValue(); } - return StringUtils::EmptyString; + return ""; } -bool CPeripheral::SetSetting(const CStdString &strKey, bool bValue) +bool CPeripheral::SetSetting(const std::string &strKey, bool bValue) { bool bChanged(false); - map<CStdString, PeripheralDeviceSetting>::iterator it = m_settings.find(strKey); + map<std::string, PeripheralDeviceSetting>::iterator it = m_settings.find(strKey); if (it != m_settings.end() && (*it).second.m_setting->GetType() == SettingTypeBool) { CSettingBool *boolSetting = (CSettingBool *) (*it).second.m_setting; @@ -349,10 +348,10 @@ bool CPeripheral::SetSetting(const CStdString &strKey, bool bValue) return bChanged; } -bool CPeripheral::SetSetting(const CStdString &strKey, int iValue) +bool CPeripheral::SetSetting(const std::string &strKey, int iValue) { bool bChanged(false); - map<CStdString, PeripheralDeviceSetting>::iterator it = m_settings.find(strKey); + map<std::string, PeripheralDeviceSetting>::iterator it = m_settings.find(strKey); if (it != m_settings.end() && (*it).second.m_setting->GetType() == SettingTypeInteger) { CSettingInt *intSetting = (CSettingInt *) (*it).second.m_setting; @@ -367,10 +366,10 @@ bool CPeripheral::SetSetting(const CStdString &strKey, int iValue) return bChanged; } -bool CPeripheral::SetSetting(const CStdString &strKey, float fValue) +bool CPeripheral::SetSetting(const std::string &strKey, float fValue) { bool bChanged(false); - map<CStdString, PeripheralDeviceSetting>::iterator it = m_settings.find(strKey); + map<std::string, PeripheralDeviceSetting>::iterator it = m_settings.find(strKey); if (it != m_settings.end() && (*it).second.m_setting->GetType() == SettingTypeNumber) { CSettingNumber *floatSetting = (CSettingNumber *) (*it).second.m_setting; @@ -385,25 +384,25 @@ bool CPeripheral::SetSetting(const CStdString &strKey, float fValue) return bChanged; } -void CPeripheral::SetSettingVisible(const CStdString &strKey, bool bSetTo) +void CPeripheral::SetSettingVisible(const std::string &strKey, bool bSetTo) { - map<CStdString, PeripheralDeviceSetting>::iterator it = m_settings.find(strKey); + map<std::string, PeripheralDeviceSetting>::iterator it = m_settings.find(strKey); if (it != m_settings.end()) (*it).second.m_setting->SetVisible(bSetTo); } -bool CPeripheral::IsSettingVisible(const CStdString &strKey) const +bool CPeripheral::IsSettingVisible(const std::string &strKey) const { - map<CStdString, PeripheralDeviceSetting>::const_iterator it = m_settings.find(strKey); + map<std::string, PeripheralDeviceSetting>::const_iterator it = m_settings.find(strKey); if (it != m_settings.end()) return (*it).second.m_setting->IsVisible(); return false; } -bool CPeripheral::SetSetting(const CStdString &strKey, const CStdString &strValue) +bool CPeripheral::SetSetting(const std::string &strKey, const std::string &strValue) { bool bChanged(false); - map<CStdString, PeripheralDeviceSetting>::iterator it = m_settings.find(strKey); + map<std::string, PeripheralDeviceSetting>::iterator it = m_settings.find(strKey); if (it != m_settings.end()) { if ((*it).second.m_setting->GetType() == SettingTypeString) @@ -422,7 +421,7 @@ bool CPeripheral::SetSetting(const CStdString &strKey, const CStdString &strValu else if ((*it).second.m_setting->GetType() == SettingTypeNumber) bChanged = SetSetting(strKey, (float) (strValue.empty() ? 0 : atof(strValue.c_str()))); else if ((*it).second.m_setting->GetType() == SettingTypeBool) - bChanged = SetSetting(strKey, strValue.Equals("1")); + bChanged = SetSetting(strKey, strValue == "1"); } return bChanged; } @@ -432,11 +431,11 @@ void CPeripheral::PersistSettings(bool bExiting /* = false */) CXBMCTinyXML doc; TiXmlElement node("settings"); doc.InsertEndChild(node); - for (map<CStdString, PeripheralDeviceSetting>::const_iterator itr = m_settings.begin(); itr != m_settings.end(); ++itr) + for (map<std::string, PeripheralDeviceSetting>::const_iterator itr = m_settings.begin(); itr != m_settings.end(); ++itr) { TiXmlElement nodeSetting("setting"); nodeSetting.SetAttribute("id", itr->first.c_str()); - CStdString strValue; + std::string strValue; switch ((*itr).second.m_setting->GetType()) { case SettingTypeString: @@ -478,7 +477,7 @@ void CPeripheral::PersistSettings(bool bExiting /* = false */) if (!bExiting) { - for (set<CStdString>::const_iterator it = m_changedSettings.begin(); it != m_changedSettings.end(); ++it) + for (set<std::string>::const_iterator it = m_changedSettings.begin(); it != m_changedSettings.end(); ++it) OnSettingChanged(*it); } m_changedSettings.clear(); @@ -492,8 +491,8 @@ void CPeripheral::LoadPersistedSettings(void) const TiXmlElement *setting = doc.RootElement()->FirstChildElement("setting"); while (setting) { - CStdString strId = XMLUtils::GetAttribute(setting, "id"); - CStdString strValue = XMLUtils::GetAttribute(setting, "value"); + std::string strId = XMLUtils::GetAttribute(setting, "id"); + std::string strValue = XMLUtils::GetAttribute(setting, "value"); SetSetting(strId, strValue); setting = setting->NextSiblingElement("setting"); @@ -506,7 +505,7 @@ void CPeripheral::ResetDefaultSettings(void) ClearSettings(); g_peripherals.GetSettingsFromMapping(*this); - map<CStdString, PeripheralDeviceSetting>::iterator it = m_settings.begin(); + map<std::string, PeripheralDeviceSetting>::iterator it = m_settings.begin(); while (it != m_settings.end()) { m_changedSettings.insert((*it).first); @@ -518,7 +517,7 @@ void CPeripheral::ResetDefaultSettings(void) void CPeripheral::ClearSettings(void) { - map<CStdString, PeripheralDeviceSetting>::iterator it = m_settings.begin(); + map<std::string, PeripheralDeviceSetting>::iterator it = m_settings.begin(); while (it != m_settings.end()) { delete (*it).second.m_setting; @@ -529,7 +528,7 @@ void CPeripheral::ClearSettings(void) bool CPeripheral::operator ==(const PeripheralScanResult& right) const { - return m_strLocation.Equals(right.m_strLocation); + return StringUtils::EqualsNoCase(m_strLocation, right.m_strLocation); } bool CPeripheral::operator !=(const PeripheralScanResult& right) const diff --git a/xbmc/peripherals/devices/Peripheral.h b/xbmc/peripherals/devices/Peripheral.h index 10a7fb33cb..de7cac0b9e 100644 --- a/xbmc/peripherals/devices/Peripheral.h +++ b/xbmc/peripherals/devices/Peripheral.h @@ -20,7 +20,7 @@ */ #include <set> -#include "utils/StdString.h" +#include <string> #include "peripherals/PeripheralTypes.h" class TiXmlDocument; @@ -51,18 +51,18 @@ namespace PERIPHERALS bool operator ==(const PeripheralScanResult& right) const; bool operator !=(const PeripheralScanResult& right) const; - const CStdString &FileLocation(void) const { return m_strFileLocation; } - const CStdString &Location(void) const { return m_strLocation; } + const std::string &FileLocation(void) const { return m_strFileLocation; } + const std::string &Location(void) const { return m_strLocation; } int VendorId(void) const { return m_iVendorId; } const char *VendorIdAsString(void) const { return m_strVendorId.c_str(); } int ProductId(void) const { return m_iProductId; } const char *ProductIdAsString(void) const { return m_strProductId.c_str(); } const PeripheralType Type(void) const { return m_type; } const PeripheralBusType GetBusType(void) const { return m_busType; }; - const CStdString &DeviceName(void) const { return m_strDeviceName; } + const std::string &DeviceName(void) const { return m_strDeviceName; } bool IsHidden(void) const { return m_bHidden; } void SetHidden(bool bSetTo = true) { m_bHidden = bSetTo; } - const CStdString &GetVersionInfo(void) const { return m_strVersionInfo; } + const std::string &GetVersionInfo(void) const { return m_strVersionInfo; } /*! * @brief Check whether this device has the given feature. @@ -94,7 +94,7 @@ namespace PERIPHERALS * @brief Called when a setting changed. * @param strChangedSetting The changed setting. */ - virtual void OnSettingChanged(const CStdString &strChangedSetting) {}; + virtual void OnSettingChanged(const std::string &strChangedSetting) {}; /*! * @brief Called when this device is removed, before calling the destructor. @@ -117,14 +117,14 @@ namespace PERIPHERALS * @param strKey The key of the setting. * @param setting The setting. */ - virtual void AddSetting(const CStdString &strKey, const CSetting *setting, int order); + virtual void AddSetting(const std::string &strKey, const CSetting *setting, int order); /*! * @brief Check whether a setting is known with the given key. * @param strKey The key to search. * @return True when found, false otherwise. */ - virtual bool HasSetting(const CStdString &strKey) const; + virtual bool HasSetting(const std::string &strKey) const; /*! * @return True when this device has any settings, false otherwise. @@ -141,19 +141,19 @@ namespace PERIPHERALS * @param strKey The key to search. * @return The value or an empty string if it wasn't found. */ - virtual const CStdString GetSettingString(const CStdString &strKey) const; - virtual bool SetSetting(const CStdString &strKey, const CStdString &strValue); - virtual void SetSettingVisible(const CStdString &strKey, bool bSetTo); - virtual bool IsSettingVisible(const CStdString &strKey) const; + virtual const std::string GetSettingString(const std::string &strKey) const; + virtual bool SetSetting(const std::string &strKey, const std::string &strValue); + virtual void SetSettingVisible(const std::string &strKey, bool bSetTo); + virtual bool IsSettingVisible(const std::string &strKey) const; - virtual int GetSettingInt(const CStdString &strKey) const; - virtual bool SetSetting(const CStdString &strKey, int iValue); + virtual int GetSettingInt(const std::string &strKey) const; + virtual bool SetSetting(const std::string &strKey, int iValue); - virtual bool GetSettingBool(const CStdString &strKey) const; - virtual bool SetSetting(const CStdString &strKey, bool bValue); + virtual bool GetSettingBool(const std::string &strKey) const; + virtual bool SetSetting(const std::string &strKey, bool bValue); - virtual float GetSettingFloat(const CStdString &strKey) const; - virtual bool SetSetting(const CStdString &strKey, float fValue); + virtual float GetSettingFloat(const std::string &strKey) const; + virtual bool SetSetting(const std::string &strKey, float fValue); virtual void PersistSettings(bool bExiting = false); virtual void LoadPersistedSettings(void); @@ -169,21 +169,21 @@ namespace PERIPHERALS PeripheralType m_type; PeripheralBusType m_busType; PeripheralBusType m_mappedBusType; - CStdString m_strLocation; - CStdString m_strDeviceName; - CStdString m_strSettingsFile; - CStdString m_strFileLocation; + std::string m_strLocation; + std::string m_strDeviceName; + std::string m_strSettingsFile; + std::string m_strFileLocation; int m_iVendorId; - CStdString m_strVendorId; + std::string m_strVendorId; int m_iProductId; - CStdString m_strProductId; - CStdString m_strVersionInfo; + std::string m_strProductId; + std::string m_strVersionInfo; bool m_bInitialised; bool m_bHidden; bool m_bError; std::vector<PeripheralFeature> m_features; std::vector<CPeripheral *> m_subDevices; - std::map<CStdString, PeripheralDeviceSetting> m_settings; - std::set<CStdString> m_changedSettings; + std::map<std::string, PeripheralDeviceSetting> m_settings; + std::set<std::string> m_changedSettings; }; } diff --git a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp index e80feb16bb..98c4d77eed 100644 --- a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp +++ b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp @@ -269,7 +269,7 @@ bool CPeripheralCecAdapter::InitialiseFeature(const PeripheralFeature feature) CLog::Log(LOGERROR, g_localizeStrings.Get(36040).c_str(), m_cecAdapter ? m_configuration.serverVersion : -1, CEC_LIB_SUPPORTED_VERSION); // display warning: incompatible libCEC - CStdString strMessage = StringUtils::Format(g_localizeStrings.Get(36040).c_str(), m_cecAdapter ? m_configuration.serverVersion : -1, CEC_LIB_SUPPORTED_VERSION); + std::string strMessage = StringUtils::Format(g_localizeStrings.Get(36040).c_str(), m_cecAdapter ? m_configuration.serverVersion : -1, CEC_LIB_SUPPORTED_VERSION); CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(36000), strMessage); m_bError = true; if (m_cecAdapter) @@ -319,7 +319,7 @@ bool CPeripheralCecAdapter::OpenConnection(void) CLog::Log(LOGDEBUG, "%s - opening a connection to the CEC adapter: %s", __FUNCTION__, m_strComPort.c_str()); // scanning the CEC bus takes about 5 seconds, so display a notification to inform users that we're busy - CStdString strMessage = StringUtils::Format(g_localizeStrings.Get(21336).c_str(), g_localizeStrings.Get(36000).c_str()); + std::string strMessage = StringUtils::Format(g_localizeStrings.Get(21336).c_str(), g_localizeStrings.Get(36000).c_str()); CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(36000), strMessage); bool bConnectionFailedDisplayed(false); @@ -551,10 +551,10 @@ bool CPeripheralCecAdapter::IsMuted(void) void CPeripheralCecAdapter::SetMenuLanguage(const char *strLanguage) { - if (m_strMenuLanguage.Equals(strLanguage)) + if (StringUtils::EqualsNoCase(m_strMenuLanguage, strLanguage)) return; - CStdString strGuiLanguage; + std::string strGuiLanguage; if (!strcmp(strLanguage, "bul")) strGuiLanguage = "Bulgarian"; @@ -628,9 +628,9 @@ int CPeripheralCecAdapter::CecCommand(void *cbParam, const cec_command command) { adapter->m_bStarted = false; if (adapter->m_configuration.bPowerOffOnStandby == 1) - CApplicationMessenger::Get().Suspend(); + g_application.ExecuteXBMCAction("Suspend"); else if (adapter->m_configuration.bShutdownOnStandby == 1) - CApplicationMessenger::Get().Shutdown(); + g_application.ExecuteXBMCAction("Shutdown"); } break; case CEC_OPCODE_SET_MENU_LANGUAGE: @@ -726,7 +726,7 @@ int CPeripheralCecAdapter::CecAlert(void *cbParam, const libcec_alert alert, con // display the alert if (iAlertString) { - CStdString strLog(g_localizeStrings.Get(iAlertString)); + std::string strLog(g_localizeStrings.Get(iAlertString)); if (data.paramType == CEC_PARAMETER_TYPE_STRING && data.paramData) strLog += StringUtils::Format(" - %s", (const char *)data.paramData); CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(36000), strLog); @@ -1109,9 +1109,9 @@ void CPeripheralCecAdapter::ResetButton(void) } } -void CPeripheralCecAdapter::OnSettingChanged(const CStdString &strChangedSetting) +void CPeripheralCecAdapter::OnSettingChanged(const std::string &strChangedSetting) { - if (strChangedSetting.Equals("enabled")) + if (StringUtils::EqualsNoCase(strChangedSetting, "enabled")) { bool bEnabled(GetSettingBool("enabled")); if (!bEnabled && IsRunning()) @@ -1233,7 +1233,7 @@ void CPeripheralCecAdapter::SetConfigurationFromLibCEC(const CEC::libcec_configu bChanged |= SetSetting("cec_hdmi_port", config.iHDMIPort); // set the physical address, when baseDevice or iHDMIPort are not set - CStdString strPhysicalAddress("0"); + std::string strPhysicalAddress("0"); if (!bPAAutoDetected && (m_configuration.baseDevice == CECDEVICE_UNKNOWN || m_configuration.iHDMIPort < CEC_MIN_HDMI_PORTNUMBER || m_configuration.iHDMIPort > CEC_MAX_HDMI_PORTNUMBER)) @@ -1308,7 +1308,7 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void) // set the physical address // when set, it will override the connected device and hdmi port settings - CStdString strPhysicalAddress = GetSettingString("physical_address"); + std::string strPhysicalAddress = GetSettingString("physical_address"); int iPhysicalAddress; if (sscanf(strPhysicalAddress.c_str(), "%x", &iPhysicalAddress) && iPhysicalAddress >= CEC_PHYSICAL_ADDRESS_TV && @@ -1337,7 +1337,7 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void) m_configuration.tvVendor = iVendor; // read the devices to wake when starting - CStdString strWakeDevices = GetSettingString("wake_devices_advanced"); + std::string strWakeDevices = GetSettingString("wake_devices_advanced"); StringUtils::Trim(strWakeDevices); m_configuration.wakeDevices.Clear(); if (!strWakeDevices.empty()) @@ -1346,7 +1346,7 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void) ReadLogicalAddresses(GetSettingInt("wake_devices"), m_configuration.wakeDevices); // read the devices to power off when stopping - CStdString strStandbyDevices = GetSettingString("standby_devices_advanced"); + std::string strStandbyDevices = GetSettingString("standby_devices_advanced"); StringUtils::Trim(strStandbyDevices); m_configuration.powerOffDevices.Clear(); if (!strStandbyDevices.empty()) @@ -1375,11 +1375,11 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void) #endif } -void CPeripheralCecAdapter::ReadLogicalAddresses(const CStdString &strString, cec_logical_addresses &addresses) +void CPeripheralCecAdapter::ReadLogicalAddresses(const std::string &strString, cec_logical_addresses &addresses) { for (size_t iPtr = 0; iPtr < strString.size(); iPtr++) { - CStdString strDevice = strString.substr(iPtr, 1); + std::string strDevice = strString.substr(iPtr, 1); StringUtils::Trim(strDevice); if (!strDevice.empty()) { @@ -1418,7 +1418,7 @@ bool CPeripheralCecAdapter::WriteLogicalAddresses(const cec_logical_addresses& a // only update the advanced setting if it was set by the user if (!GetSettingString(strAdvancedSettingName).empty()) { - CStdString strPowerOffDevices; + std::string strPowerOffDevices; for (unsigned int iPtr = CECDEVICE_TV; iPtr <= CECDEVICE_BROADCAST; iPtr++) if (addresses[iPtr]) strPowerOffDevices += StringUtils::Format(" %X", iPtr); @@ -1520,9 +1520,9 @@ void CPeripheralCecAdapterUpdateThread::UpdateMenuLanguage(void) } } -CStdString CPeripheralCecAdapterUpdateThread::UpdateAudioSystemStatus(void) +std::string CPeripheralCecAdapterUpdateThread::UpdateAudioSystemStatus(void) { - CStdString strAmpName; + std::string strAmpName; /* disable the mute setting when an amp is found, because the amp handles the mute setting and set PCM output to 100% */ @@ -1567,11 +1567,11 @@ bool CPeripheralCecAdapterUpdateThread::SetInitialConfiguration(void) UpdateMenuLanguage(); // request the OSD name of the TV - CStdString strNotification; + std::string strNotification; cec_osd_name tvName = m_adapter->m_cecAdapter->GetDeviceOSDName(CECDEVICE_TV); strNotification = StringUtils::Format("%s: %s", g_localizeStrings.Get(36016).c_str(), tvName.name); - CStdString strAmpName = UpdateAudioSystemStatus(); + std::string strAmpName = UpdateAudioSystemStatus(); if (!strAmpName.empty()) strNotification += StringUtils::Format("- %s", strAmpName.c_str()); diff --git a/xbmc/peripherals/devices/PeripheralCecAdapter.h b/xbmc/peripherals/devices/PeripheralCecAdapter.h index 0809b038fd..7acb255082 100644 --- a/xbmc/peripherals/devices/PeripheralCecAdapter.h +++ b/xbmc/peripherals/devices/PeripheralCecAdapter.h @@ -100,7 +100,7 @@ namespace PERIPHERALS bool IsMuted(void); // CPeripheral callbacks - void OnSettingChanged(const CStdString &strChangedSetting); + void OnSettingChanged(const std::string &strChangedSetting); void OnDeviceRemoved(void); // input @@ -126,7 +126,7 @@ namespace PERIPHERALS void SetConfigurationFromLibCEC(const CEC::libcec_configuration &config); void SetVersionInfo(const CEC::libcec_configuration &configuration); - static void ReadLogicalAddresses(const CStdString &strString, CEC::cec_logical_addresses &addresses); + static void ReadLogicalAddresses(const std::string &strString, CEC::cec_logical_addresses &addresses); static void ReadLogicalAddresses(int iLocalisedId, CEC::cec_logical_addresses &addresses); bool WriteLogicalAddresses(const CEC::cec_logical_addresses& addresses, const std::string& strSettingName, const std::string& strAdvancedSettingName); @@ -155,7 +155,7 @@ namespace PERIPHERALS bool m_bHasButton; bool m_bIsReady; bool m_bHasConnectedAudioSystem; - CStdString m_strMenuLanguage; + std::string m_strMenuLanguage; CDateTime m_standbySent; std::vector<CecButtonPress> m_buttonQueue; CecButtonPress m_currentButton; @@ -177,7 +177,7 @@ namespace PERIPHERALS bool m_bActiveSourceBeforeStandby; bool m_bOnPlayReceived; bool m_bPlaybackPaused; - CStdString m_strComPort; + std::string m_strComPort; }; class CPeripheralCecAdapterUpdateThread : public CThread @@ -191,7 +191,7 @@ namespace PERIPHERALS protected: void UpdateMenuLanguage(void); - CStdString UpdateAudioSystemStatus(void); + std::string UpdateAudioSystemStatus(void); bool WaitReady(void); bool SetInitialConfiguration(void); void Process(void); diff --git a/xbmc/peripherals/devices/PeripheralHID.cpp b/xbmc/peripherals/devices/PeripheralHID.cpp index ed1976b48d..6433a0d831 100644 --- a/xbmc/peripherals/devices/PeripheralHID.cpp +++ b/xbmc/peripherals/devices/PeripheralHID.cpp @@ -81,9 +81,9 @@ bool CPeripheralHID::InitialiseFeature(const PeripheralFeature feature) return CPeripheral::InitialiseFeature(feature); } -void CPeripheralHID::OnSettingChanged(const CStdString &strChangedSetting) +void CPeripheralHID::OnSettingChanged(const std::string &strChangedSetting) { - if (m_bInitialised && ((strChangedSetting.Equals("keymap") && !GetSettingBool("do_not_use_custom_keymap")) || strChangedSetting.Equals("keymap_enabled"))) + if (m_bInitialised && ((StringUtils::EqualsNoCase(strChangedSetting, "keymap") && !GetSettingBool("do_not_use_custom_keymap")) || StringUtils::EqualsNoCase(strChangedSetting, "keymap_enabled"))) { m_bInitialised = false; InitialiseFeature(FEATURE_HID); diff --git a/xbmc/peripherals/devices/PeripheralHID.h b/xbmc/peripherals/devices/PeripheralHID.h index bc9ea69f56..b1e0a21e31 100644 --- a/xbmc/peripherals/devices/PeripheralHID.h +++ b/xbmc/peripherals/devices/PeripheralHID.h @@ -31,9 +31,9 @@ namespace PERIPHERALS virtual ~CPeripheralHID(void); virtual bool InitialiseFeature(const PeripheralFeature feature); virtual bool LookupSymAndUnicode(XBMC_keysym &keysym, uint8_t *key, char *unicode) { return false; } - virtual void OnSettingChanged(const CStdString &strChangedSetting); + virtual void OnSettingChanged(const std::string &strChangedSetting); protected: - CStdString m_strKeymap; + std::string m_strKeymap; }; } diff --git a/xbmc/peripherals/devices/PeripheralImon.cpp b/xbmc/peripherals/devices/PeripheralImon.cpp index d42d647589..daaaadf89f 100644 --- a/xbmc/peripherals/devices/PeripheralImon.cpp +++ b/xbmc/peripherals/devices/PeripheralImon.cpp @@ -75,7 +75,7 @@ bool CPeripheralImon::InitialiseFeature(const PeripheralFeature feature) return CPeripheralHID::InitialiseFeature(feature); } -void CPeripheralImon::AddSetting(const CStdString &strKey, const CSetting *setting, int order) +void CPeripheralImon::AddSetting(const std::string &strKey, const CSetting *setting, int order) { #if !defined(TARGET_WINDOWS) if (strKey.compare("disable_winjoystick")!=0) @@ -83,7 +83,7 @@ void CPeripheralImon::AddSetting(const CStdString &strKey, const CSetting *setti CPeripheralHID::AddSetting(strKey, setting, order); } -void CPeripheralImon::OnSettingChanged(const CStdString &strChangedSetting) +void CPeripheralImon::OnSettingChanged(const std::string &strChangedSetting) { if (strChangedSetting.compare("disable_winjoystick") == 0) { diff --git a/xbmc/peripherals/devices/PeripheralImon.h b/xbmc/peripherals/devices/PeripheralImon.h index d73ac8f4f5..643e8c8b86 100644 --- a/xbmc/peripherals/devices/PeripheralImon.h +++ b/xbmc/peripherals/devices/PeripheralImon.h @@ -31,9 +31,9 @@ namespace PERIPHERALS CPeripheralImon(const PeripheralScanResult& scanResult); virtual ~CPeripheralImon(void) {} virtual bool InitialiseFeature(const PeripheralFeature feature); - virtual void OnSettingChanged(const CStdString &strChangedSetting); + virtual void OnSettingChanged(const std::string &strChangedSetting); virtual void OnDeviceRemoved(); - virtual void AddSetting(const CStdString &strKey, const CSetting *setting, int order); + virtual void AddSetting(const std::string &strKey, const CSetting *setting, int order); inline bool IsImonConflictsWithDInput() { return m_bImonConflictsWithDInput;} static inline long GetCountOfImonsConflictWithDInput() diff --git a/xbmc/peripherals/devices/PeripheralNyxboard.cpp b/xbmc/peripherals/devices/PeripheralNyxboard.cpp index a66bd01241..777111b8b6 100644 --- a/xbmc/peripherals/devices/PeripheralNyxboard.cpp +++ b/xbmc/peripherals/devices/PeripheralNyxboard.cpp @@ -35,7 +35,7 @@ CPeripheralNyxboard::CPeripheralNyxboard(const PeripheralScanResult& scanResult) bool CPeripheralNyxboard::LookupSymAndUnicode(XBMC_keysym &keysym, uint8_t *key, char *unicode) { - CStdString strCommand; + std::string strCommand; if (keysym.sym == XBMCK_F7 && keysym.mod == XBMCKMOD_NONE && GetSettingBool("enable_flip_commands")) { /* switched to keyboard side */ diff --git a/xbmc/pictures/GUIDialogPictureInfo.cpp b/xbmc/pictures/GUIDialogPictureInfo.cpp index 8d626e960e..cf86c45c92 100644 --- a/xbmc/pictures/GUIDialogPictureInfo.cpp +++ b/xbmc/pictures/GUIDialogPictureInfo.cpp @@ -99,7 +99,7 @@ void CGUIDialogPictureInfo::UpdatePictureInfo() if (info == SLIDE_EXIF_DATE || info == SLIDE_EXIF_LONG_DATE || info == SLIDE_EXIF_LONG_DATE_TIME ) continue; - CStdString picInfo = g_infoManager.GetLabel(info); + std::string picInfo = g_infoManager.GetLabel(info); if (!picInfo.empty()) { CFileItemPtr item(new CFileItem(g_localizeStrings.Get(SLIDE_STRING_BASE + info))); diff --git a/xbmc/pictures/GUIDialogPictureInfo.h b/xbmc/pictures/GUIDialogPictureInfo.h index 3c95b79191..a0b78dc2ed 100644 --- a/xbmc/pictures/GUIDialogPictureInfo.h +++ b/xbmc/pictures/GUIDialogPictureInfo.h @@ -40,5 +40,5 @@ protected: void UpdatePictureInfo(); CFileItemList* m_pictureInfo; - CStdString m_currentPicture; + std::string m_currentPicture; }; diff --git a/xbmc/pictures/GUIWindowPictures.cpp b/xbmc/pictures/GUIWindowPictures.cpp index 278ea87ea7..fd2f0b69d2 100644 --- a/xbmc/pictures/GUIWindowPictures.cpp +++ b/xbmc/pictures/GUIWindowPictures.cpp @@ -72,7 +72,7 @@ void CGUIWindowPictures::OnInitWindow() if (m_slideShowStarted) { CGUIWindowSlideShow* wndw = (CGUIWindowSlideShow*)g_windowManager.GetWindow(WINDOW_SLIDESHOW); - CStdString path; + std::string path; if (wndw && wndw->GetCurrentSlide()) path = URIUtils::GetDirectory(wndw->GetCurrentSlide()->GetPath()); if (m_vecItems->IsPath(path)) @@ -268,7 +268,7 @@ bool CGUIWindowPictures::Update(const std::string &strDirectory, bool updateFilt m_thumbLoader.Load(*m_vecItems); CPictureThumbLoader thumbLoader; - CStdString thumb = thumbLoader.GetCachedImage(*m_vecItems, "thumb"); + std::string thumb = thumbLoader.GetCachedImage(*m_vecItems, "thumb"); m_vecItems->SetArt("thumb", thumb); return true; @@ -301,7 +301,7 @@ bool CGUIWindowPictures::GetDirectory(const std::string &strDirectory, CFileItem if (!CGUIMediaWindow::GetDirectory(strDirectory, items)) return false; - CStdString label; + std::string label; if (items.GetLabel().empty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::Get().GetSources("pictures"), &label)) items.SetLabel(label); @@ -320,7 +320,7 @@ bool CGUIWindowPictures::ShowPicture(int iItem, bool startSlideShow) { if ( iItem < 0 || iItem >= (int)m_vecItems->Size() ) return false; CFileItemPtr pItem = m_vecItems->Get(iItem); - CStdString strPicture = pItem->GetPath(); + std::string strPicture = pItem->GetPath(); #ifdef HAS_DVD_DRIVE if (pItem->IsDVD()) @@ -370,7 +370,7 @@ bool CGUIWindowPictures::ShowPicture(int iItem, bool startSlideShow) return true; } -void CGUIWindowPictures::OnShowPictureRecursive(const CStdString& strPath) +void CGUIWindowPictures::OnShowPictureRecursive(const std::string& strPath) { CGUIWindowSlideShow *pSlideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW); if (pSlideShow) @@ -390,12 +390,12 @@ void CGUIWindowPictures::OnShowPictureRecursive(const CStdString& strPath) } } -void CGUIWindowPictures::OnSlideShowRecursive(const CStdString &strPicture) +void CGUIWindowPictures::OnSlideShowRecursive(const std::string &strPicture) { CGUIWindowSlideShow *pSlideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW); if (pSlideShow) { - CStdString strExtensions; + std::string strExtensions; CFileItemList items; CGUIViewState* viewState=CGUIViewState::GetViewState(GetID(), items); if (viewState) @@ -416,7 +416,7 @@ void CGUIWindowPictures::OnSlideShowRecursive(const CStdString &strPicture) void CGUIWindowPictures::OnSlideShowRecursive() { - CStdString strEmpty = ""; + std::string strEmpty = ""; OnSlideShowRecursive(m_vecItems->GetPath()); } @@ -425,12 +425,12 @@ void CGUIWindowPictures::OnSlideShow() OnSlideShow(m_vecItems->GetPath()); } -void CGUIWindowPictures::OnSlideShow(const CStdString &strPicture) +void CGUIWindowPictures::OnSlideShow(const std::string &strPicture) { CGUIWindowSlideShow *pSlideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW); if (pSlideShow) { - CStdString strExtensions; + std::string strExtensions; CFileItemList items; CGUIViewState* viewState=CGUIViewState::GetViewState(GetID(), items); if (viewState) diff --git a/xbmc/pictures/GUIWindowPictures.h b/xbmc/pictures/GUIWindowPictures.h index 868cb06009..c9be441640 100644 --- a/xbmc/pictures/GUIWindowPictures.h +++ b/xbmc/pictures/GUIWindowPictures.h @@ -49,10 +49,10 @@ protected: void OnRegenerateThumbs(); virtual bool OnPlayMedia(int iItem); bool ShowPicture(int iItem, bool startSlideShow); - void OnShowPictureRecursive(const CStdString& strPath); - void OnSlideShow(const CStdString& strPicture); + void OnShowPictureRecursive(const std::string& strPath); + void OnSlideShow(const std::string& strPicture); void OnSlideShow(); - void OnSlideShowRecursive(const CStdString& strPicture); + void OnSlideShowRecursive(const std::string& strPicture); void OnSlideShowRecursive(); virtual void OnItemLoaded(CFileItem* pItem); virtual void LoadPlayList(const std::string& strPlayList); diff --git a/xbmc/pictures/GUIWindowSlideShow.cpp b/xbmc/pictures/GUIWindowSlideShow.cpp index 3ca0c76e56..0ce46565fc 100644 --- a/xbmc/pictures/GUIWindowSlideShow.cpp +++ b/xbmc/pictures/GUIWindowSlideShow.cpp @@ -131,7 +131,7 @@ void CBackgroundPicLoader::Process() count, totalTime, totalTime / count); } -void CBackgroundPicLoader::LoadPic(int iPic, int iSlideNumber, const CStdString &strFileName, const int maxWidth, const int maxHeight) +void CBackgroundPicLoader::LoadPic(int iPic, int iSlideNumber, const std::string &strFileName, const int maxWidth, const int maxHeight) { m_iPic = iPic; m_iSlideNumber = iSlideNumber; @@ -332,7 +332,7 @@ void CGUIWindowSlideShow::ShowPrevious() } -void CGUIWindowSlideShow::Select(const CStdString& strPicture) +void CGUIWindowSlideShow::Select(const std::string& strPicture) { for (int i = 0; i < m_slides->Size(); ++i) { @@ -504,7 +504,7 @@ void CGUIWindowSlideShow::Process(unsigned int currentTime, CDirtyRegionList &re if (!m_Image[m_iCurrentPic].IsLoaded() && !m_pBackgroundLoader->IsLoading()) { // load first image CFileItemPtr item = m_slides->Get(m_iCurrentSlide); - CStdString picturePath = GetPicturePath(item.get()); + std::string picturePath = GetPicturePath(item.get()); if (!picturePath.empty()) { if (item->IsVideo()) @@ -532,7 +532,7 @@ void CGUIWindowSlideShow::Process(unsigned int currentTime, CDirtyRegionList &re { // load the next image m_iLastFailedNextSlide = -1; CFileItemPtr item = m_slides->Get(m_iNextSlide); - CStdString picturePath = GetPicturePath(item.get()); + std::string picturePath = GetPicturePath(item.get()); if (!picturePath.empty() && (!item->IsVideo() || !m_bSlideShow || m_bPause)) { if (item->IsVideo()) @@ -940,7 +940,7 @@ bool CGUIWindowSlideShow::OnMessage(CGUIMessage& message) case GUI_MSG_SHOW_PICTURE: { - CStdString strFile = message.GetStringParam(); + std::string strFile = message.GetStringParam(); Reset(); CFileItem item(strFile, false); Add(&item); @@ -950,7 +950,7 @@ bool CGUIWindowSlideShow::OnMessage(CGUIMessage& message) case GUI_MSG_START_SLIDESHOW: { - CStdString strFolder = message.GetStringParam(); + std::string strFolder = message.GetStringParam(); unsigned int iParams = message.GetParam1(); std::string beginSlidePath = message.GetStringParam(1); //decode params @@ -1129,7 +1129,7 @@ CSlideShowPic::DISPLAY_EFFECT CGUIWindowSlideShow::GetDisplayEffect(int iSlideNu return CSlideShowPic::EFFECT_NO_TIMEOUT; } -void CGUIWindowSlideShow::OnLoadPic(int iPic, int iSlideNumber, const CStdString &strFileName, CBaseTexture* pTexture, bool bFullSize) +void CGUIWindowSlideShow::OnLoadPic(int iPic, int iSlideNumber, const std::string &strFileName, CBaseTexture* pTexture, bool bFullSize) { if (pTexture) { @@ -1148,7 +1148,7 @@ void CGUIWindowSlideShow::OnLoadPic(int iPic, int iSlideNumber, const CStdString if (URIUtils::IsInRAR(m_slides->Get(m_iCurrentSlide)->GetPath()) || URIUtils::IsInZIP(m_slides->Get(m_iCurrentSlide)->GetPath())) // move to top for cbr/cbz { CURL url(m_slides->Get(m_iCurrentSlide)->GetPath()); - CStdString strHostName = url.GetHostName(); + std::string strHostName = url.GetHostName(); if (URIUtils::HasExtension(strHostName, ".cbr|.cbz")) { m_Image[iPic].m_bIsComic = true; @@ -1188,10 +1188,10 @@ int CGUIWindowSlideShow::CurrentSlide() const return m_iCurrentSlide + 1; } -void CGUIWindowSlideShow::AddFromPath(const CStdString &strPath, +void CGUIWindowSlideShow::AddFromPath(const std::string &strPath, bool bRecursive, SortBy method, SortOrder order, SortAttribute sortAttributes, - const CStdString &strExtensions) + const std::string &strExtensions) { if (strPath!="") { @@ -1208,12 +1208,12 @@ void CGUIWindowSlideShow::AddFromPath(const CStdString &strPath, } } -void CGUIWindowSlideShow::RunSlideShow(const CStdString &strPath, +void CGUIWindowSlideShow::RunSlideShow(const std::string &strPath, bool bRecursive /* = false */, bool bRandom /* = false */, - bool bNotRandom /* = false */, const CStdString &beginSlidePath /* = "" */, + bool bNotRandom /* = false */, const std::string &beginSlidePath /* = "" */, bool startSlideShow /* = true */, SortBy method /* = SortByLabel */, SortOrder order /* = SortOrderAscending */, SortAttribute sortAttributes /* = SortAttributeNone */, - const CStdString &strExtensions) + const std::string &strExtensions) { // stop any video if (g_application.m_pPlayer->IsPlayingVideo()) @@ -1249,12 +1249,12 @@ void CGUIWindowSlideShow::RunSlideShow(const CStdString &strPath, g_windowManager.ActivateWindow(WINDOW_SLIDESHOW); } -void CGUIWindowSlideShow::AddItems(const CStdString &strPath, path_set *recursivePaths, SortBy method, SortOrder order, SortAttribute sortAttributes) +void CGUIWindowSlideShow::AddItems(const std::string &strPath, path_set *recursivePaths, SortBy method, SortOrder order, SortAttribute sortAttributes) { // check whether we've already added this path if (recursivePaths) { - CStdString path(strPath); + std::string path(strPath); URIUtils::RemoveSlashAtEnd(path); if (recursivePaths->find(path) != recursivePaths->end()) return; @@ -1289,10 +1289,10 @@ void CGUIWindowSlideShow::GetCheckedSize(float width, float height, int &maxWidt maxHeight = g_Windowing.GetMaxTextureSize(); } -CStdString CGUIWindowSlideShow::GetPicturePath(CFileItem *item) +std::string CGUIWindowSlideShow::GetPicturePath(CFileItem *item) { bool isVideo = item->IsVideo(); - CStdString picturePath = item->GetPath(); + std::string picturePath = item->GetPath(); if (isVideo) { picturePath = item->GetArt("thumb"); diff --git a/xbmc/pictures/GUIWindowSlideShow.h b/xbmc/pictures/GUIWindowSlideShow.h index b59b4ee134..da92854292 100644 --- a/xbmc/pictures/GUIWindowSlideShow.h +++ b/xbmc/pictures/GUIWindowSlideShow.h @@ -41,7 +41,7 @@ public: ~CBackgroundPicLoader(); void Create(CGUIWindowSlideShow *pCallback); - void LoadPic(int iPic, int iSlideNumber, const CStdString &strFileName, const int maxWidth, const int maxHeight); + void LoadPic(int iPic, int iSlideNumber, const std::string &strFileName, const int maxWidth, const int maxHeight); bool IsLoading() { return m_isLoading;}; int SlideNumber() const { return m_iSlideNumber; } int Pic() const { return m_iPic; } @@ -50,7 +50,7 @@ private: void Process(); int m_iPic; int m_iSlideNumber; - CStdString m_strFileName; + std::string m_strFileName; int m_maxWidth; int m_maxHeight; @@ -71,22 +71,22 @@ public: bool IsPlaying() const; void ShowNext(); void ShowPrevious(); - void Select(const CStdString& strPicture); + void Select(const std::string& strPicture); const CFileItemList &GetSlideShowContents(); void GetSlideShowContents(CFileItemList &list); const CFileItemPtr GetCurrentSlide(); - void RunSlideShow(const CStdString &strPath, bool bRecursive = false, + void RunSlideShow(const std::string &strPath, bool bRecursive = false, bool bRandom = false, bool bNotRandom = false, - const CStdString &beginSlidePath="", bool startSlideShow = true, + const std::string &beginSlidePath="", bool startSlideShow = true, SortBy method = SortByLabel, SortOrder order = SortOrderAscending, SortAttribute sortAttributes = SortAttributeNone, - const CStdString &strExtensions=""); - void AddFromPath(const CStdString &strPath, bool bRecursive, + const std::string &strExtensions=""); + void AddFromPath(const std::string &strPath, bool bRecursive, SortBy method = SortByLabel, SortOrder order = SortOrderAscending, SortAttribute sortAttributes = SortAttributeNone, - const CStdString &strExtensions=""); + const std::string &strExtensions=""); void StartSlideShow(); bool InSlideShow() const; virtual bool OnMessage(CGUIMessage& message); @@ -95,7 +95,7 @@ public: virtual void Render(); virtual void Process(unsigned int currentTime, CDirtyRegionList ®ions); virtual void OnDeinitWindow(int nextWindowID); - void OnLoadPic(int iPic, int iSlideNumber, const CStdString &strFileName, CBaseTexture* pTexture, bool bFullSize); + void OnLoadPic(int iPic, int iSlideNumber, const std::string &strFileName, CBaseTexture* pTexture, bool bFullSize); int NumSlides() const; int CurrentSlide() const; void Shuffle(); @@ -104,8 +104,8 @@ public: int GetDirection() const { return m_iDirection; } void SetDirection(int direction); // -1: rewind, 1: forward private: - typedef std::set<CStdString> path_set; // set to track which paths we're adding - void AddItems(const CStdString &strPath, path_set *recursivePaths, + typedef std::set<std::string> path_set; // set to track which paths we're adding + void AddItems(const std::string &strPath, path_set *recursivePaths, SortBy method = SortByLabel, SortOrder order = SortOrderAscending, SortAttribute sortAttributes = SortAttributeNone); @@ -118,7 +118,7 @@ private: void ZoomRelative(float fZoom, bool immediate = false); void Move(float fX, float fY); void GetCheckedSize(float width, float height, int &maxWidth, int &maxHeight); - CStdString GetPicturePath(CFileItem *item); + std::string GetPicturePath(CFileItem *item); int GetNextSlide(); void AnnouncePlayerPlay(const CFileItemPtr& item); @@ -156,6 +156,6 @@ private: DllImageLib m_ImageLib; RESOLUTION m_Resolution; CCriticalSection m_slideSection; - CStdString m_strExtensions; + std::string m_strExtensions; CPoint m_firstGesturePoint; }; diff --git a/xbmc/pictures/Picture.cpp b/xbmc/pictures/Picture.cpp index 34ae62db7d..7a776fca49 100644 --- a/xbmc/pictures/Picture.cpp +++ b/xbmc/pictures/Picture.cpp @@ -43,7 +43,7 @@ extern "C" { using namespace XFILE; -bool CPicture::CreateThumbnailFromSurface(const unsigned char *buffer, int width, int height, int stride, const CStdString &thumbFile) +bool CPicture::CreateThumbnailFromSurface(const unsigned char *buffer, int width, int height, int stride, const std::string &thumbFile) { CLog::Log(LOGDEBUG, "cached image '%s' size %dx%d", thumbFile.c_str(), width, height); if (URIUtils::HasExtension(thumbFile, ".jpg")) @@ -72,7 +72,7 @@ bool CPicture::CreateThumbnailFromSurface(const unsigned char *buffer, int width return ret; } -CThumbnailWriter::CThumbnailWriter(unsigned char* buffer, int width, int height, int stride, const CStdString& thumbFile) +CThumbnailWriter::CThumbnailWriter(unsigned char* buffer, int width, int height, int stride, const std::string& thumbFile) { m_buffer = buffer; m_width = width; diff --git a/xbmc/pictures/Picture.h b/xbmc/pictures/Picture.h index b5e42b283a..2eb041ac1d 100644 --- a/xbmc/pictures/Picture.h +++ b/xbmc/pictures/Picture.h @@ -18,15 +18,16 @@ * <http://www.gnu.org/licenses/>. * */ -#include "utils/StdString.h" #include "utils/Job.h" +#include <string> +#include <vector> class CBaseTexture; class CPicture { public: - static bool CreateThumbnailFromSurface(const unsigned char* buffer, int width, int height, int stride, const CStdString &thumbFile); + static bool CreateThumbnailFromSurface(const unsigned char* buffer, int width, int height, int stride, const std::string &thumbFile); /*! \brief Create a tiled thumb of the given files \param files the files to create the thumb from @@ -64,7 +65,7 @@ class CThumbnailWriter : public CJob { public: //WARNING: buffer is deleted from DoWork() - CThumbnailWriter(unsigned char* buffer, int width, int height, int stride, const CStdString& thumbFile); + CThumbnailWriter(unsigned char* buffer, int width, int height, int stride, const std::string& thumbFile); ~CThumbnailWriter(); bool DoWork(); @@ -73,6 +74,6 @@ class CThumbnailWriter : public CJob int m_width; int m_height; int m_stride; - CStdString m_thumbFile; + std::string m_thumbFile; }; diff --git a/xbmc/pictures/PictureInfoLoader.h b/xbmc/pictures/PictureInfoLoader.h index 48e787162b..2a022ff0ff 100644 --- a/xbmc/pictures/PictureInfoLoader.h +++ b/xbmc/pictures/PictureInfoLoader.h @@ -20,7 +20,7 @@ */ #include "BackgroundInfoLoader.h" -#include "utils/StdString.h" +#include <string> class CPictureInfoLoader : public CBackgroundInfoLoader { @@ -28,7 +28,7 @@ public: CPictureInfoLoader(); virtual ~CPictureInfoLoader(); - void UseCacheOnHD(const CStdString& strFileName); + void UseCacheOnHD(const std::string& strFileName); virtual bool LoadItem(CFileItem* pItem); virtual bool LoadItemCached(CFileItem* pItem); virtual bool LoadItemLookup(CFileItem* pItem); diff --git a/xbmc/pictures/PictureInfoTag.cpp b/xbmc/pictures/PictureInfoTag.cpp index 832902131e..9704a4b77f 100644 --- a/xbmc/pictures/PictureInfoTag.cpp +++ b/xbmc/pictures/PictureInfoTag.cpp @@ -48,7 +48,7 @@ const CPictureInfoTag& CPictureInfoTag::operator=(const CPictureInfoTag& right) return *this; } -bool CPictureInfoTag::Load(const CStdString &path) +bool CPictureInfoTag::Load(const std::string &path) { m_isLoaded = false; @@ -71,12 +71,12 @@ void CPictureInfoTag::Archive(CArchive& ar) ar << m_isLoaded; ar << m_isInfoSetExternally; ar << m_exifInfo.ApertureFNumber; - ar << CStdString(m_exifInfo.CameraMake); - ar << CStdString(m_exifInfo.CameraModel); + ar << std::string(m_exifInfo.CameraMake); + ar << std::string(m_exifInfo.CameraModel); ar << m_exifInfo.CCDWidth; ar << GetInfo(SLIDE_EXIF_COMMENT); // Store and restore the comment charset converted - ar << CStdString(m_exifInfo.Description); - ar << CStdString(m_exifInfo.DateTime); + ar << std::string(m_exifInfo.Description); + ar << std::string(m_exifInfo.DateTime); for (int i = 0; i < 10; i++) ar << m_exifInfo.DateTimeOffsets[i]; ar << m_exifInfo.DigitalZoomRatio; @@ -89,9 +89,9 @@ void CPictureInfoTag::Archive(CArchive& ar) ar << m_exifInfo.FocalLength; ar << m_exifInfo.FocalLength35mmEquiv; ar << m_exifInfo.GpsInfoPresent; - ar << CStdString(m_exifInfo.GpsAlt); - ar << CStdString(m_exifInfo.GpsLat); - ar << CStdString(m_exifInfo.GpsLong); + ar << std::string(m_exifInfo.GpsAlt); + ar << std::string(m_exifInfo.GpsLat); + ar << std::string(m_exifInfo.GpsLong); ar << m_exifInfo.Height; ar << m_exifInfo.IsColor; ar << m_exifInfo.ISOequivalent; @@ -109,30 +109,30 @@ void CPictureInfoTag::Archive(CArchive& ar) ar << m_exifInfo.Width; ar << m_dateTimeTaken; - ar << CStdString(m_iptcInfo.Author); - ar << CStdString(m_iptcInfo.Byline); - ar << CStdString(m_iptcInfo.BylineTitle); - ar << CStdString(m_iptcInfo.Caption); - ar << CStdString(m_iptcInfo.Category); - ar << CStdString(m_iptcInfo.City); - ar << CStdString(m_iptcInfo.Urgency); - ar << CStdString(m_iptcInfo.CopyrightNotice); - ar << CStdString(m_iptcInfo.Country); - ar << CStdString(m_iptcInfo.CountryCode); - ar << CStdString(m_iptcInfo.Credit); - ar << CStdString(m_iptcInfo.Date); - ar << CStdString(m_iptcInfo.Headline); - ar << CStdString(m_iptcInfo.Keywords); - ar << CStdString(m_iptcInfo.ObjectName); - ar << CStdString(m_iptcInfo.ReferenceService); - ar << CStdString(m_iptcInfo.Source); - ar << CStdString(m_iptcInfo.SpecialInstructions); - ar << CStdString(m_iptcInfo.State); - ar << CStdString(m_iptcInfo.SupplementalCategories); - ar << CStdString(m_iptcInfo.TransmissionReference); - ar << CStdString(m_iptcInfo.TimeCreated); - ar << CStdString(m_iptcInfo.SubLocation); - ar << CStdString(m_iptcInfo.ImageType); + ar << std::string(m_iptcInfo.Author); + ar << std::string(m_iptcInfo.Byline); + ar << std::string(m_iptcInfo.BylineTitle); + ar << std::string(m_iptcInfo.Caption); + ar << std::string(m_iptcInfo.Category); + ar << std::string(m_iptcInfo.City); + ar << std::string(m_iptcInfo.Urgency); + ar << std::string(m_iptcInfo.CopyrightNotice); + ar << std::string(m_iptcInfo.Country); + ar << std::string(m_iptcInfo.CountryCode); + ar << std::string(m_iptcInfo.Credit); + ar << std::string(m_iptcInfo.Date); + ar << std::string(m_iptcInfo.Headline); + ar << std::string(m_iptcInfo.Keywords); + ar << std::string(m_iptcInfo.ObjectName); + ar << std::string(m_iptcInfo.ReferenceService); + ar << std::string(m_iptcInfo.Source); + ar << std::string(m_iptcInfo.SpecialInstructions); + ar << std::string(m_iptcInfo.State); + ar << std::string(m_iptcInfo.SupplementalCategories); + ar << std::string(m_iptcInfo.TransmissionReference); + ar << std::string(m_iptcInfo.TimeCreated); + ar << std::string(m_iptcInfo.SubLocation); + ar << std::string(m_iptcInfo.ImageType); } else { @@ -208,12 +208,12 @@ void CPictureInfoTag::Archive(CArchive& ar) void CPictureInfoTag::Serialize(CVariant& value) const { value["aperturefnumber"] = m_exifInfo.ApertureFNumber; - value["cameramake"] = CStdString(m_exifInfo.CameraMake); - value["cameramodel"] = CStdString(m_exifInfo.CameraModel); + value["cameramake"] = std::string(m_exifInfo.CameraMake); + value["cameramodel"] = std::string(m_exifInfo.CameraModel); value["ccdwidth"] = m_exifInfo.CCDWidth; value["comments"] = GetInfo(SLIDE_EXIF_COMMENT); // Charset conversion - value["description"] = CStdString(m_exifInfo.Description); - value["datetime"] = CStdString(m_exifInfo.DateTime); + value["description"] = std::string(m_exifInfo.Description); + value["datetime"] = std::string(m_exifInfo.DateTime); for (int i = 0; i < 10; i++) value["datetimeoffsets"][i] = m_exifInfo.DateTimeOffsets[i]; value["digitalzoomratio"] = m_exifInfo.DigitalZoomRatio; @@ -226,9 +226,9 @@ void CPictureInfoTag::Serialize(CVariant& value) const value["focallength"] = m_exifInfo.FocalLength; value["focallength35mmequiv"] = m_exifInfo.FocalLength35mmEquiv; value["gpsinfopresent"] = m_exifInfo.GpsInfoPresent; - value["gpsinfo"]["alt"] = CStdString(m_exifInfo.GpsAlt); - value["gpsinfo"]["lat"] = CStdString(m_exifInfo.GpsLat); - value["gpsinfo"]["long"] = CStdString(m_exifInfo.GpsLong); + value["gpsinfo"]["alt"] = std::string(m_exifInfo.GpsAlt); + value["gpsinfo"]["lat"] = std::string(m_exifInfo.GpsLat); + value["gpsinfo"]["long"] = std::string(m_exifInfo.GpsLong); value["height"] = m_exifInfo.Height; value["iscolor"] = m_exifInfo.IsColor; value["isoequivalent"] = m_exifInfo.ISOequivalent; @@ -245,30 +245,30 @@ void CPictureInfoTag::Serialize(CVariant& value) const value["whitebalance"] = m_exifInfo.Whitebalance; value["width"] = m_exifInfo.Width; - value["author"] = CStdString(m_iptcInfo.Author); - value["byline"] = CStdString(m_iptcInfo.Byline); - value["bylinetitle"] = CStdString(m_iptcInfo.BylineTitle); - value["caption"] = CStdString(m_iptcInfo.Caption); - value["category"] = CStdString(m_iptcInfo.Category); - value["city"] = CStdString(m_iptcInfo.City); - value["urgency"] = CStdString(m_iptcInfo.Urgency); - value["copyrightnotice"] = CStdString(m_iptcInfo.CopyrightNotice); - value["country"] = CStdString(m_iptcInfo.Country); - value["countrycode"] = CStdString(m_iptcInfo.CountryCode); - value["credit"] = CStdString(m_iptcInfo.Credit); - value["date"] = CStdString(m_iptcInfo.Date); - value["headline"] = CStdString(m_iptcInfo.Headline); - value["keywords"] = CStdString(m_iptcInfo.Keywords); - value["objectname"] = CStdString(m_iptcInfo.ObjectName); - value["referenceservice"] = CStdString(m_iptcInfo.ReferenceService); - value["source"] = CStdString(m_iptcInfo.Source); - value["specialinstructions"] = CStdString(m_iptcInfo.SpecialInstructions); - value["state"] = CStdString(m_iptcInfo.State); - value["supplementalcategories"] = CStdString(m_iptcInfo.SupplementalCategories); - value["transmissionreference"] = CStdString(m_iptcInfo.TransmissionReference); - value["timecreated"] = CStdString(m_iptcInfo.TimeCreated); - value["sublocation"] = CStdString(m_iptcInfo.SubLocation); - value["imagetype"] = CStdString(m_iptcInfo.ImageType); + value["author"] = std::string(m_iptcInfo.Author); + value["byline"] = std::string(m_iptcInfo.Byline); + value["bylinetitle"] = std::string(m_iptcInfo.BylineTitle); + value["caption"] = std::string(m_iptcInfo.Caption); + value["category"] = std::string(m_iptcInfo.Category); + value["city"] = std::string(m_iptcInfo.City); + value["urgency"] = std::string(m_iptcInfo.Urgency); + value["copyrightnotice"] = std::string(m_iptcInfo.CopyrightNotice); + value["country"] = std::string(m_iptcInfo.Country); + value["countrycode"] = std::string(m_iptcInfo.CountryCode); + value["credit"] = std::string(m_iptcInfo.Credit); + value["date"] = std::string(m_iptcInfo.Date); + value["headline"] = std::string(m_iptcInfo.Headline); + value["keywords"] = std::string(m_iptcInfo.Keywords); + value["objectname"] = std::string(m_iptcInfo.ObjectName); + value["referenceservice"] = std::string(m_iptcInfo.ReferenceService); + value["source"] = std::string(m_iptcInfo.Source); + value["specialinstructions"] = std::string(m_iptcInfo.SpecialInstructions); + value["state"] = std::string(m_iptcInfo.State); + value["supplementalcategories"] = std::string(m_iptcInfo.SupplementalCategories); + value["transmissionreference"] = std::string(m_iptcInfo.TransmissionReference); + value["timecreated"] = std::string(m_iptcInfo.TimeCreated); + value["sublocation"] = std::string(m_iptcInfo.SubLocation); + value["imagetype"] = std::string(m_iptcInfo.ImageType); } void CPictureInfoTag::ToSortable(SortItem& sortable, Field field) const @@ -279,7 +279,7 @@ void CPictureInfoTag::ToSortable(SortItem& sortable, Field field) const void CPictureInfoTag::GetStringFromArchive(CArchive &ar, char *string, size_t length) { - CStdString temp; + std::string temp; ar >> temp; length = min((size_t)temp.size(), length - 1); if (!temp.empty()) @@ -287,12 +287,12 @@ void CPictureInfoTag::GetStringFromArchive(CArchive &ar, char *string, size_t le string[length] = 0; } -const CStdString CPictureInfoTag::GetInfo(int info) const +const std::string CPictureInfoTag::GetInfo(int info) const { if (!m_isLoaded && !m_isInfoSetExternally) // If no metadata has been loaded from the picture file or set with SetInfo(), just return return ""; - CStdString value; + std::string value; switch (info) { case SLIDE_RESOLUTION: @@ -541,72 +541,72 @@ const CStdString CPictureInfoTag::GetInfo(int info) const return value; } -int CPictureInfoTag::TranslateString(const CStdString &info) +int CPictureInfoTag::TranslateString(const std::string &info) { - if (info.Equals("filename")) return SLIDE_FILE_NAME; - else if (info.Equals("path")) return SLIDE_FILE_PATH; - else if (info.Equals("filesize")) return SLIDE_FILE_SIZE; - else if (info.Equals("filedate")) return SLIDE_FILE_DATE; - else if (info.Equals("slideindex")) return SLIDE_INDEX; - else if (info.Equals("resolution")) return SLIDE_RESOLUTION; - else if (info.Equals("slidecomment")) return SLIDE_COMMENT; - else if (info.Equals("colour")) return SLIDE_COLOUR; - else if (info.Equals("process")) return SLIDE_PROCESS; - else if (info.Equals("exiftime")) return SLIDE_EXIF_DATE_TIME; - else if (info.Equals("exifdate")) return SLIDE_EXIF_DATE; - else if (info.Equals("longexiftime")) return SLIDE_EXIF_LONG_DATE_TIME; - else if (info.Equals("longexifdate")) return SLIDE_EXIF_LONG_DATE; - else if (info.Equals("exifdescription")) return SLIDE_EXIF_DESCRIPTION; - else if (info.Equals("cameramake")) return SLIDE_EXIF_CAMERA_MAKE; - else if (info.Equals("cameramodel")) return SLIDE_EXIF_CAMERA_MODEL; - else if (info.Equals("exifcomment")) return SLIDE_EXIF_COMMENT; - else if (info.Equals("exifsoftware")) return SLIDE_EXIF_SOFTWARE; - else if (info.Equals("aperture")) return SLIDE_EXIF_APERTURE; - else if (info.Equals("focallength")) return SLIDE_EXIF_FOCAL_LENGTH; - else if (info.Equals("focusdistance")) return SLIDE_EXIF_FOCUS_DIST; - else if (info.Equals("exposure")) return SLIDE_EXIF_EXPOSURE; - else if (info.Equals("exposuretime")) return SLIDE_EXIF_EXPOSURE_TIME; - else if (info.Equals("exposurebias")) return SLIDE_EXIF_EXPOSURE_BIAS; - else if (info.Equals("exposuremode")) return SLIDE_EXIF_EXPOSURE_MODE; - else if (info.Equals("flashused")) return SLIDE_EXIF_FLASH_USED; - else if (info.Equals("whitebalance")) return SLIDE_EXIF_WHITE_BALANCE; - else if (info.Equals("lightsource")) return SLIDE_EXIF_LIGHT_SOURCE; - else if (info.Equals("meteringmode")) return SLIDE_EXIF_METERING_MODE; - else if (info.Equals("isoequivalence")) return SLIDE_EXIF_ISO_EQUIV; - else if (info.Equals("digitalzoom")) return SLIDE_EXIF_DIGITAL_ZOOM; - else if (info.Equals("ccdwidth")) return SLIDE_EXIF_CCD_WIDTH; - else if (info.Equals("orientation")) return SLIDE_EXIF_ORIENTATION; - else if (info.Equals("supplementalcategories")) return SLIDE_IPTC_SUP_CATEGORIES; - else if (info.Equals("keywords")) return SLIDE_IPTC_KEYWORDS; - else if (info.Equals("caption")) return SLIDE_IPTC_CAPTION; - else if (info.Equals("author")) return SLIDE_IPTC_AUTHOR; - else if (info.Equals("headline")) return SLIDE_IPTC_HEADLINE; - else if (info.Equals("specialinstructions")) return SLIDE_IPTC_SPEC_INSTR; - else if (info.Equals("category")) return SLIDE_IPTC_CATEGORY; - else if (info.Equals("byline")) return SLIDE_IPTC_BYLINE; - else if (info.Equals("bylinetitle")) return SLIDE_IPTC_BYLINE_TITLE; - else if (info.Equals("credit")) return SLIDE_IPTC_CREDIT; - else if (info.Equals("source")) return SLIDE_IPTC_SOURCE; - else if (info.Equals("copyrightnotice")) return SLIDE_IPTC_COPYRIGHT_NOTICE; - else if (info.Equals("objectname")) return SLIDE_IPTC_OBJECT_NAME; - else if (info.Equals("city")) return SLIDE_IPTC_CITY; - else if (info.Equals("state")) return SLIDE_IPTC_STATE; - else if (info.Equals("country")) return SLIDE_IPTC_COUNTRY; - else if (info.Equals("transmissionreference")) return SLIDE_IPTC_TX_REFERENCE; - else if (info.Equals("iptcdate")) return SLIDE_IPTC_DATE; - else if (info.Equals("urgency")) return SLIDE_IPTC_URGENCY; - else if (info.Equals("countrycode")) return SLIDE_IPTC_COUNTRY_CODE; - else if (info.Equals("referenceservice")) return SLIDE_IPTC_REF_SERVICE; - else if (info.Equals("latitude")) return SLIDE_EXIF_GPS_LATITUDE; - else if (info.Equals("longitude")) return SLIDE_EXIF_GPS_LONGITUDE; - else if (info.Equals("altitude")) return SLIDE_EXIF_GPS_ALTITUDE; - else if (info.Equals("timecreated")) return SLIDE_IPTC_TIMECREATED; - else if (info.Equals("sublocation")) return SLIDE_IPTC_SUBLOCATION; - else if (info.Equals("imagetype")) return SLIDE_IPTC_IMAGETYPE; + if (StringUtils::EqualsNoCase(info, "filename")) return SLIDE_FILE_NAME; + else if (StringUtils::EqualsNoCase(info, "path")) return SLIDE_FILE_PATH; + else if (StringUtils::EqualsNoCase(info, "filesize")) return SLIDE_FILE_SIZE; + else if (StringUtils::EqualsNoCase(info, "filedate")) return SLIDE_FILE_DATE; + else if (StringUtils::EqualsNoCase(info, "slideindex")) return SLIDE_INDEX; + else if (StringUtils::EqualsNoCase(info, "resolution")) return SLIDE_RESOLUTION; + else if (StringUtils::EqualsNoCase(info, "slidecomment")) return SLIDE_COMMENT; + else if (StringUtils::EqualsNoCase(info, "colour")) return SLIDE_COLOUR; + else if (StringUtils::EqualsNoCase(info, "process")) return SLIDE_PROCESS; + else if (StringUtils::EqualsNoCase(info, "exiftime")) return SLIDE_EXIF_DATE_TIME; + else if (StringUtils::EqualsNoCase(info, "exifdate")) return SLIDE_EXIF_DATE; + else if (StringUtils::EqualsNoCase(info, "longexiftime")) return SLIDE_EXIF_LONG_DATE_TIME; + else if (StringUtils::EqualsNoCase(info, "longexifdate")) return SLIDE_EXIF_LONG_DATE; + else if (StringUtils::EqualsNoCase(info, "exifdescription")) return SLIDE_EXIF_DESCRIPTION; + else if (StringUtils::EqualsNoCase(info, "cameramake")) return SLIDE_EXIF_CAMERA_MAKE; + else if (StringUtils::EqualsNoCase(info, "cameramodel")) return SLIDE_EXIF_CAMERA_MODEL; + else if (StringUtils::EqualsNoCase(info, "exifcomment")) return SLIDE_EXIF_COMMENT; + else if (StringUtils::EqualsNoCase(info, "exifsoftware")) return SLIDE_EXIF_SOFTWARE; + else if (StringUtils::EqualsNoCase(info, "aperture")) return SLIDE_EXIF_APERTURE; + else if (StringUtils::EqualsNoCase(info, "focallength")) return SLIDE_EXIF_FOCAL_LENGTH; + else if (StringUtils::EqualsNoCase(info, "focusdistance")) return SLIDE_EXIF_FOCUS_DIST; + else if (StringUtils::EqualsNoCase(info, "exposure")) return SLIDE_EXIF_EXPOSURE; + else if (StringUtils::EqualsNoCase(info, "exposuretime")) return SLIDE_EXIF_EXPOSURE_TIME; + else if (StringUtils::EqualsNoCase(info, "exposurebias")) return SLIDE_EXIF_EXPOSURE_BIAS; + else if (StringUtils::EqualsNoCase(info, "exposuremode")) return SLIDE_EXIF_EXPOSURE_MODE; + else if (StringUtils::EqualsNoCase(info, "flashused")) return SLIDE_EXIF_FLASH_USED; + else if (StringUtils::EqualsNoCase(info, "whitebalance")) return SLIDE_EXIF_WHITE_BALANCE; + else if (StringUtils::EqualsNoCase(info, "lightsource")) return SLIDE_EXIF_LIGHT_SOURCE; + else if (StringUtils::EqualsNoCase(info, "meteringmode")) return SLIDE_EXIF_METERING_MODE; + else if (StringUtils::EqualsNoCase(info, "isoequivalence")) return SLIDE_EXIF_ISO_EQUIV; + else if (StringUtils::EqualsNoCase(info, "digitalzoom")) return SLIDE_EXIF_DIGITAL_ZOOM; + else if (StringUtils::EqualsNoCase(info, "ccdwidth")) return SLIDE_EXIF_CCD_WIDTH; + else if (StringUtils::EqualsNoCase(info, "orientation")) return SLIDE_EXIF_ORIENTATION; + else if (StringUtils::EqualsNoCase(info, "supplementalcategories")) return SLIDE_IPTC_SUP_CATEGORIES; + else if (StringUtils::EqualsNoCase(info, "keywords")) return SLIDE_IPTC_KEYWORDS; + else if (StringUtils::EqualsNoCase(info, "caption")) return SLIDE_IPTC_CAPTION; + else if (StringUtils::EqualsNoCase(info, "author")) return SLIDE_IPTC_AUTHOR; + else if (StringUtils::EqualsNoCase(info, "headline")) return SLIDE_IPTC_HEADLINE; + else if (StringUtils::EqualsNoCase(info, "specialinstructions")) return SLIDE_IPTC_SPEC_INSTR; + else if (StringUtils::EqualsNoCase(info, "category")) return SLIDE_IPTC_CATEGORY; + else if (StringUtils::EqualsNoCase(info, "byline")) return SLIDE_IPTC_BYLINE; + else if (StringUtils::EqualsNoCase(info, "bylinetitle")) return SLIDE_IPTC_BYLINE_TITLE; + else if (StringUtils::EqualsNoCase(info, "credit")) return SLIDE_IPTC_CREDIT; + else if (StringUtils::EqualsNoCase(info, "source")) return SLIDE_IPTC_SOURCE; + else if (StringUtils::EqualsNoCase(info, "copyrightnotice")) return SLIDE_IPTC_COPYRIGHT_NOTICE; + else if (StringUtils::EqualsNoCase(info, "objectname")) return SLIDE_IPTC_OBJECT_NAME; + else if (StringUtils::EqualsNoCase(info, "city")) return SLIDE_IPTC_CITY; + else if (StringUtils::EqualsNoCase(info, "state")) return SLIDE_IPTC_STATE; + else if (StringUtils::EqualsNoCase(info, "country")) return SLIDE_IPTC_COUNTRY; + else if (StringUtils::EqualsNoCase(info, "transmissionreference")) return SLIDE_IPTC_TX_REFERENCE; + else if (StringUtils::EqualsNoCase(info, "iptcdate")) return SLIDE_IPTC_DATE; + else if (StringUtils::EqualsNoCase(info, "urgency")) return SLIDE_IPTC_URGENCY; + else if (StringUtils::EqualsNoCase(info, "countrycode")) return SLIDE_IPTC_COUNTRY_CODE; + else if (StringUtils::EqualsNoCase(info, "referenceservice")) return SLIDE_IPTC_REF_SERVICE; + else if (StringUtils::EqualsNoCase(info, "latitude")) return SLIDE_EXIF_GPS_LATITUDE; + else if (StringUtils::EqualsNoCase(info, "longitude")) return SLIDE_EXIF_GPS_LONGITUDE; + else if (StringUtils::EqualsNoCase(info, "altitude")) return SLIDE_EXIF_GPS_ALTITUDE; + else if (StringUtils::EqualsNoCase(info, "timecreated")) return SLIDE_IPTC_TIMECREATED; + else if (StringUtils::EqualsNoCase(info, "sublocation")) return SLIDE_IPTC_SUBLOCATION; + else if (StringUtils::EqualsNoCase(info, "imagetype")) return SLIDE_IPTC_IMAGETYPE; return 0; } -void CPictureInfoTag::SetInfo(int info, const CStdString& value) +void CPictureInfoTag::SetInfo(int info, const std::string& value) { switch (info) { @@ -643,7 +643,7 @@ void CPictureInfoTag::ConvertDateTime() { if (strlen(m_exifInfo.DateTime) >= 19 && m_exifInfo.DateTime[0] != ' ') { - CStdString dateTime = m_exifInfo.DateTime; + std::string dateTime = m_exifInfo.DateTime; int year = atoi(dateTime.substr(0, 4).c_str()); int month = atoi(dateTime.substr(5, 2).c_str()); int day = atoi(dateTime.substr(8, 2).c_str()); diff --git a/xbmc/pictures/PictureInfoTag.h b/xbmc/pictures/PictureInfoTag.h index 859f33ebc3..06846128b1 100644 --- a/xbmc/pictures/PictureInfoTag.h +++ b/xbmc/pictures/PictureInfoTag.h @@ -98,14 +98,14 @@ public: virtual void Serialize(CVariant& value) const; virtual void ToSortable(SortItem& sortable, Field field) const; const CPictureInfoTag& operator=(const CPictureInfoTag& item); - const CStdString GetInfo(int info) const; + const std::string GetInfo(int info) const; bool Loaded() const { return m_isLoaded; }; - bool Load(const CStdString &path); + bool Load(const std::string &path); - static int TranslateString(const CStdString &info); + static int TranslateString(const std::string &info); - void SetInfo(int info, const CStdString& value); + void SetInfo(int info, const std::string& value); /** * GetDateTimeTaken() -- Returns the EXIF DateTimeOriginal for current picture diff --git a/xbmc/pictures/PictureThumbLoader.cpp b/xbmc/pictures/PictureThumbLoader.cpp index d14b360af3..6d2f1233b7 100644 --- a/xbmc/pictures/PictureThumbLoader.cpp +++ b/xbmc/pictures/PictureThumbLoader.cpp @@ -77,7 +77,7 @@ bool CPictureThumbLoader::LoadItemCached(CFileItem* pItem) pItem->SetArt("thumb", ""); } - CStdString thumb; + std::string thumb; if (pItem->IsPicture() && !pItem->IsZIP() && !pItem->IsRAR() && !pItem->IsCBZ() && !pItem->IsCBR() && !pItem->IsPlayList()) { // load the thumb from the image file thumb = pItem->HasArt("thumb") ? pItem->GetArt("thumb") : CTextureUtils::GetWrappedThumbURL(pItem->GetPath()); @@ -87,7 +87,7 @@ bool CPictureThumbLoader::LoadItemCached(CFileItem* pItem) CVideoThumbLoader loader; if (!loader.FillThumb(*pItem)) { - CStdString thumbURL = CVideoThumbLoader::GetEmbeddedThumbURL(*pItem); + std::string thumbURL = CVideoThumbLoader::GetEmbeddedThumbURL(*pItem); if (CTextureCache::Get().HasCachedImage(thumbURL)) { thumb = thumbURL; @@ -141,7 +141,7 @@ void CPictureThumbLoader::ProcessFoldersAndArchives(CFileItem *pItem) db.Open(); if (pItem->IsCBR() || pItem->IsCBZ()) { - CStdString strTBN(URIUtils::ReplaceExtension(pItem->GetPath(),".tbn")); + std::string strTBN(URIUtils::ReplaceExtension(pItem->GetPath(),".tbn")); if (CFile::Exists(strTBN)) { db.SetTextureForPath(pItem->GetPath(), "thumb", strTBN); @@ -154,7 +154,7 @@ void CPictureThumbLoader::ProcessFoldersAndArchives(CFileItem *pItem) && !pItem->IsParentFolder() && !pItem->IsPath("add")) { // first check for a folder.jpg - CStdString thumb = "folder.jpg"; + std::string thumb = "folder.jpg"; CURL pathToUrl = pItem->GetURL(); if (pItem->IsCBR()) { @@ -224,7 +224,7 @@ void CPictureThumbLoader::ProcessFoldersAndArchives(CFileItem *pItem) if (items.Size() < 4 || pItem->IsCBR() || pItem->IsCBZ()) { // less than 4 items, so just grab the first thumb items.Sort(SortByLabel, SortOrderAscending); - CStdString thumb = CTextureUtils::GetWrappedThumbURL(items[0]->GetPath()); + std::string thumb = CTextureUtils::GetWrappedThumbURL(items[0]->GetPath()); db.SetTextureForPath(pItem->GetPath(), "thumb", thumb); CTextureCache::Get().BackgroundCacheImage(thumb); pItem->SetArt("thumb", thumb); @@ -236,8 +236,8 @@ void CPictureThumbLoader::ProcessFoldersAndArchives(CFileItem *pItem) vector<string> files; for (int thumb = 0; thumb < 4; thumb++) files.push_back(items[thumb]->GetPath()); - CStdString thumb = CTextureUtils::GetWrappedImageURL(pItem->GetPath(), "picturefolder"); - CStdString relativeCacheFile = CTextureCache::GetCacheFile(thumb) + ".png"; + std::string thumb = CTextureUtils::GetWrappedImageURL(pItem->GetPath(), "picturefolder"); + std::string relativeCacheFile = CTextureCache::GetCacheFile(thumb) + ".png"; if (CPicture::CreateTiledThumb(files, CTextureCache::GetCachedPath(relativeCacheFile))) { CTextureDetails details; diff --git a/xbmc/pictures/PictureThumbLoader.h b/xbmc/pictures/PictureThumbLoader.h index 31580d98f0..e8df6a92bf 100644 --- a/xbmc/pictures/PictureThumbLoader.h +++ b/xbmc/pictures/PictureThumbLoader.h @@ -19,7 +19,6 @@ * */ -#include "utils/StdString.h" #include "utils/JobManager.h" #include "ThumbLoader.h" diff --git a/xbmc/pictures/SlideShowPicture.h b/xbmc/pictures/SlideShowPicture.h index 369b34ebd3..ffc995f12f 100644 --- a/xbmc/pictures/SlideShowPicture.h +++ b/xbmc/pictures/SlideShowPicture.h @@ -21,8 +21,8 @@ #include "threads/CriticalSection.h" #include "guilib/gui3d.h" -#include "utils/StdString.h" #include "guilib/DirtyRegion.h" +#include <string> typedef uint32_t color_t; @@ -97,7 +97,7 @@ private: bool m_bIsFinished; bool m_bDrawNextImage; bool m_bIsDirty; - CStdString m_strFileName; + std::string m_strFileName; float m_fWidth; float m_fHeight; color_t m_alpha; diff --git a/xbmc/playlists/PlayList.cpp b/xbmc/playlists/PlayList.cpp index a7c3d0b937..5aa96b8a93 100644 --- a/xbmc/playlists/PlayList.cpp +++ b/xbmc/playlists/PlayList.cpp @@ -362,7 +362,7 @@ int CPlayList::RemoveDVDItems() { vecFilenames.push_back( item->GetPath() ); } - it++; + ++it; } // Delete them from playlist @@ -375,7 +375,7 @@ int CPlayList::RemoveDVDItems() { std::string& strFilename = *it; Remove( strFilename ); - it++; + ++it; } vecFilenames.erase( vecFilenames.begin(), vecFilenames.end() ); } diff --git a/xbmc/playlists/SmartPlayList.cpp b/xbmc/playlists/SmartPlayList.cpp index 21a41a63c9..a0d86b4c4e 100644 --- a/xbmc/playlists/SmartPlayList.cpp +++ b/xbmc/playlists/SmartPlayList.cpp @@ -658,22 +658,22 @@ std::string CSmartPlaylistRule::GetBooleanQuery(const std::string &negate, const if (strType == "movies") { if (m_field == FieldInProgress) - return "movieview.idFile " + negate + " IN (SELECT DISTINCT idFile FROM bookmark WHERE type = 1)"; + return "movie_view.idFile " + negate + " IN (SELECT DISTINCT idFile FROM bookmark WHERE type = 1)"; else if (m_field == FieldTrailer) return negate + GetField(m_field, strType) + "!= ''"; } else if (strType == "episodes") { if (m_field == FieldInProgress) - return "episodeview.idFile " + negate + " IN (SELECT DISTINCT idFile FROM bookmark WHERE type = 1)"; + return "episode_view.idFile " + negate + " IN (SELECT DISTINCT idFile FROM bookmark WHERE type = 1)"; } else if (strType == "tvshows") { if (m_field == FieldInProgress) return negate + " (" - "(tvshowview.watchedcount > 0 AND tvshowview.watchedcount < tvshowview.totalCount) OR " - "(tvshowview.watchedcount = 0 AND EXISTS " - "(SELECT 1 FROM episodeview WHERE episodeview.idShow = " + GetField(FieldId, strType) + " AND episodeview.resumeTimeInSeconds > 0)" + "(tvshow_view.watchedcount > 0 AND tvshow_view.watchedcount < tvshow_view.totalCount) OR " + "(tvshow_view.watchedcount = 0 AND EXISTS " + "(SELECT 1 FROM episode_view WHERE episode_view.idShow = " + GetField(FieldId, strType) + " AND episode_view.resumeTimeInSeconds > 0)" ")" ")"; } @@ -705,6 +705,15 @@ std::string CSmartPlaylistRule::FormatParameter(const std::string &operatorStrin return CDatabaseQueryRule::FormatParameter(operatorString, param, db, strType); } +std::string CSmartPlaylistRule::FormatLinkQuery(const char *field, const char *table, const MediaType& mediaType, const std::string& mediaField, const std::string& parameter) +{ + // NOTE: no need for a PrepareSQL here, as the parameter has already been formatted + return StringUtils::Format(" EXISTS (SELECT 1 FROM %s_link" + " JOIN %s ON %s.%s_id=%s_link.%s_id" + " WHERE %s_link.media_id=%s AND %s.name %s AND %s_link.media_type = '%s')", + field, table, table, table, field, table, field, mediaField.c_str(), table, parameter.c_str(), field, mediaType.c_str()); +} + std::string CSmartPlaylistRule::FormatWhereClause(const std::string &negate, const std::string &oper, const std::string ¶m, const CDatabase &db, const std::string &strType) const { @@ -745,54 +754,54 @@ std::string CSmartPlaylistRule::FormatWhereClause(const std::string &negate, con } else if (strType == "movies") { - table = "movieview"; + table = "movie_view"; if (m_field == FieldGenre) - query = negate + " EXISTS (SELECT 1 FROM genrelinkmovie JOIN genre ON genre.idGenre=genrelinkmovie.idGenre WHERE genrelinkmovie.idMovie = " + GetField(FieldId, strType) + " AND genre.strGenre" + parameter + ")"; + query = negate + FormatLinkQuery("genre", "genre", MediaTypeMovie, GetField(FieldId, strType), parameter); else if (m_field == FieldDirector) - query = negate + " EXISTS (SELECT 1 FROM directorlinkmovie JOIN actors ON actors.idActor=directorlinkmovie.idDirector WHERE directorlinkmovie.idMovie = " + GetField(FieldId, strType) + " AND actors.strActor" + parameter + ")"; + query = negate + FormatLinkQuery("director", "actor", MediaTypeMovie, GetField(FieldId, strType), parameter); else if (m_field == FieldActor) - query = negate + " EXISTS (SELECT 1 FROM actorlinkmovie JOIN actors ON actors.idActor=actorlinkmovie.idActor WHERE actorlinkmovie.idMovie = " + GetField(FieldId, strType) + " AND actors.strActor" + parameter + ")"; + query = negate + FormatLinkQuery("actor", "actor", MediaTypeMovie, GetField(FieldId, strType), parameter); else if (m_field == FieldWriter) - query = negate + " EXISTS (SELECT 1 FROM writerlinkmovie JOIN actors ON actors.idActor=writerlinkmovie.idWriter WHERE writerlinkmovie.idMovie = " + GetField(FieldId, strType) + " AND actors.strActor" + parameter + ")"; + query = negate + FormatLinkQuery("writer", "actor", MediaTypeMovie, GetField(FieldId, strType), parameter); else if (m_field == FieldStudio) - query = negate + " EXISTS (SELECT 1 FROM studiolinkmovie JOIN studio ON studio.idStudio=studiolinkmovie.idStudio WHERE studiolinkmovie.idMovie = " + GetField(FieldId, strType) + " AND studio.strStudio" + parameter + ")"; + query = negate + FormatLinkQuery("studio", "studio", MediaTypeMovie, GetField(FieldId, strType), parameter); else if (m_field == FieldCountry) - query = negate + " EXISTS (SELECT 1 FROM countrylinkmovie JOIN country ON country.idCountry=countrylinkmovie.idCountry WHERE countrylinkmovie.idMovie = " + GetField(FieldId, strType) + " AND country.strCountry" + parameter + ")"; + query = negate + FormatLinkQuery("country", "country", MediaTypeMovie, GetField(FieldId, strType), parameter); else if ((m_field == FieldLastPlayed || m_field == FieldDateAdded) && (m_operator == OPERATOR_LESS_THAN || m_operator == OPERATOR_BEFORE || m_operator == OPERATOR_NOT_IN_THE_LAST)) query = GetField(m_field, strType) + " IS NULL OR " + GetField(m_field, strType) + parameter; else if (m_field == FieldTag) - query = negate + " EXISTS (SELECT 1 FROM taglinks JOIN tag ON tag.idTag = taglinks.idTag WHERE taglinks.idMedia = " + GetField(FieldId, strType) + " AND tag.strTag" + parameter + " AND taglinks.media_type = 'movie')"; + query = negate + FormatLinkQuery("tag", "tag", MediaTypeMovie, GetField(FieldId, strType), parameter); } else if (strType == "musicvideos") { - table = "musicvideoview"; + table = "musicvideo_view"; if (m_field == FieldGenre) - query = negate + " EXISTS (SELECT 1 FROM genrelinkmusicvideo JOIN genre ON genre.idGenre=genrelinkmusicvideo.idGenre WHERE genrelinkmusicvideo.idMVideo = " + GetField(FieldId, strType) + " AND genre.strGenre" + parameter + ")"; + query = negate + FormatLinkQuery("genre", "genre", MediaTypeMusicVideo, GetField(FieldId, strType), parameter); else if (m_field == FieldArtist || m_field == FieldAlbumArtist) - query = negate + " EXISTS (SELECT 1 FROM artistlinkmusicvideo JOIN actors ON actors.idActor=artistlinkmusicvideo.idArtist WHERE artistlinkmusicvideo.idMVideo = " + GetField(FieldId, strType) + " AND actors.strActor" + parameter + ")"; + query = negate + FormatLinkQuery("artist", "actor", MediaTypeMusicVideo, GetField(FieldId, strType), parameter); else if (m_field == FieldStudio) - query = negate + " EXISTS (SELECT 1 FROM studiolinkmusicvideo JOIN studio ON studio.idStudio=studiolinkmusicvideo.idStudio WHERE studiolinkmusicvideo.idMVideo = " + GetField(FieldId, strType) + " AND studio.strStudio" + parameter + ")"; + query = negate + FormatLinkQuery("studio", "studio", MediaTypeMusicVideo, GetField(FieldId, strType), parameter); else if (m_field == FieldDirector) - query = negate + " EXISTS (SELECT 1 FROM directorlinkmusicvideo JOIN actors ON actors.idActor=directorlinkmusicvideo.idDirector WHERE directorlinkmusicvideo.idMVideo = " + GetField(FieldId, strType) + " AND actors.strActor" + parameter + ")"; + query = negate + FormatLinkQuery("director", "actor", MediaTypeMusicVideo, GetField(FieldId, strType), parameter); else if ((m_field == FieldLastPlayed || m_field == FieldDateAdded) && (m_operator == OPERATOR_LESS_THAN || m_operator == OPERATOR_BEFORE || m_operator == OPERATOR_NOT_IN_THE_LAST)) query = GetField(m_field, strType) + " IS NULL OR " + GetField(m_field, strType) + parameter; else if (m_field == FieldTag) - query = negate + " EXISTS (SELECT 1 FROM taglinks JOIN tag ON tag.idTag = taglinks.idTag WHERE taglinks.idMedia = " + GetField(FieldId, strType) + " AND tag.strTag" + parameter + " AND taglinks.media_type = 'musicvideo')"; + query = negate + FormatLinkQuery("tag", "tag", MediaTypeMusicVideo, GetField(FieldId, strType), parameter); } else if (strType == "tvshows") { - table = "tvshowview"; + table = "tvshow_view"; if (m_field == FieldGenre) - query = negate + " EXISTS (SELECT 1 FROM genrelinktvshow JOIN genre ON genre.idGenre=genrelinktvshow.idGenre WHERE genrelinktvshow.idShow = " + GetField(FieldId, strType) + " AND genre.strGenre" + parameter + ")"; + query = negate + FormatLinkQuery("genre", "genre", MediaTypeTvShow, GetField(FieldId, strType), parameter); else if (m_field == FieldDirector) - query = negate + " EXISTS (SELECT 1 FROM directorlinktvshow JOIN actors ON actors.idActor=directorlinktvshow.idDirector WHERE directorlinktvshow.idShow = " + GetField(FieldId, strType) + " AND actors.strActor" + parameter + ")"; + query = negate + FormatLinkQuery("director", "actor", MediaTypeTvShow, GetField(FieldId, strType), parameter); else if (m_field == FieldActor) - query = negate + " EXISTS (SELECT 1 FROM actorlinktvshow JOIN actors ON actors.idActor=actorlinktvshow.idActor WHERE actorlinktvshow.idShow = " + GetField(FieldId, strType) + " AND actors.strActor" + parameter + ")"; + query = negate + FormatLinkQuery("actor", "actor", MediaTypeTvShow, GetField(FieldId, strType), parameter); else if (m_field == FieldStudio) - query = negate + " (" + GetField(m_field, strType) + parameter + ")"; + query = negate + FormatLinkQuery("studio", "studio", MediaTypeTvShow, GetField(FieldId, strType), parameter); else if (m_field == FieldMPAA) query = negate + " (" + GetField(m_field, strType) + parameter + ")"; else if ((m_field == FieldLastPlayed || m_field == FieldDateAdded) && (m_operator == OPERATOR_LESS_THAN || m_operator == OPERATOR_BEFORE || m_operator == OPERATOR_NOT_IN_THE_LAST)) @@ -800,24 +809,24 @@ std::string CSmartPlaylistRule::FormatWhereClause(const std::string &negate, con else if (m_field == FieldPlaycount) query = "CASE WHEN COALESCE(" + GetField(FieldNumberOfEpisodes, strType) + " - " + GetField(FieldNumberOfWatchedEpisodes, strType) + ", 0) > 0 THEN 0 ELSE 1 END " + parameter; else if (m_field == FieldTag) - query = negate + " EXISTS (SELECT 1 FROM taglinks JOIN tag ON tag.idTag = taglinks.idTag WHERE taglinks.idMedia = " + GetField(FieldId, strType) + " AND tag.strTag" + parameter + " AND taglinks.media_type = 'tvshow')"; + query = negate + FormatLinkQuery("tag", "tag", MediaTypeTvShow, GetField(FieldId, strType), parameter); } else if (strType == "episodes") { - table = "episodeview"; + table = "episode_view"; if (m_field == FieldGenre) - query = negate + " EXISTS (SELECT 1 FROM genrelinktvshow JOIN genre ON genre.idGenre=genrelinktvshow.idGenre WHERE genrelinktvshow.idShow = " + table + ".idShow AND genre.strGenre" + parameter + ")"; + query = negate + FormatLinkQuery("genre", "genre", MediaTypeTvShow, (table + ".idShow").c_str(), parameter); else if (m_field == FieldDirector) - query = negate + " EXISTS (SELECT 1 FROM directorlinkepisode JOIN actors ON actors.idActor=directorlinkepisode.idDirector WHERE directorlinkepisode.idEpisode = " + GetField(FieldId, strType) + " AND actors.strActor" + parameter + ")"; + query = negate + FormatLinkQuery("director", "actor", MediaTypeEpisode, GetField(FieldId, strType), parameter); else if (m_field == FieldActor) - query = negate + " EXISTS (SELECT 1 FROM actorlinkepisode JOIN actors ON actors.idActor=actorlinkepisode.idActor WHERE actorlinkepisode.idEpisode = " + GetField(FieldId, strType) + " AND actors.strActor" + parameter + ")"; + query = negate + FormatLinkQuery("actor", "actor", MediaTypeEpisode, GetField(FieldId, strType), parameter); else if (m_field == FieldWriter) - query = negate + " EXISTS (SELECT 1 FROM writerlinkepisode JOIN actors ON actors.idActor=writerlinkepisode.idWriter WHERE writerlinkepisode.idEpisode = " + GetField(FieldId, strType) + " AND actors.strActor" + parameter + ")"; + query = negate + FormatLinkQuery("writer", "actor", MediaTypeEpisode, GetField(FieldId, strType), parameter); else if ((m_field == FieldLastPlayed || m_field == FieldDateAdded) && (m_operator == OPERATOR_LESS_THAN || m_operator == OPERATOR_BEFORE || m_operator == OPERATOR_NOT_IN_THE_LAST)) query = GetField(m_field, strType) + " IS NULL OR " + GetField(m_field, strType) + parameter; else if (m_field == FieldStudio) - query = negate + " (" + GetField(m_field, strType) + parameter + ")"; + query = negate + FormatLinkQuery("studio", "studio", MediaTypeTvShow, (table + ".idShow").c_str(), parameter); else if (m_field == FieldMPAA) query = negate + " (" + GetField(m_field, strType) + parameter + ")"; } @@ -1343,7 +1352,7 @@ std::string CSmartPlaylist::GetSaveLocation() const void CSmartPlaylist::GetAvailableFields(const std::string &type, std::vector<std::string> &fieldList) { vector<Field> typeFields = CSmartPlaylistRule::GetFields(type); - for (vector<Field>::const_iterator field = typeFields.begin(); field != typeFields.end(); field++) + for (vector<Field>::const_iterator field = typeFields.begin(); field != typeFields.end(); ++field) { for (unsigned int i = 0; i < NUM_FIELDS; i++) { diff --git a/xbmc/playlists/SmartPlayList.h b/xbmc/playlists/SmartPlayList.h index 5d8187a7df..5813b0ae87 100644 --- a/xbmc/playlists/SmartPlayList.h +++ b/xbmc/playlists/SmartPlayList.h @@ -76,6 +76,7 @@ protected: private: std::string GetVideoResolutionQuery(const std::string ¶meter) const; + static std::string FormatLinkQuery(const char *field, const char *table, const MediaType& mediaType, const std::string& mediaField, const std::string& parameter); }; class CSmartPlaylistRuleCombination : public CDatabaseQueryRuleCombination diff --git a/xbmc/powermanagement/linux/UPowerSyscall.h b/xbmc/powermanagement/linux/UPowerSyscall.h index a314b1ac61..d4fecd5a44 100644 --- a/xbmc/powermanagement/linux/UPowerSyscall.h +++ b/xbmc/powermanagement/linux/UPowerSyscall.h @@ -23,9 +23,9 @@ #ifdef HAS_DBUS #include "powermanagement/IPowerSyscall.h" #include "DBusUtil.h" -#include "utils/StdString.h" #include <list> +#include <string> class CUPowerSource { @@ -38,7 +38,7 @@ public: double BatteryLevel(); private: - CStdString m_powerSource; + std::string m_powerSource; bool m_isRechargeable; double m_batteryLevel; }; diff --git a/xbmc/profiles/Profile.cpp b/xbmc/profiles/Profile.cpp index 567875047c..02d8eabfae 100644 --- a/xbmc/profiles/Profile.cpp +++ b/xbmc/profiles/Profile.cpp @@ -22,7 +22,7 @@ #include "GUIInfoManager.h" #include "utils/XMLUtils.h" -CProfile::CLock::CLock(LockType type, const CStdString &password) +CProfile::CLock::CLock(LockType type, const std::string &password) { programs = false; pictures = false; @@ -44,7 +44,7 @@ void CProfile::CLock::Validate() code = "-"; } -CProfile::CProfile(const CStdString &directory, const CStdString &name, const int id) +CProfile::CProfile(const std::string &directory, const std::string &name, const int id) { m_id = id; m_directory = directory; @@ -61,8 +61,8 @@ CProfile::~CProfile(void) void CProfile::setDate() { - CStdString strDate = g_infoManager.GetDate(true); - CStdString strTime = g_infoManager.GetTime(); + std::string strDate = g_infoManager.GetDate(true); + std::string strTime = g_infoManager.GetTime(); if (strDate.empty() || strTime.empty()) setDate("-"); else diff --git a/xbmc/profiles/Profile.h b/xbmc/profiles/Profile.h index a50610976d..6cf7f8995c 100644 --- a/xbmc/profiles/Profile.h +++ b/xbmc/profiles/Profile.h @@ -20,8 +20,8 @@ */ #include "GUIPassword.h" -#include "utils/StdString.h" +#include <string> #include <vector> class TiXmlNode; @@ -34,11 +34,11 @@ public: class CLock { public: - CLock(LockType type = LOCK_MODE_EVERYONE, const CStdString &password = ""); + CLock(LockType type = LOCK_MODE_EVERYONE, const std::string &password = ""); void Validate(); LockType mode; - CStdString code; + std::string code; bool addonManager; LOCK_LEVEL::SETTINGS_LOCK settings; bool music; @@ -48,18 +48,18 @@ public: bool programs; }; - CProfile(const CStdString &directory = "", const CStdString &name = "", const int id = -1); + CProfile(const std::string &directory = "", const std::string &name = "", const int id = -1); ~CProfile(void); void Load(const TiXmlNode *node, int nextIdProfile); void Save(TiXmlNode *root) const; - const CStdString& getDate() const { return m_date;} + const std::string& getDate() const { return m_date;} const int getId() const { return m_id; } - const CStdString& getName() const { return m_name;} - const CStdString& getDirectory() const { return m_directory;} - const CStdString& getThumb() const { return m_thumb;} - const CStdString& getLockCode() const { return m_locks.code;} + const std::string& getName() const { return m_name;} + const std::string& getDirectory() const { return m_directory;} + const std::string& getThumb() const { return m_thumb;} + const std::string& getLockCode() const { return m_locks.code;} LockType getLockMode() const { return m_locks.mode; } bool hasDatabases() const { return m_bDatabases; } @@ -80,11 +80,11 @@ public: bool programsLocked() const { return m_locks.programs; } const CLock &GetLocks() const { return m_locks; } - void setName(const CStdString& name) {m_name = name;} - void setDirectory(const CStdString& directory) {m_directory = directory;} - void setDate(const CStdString& strDate) { m_date = strDate;} + void setName(const std::string& name) {m_name = name;} + void setDirectory(const std::string& directory) {m_directory = directory;} + void setDate(const std::string& strDate) { m_date = strDate;} void setDate(); - void setThumb(const CStdString& thumb) {m_thumb = thumb;} + void setThumb(const std::string& thumb) {m_thumb = thumb;} void setDatabases(bool bHas) { m_bDatabases = bHas; } void setWriteDatabases(bool bCan) { m_bCanWrite = bCan; } void setSources(bool bHas) { m_bSources = bHas; } @@ -92,11 +92,11 @@ public: void SetLocks(const CLock &locks); private: - CStdString m_directory; + std::string m_directory; int m_id; - CStdString m_name; - CStdString m_date; - CStdString m_thumb; + std::string m_name; + std::string m_date; + std::string m_thumb; bool m_bDatabases; bool m_bCanWrite; bool m_bSources; diff --git a/xbmc/profiles/ProfilesManager.cpp b/xbmc/profiles/ProfilesManager.cpp index 93e2946b17..e9b229514b 100644 --- a/xbmc/profiles/ProfilesManager.cpp +++ b/xbmc/profiles/ProfilesManager.cpp @@ -133,7 +133,7 @@ bool CProfilesManager::Load(const std::string &file) XMLUtils::GetInt(rootElement, XML_AUTO_LOGIN, m_autoLoginProfile); XMLUtils::GetInt(rootElement, XML_NEXTID, m_nextProfileId); - CStdString defaultDir("special://home/userdata"); + std::string defaultDir("special://home/userdata"); if (!CDirectory::Exists(defaultDir)) defaultDir = "special://xbmc/userdata"; @@ -206,7 +206,7 @@ bool CProfilesManager::Save(const std::string &file) const XMLUtils::SetInt(pRoot, XML_AUTO_LOGIN, m_autoLoginProfile); XMLUtils::SetInt(pRoot, XML_NEXTID, m_nextProfileId); - for (vector<CProfile>::const_iterator profile = m_profiles.begin(); profile != m_profiles.end(); profile++) + for (vector<CProfile>::const_iterator profile = m_profiles.begin(); profile != m_profiles.end(); ++profile) profile->Save(pRoot); // save the file @@ -502,7 +502,7 @@ std::string CProfilesManager::GetLibraryFolder() const std::string CProfilesManager::GetSettingsFile() const { - CStdString settings; + std::string settings; if (m_currentProfile == 0) return "special://masterprofile/guisettings.xml"; diff --git a/xbmc/profiles/ProfilesManager.h b/xbmc/profiles/ProfilesManager.h index ccaee55574..72f6751d43 100644 --- a/xbmc/profiles/ProfilesManager.h +++ b/xbmc/profiles/ProfilesManager.h @@ -19,6 +19,7 @@ * */ +#include <stdint.h> #include <vector> #include "profiles/Profile.h" diff --git a/xbmc/profiles/dialogs/GUIDialogLockSettings.cpp b/xbmc/profiles/dialogs/GUIDialogLockSettings.cpp index 864b4fef5a..9d83a726a2 100644 --- a/xbmc/profiles/dialogs/GUIDialogLockSettings.cpp +++ b/xbmc/profiles/dialogs/GUIDialogLockSettings.cpp @@ -161,7 +161,7 @@ void CGUIDialogLockSettings::OnSettingAction(const CSetting *setting) choices.Add(4, 12339); int choice = CGUIDialogContextMenu::ShowAndGetChoice(choices); - CStdString newPassword; + std::string newPassword; LockType iLockMode = LOCK_MODE_UNKNOWN; bool bResult = false; switch(choice) diff --git a/xbmc/profiles/dialogs/GUIDialogProfileSettings.cpp b/xbmc/profiles/dialogs/GUIDialogProfileSettings.cpp index 02a6c0c749..a65c1b6d9f 100644 --- a/xbmc/profiles/dialogs/GUIDialogProfileSettings.cpp +++ b/xbmc/profiles/dialogs/GUIDialogProfileSettings.cpp @@ -85,7 +85,7 @@ bool CGUIDialogProfileSettings::ShowForProfile(unsigned int iProfile, bool first dialog->m_thumb.clear(); // prompt for a name - CStdString profileName; + std::string profileName; if (!CGUIKeyboardFactory::ShowAndGetInput(profileName, g_localizeStrings.Get(20093),false) || profileName.empty()) return false; dialog->m_name = profileName; @@ -128,7 +128,7 @@ bool CGUIDialogProfileSettings::ShowForProfile(unsigned int iProfile, bool first if (dialog->m_name.empty() || dialog->m_directory.empty()) return false; - /*CStdString strLabel; + /*std::string strLabel; strLabel.Format(g_localizeStrings.Get(20047),dialog->m_strName); if (!CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(20058),strLabel,dialog->m_strDirectory,"")) { @@ -252,12 +252,12 @@ void CGUIDialogProfileSettings::OnSettingAction(const CSetting *setting) item->SetLabel(g_localizeStrings.Get(20018)); items.Add(item); - CStdString thumb; + std::string thumb; if (CGUIDialogFileBrowser::ShowAndGetImage(items, shares, g_localizeStrings.Get(1030), thumb) && - !thumb.Equals("thumb://Current")) + !StringUtils::EqualsNoCase(thumb, "thumb://Current")) { m_needsSaving = true; - m_thumb = thumb.Equals("thumb://None") ? "" : thumb; + m_thumb = StringUtils::EqualsNoCase(thumb, "thumb://None") ? "" : thumb; SET_CONTROL_FILENAME(CONTROL_PROFILE_IMAGE, !m_thumb.empty() ? m_thumb : m_defaultImage); } @@ -372,7 +372,7 @@ bool CGUIDialogProfileSettings::GetProfilePath(std::string &directory, bool isDe share.strPath = "special://masterprofile/profiles/"; shares.push_back(share); - CStdString strDirectory; + std::string strDirectory; if (directory.empty()) strDirectory = share.strPath; else diff --git a/xbmc/profiles/windows/GUIWindowSettingsProfile.cpp b/xbmc/profiles/windows/GUIWindowSettingsProfile.cpp index fd714eb949..717d74efea 100644 --- a/xbmc/profiles/windows/GUIWindowSettingsProfile.cpp +++ b/xbmc/profiles/windows/GUIWindowSettingsProfile.cpp @@ -249,10 +249,10 @@ bool CGUIWindowSettingsProfile::GetAutoLoginProfileChoice(int &iProfile) for (unsigned int i = 0; i < CProfilesManager::Get().GetNumberOfProfiles(); i++) { const CProfile *profile = CProfilesManager::Get().GetProfile(i); - CStdString locked = g_localizeStrings.Get(profile->getLockMode() > 0 ? 20166 : 20165); + std::string locked = g_localizeStrings.Get(profile->getLockMode() > 0 ? 20166 : 20165); CFileItemPtr item(new CFileItem(profile->getName())); item->SetProperty("Addon.Summary", locked); // lock setting - CStdString thumb = profile->getThumb(); + std::string thumb = profile->getThumb(); if (thumb.empty()) thumb = "unknown-user.png"; item->SetIconImage(thumb); diff --git a/xbmc/pvr/PVRDatabase.cpp b/xbmc/pvr/PVRDatabase.cpp index 62f927005f..256336f5ae 100644 --- a/xbmc/pvr/PVRDatabase.cpp +++ b/xbmc/pvr/PVRDatabase.cpp @@ -106,7 +106,8 @@ void CPVRDatabase::CreateTables() "bIsRadio bool, " "iGroupType integer, " "sName varchar(64), " - "iLastWatched integer" + "iLastWatched integer, " + "bIsHidden bool" ")" ); @@ -187,6 +188,9 @@ void CPVRDatabase::UpdateTables(int iVersion) m_pDS->exec("ALTER TABLE map_channelgroups_channels ADD iSubChannelNumber integer"); m_pDS->exec("UPDATE map_channelgroups_channels SET iSubChannelNumber = 0"); } + + if (iVersion < 27) + m_pDS->exec("ALTER TABLE channelgroups ADD bIsHidden bool"); } int CPVRDatabase::GetLastChannelId(void) @@ -428,7 +432,7 @@ bool CPVRDatabase::RemoveStaleChannelsFromGroup(const CPVRChannelGroup &group) // XXX work around for frodo: fix this up so it uses one query for all db types // mysql doesn't support subqueries when deleting and sqlite doesn't support joins when deleting - if (g_advancedSettings.m_databaseTV.type.Equals("mysql")) + if (StringUtils::EqualsNoCase(g_advancedSettings.m_databaseTV.type, "mysql")) { std::string strQuery = PrepareSQL("DELETE m FROM map_channelgroups_channels m LEFT JOIN channels c ON (c.idChannel = m.idChannel) WHERE c.idChannel IS NULL"); bDelete = ExecuteQuery(strQuery); @@ -507,6 +511,7 @@ bool CPVRDatabase::Get(CPVRChannelGroups &results) CPVRChannelGroup data(m_pDS->fv("bIsRadio").get_asBool(), m_pDS->fv("idGroup").get_asInt(), m_pDS->fv("sName").get_asString()); data.SetGroupType(m_pDS->fv("iGroupType").get_asInt()); data.SetLastWatched((time_t) m_pDS->fv("iLastWatched").get_asInt()); + data.SetHidden(m_pDS->fv("bIsHidden").get_asBool()); results.Update(data); CLog::Log(LOGDEBUG, "PVR - %s - group '%s' loaded from the database", __FUNCTION__, data.GroupName().c_str()); @@ -701,11 +706,11 @@ bool CPVRDatabase::Persist(CPVRChannelGroup &group) /* insert a new entry when this is a new group, or replace the existing one otherwise */ if (group.GroupID() <= 0) - strQuery = PrepareSQL("INSERT INTO channelgroups (bIsRadio, iGroupType, sName, iLastWatched) VALUES (%i, %i, '%s', %u)", - (group.IsRadio() ? 1 :0), group.GroupType(), group.GroupName().c_str(), group.LastWatched()); + strQuery = PrepareSQL("INSERT INTO channelgroups (bIsRadio, iGroupType, sName, iLastWatched, bIsHidden) VALUES (%i, %i, '%s', %u, %i)", + (group.IsRadio() ? 1 :0), group.GroupType(), group.GroupName().c_str(), group.LastWatched(), group.IsHidden()); else - strQuery = PrepareSQL("REPLACE INTO channelgroups (idGroup, bIsRadio, iGroupType, sName, iLastWatched) VALUES (%i, %i, %i, '%s', %u)", - group.GroupID(), (group.IsRadio() ? 1 :0), group.GroupType(), group.GroupName().c_str(), group.LastWatched()); + strQuery = PrepareSQL("REPLACE INTO channelgroups (idGroup, bIsRadio, iGroupType, sName, iLastWatched, bIsHidden) VALUES (%i, %i, %i, '%s', %u, %i)", + group.GroupID(), (group.IsRadio() ? 1 :0), group.GroupType(), group.GroupName().c_str(), group.LastWatched(), group.IsHidden()); bReturn = ExecuteQuery(strQuery); diff --git a/xbmc/pvr/PVRDatabase.h b/xbmc/pvr/PVRDatabase.h index f57459c2a6..6a48796a90 100644 --- a/xbmc/pvr/PVRDatabase.h +++ b/xbmc/pvr/PVRDatabase.h @@ -59,7 +59,7 @@ namespace PVR * @brief Get the minimal database version that is required to operate correctly. * @return The minimal database version. */ - virtual int GetSchemaVersion() const { return 26; }; + virtual int GetSchemaVersion() const { return 27; }; /*! * @brief Get the default sqlite database filename. diff --git a/xbmc/pvr/PVRGUIInfo.cpp b/xbmc/pvr/PVRGUIInfo.cpp index 7212910510..b178ec3a6b 100644 --- a/xbmc/pvr/PVRGUIInfo.cpp +++ b/xbmc/pvr/PVRGUIInfo.cpp @@ -39,8 +39,7 @@ using namespace PVR; using namespace EPG; CPVRGUIInfo::CPVRGUIInfo(void) : - CThread("PVRGUIInfo"), - m_playingEpgTag(NULL) + CThread("PVRGUIInfo") { ResetProperties(); } @@ -684,7 +683,6 @@ void CPVRGUIInfo::UpdateBackendCache(void) std::string strBackendName; std::string strBackendVersion; std::string strBackendHost; - std::string strBackendDiskspace; std::string strBackendTimers; std::string strBackendRecordings; std::string strBackendChannels; @@ -861,22 +859,14 @@ int CPVRGUIInfo::GetStartTime(void) const void CPVRGUIInfo::ResetPlayingTag(void) { CSingleLock lock(m_critSection); - SAFE_DELETE(m_playingEpgTag); + m_playingEpgTag.reset(); m_iDuration = 0; } -bool CPVRGUIInfo::GetPlayingTag(CEpgInfoTag &tag) const +CEpgInfoTagPtr CPVRGUIInfo::GetPlayingTag() const { - bool bReturn(false); - CSingleLock lock(m_critSection); - if (m_playingEpgTag) - { - tag = *m_playingEpgTag; - bReturn = true; - } - - return bReturn; + return m_playingEpgTag; } void CPVRGUIInfo::UpdatePlayingTag(void) @@ -885,22 +875,21 @@ void CPVRGUIInfo::UpdatePlayingTag(void) CPVRRecording recording; if (g_PVRManager.GetCurrentChannel(currentChannel)) { - CEpgInfoTag epgTag; - bool bHasEpgTag = GetPlayingTag(epgTag); + CEpgInfoTagPtr epgTag(GetPlayingTag()); CPVRChannelPtr channel; - if (bHasEpgTag) - channel = epgTag.ChannelTag(); + if (epgTag) + channel = epgTag->ChannelTag(); - if (!bHasEpgTag || !epgTag.IsActive() || + if (!epgTag || !epgTag->IsActive() || !channel || *channel != *currentChannel) { - CEpgInfoTag newTag; { CSingleLock lock(m_critSection); ResetPlayingTag(); - if (currentChannel->GetEPGNow(newTag)) + CEpgInfoTagPtr newTag(currentChannel->GetEPGNow()); + if (newTag) { - m_playingEpgTag = new CEpgInfoTag(newTag); + m_playingEpgTag = newTag; m_iDuration = m_playingEpgTag->GetDuration() * 1000; } } diff --git a/xbmc/pvr/PVRGUIInfo.h b/xbmc/pvr/PVRGUIInfo.h index f1cfb2192a..9e66e6d62e 100644 --- a/xbmc/pvr/PVRGUIInfo.h +++ b/xbmc/pvr/PVRGUIInfo.h @@ -28,6 +28,7 @@ namespace EPG { class CEpgInfoTag; + typedef boost::shared_ptr<EPG::CEpgInfoTag> CEpgInfoTagPtr; } namespace PVR @@ -75,11 +76,16 @@ namespace PVR */ void ResetPlayingTag(void); - bool GetPlayingTag(EPG::CEpgInfoTag &tag) const; + /*! + * @brief Get the currently playing EPG tag. + * @return The currently playing EPG tag or NULL if no EPG tag is playing. + */ + EPG::CEpgInfoTagPtr GetPlayingTag() const; /*! - * @brief Get playing TV group. - */ + * @brief Get playing TV group. + * @return The currently playing TV group or NULL if no TV group is playing. + */ std::string GetPlayingTVGroup(); private: @@ -176,7 +182,7 @@ namespace PVR unsigned int m_iTimerInfoToggleStart; unsigned int m_iTimerInfoToggleCurrent; XbmcThreads::EndTime m_ToggleShowInfo; - EPG::CEpgInfoTag * m_playingEpgTag; + EPG::CEpgInfoTagPtr m_playingEpgTag; CCriticalSection m_critSection; }; diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index 0cea005770..b5ebfc7436 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -59,6 +59,7 @@ #include "addons/AddonInstaller.h" #include "guilib/Key.h" #include "dialogs/GUIDialogPVRChannelManager.h" +#include "dialogs/GUIDialogPVRGroupManager.h" using namespace MUSIC_INFO; using namespace PVR; @@ -203,6 +204,15 @@ void CPVRManager::OnSettingAction(const CSetting *setting) dialog->DoModal(); } } + else if (settingId == "pvrmanager.groupmanager") + { + if (IsStarted()) + { + CGUIDialogPVRGroupManager *dialog = (CGUIDialogPVRGroupManager *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_GROUP_MANAGER); + if (dialog) + dialog->DoModal(); + } + } else if (settingId == "pvrclient.menuhook") { if (IsStarted()) @@ -271,7 +281,7 @@ bool CPVRManager::UpgradeOutdatedAddons(void) return true; // there's add-ons that couldn't be updated - for (std::map<std::string, std::string>::iterator it = m_outdatedAddons.begin(); it != m_outdatedAddons.end(); it++) + for (std::map<std::string, std::string>::iterator it = m_outdatedAddons.begin(); it != m_outdatedAddons.end(); ++it) { if (!InstallAddonAllowed(it->first)) { @@ -292,7 +302,7 @@ bool CPVRManager::UpgradeOutdatedAddons(void) Cleanup(); // upgrade all add-ons - for (std::map<std::string, std::string>::iterator it = outdatedAddons.begin(); it != outdatedAddons.end(); it++) + for (std::map<std::string, std::string>::iterator it = outdatedAddons.begin(); it != outdatedAddons.end(); ++it) { CLog::Log(LOGINFO, "PVR - updating add-on '%s'", it->first.c_str()); CAddonInstaller::Get().Install(it->first, true, it->second, false); @@ -1135,22 +1145,21 @@ bool CPVRManager::UpdateItem(CFileItem& item) g_infoManager.SetCurrentItem(*m_currentFile); CPVRChannel* channelTag = item.GetPVRChannelInfoTag(); - CEpgInfoTag epgTagNow; - bool bHasTagNow = channelTag->GetEPGNow(epgTagNow); + CEpgInfoTagPtr epgTagNow(channelTag->GetEPGNow()); if (channelTag->IsRadio()) { CMusicInfoTag* musictag = item.GetMusicInfoTag(); if (musictag) { - musictag->SetTitle(bHasTagNow ? - epgTagNow.Title() : + musictag->SetTitle(epgTagNow ? + epgTagNow->Title() : CSettings::Get().GetBool("epg.hidenoinfoavailable") ? "" : g_localizeStrings.Get(19055)); // no information available - if (bHasTagNow) - musictag->SetGenre(epgTagNow.Genre()); - musictag->SetDuration(bHasTagNow ? epgTagNow.GetDuration() : 3600); + if (epgTagNow) + musictag->SetGenre(epgTagNow->Genre()); + musictag->SetDuration(epgTagNow ? epgTagNow->GetDuration() : 3600); musictag->SetURL(channelTag->Path()); musictag->SetArtist(channelTag->ChannelName()); musictag->SetAlbumArtist(channelTag->ChannelName()); @@ -1164,18 +1173,18 @@ bool CPVRManager::UpdateItem(CFileItem& item) CVideoInfoTag *videotag = item.GetVideoInfoTag(); if (videotag) { - videotag->m_strTitle = bHasTagNow ? - epgTagNow.Title() : + videotag->m_strTitle = epgTagNow ? + epgTagNow->Title() : CSettings::Get().GetBool("epg.hidenoinfoavailable") ? "" : g_localizeStrings.Get(19055); // no information available - if (bHasTagNow) - videotag->m_genre = epgTagNow.Genre(); + if (epgTagNow) + videotag->m_genre = epgTagNow->Genre(); videotag->m_strPath = channelTag->Path(); videotag->m_strFileNameAndPath = channelTag->Path(); - videotag->m_strPlot = bHasTagNow ? epgTagNow.Plot() : ""; - videotag->m_strPlotOutline = bHasTagNow ? epgTagNow.PlotOutline() : ""; - videotag->m_iEpisode = bHasTagNow ? epgTagNow.EpisodeNum() : 0; + videotag->m_strPlot = epgTagNow ? epgTagNow->Plot() : ""; + videotag->m_strPlotOutline = epgTagNow ? epgTagNow->PlotOutline() : ""; + videotag->m_iEpisode = epgTagNow ? epgTagNow->EpisodeNum() : 0; } } @@ -1404,6 +1413,26 @@ bool CPVRManager::IsIdle(void) const return true; } +bool CPVRManager::CanSystemPowerdown(bool bAskUser /*= true*/) const +{ + bool bReturn(true); + if (IsStarted()) + { + if (!m_addons->AllLocalBackendsIdle()) + { + if (bAskUser) + { + // Inform user about PVR being busy. Ask if user wants to powerdown anyway. + bool bCanceled = false; + bReturn = CGUIDialogYesNo::ShowAndGetInput(19685, 19686, 0, 0, -1, -1, bCanceled, 10000); + } + else + bReturn = false; // do not powerdown (busy, but no user interaction requested). + } + } + return bReturn; +} + void CPVRManager::ShowPlayerInfo(int iTimeout) { if (IsStarted() && m_guiInfo) diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index 205cc99970..72b17e7767 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -372,6 +372,18 @@ namespace PVR bool IsIdle(void) const; /*! + * @brief Check whether the system Kodi is running on can be powered down + * (shutdown/reboot/suspend/hibernate) without stopping any active + * recordings and/or without preventing the start of recordings + * sheduled for now + pvrpowermanagement.backendidletime. + * @param bAskUser True to informs user in case of potential + * data loss. User can decide to allow powerdown anyway. False to + * not to ask user and to not confirm power down. + * @return True if system can be safely powered down, false otherwise. + */ + bool CanSystemPowerdown(bool bAskUser = true) const; + + /*! * @brief Set the current playing group, used to load the right channel. * @param group The new group. */ diff --git a/xbmc/pvr/addons/PVRClient.cpp b/xbmc/pvr/addons/PVRClient.cpp index 842e717d01..6491b36c0a 100644 --- a/xbmc/pvr/addons/PVRClient.cpp +++ b/xbmc/pvr/addons/PVRClient.cpp @@ -132,6 +132,7 @@ void CPVRClient::ResetProperties(int iClientId /* = PVR_INVALID_CLIENT_ID */) m_strConnectionString = DEFAULT_INFO_STRING_VALUE; m_strFriendlyName = DEFAULT_INFO_STRING_VALUE; m_strBackendName = DEFAULT_INFO_STRING_VALUE; + m_strBackendHostname.clear(); m_bIsPlayingTV = false; m_bIsPlayingRecording = false; memset(&m_addonCapabilities, 0, sizeof(m_addonCapabilities)); @@ -270,7 +271,6 @@ void CPVRClient::WriteClientTimerInfo(const CPVRTimerInfoTag &xbmcTimer, PVR_TIM addonTimer.iClientIndex = xbmcTimer.m_iClientIndex; addonTimer.state = xbmcTimer.m_state; - addonTimer.iClientIndex = xbmcTimer.m_iClientIndex; addonTimer.iClientChannelUid = xbmcTimer.m_iClientChannelUid; strncpy(addonTimer.strTitle, xbmcTimer.m_strTitle.c_str(), sizeof(addonTimer.strTitle) - 1); strncpy(addonTimer.strDirectory, xbmcTimer.m_strDirectory.c_str(), sizeof(addonTimer.strDirectory) - 1); @@ -354,7 +354,7 @@ bool CPVRClient::CheckAPIVersion(void) bool CPVRClient::GetAddonProperties(void) { - std::string strBackendName, strConnectionString, strFriendlyName, strBackendVersion; + std::string strBackendName, strConnectionString, strFriendlyName, strBackendVersion, strBackendHostname; PVR_ADDON_CAPABILITIES addonCapabilities; /* get the capabilities */ @@ -385,12 +385,17 @@ bool CPVRClient::GetAddonProperties(void) try { strBackendVersion = m_pStruct->GetBackendVersion(); } catch (std::exception &e) { LogException(e, "GetBackendVersion()"); return false; } + /* backend hostname */ + try { strBackendHostname = m_pStruct->GetBackendHostname(); } + catch (std::exception &e) { LogException(e, "GetBackendHostname()"); return false; } + /* update the members */ m_strBackendName = strBackendName; m_strConnectionString = strConnectionString; m_strFriendlyName = strFriendlyName; m_strBackendVersion = strBackendVersion; m_addonCapabilities = addonCapabilities; + m_strBackendHostname = strBackendHostname; return true; } @@ -411,6 +416,11 @@ const std::string& CPVRClient::GetBackendVersion(void) const return m_strBackendVersion; } +const std::string& CPVRClient::GetBackendHostname(void) const +{ + return m_strBackendHostname; +} + const std::string& CPVRClient::GetConnectionString(void) const { return m_strConnectionString; diff --git a/xbmc/pvr/addons/PVRClient.h b/xbmc/pvr/addons/PVRClient.h index 179d85aaa1..77a3e5b3f2 100644 --- a/xbmc/pvr/addons/PVRClient.h +++ b/xbmc/pvr/addons/PVRClient.h @@ -129,6 +129,11 @@ namespace PVR const std::string& GetBackendVersion(void) const; /*! + * @brief the ip address or alias of the pvr backend server + */ + const std::string& GetBackendHostname(void) const; + + /*! * @return The connection string reported by the backend. */ const std::string& GetConnectionString(void) const; @@ -625,6 +630,7 @@ namespace PVR PVR_ADDON_CAPABILITIES m_addonCapabilities; /*!< the cached add-on capabilities */ bool m_bGotAddonCapabilities; /*!< true if the add-on capabilities have already been fetched */ PVR_SIGNAL_STATUS m_qualityInfo; /*!< stream quality information */ + std::string m_strBackendHostname; /*!< the cached backend hostname */ /* stored strings to make sure const char* members in PVR_PROPERTIES stay valid */ std::string m_strUserPath; /*!< @brief translated path to the user profile */ diff --git a/xbmc/pvr/addons/PVRClients.cpp b/xbmc/pvr/addons/PVRClients.cpp index 8287d4d03b..d252e6d686 100644 --- a/xbmc/pvr/addons/PVRClients.cpp +++ b/xbmc/pvr/addons/PVRClients.cpp @@ -34,6 +34,7 @@ #include "pvr/recordings/PVRRecordings.h" #include "pvr/timers/PVRTimers.h" #include "cores/IPlayer.h" +#include "network/Network.h" using namespace ADDON; using namespace PVR; @@ -676,8 +677,6 @@ bool CPVRClients::GetMenuHooks(int iClientID, PVR_MENUHOOK_CAT cat, PVR_MENUHOOK void CPVRClients::ProcessMenuHooks(int iClientID, PVR_MENUHOOK_CAT cat, const CFileItem *item) { - PVR_MENUHOOKS *hooks = NULL; - // get client id if (iClientID < 0 && cat == PVR_MENUHOOK_SETTING) { @@ -719,7 +718,7 @@ void CPVRClients::ProcessMenuHooks(int iClientID, PVR_MENUHOOK_CAT cat, const CF PVR_CLIENT client; if (GetConnectedClient(iClientID, client) && client->HaveMenuHooks(cat)) { - hooks = client->GetMenuHooks(); + PVR_MENUHOOKS *hooks = client->GetMenuHooks(); std::vector<int> hookIDs; int selection = 0; @@ -971,7 +970,7 @@ bool CPVRClients::UpdateAndInitialiseClients(bool bInitialiseAllClients /* = fal if (disableAddons.size() > 0) { CSingleLock lock(m_critSection); - for (VECADDONS::iterator it = disableAddons.begin(); it != disableAddons.end(); it++) + for (VECADDONS::iterator it = disableAddons.begin(); it != disableAddons.end(); ++it) { // disable in the add-on db CAddonMgr::Get().DisableAddon((*it)->ID(), true); @@ -1373,3 +1372,33 @@ time_t CPVRClients::GetBufferTimeEnd() const return time; } + +bool CPVRClients::NextEventWithinBackendIdleTime(const CPVRTimers& timers) +{ + // timers going off soon? + const CDateTime now(CDateTime::GetUTCDateTime()); + const CDateTimeSpan idle( + 0, 0, CSettings::Get().GetInt("pvrpowermanagement.backendidletime"), 0); + const CDateTime next(timers.GetNextEventTime()); + const CDateTimeSpan delta(next - now); + + return (delta <= idle); +} + +bool CPVRClients::AllLocalBackendsIdle() const +{ + PVR_CLIENTMAP clients; + GetConnectedClients(clients); + for (PVR_CLIENTMAP_CITR itr = clients.begin(); itr != clients.end(); itr++) + { + CPVRTimers timers; + PVR_ERROR ret = itr->second->GetTimers(&timers); + if (ret == PVR_ERROR_NOT_IMPLEMENTED || ret != PVR_ERROR_NO_ERROR) + continue; + + if (((timers.AmountActiveRecordings() > 0) || NextEventWithinBackendIdleTime(timers)) + && g_application.getNetwork().IsLocalHost(itr->second->GetBackendHostname())) + return false; + } + return true; +} diff --git a/xbmc/pvr/addons/PVRClients.h b/xbmc/pvr/addons/PVRClients.h index d10926ab5f..08719e2a12 100644 --- a/xbmc/pvr/addons/PVRClients.h +++ b/xbmc/pvr/addons/PVRClients.h @@ -552,6 +552,12 @@ namespace PVR bool GetPlayingClient(PVR_CLIENT &client) const; + /*! + * @brief Checks whether all local pvr backends (if any) are idle (no recording active, ...). + * @return True if all local backends are idle or no local backends are connected, false otherwise. + */ + bool AllLocalBackendsIdle() const; + time_t GetPlayingTime() const; time_t GetBufferTimeStart() const; time_t GetBufferTimeEnd() const; @@ -621,6 +627,8 @@ namespace PVR int GetClientId(const ADDON::AddonPtr client) const; + static bool NextEventWithinBackendIdleTime(const CPVRTimers& timers); + bool m_bChannelScanRunning; /*!< true when a channel scan is currently running, false otherwise */ bool m_bIsSwitchingChannels; /*!< true while switching channels */ int m_playingClientId; /*!< the ID of the client that is currently playing */ diff --git a/xbmc/pvr/channels/PVRChannel.cpp b/xbmc/pvr/channels/PVRChannel.cpp index 3416304c91..ba3565c64a 100644 --- a/xbmc/pvr/channels/PVRChannel.cpp +++ b/xbmc/pvr/channels/PVRChannel.cpp @@ -161,17 +161,18 @@ void CPVRChannel::Serialize(CVariant& value) const value["channelnumber"] = m_iCachedChannelNumber; value["subchannelnumber"] = m_iCachedSubChannelNumber; - CEpgInfoTag epg; - if (GetEPGNow(epg)) + CEpgInfoTagPtr epg(GetEPGNow()); + if (epg) { // add the properties of the current EPG item to the main object - epg.Serialize(value); + epg->Serialize(value); // and add an extra sub-object with only the current EPG details - epg.Serialize(value["broadcastnow"]); + epg->Serialize(value["broadcastnow"]); } - if (GetEPGNext(epg)) - epg.Serialize(value["broadcastnext"]); + epg = GetEPGNext(); + if (epg) + epg->Serialize(value["broadcastnext"]); } /********** XBMC related channel methods **********/ @@ -616,16 +617,24 @@ bool CPVRChannel::ClearEPG() const return true; } -bool CPVRChannel::GetEPGNow(CEpgInfoTag &tag) const +CEpgInfoTagPtr CPVRChannel::GetEPGNow() const { CEpg *epg = GetEPG(); - return epg ? epg->InfoTagNow(tag) : false; + if (epg) + return epg->GetTagNow(); + + CEpgInfoTagPtr empty; + return empty; } -bool CPVRChannel::GetEPGNext(CEpgInfoTag &tag) const +CEpgInfoTagPtr CPVRChannel::GetEPGNext() const { CEpg *epg = GetEPG(); - return epg ? epg->InfoTagNext(tag) : false; + if (epg) + return epg->GetTagNext(); + + CEpgInfoTagPtr empty; + return empty; } bool CPVRChannel::SetEPGEnabled(bool bEPGEnabled) diff --git a/xbmc/pvr/channels/PVRChannel.h b/xbmc/pvr/channels/PVRChannel.h index 63a16a1177..abbe577313 100644 --- a/xbmc/pvr/channels/PVRChannel.h +++ b/xbmc/pvr/channels/PVRChannel.h @@ -32,6 +32,9 @@ namespace EPG { class CEpg; + class CEpgInfoTag; + typedef boost::shared_ptr<CEpgInfoTag> CEpgInfoTagPtr; + } namespace PVR @@ -411,7 +414,7 @@ namespace PVR * * @return The EPG tag that is active on this channel now. */ - bool GetEPGNow(EPG::CEpgInfoTag &tag) const; + EPG::CEpgInfoTagPtr GetEPGNow() const; /*! * @brief Get the EPG tag that is active on this channel next. @@ -421,7 +424,7 @@ namespace PVR * * @return The EPG tag that is active on this channel next. */ - bool GetEPGNext(EPG::CEpgInfoTag &tag) const; + EPG::CEpgInfoTagPtr GetEPGNext() const; /*! * @return Don't use an EPG for this channel if set to false. diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index 95395ebff8..08731124d6 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -52,9 +52,11 @@ CPVRChannelGroup::CPVRChannelGroup(void) : m_bLoaded(false), m_bChanged(false), m_bUsingBackendChannelOrder(false), + m_bUsingBackendChannelNumbers(false), m_bSelectedGroup(false), m_bPreventSortAndRenumber(false), - m_iLastWatched(0) + m_iLastWatched(0), + m_bHidden(false) { } @@ -66,9 +68,11 @@ CPVRChannelGroup::CPVRChannelGroup(bool bRadio, unsigned int iGroupId, const std m_bLoaded(false), m_bChanged(false), m_bUsingBackendChannelOrder(false), + m_bUsingBackendChannelNumbers(false), m_bSelectedGroup(false), m_bPreventSortAndRenumber(false), - m_iLastWatched(0) + m_iLastWatched(0), + m_bHidden(false) { } @@ -80,9 +84,11 @@ CPVRChannelGroup::CPVRChannelGroup(const PVR_CHANNEL_GROUP &group) : m_bLoaded(false), m_bChanged(false), m_bUsingBackendChannelOrder(false), + m_bUsingBackendChannelNumbers(false), m_bSelectedGroup(false), m_bPreventSortAndRenumber(false), - m_iLastWatched(0) + m_iLastWatched(0), + m_bHidden(false) { } @@ -104,17 +110,18 @@ bool CPVRChannelGroup::operator!=(const CPVRChannelGroup &right) const return !(*this == right); } -CPVRChannelGroup::CPVRChannelGroup(const CPVRChannelGroup &group) +CPVRChannelGroup::CPVRChannelGroup(const CPVRChannelGroup &group) : + m_strGroupName(group.m_strGroupName) { m_bRadio = group.m_bRadio; m_iGroupType = group.m_iGroupType; m_iGroupId = group.m_iGroupId; - m_strGroupName = group.m_strGroupName; m_bLoaded = group.m_bLoaded; m_bChanged = group.m_bChanged; m_bUsingBackendChannelOrder = group.m_bUsingBackendChannelOrder; m_bUsingBackendChannelNumbers = group.m_bUsingBackendChannelNumbers; m_iLastWatched = group.m_iLastWatched; + m_bHidden = group.m_bHidden; for (int iPtr = 0; iPtr < group.Size(); iPtr++) m_members.push_back(group.m_members.at(iPtr)); @@ -317,7 +324,7 @@ void CPVRChannelGroup::SearchAndSetChannelIcons(bool bUpdateDb /* = false */) struct sortByClientChannelNumber { - bool operator()(const PVRChannelGroupMember &channel1, const PVRChannelGroupMember &channel2) + bool operator()(const PVRChannelGroupMember &channel1, const PVRChannelGroupMember &channel2) const { if (channel1.channel->ClientChannelNumber() == channel2.channel->ClientChannelNumber()) return channel1.channel->ClientSubChannelNumber() < channel2.channel->ClientSubChannelNumber(); @@ -327,7 +334,7 @@ struct sortByClientChannelNumber struct sortByChannelNumber { - bool operator()(const PVRChannelGroupMember &channel1, const PVRChannelGroupMember &channel2) + bool operator()(const PVRChannelGroupMember &channel1, const PVRChannelGroupMember &channel2) const { if (channel1.iChannelNumber == channel2.iChannelNumber) return channel1.iSubChannelNumber < channel2.iSubChannelNumber; @@ -740,11 +747,10 @@ bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels) void CPVRChannelGroup::RemoveInvalidChannels(void) { - bool bDelete(false); CSingleLock lock(m_critSection); for (unsigned int ptr = 0; ptr < m_members.size(); ptr--) { - bDelete = false; + bool bDelete = false; CPVRChannelPtr channel = m_members.at(ptr).channel; if (channel->IsVirtual()) continue; @@ -967,10 +973,6 @@ void CPVRChannelGroup::ResetChannelNumberCache(void) if (!m_bSelectedGroup) return; - /* reset the channel number cache */ - if (!IsInternalGroup()) - g_PVRChannelGroups->GetGroupAll(m_bRadio)->ResetChannelNumbers(); - /* set all channel numbers on members of this group */ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++) { @@ -1019,13 +1021,6 @@ bool CPVRChannelGroup::HasChanges(void) const return m_bChanged || HasNewChannels() || HasChangedChannels(); } -void CPVRChannelGroup::ResetChannelNumbers(void) -{ - CSingleLock lock(m_critSection); - for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++) - m_members.at(iChannelPtr).channel->SetCachedChannelNumber(0); -} - void CPVRChannelGroup::OnSettingChanged(const CSetting *setting) { if (setting == NULL) @@ -1101,12 +1096,12 @@ int CPVRChannelGroup::GetEPGNow(CFileItemList &results) if (!epg || !epg->HasValidEntries() || m_members.at(iChannelPtr).channel->IsHidden()) continue; - CEpgInfoTag epgNow; - if (!epg->InfoTagNow(epgNow)) + CEpgInfoTagPtr epgNow(epg->GetTagNow()); + if (!epgNow) continue; CFileItemPtr entry(new CFileItem(epgNow)); - entry->SetLabel2(epgNow.StartAsLocalTime().GetAsLocalizedTime("", false)); + entry->SetLabel2(epgNow->StartAsLocalTime().GetAsLocalizedTime("", false)); entry->SetPath(channel->Path()); entry->SetArt("thumb", channel->IconPath()); results.Add(entry); @@ -1127,12 +1122,12 @@ int CPVRChannelGroup::GetEPGNext(CFileItemList &results) if (!epg || !epg->HasValidEntries() || m_members.at(iChannelPtr).channel->IsHidden()) continue; - CEpgInfoTag epgNow; - if (!epg->InfoTagNext(epgNow)) + CEpgInfoTagPtr epgNext(epg->GetTagNext()); + if (!epgNext) continue; - CFileItemPtr entry(new CFileItem(epgNow)); - entry->SetLabel2(epgNow.StartAsLocalTime().GetAsLocalizedTime("", false)); + CFileItemPtr entry(new CFileItem(epgNext)); + entry->SetLabel2(epgNext->StartAsLocalTime().GetAsLocalizedTime("", false)); entry->SetPath(channel->Path()); entry->SetArt("thumb", channel->IconPath()); results.Add(entry); @@ -1168,7 +1163,7 @@ CDateTime CPVRChannelGroup::GetEPGDate(EpgDateType epgDateType) const CDateTime date; CSingleLock lock(m_critSection); - for (std::vector<PVRChannelGroupMember>::const_iterator it = m_members.begin(); it != m_members.end(); it++) + for (std::vector<PVRChannelGroupMember>::const_iterator it = m_members.begin(); it != m_members.end(); ++it) { if (it->channel && !it->channel->IsHidden()) { @@ -1358,3 +1353,20 @@ bool CPVRChannelGroup::CreateChannelEpgs(bool bForce /* = false */) /* used only by internal channel groups */ return true; } + +void CPVRChannelGroup::SetHidden(bool bHidden) +{ + CSingleLock lock(m_critSection); + + if (m_bHidden != bHidden) + { + m_bHidden = bHidden; + m_bChanged = true; + } +} + +bool CPVRChannelGroup::IsHidden(void) const +{ + CSingleLock lock(m_critSection); + return m_bHidden; +} diff --git a/xbmc/pvr/channels/PVRChannelGroup.h b/xbmc/pvr/channels/PVRChannelGroup.h index 80b6d55ddc..6b96e64d6a 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.h +++ b/xbmc/pvr/channels/PVRChannelGroup.h @@ -442,6 +442,9 @@ namespace PVR void SetSelectedGroup(bool bSetTo); bool IsSelectedGroup(void) const; + void SetHidden(bool bHidden); + bool IsHidden(void) const; + protected: /*! * @brief Load the channels stored in the database. @@ -518,8 +521,6 @@ namespace PVR */ CFileItemPtr GetByChannelUpDown(const CFileItem &channel, bool bChannelUp) const; - void ResetChannelNumbers(void); - /*! * @brief Get a channel given it's channel ID. * @param iChannelID The channel ID. @@ -538,6 +539,7 @@ namespace PVR bool m_bSelectedGroup; /*!< true when this is the selected group, false otherwise */ bool m_bPreventSortAndRenumber; /*!< true when sorting and renumbering should not be done after adding/updating channels to the group */ time_t m_iLastWatched; /*!< last time group has been watched */ + bool m_bHidden; /*!< true if this group is hidden, false otherwise */ std::vector<PVRChannelGroupMember> m_members; CCriticalSection m_critSection; diff --git a/xbmc/pvr/channels/PVRChannelGroups.cpp b/xbmc/pvr/channels/PVRChannelGroups.cpp index 98a186ab5d..0b77928654 100644 --- a/xbmc/pvr/channels/PVRChannelGroups.cpp +++ b/xbmc/pvr/channels/PVRChannelGroups.cpp @@ -90,7 +90,9 @@ bool CPVRChannelGroups::Update(const CPVRChannelGroup &group, bool bUpdateFromCl if (!bUpdateFromClient) { updateGroup->SetLastWatched(group.LastWatched()); + updateGroup->SetHidden(group.IsHidden()); } + } // persist changes @@ -108,7 +110,7 @@ CFileItemPtr CPVRChannelGroups::GetByPath(const std::string &strPath) const URIUtils::RemoveSlashAtEnd(strFileName); std::string strCheckPath; - for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); it++) + for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); ++it) { // check if the path matches strCheckPath = StringUtils::Format("channels/%s/%s/", (*it)->IsRadio() ? "radio" : "tv", (*it)->GroupName().c_str()); @@ -127,7 +129,7 @@ CFileItemPtr CPVRChannelGroups::GetByPath(const std::string &strPath) const CPVRChannelGroupPtr CPVRChannelGroups::GetById(int iGroupId) const { CSingleLock lock(m_critSection); - for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); it++) + for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); ++it) { if ((*it)->GroupID() == iGroupId) return *it; @@ -140,7 +142,7 @@ CPVRChannelGroupPtr CPVRChannelGroups::GetById(int iGroupId) const CPVRChannelGroupPtr CPVRChannelGroups::GetByName(const std::string &strName) const { CSingleLock lock(m_critSection); - for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); it++) + for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); ++it) { if ((*it)->GroupName() == strName) return *it; @@ -153,7 +155,7 @@ CPVRChannelGroupPtr CPVRChannelGroups::GetByName(const std::string &strName) con void CPVRChannelGroups::RemoveFromAllGroups(const CPVRChannel &channel) { CSingleLock lock(m_critSection); - for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); it++) + for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); ++it) { // only delete the channel from non-system groups if (!(*it)->IsInternalGroup()) @@ -173,7 +175,7 @@ bool CPVRChannelGroups::Update(bool bChannelsOnly /* = false */) // sync channels in groups { CSingleLock lock(m_critSection); - for (std::vector<CPVRChannelGroupPtr>::iterator it = m_groups.begin(); it != m_groups.end(); it++) + for (std::vector<CPVRChannelGroupPtr>::iterator it = m_groups.begin(); it != m_groups.end(); ++it) { if (bUpdateAllGroups || (*it)->IsInternalGroup()) bReturn = (*it)->Update() && bReturn; @@ -202,7 +204,7 @@ bool CPVRChannelGroups::UpdateGroupsEntries(const CPVRChannelGroups &groups) } // go through the groups list and check for new groups - for (std::vector<CPVRChannelGroupPtr>::const_iterator it = groups.m_groups.begin(); it != groups.m_groups.end(); it++) + for (std::vector<CPVRChannelGroupPtr>::const_iterator it = groups.m_groups.begin(); it != groups.m_groups.end(); ++it) { // check if this group is present in this container CPVRChannelGroupPtr existingGroup = GetByName((*it)->GroupName()); @@ -234,7 +236,7 @@ bool CPVRChannelGroups::LoadUserDefinedChannelGroups(void) std::vector<CPVRChannelGroupPtr> emptyGroups; // load group members - for (std::vector<CPVRChannelGroupPtr>::iterator it = m_groups.begin(); it != m_groups.end(); it++) + for (std::vector<CPVRChannelGroupPtr>::iterator it = m_groups.begin(); it != m_groups.end(); ++it) { // load only user defined groups, as internal group is already loaded if (!(*it)->IsInternalGroup()) @@ -251,7 +253,7 @@ bool CPVRChannelGroups::LoadUserDefinedChannelGroups(void) } } - for (std::vector<CPVRChannelGroupPtr>::iterator it = emptyGroups.begin(); it != emptyGroups.end(); it++) + for (std::vector<CPVRChannelGroupPtr>::iterator it = emptyGroups.begin(); it != emptyGroups.end(); ++it) { CLog::Log(LOGDEBUG, "PVR - %s - deleting empty group '%s'", __FUNCTION__, (*it)->GroupName().c_str()); DeleteGroup(*(*it)); @@ -312,7 +314,7 @@ bool CPVRChannelGroups::PersistAll(void) CLog::Log(LOGDEBUG, "PVR - %s - persisting all changes in channel groups", __FUNCTION__); CSingleLock lock(m_critSection); - for (std::vector<CPVRChannelGroupPtr>::iterator it = m_groups.begin(); it != m_groups.end(); it++) + for (std::vector<CPVRChannelGroupPtr>::iterator it = m_groups.begin(); it != m_groups.end(); ++it) bReturn &= (*it)->Persist(); return bReturn; @@ -343,10 +345,10 @@ CPVRChannelGroupPtr CPVRChannelGroups::GetLastPlayedGroup(int iChannelID /* = -1 CSingleLock lock(m_critSection); CPVRChannelGroupPtr group; - for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); it++) + for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); ++it) { if ((*it)->LastWatched() > 0 && (!group || (*it)->LastWatched() > group->LastWatched()) && - (iChannelID == -1 || (iChannelID >= 0 && (*it)->IsGroupMember(iChannelID)))) + (iChannelID == -1 || (iChannelID >= 0 && (*it)->IsGroupMember(iChannelID))) && !(*it)->IsHidden()) group = (*it); } @@ -360,14 +362,18 @@ std::vector<CPVRChannelGroupPtr> CPVRChannelGroups::GetMembers() const return groups; } -int CPVRChannelGroups::GetGroupList(CFileItemList* results) const +int CPVRChannelGroups::GetGroupList(CFileItemList* results, bool bExcludeHidden /* = false */) const { int iReturn(0); CSingleLock lock(m_critSection); std::string strPath; - for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); it++) + for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); ++it) { + // exclude hidden groups if desired + if (bExcludeHidden && (*it)->IsHidden()) + continue; + strPath = StringUtils::Format("pvr://channels/%s/%s/", m_bRadio ? "radio" : "tv", (*it)->GroupName().c_str()); CFileItemPtr group(new CFileItem(strPath, true)); group->m_strTitle = (*it)->GroupName(); @@ -385,16 +391,23 @@ CPVRChannelGroupPtr CPVRChannelGroups::GetPreviousGroup(const CPVRChannelGroup & { CSingleLock lock(m_critSection); - for (std::vector<CPVRChannelGroupPtr>::const_reverse_iterator it = m_groups.rbegin(); it != m_groups.rend(); it++) + for (std::vector<CPVRChannelGroupPtr>::const_reverse_iterator it = m_groups.rbegin(); it != m_groups.rend(); ++it) { // return this entry - if (bReturnNext) + if (bReturnNext && !(*it)->IsHidden()) return *it; // return the next entry if ((*it)->GroupID() == group.GroupID()) bReturnNext = true; } + + // no match return last visible group + for (std::vector<CPVRChannelGroupPtr>::const_reverse_iterator it = m_groups.rbegin(); it != m_groups.rend(); it++) + { + if (!(*it)->IsHidden()) + return *it; + } } // no match @@ -407,16 +420,23 @@ CPVRChannelGroupPtr CPVRChannelGroups::GetNextGroup(const CPVRChannelGroup &grou { CSingleLock lock(m_critSection); - for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); it++) + for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); ++it) { // return this entry - if (bReturnNext) + if (bReturnNext && !(*it)->IsHidden()) return *it; // return the next entry if ((*it)->GroupID() == group.GroupID()) bReturnNext = true; } + + // no match return first visible group + for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); it++) + { + if (!(*it)->IsHidden()) + return *it; + } } // no match @@ -481,7 +501,7 @@ bool CPVRChannelGroups::DeleteGroup(const CPVRChannelGroup &group) // delete the group in this container { CSingleLock lock(m_critSection); - for (std::vector<CPVRChannelGroupPtr>::iterator it = m_groups.begin(); !bFound && it != m_groups.end(); it++) + for (std::vector<CPVRChannelGroupPtr>::iterator it = m_groups.begin(); !bFound && it != m_groups.end(); ++it) { if ((*it)->GroupID() == group.GroupID()) { @@ -515,7 +535,7 @@ void CPVRChannelGroups::FillGroupsGUI(int iWindowId, int iControlId) const // fetch all groups { CSingleLock lock(m_critSection); - for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); it++) + for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); ++it) { // skip empty groups if ((*it)->Size() == 0) @@ -538,7 +558,7 @@ bool CPVRChannelGroups::CreateChannelEpgs(void) { bool bReturn(false); CSingleLock lock(m_critSection); - for (std::vector<CPVRChannelGroupPtr>::iterator it = m_groups.begin(); it != m_groups.end(); it++) + for (std::vector<CPVRChannelGroupPtr>::iterator it = m_groups.begin(); it != m_groups.end(); ++it) { /* Only create EPGs for the internatl groups */ if ((*it)->IsInternalGroup()) diff --git a/xbmc/pvr/channels/PVRChannelGroups.h b/xbmc/pvr/channels/PVRChannelGroups.h index fed651dd03..cf437ed3f4 100644 --- a/xbmc/pvr/channels/PVRChannelGroups.h +++ b/xbmc/pvr/channels/PVRChannelGroups.h @@ -125,9 +125,10 @@ namespace PVR /*! * @brief Get the list of groups. * @param results The file list to store the results in. + * @param bExcludeHidden Decides whether to filter hidden groups * @return The amount of items that were added. */ - int GetGroupList(CFileItemList* results) const; + int GetGroupList(CFileItemList* results, bool bExcludeHidden = false) const; /*! * @brief Get the previous group in this container. diff --git a/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp b/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp index 9fb3b27249..76184e9517 100644 --- a/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp +++ b/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp @@ -115,7 +115,7 @@ CPVRChannelPtr CPVRChannelGroupsContainer::GetChannelByEpgId(int iEpgId) const return channel; } -bool CPVRChannelGroupsContainer::GetGroupsDirectory(CFileItemList *results, bool bRadio) +bool CPVRChannelGroupsContainer::GetGroupsDirectory(CFileItemList *results, bool bRadio) const { const CPVRChannelGroups *channelGroups = Get(bRadio); if (channelGroups) @@ -140,7 +140,7 @@ CFileItemPtr CPVRChannelGroupsContainer::GetByPath(const std::string &strPath) c return retVal; } -bool CPVRChannelGroupsContainer::GetDirectory(const std::string& strPath, CFileItemList &results) +bool CPVRChannelGroupsContainer::GetDirectory(const std::string& strPath, CFileItemList &results) const { std::string strBase(strPath); URIUtils::RemoveSlashAtEnd(strBase); @@ -202,7 +202,7 @@ bool CPVRChannelGroupsContainer::GetDirectory(const std::string& strPath, CFileI return false; } -int CPVRChannelGroupsContainer::GetNumChannelsFromAll() +int CPVRChannelGroupsContainer::GetNumChannelsFromAll() const { return GetGroupAllTV()->Size() + GetGroupAllRadio()->Size(); } @@ -212,7 +212,7 @@ CPVRChannelGroupPtr CPVRChannelGroupsContainer::GetSelectedGroup(bool bRadio) co return Get(bRadio)->GetSelectedGroup(); } -CPVRChannelPtr CPVRChannelGroupsContainer::GetByUniqueID(int iUniqueChannelId, int iClientID) +CPVRChannelPtr CPVRChannelGroupsContainer::GetByUniqueID(int iUniqueChannelId, int iClientID) const { CPVRChannelPtr channel; CPVRChannelGroupPtr channelgroup = GetGroupAllTV(); @@ -227,7 +227,7 @@ CPVRChannelPtr CPVRChannelGroupsContainer::GetByUniqueID(int iUniqueChannelId, i return channel; } -CFileItemPtr CPVRChannelGroupsContainer::GetByChannelIDFromAll(int iChannelID) +CFileItemPtr CPVRChannelGroupsContainer::GetByChannelIDFromAll(int iChannelID) const { CPVRChannelPtr channel; CPVRChannelGroupPtr channelgroup = GetGroupAllTV(); @@ -251,7 +251,7 @@ CFileItemPtr CPVRChannelGroupsContainer::GetByChannelIDFromAll(int iChannelID) return retVal; } -void CPVRChannelGroupsContainer::SearchMissingChannelIcons(void) +void CPVRChannelGroupsContainer::SearchMissingChannelIcons(void) const { CLog::Log(LOGINFO, "PVRChannelGroupsContainer - %s - starting channel icon search", __FUNCTION__); @@ -289,7 +289,7 @@ CPVRChannelGroupPtr CPVRChannelGroupsContainer::GetLastPlayedGroup(int iChannelI return groupTV; } -bool CPVRChannelGroupsContainer::CreateChannel(const CPVRChannel &channel) +bool CPVRChannelGroupsContainer::CreateChannel(const CPVRChannel &channel) const { return GetGroupAll(channel.IsRadio())->AddNewChannel(channel); } diff --git a/xbmc/pvr/channels/PVRChannelGroupsContainer.h b/xbmc/pvr/channels/PVRChannelGroupsContainer.h index 30f063f974..8d7e4cb694 100644 --- a/xbmc/pvr/channels/PVRChannelGroupsContainer.h +++ b/xbmc/pvr/channels/PVRChannelGroupsContainer.h @@ -124,7 +124,7 @@ namespace PVR * @param bRadio Get radio channels or tv channels. * @return True if the list was filled succesfully. */ - bool GetGroupsDirectory(CFileItemList *results, bool bRadio); + bool GetGroupsDirectory(CFileItemList *results, bool bRadio) const; /*! * @brief Get a channel given it's path. @@ -139,13 +139,13 @@ namespace PVR * @param results The file list to store the results in. * @return True if the directory was found, false if not. */ - bool GetDirectory(const std::string& strPath, CFileItemList &results); + bool GetDirectory(const std::string& strPath, CFileItemList &results) const; /*! * @brief The total amount of unique channels in all containers. * @return The total amount of unique channels in all containers. */ - int GetNumChannelsFromAll(void); + int GetNumChannelsFromAll(void) const; /*! * @brief Get the group that is currently selected in the UI. @@ -160,19 +160,19 @@ namespace PVR * @param iClientID The ID of the client. * @return The channel or NULL if it wasn't found. */ - CPVRChannelPtr GetByUniqueID(int iUniqueChannelId, int iClientID); + CPVRChannelPtr GetByUniqueID(int iUniqueChannelId, int iClientID) const; /*! * @brief Get a channel given it's channel ID from all containers. * @param iChannelID The channel ID. * @return The channel or NULL if it wasn't found. */ - CFileItemPtr GetByChannelIDFromAll(int iChannelID); + CFileItemPtr GetByChannelIDFromAll(int iChannelID) const; /*! * @brief Try to find missing channel icons automatically */ - void SearchMissingChannelIcons(void); + void SearchMissingChannelIcons(void) const; /*! * @brief The channel that was played last that has a valid client or NULL if there was none. @@ -187,7 +187,7 @@ namespace PVR */ CPVRChannelGroupPtr GetLastPlayedGroup(int iChannelID = -1) const; - bool CreateChannel(const CPVRChannel &channel); + bool CreateChannel(const CPVRChannel &channel) const; /*! * @brief Create EPG tags for channels in all internal channel groups. @@ -221,5 +221,9 @@ namespace PVR bool m_bUpdateChannelsOnly; bool m_bIsUpdating; CPVRChannelGroupPtr m_lastPlayedGroups[2]; /*!< used to store the last played groups */ + + private : + CPVRChannelGroupsContainer& operator=(const CPVRChannelGroupsContainer&); + CPVRChannelGroupsContainer(const CPVRChannelGroupsContainer&); }; } diff --git a/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp b/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp index 6631096e79..c02e6c336d 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp @@ -80,7 +80,8 @@ bool CGUIDialogPVRChannelManager::OnActionMove(const CAction &action) int iActionId = action.GetID(); if (GetFocusedControlID() == CONTROL_LIST_CHANNELS && (iActionId == ACTION_MOVE_DOWN || iActionId == ACTION_MOVE_UP || - iActionId == ACTION_PAGE_DOWN || iActionId == ACTION_PAGE_UP)) + iActionId == ACTION_PAGE_DOWN || iActionId == ACTION_PAGE_UP || + iActionId == ACTION_MOUSE_MOVE)) // item should be selected on hover { bReturn = true; if (!m_bMovingMode) @@ -242,10 +243,10 @@ bool CGUIDialogPVRChannelManager::OnClickButtonRadioActive(CGUIMessage &message) CGUIMessage msg(GUI_MSG_IS_SELECTED, GetID(), RADIOBUTTON_ACTIVE); if (OnMessage(msg)) { - bool selected(msg.GetParam1() == 1); CFileItemPtr pItem = m_channelItems->Get(m_iSelected); if (pItem) { + bool selected(msg.GetParam1() == 1); pItem->SetProperty("Changed", true); pItem->SetProperty("ActiveChannel", selected); m_bContainsChanges = true; @@ -368,10 +369,10 @@ bool CGUIDialogPVRChannelManager::OnClickButtonUseEPG(CGUIMessage &message) CGUIMessage msg(GUI_MSG_IS_SELECTED, GetID(), RADIOBUTTON_USEEPG); if (OnMessage(msg)) { - bool selected(msg.GetParam1() == 1); CFileItemPtr pItem = m_channelItems->Get(m_iSelected); if (pItem) { + bool selected(msg.GetParam1() == 1); pItem->SetProperty("Changed", true); pItem->SetProperty("UseEPG", selected); m_bContainsChanges = true; diff --git a/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp b/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp index 5fb5c7917e..0d66c4b041 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp @@ -286,8 +286,8 @@ void CGUIDialogPVRChannelsOSD::ShowInfo(int item) return; /* Get the current running show on this channel from the EPG storage */ - CEpgInfoTag epgnow; - if (!channel->GetEPGNow(epgnow)) + CEpgInfoTagPtr epgnow(channel->GetEPGNow()); + if (!epgnow) return; /* Load programme info dialog */ diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp b/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp index 5165588c85..d454bb0882 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp @@ -26,6 +26,7 @@ #include "guilib/GUIWindowManager.h" #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" +#include "guilib/GUIRadioButtonControl.h" #include "utils/StringUtils.h" #include "pvr/PVRManager.h" @@ -39,6 +40,7 @@ using namespace PVR; #define CONTROL_CURRENT_GROUP_LABEL 20 #define CONTROL_UNGROUPED_LABEL 21 #define CONTROL_IN_GROUP_LABEL 22 +#define BUTTON_HIDE_GROUP 25 #define BUTTON_NEWGROUP 26 #define BUTTON_RENAMEGROUP 27 #define BUTTON_DELGROUP 28 @@ -47,6 +49,10 @@ using namespace PVR; CGUIDialogPVRGroupManager::CGUIDialogPVRGroupManager() : CGUIDialog(WINDOW_DIALOG_PVR_GROUP_MANAGER, "DialogPVRGroupManager.xml") { + m_bIsRadio = 0; + m_iSelectedUngroupedChannel = 0; + m_iSelectedGroupMember = 0; + m_iSelectedChannelGroup = 0; m_ungroupedChannels = new CFileItemList; m_groupMembers = new CFileItemList; m_channelGroups = new CFileItemList; @@ -246,6 +252,25 @@ bool CGUIDialogPVRGroupManager::ActionButtonChannelGroups(CGUIMessage &message) return bReturn; } +bool CGUIDialogPVRGroupManager::ActionButtonHideGroup(CGUIMessage &message) +{ + bool bReturn = false; + + if (message.GetSenderId() == BUTTON_HIDE_GROUP && m_selectedGroup) + { + CGUIRadioButtonControl *button = (CGUIRadioButtonControl*) GetControl(message.GetSenderId()); + if (button) + { + m_selectedGroup->SetHidden(button->IsSelected()); + Update(); + } + + bReturn = true; + } + + return bReturn; +} + bool CGUIDialogPVRGroupManager::OnMessageClick(CGUIMessage &message) { return ActionButtonOk(message) || @@ -254,7 +279,8 @@ bool CGUIDialogPVRGroupManager::OnMessageClick(CGUIMessage &message) ActionButtonRenameGroup(message) || ActionButtonUngroupedChannels(message) || ActionButtonGroupMembers(message) || - ActionButtonChannelGroups(message); + ActionButtonChannelGroups(message) || + ActionButtonHideGroup(message); } bool CGUIDialogPVRGroupManager::OnMessage(CGUIMessage& message) @@ -336,6 +362,7 @@ void CGUIDialogPVRGroupManager::Update() /* set this group in the pvrmanager, so it becomes the selected group in other dialogs too */ g_PVRManager.SetPlayingGroup(m_selectedGroup); SET_CONTROL_LABEL(CONTROL_CURRENT_GROUP_LABEL, m_selectedGroup->GroupName()); + SET_CONTROL_SELECTED(GetID(), BUTTON_HIDE_GROUP, m_selectedGroup->IsHidden()); if (m_selectedGroup->IsInternalGroup()) { diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.h b/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.h index f9ffae1960..564864d037 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.h +++ b/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.h @@ -54,6 +54,7 @@ namespace PVR bool ActionButtonUngroupedChannels(CGUIMessage &message); bool ActionButtonGroupMembers(CGUIMessage &message); bool ActionButtonChannelGroups(CGUIMessage &message); + bool ActionButtonHideGroup(CGUIMessage &message); bool OnMessageClick(CGUIMessage &message); CPVRChannelGroupPtr m_selectedGroup; diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp b/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp index 79ee8da924..bce27265a4 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp @@ -51,7 +51,7 @@ CGUIDialogPVRGuideInfo::~CGUIDialogPVRGuideInfo(void) { } -bool CGUIDialogPVRGuideInfo::ActionStartTimer(const CEpgInfoTag *tag) +bool CGUIDialogPVRGuideInfo::ActionStartTimer(const CEpgInfoTagPtr &tag) { bool bReturn = false; @@ -142,7 +142,7 @@ bool CGUIDialogPVRGuideInfo::OnClickButtonRecord(CGUIMessage &message) { bReturn = true; - const CEpgInfoTag *tag = m_progItem->GetEPGInfoTag(); + const CEpgInfoTagPtr tag(m_progItem->GetEPGInfoTag()); if (!tag || !tag->HasPVRChannel()) { /* invalid channel */ @@ -171,7 +171,7 @@ bool CGUIDialogPVRGuideInfo::OnClickButtonSwitch(CGUIMessage &message) { Close(); PlayBackRet ret = PLAYBACK_CANCELED; - CEpgInfoTag *epgTag = m_progItem->GetEPGInfoTag(); + CEpgInfoTagPtr epgTag(m_progItem->GetEPGInfoTag()); if (epgTag) { @@ -203,7 +203,7 @@ bool CGUIDialogPVRGuideInfo::OnClickButtonFind(CGUIMessage &message) if (message.GetSenderId() == CONTROL_BTN_FIND) { - const CEpgInfoTag *tag = m_progItem->GetEPGInfoTag(); + const CEpgInfoTagPtr tag(m_progItem->GetEPGInfoTag()); if (tag && tag->HasPVRChannel()) { int windowSearchId = tag->ChannelTag()->IsRadio() ? WINDOW_RADIO_SEARCH : WINDOW_TV_SEARCH; @@ -248,7 +248,7 @@ void CGUIDialogPVRGuideInfo::OnInitWindow() { CGUIDialog::OnInitWindow(); - const CEpgInfoTag *tag = m_progItem->GetEPGInfoTag(); + const CEpgInfoTagPtr tag(m_progItem->GetEPGInfoTag()); if (!tag) { /* no epg event selected */ diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.h b/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.h index 243573300b..cf10a8dc2d 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.h +++ b/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.h @@ -20,10 +20,12 @@ */ #include "guilib/GUIDialog.h" +#include <boost/shared_ptr.hpp> namespace EPG { class CEpgInfoTag; + typedef boost::shared_ptr<EPG::CEpgInfoTag> CEpgInfoTagPtr; } namespace PVR @@ -44,7 +46,7 @@ namespace PVR protected: virtual void OnInitWindow(); - bool ActionStartTimer(const EPG::CEpgInfoTag *tag); + bool ActionStartTimer(const EPG::CEpgInfoTagPtr &tag); bool ActionCancelTimer(CFileItemPtr timer); bool OnClickButtonOK(CGUIMessage &message); diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGuideOSD.cpp b/xbmc/pvr/dialogs/GUIDialogPVRGuideOSD.cpp index cf7e5d2d25..8003da7564 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRGuideOSD.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRGuideOSD.cpp @@ -98,7 +98,7 @@ void CGUIDialogPVRGuideOSD::OnInitWindow() for (int iEpgPtr = 0; iEpgPtr < m_vecItems->Size(); iEpgPtr++) { CFileItemPtr entry = m_vecItems->Get(iEpgPtr); - if (entry->GetEPGInfoTag()->IsActive()) + if (entry->HasEPGInfoTag() && entry->GetEPGInfoTag()->IsActive()) { iSelectedItem = iEpgPtr; break; diff --git a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp index 7fda3d932c..33b9fd519e 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp @@ -52,6 +52,7 @@ CGUIDialogPVRTimerSettings::CGUIDialogPVRTimerSettings(void) m_tmp_iFirstDay(0), m_tmp_day(11), m_bTimerActive(false), + m_selectedChannelEntry(0), m_timerItem(NULL) { m_loadType = LOAD_EVERY_TIME; diff --git a/xbmc/pvr/recordings/PVRRecording.cpp b/xbmc/pvr/recordings/PVRRecording.cpp index ccf2693911..d418f0f010 100644 --- a/xbmc/pvr/recordings/PVRRecording.cpp +++ b/xbmc/pvr/recordings/PVRRecording.cpp @@ -38,16 +38,16 @@ CPVRRecordingUid::CPVRRecordingUid() : { } -CPVRRecordingUid::CPVRRecordingUid(const CPVRRecordingUid &recordingId) -{ - m_iClientId = recordingId.m_iClientId; - m_strRecordingId = recordingId.m_strRecordingId; +CPVRRecordingUid::CPVRRecordingUid(const CPVRRecordingUid &recordingId) : + m_iClientId(recordingId.m_iClientId), + m_strRecordingId(recordingId.m_strRecordingId) +{ } -CPVRRecordingUid::CPVRRecordingUid(int iClientId, const std::string& strRecordingId) +CPVRRecordingUid::CPVRRecordingUid(int iClientId, const std::string& strRecordingId) : + m_iClientId(iClientId), + m_strRecordingId(strRecordingId) { - m_iClientId = iClientId; - m_strRecordingId = strRecordingId; } bool CPVRRecordingUid::operator >(const CPVRRecordingUid& right) const @@ -221,7 +221,7 @@ bool CPVRRecording::SetPlayCount(int count) return true; } -void CPVRRecording::UpdateMetadata(void) +void CPVRRecording::UpdateMetadata(CVideoDatabase &db) { if (m_bGotMetaData) return; @@ -231,20 +231,14 @@ void CPVRRecording::UpdateMetadata(void) if (!supportsPlayCount || !supportsLastPlayed) { - CVideoDatabase db; - if (db.Open()) + if (!supportsPlayCount) { - if (!supportsPlayCount) - { - CFileItem pFileItem(*this); - m_playCount = db.GetPlayCount(pFileItem); - } - - if (!supportsLastPlayed) - db.GetResumeBookMark(m_strFileNameAndPath, m_resumePoint); - - db.Close(); + CFileItem pFileItem(*this); + m_playCount = db.GetPlayCount(pFileItem); } + + if (!supportsLastPlayed) + db.GetResumeBookMark(m_strFileNameAndPath, m_resumePoint); } m_bGotMetaData = true; diff --git a/xbmc/pvr/recordings/PVRRecording.h b/xbmc/pvr/recordings/PVRRecording.h index 91af28afd8..c9d9359651 100644 --- a/xbmc/pvr/recordings/PVRRecording.h +++ b/xbmc/pvr/recordings/PVRRecording.h @@ -39,6 +39,8 @@ #include "video/VideoInfoTag.h" #include "XBDateTime.h" +class CVideoDatabase; + namespace PVR { class CPVRRecording; @@ -149,7 +151,7 @@ namespace PVR * @brief Get the resume point and play count from the database if the * client doesn't handle it itself. */ - void UpdateMetadata(void); + void UpdateMetadata(CVideoDatabase &db); /*! * @brief Update this tag with the contents of the given tag. diff --git a/xbmc/pvr/recordings/PVRRecordings.cpp b/xbmc/pvr/recordings/PVRRecordings.cpp index 34ef40f870..c42f5d3c80 100644 --- a/xbmc/pvr/recordings/PVRRecordings.cpp +++ b/xbmc/pvr/recordings/PVRRecordings.cpp @@ -43,7 +43,14 @@ CPVRRecordings::CPVRRecordings(void) : m_iLastId(0), m_bGroupItems(true) { + m_database.Open(); +} +CPVRRecordings::~CPVRRecordings() +{ + Clear(); + if (m_database.IsOpen()) + m_database.Close(); } void CPVRRecordings::UpdateFromClients(void) @@ -119,8 +126,9 @@ void CPVRRecordings::GetSubDirectories(const std::string &strBase, CFileItemList strFilePath = StringUtils::Format("pvr://recordings/%s/%s/", strUseBase.c_str(), strCurrent.c_str()); CFileItemPtr pFileItem; - current->UpdateMetadata(); - + if (m_database.IsOpen()) + current->UpdateMetadata(m_database); + if (!results->Contains(strFilePath)) { pFileItem.reset(new CFileItem(strCurrent, true)); @@ -234,12 +242,10 @@ bool CPVRRecordings::DeleteRecording(const CFileItem &item) bool CPVRRecordings::RenameRecording(CFileItem &item, std::string &strNewName) { - bool bReturn = false; - if (!item.IsPVRRecording()) { CLog::Log(LOGERROR, "CPVRRecordings - %s - cannot rename file: no valid recording tag", __FUNCTION__); - return bReturn; + return false; } CPVRRecording* tag = item.GetPVRRecordingInfoTag(); @@ -250,8 +256,7 @@ bool CPVRRecordings::SetRecordingsPlayCount(const CFileItemPtr &item, int count) { bool bResult = false; - CVideoDatabase database; - if (database.Open()) + if (m_database.IsOpen()) { bResult = true; @@ -291,15 +296,13 @@ bool CPVRRecordings::SetRecordingsPlayCount(const CFileItemPtr &item, int count) // Clear resume bookmark if (count > 0) { - database.ClearBookMarksOfFile(pItem->GetPath(), CBookmark::RESUME); + m_database.ClearBookMarksOfFile(pItem->GetPath(), CBookmark::RESUME); recording->SetLastPlayedPosition(0); } - database.SetPlayCount(*pItem, count); + m_database.SetPlayCount(*pItem, count); } } - - database.Close(); } return bResult; @@ -330,7 +333,8 @@ bool CPVRRecordings::GetDirectory(const std::string& strPath, CFileItemList &ite if (!IsDirectoryMember(strDirectoryPath, current->m_strDirectory)) continue; - current->UpdateMetadata(); + if (m_database.IsOpen()) + current->UpdateMetadata(m_database); CFileItemPtr pFileItem(new CFileItem(*current)); pFileItem->SetLabel2(current->RecordingTimeAsLocalTime().GetAsLocalizedDateTime(true, false)); pFileItem->m_dateTime = current->RecordingTimeAsLocalTime(); @@ -369,7 +373,8 @@ void CPVRRecordings::GetAll(CFileItemList &items) for (PVR_RECORDINGMAP_CITR it = m_recordings.begin(); it != m_recordings.end(); it++) { CPVRRecordingPtr current = it->second; - current->UpdateMetadata(); + if (m_database.IsOpen()) + current->UpdateMetadata(m_database); CFileItemPtr pFileItem(new CFileItem(*current)); pFileItem->SetLabel2(current->RecordingTimeAsLocalTime().GetAsLocalizedDateTime(true, false)); diff --git a/xbmc/pvr/recordings/PVRRecordings.h b/xbmc/pvr/recordings/PVRRecordings.h index 6b8cb147a0..2bcc83409c 100644 --- a/xbmc/pvr/recordings/PVRRecordings.h +++ b/xbmc/pvr/recordings/PVRRecordings.h @@ -24,6 +24,7 @@ #include "threads/Thread.h" #include "utils/Observer.h" #include "video/VideoThumbLoader.h" +#include "video/VideoDatabase.h" #define PVR_ALL_RECORDINGS_PATH_EXTENSION "-1" @@ -40,6 +41,7 @@ namespace PVR PVR_RECORDINGMAP m_recordings; unsigned int m_iLastId; bool m_bGroupItems; + CVideoDatabase m_database; virtual void UpdateFromClients(void); virtual std::string TrimSlashes(const std::string &strOrig) const; @@ -58,7 +60,7 @@ namespace PVR public: CPVRRecordings(void); - virtual ~CPVRRecordings(void) { Clear(); }; + virtual ~CPVRRecordings(void); int Load(); void Unload(); diff --git a/xbmc/pvr/timers/PVRTimerInfoTag.cpp b/xbmc/pvr/timers/PVRTimerInfoTag.cpp index b2e03437ca..e97e6bd3f6 100644 --- a/xbmc/pvr/timers/PVRTimerInfoTag.cpp +++ b/xbmc/pvr/timers/PVRTimerInfoTag.cpp @@ -38,10 +38,10 @@ using namespace PVR; using namespace EPG; -CPVRTimerInfoTag::CPVRTimerInfoTag(void) +CPVRTimerInfoTag::CPVRTimerInfoTag(void) : + m_strTitle(g_localizeStrings.Get(19056)), // New Timer + m_strDirectory("/") { - m_strTitle = g_localizeStrings.Get(19056); // New Timer - m_strDirectory = "/"; m_iClientId = g_PVRClients->GetFirstConnectedClientID(); m_iClientIndex = -1; m_iClientChannelUid = PVR_VIRTUAL_CHANNEL_UID; @@ -64,10 +64,10 @@ CPVRTimerInfoTag::CPVRTimerInfoTag(void) m_iTimerId = 0; } -CPVRTimerInfoTag::CPVRTimerInfoTag(const PVR_TIMER &timer, CPVRChannelPtr channel, unsigned int iClientId) -{ - m_strTitle = timer.strTitle; - m_strDirectory = timer.strDirectory; +CPVRTimerInfoTag::CPVRTimerInfoTag(const PVR_TIMER &timer, CPVRChannelPtr channel, unsigned int iClientId) : + m_strTitle(timer.strTitle), + m_strDirectory(timer.strDirectory) +{ m_iClientId = iClientId; m_iClientIndex = timer.iClientIndex; m_iClientChannelUid = channel ? channel->UniqueID() : timer.iClientChannelUid; @@ -148,6 +148,10 @@ CPVRTimerInfoTag &CPVRTimerInfoTag::operator=(const CPVRTimerInfoTag &orig) m_state = orig.m_state; m_iChannelNumber = orig.m_iChannelNumber; m_iTimerId = orig.m_iTimerId; + m_iGenreType = orig.m_iGenreType; + m_iGenreSubType = orig.m_iGenreSubType; + m_epgTag = orig.m_epgTag; + m_genre = orig.m_genre; return *this; } @@ -435,10 +439,10 @@ void CPVRTimerInfoTag::DisplayError(PVR_ERROR err) const CGUIDialogOK::ShowAndGetInput(19033,19147,19110,0); /* print info dialog "Unknown error!" */ } -void CPVRTimerInfoTag::SetEpgInfoTag(CEpgInfoTagPtr tag) +void CPVRTimerInfoTag::SetEpgInfoTag(CEpgInfoTagPtr &tag) { CSingleLock lock(m_critSection); - if (tag && m_epgTag != tag) + if (tag && *m_epgTag != *tag) CLog::Log(LOGINFO, "cPVRTimerInfoTag: timer %s set to epg event %s", m_strTitle.c_str(), tag->Title().c_str()); else if (!tag && m_epgTag) CLog::Log(LOGINFO, "cPVRTimerInfoTag: timer %s set to no epg event", m_strTitle.c_str()); diff --git a/xbmc/pvr/timers/PVRTimerInfoTag.h b/xbmc/pvr/timers/PVRTimerInfoTag.h index a2c9e9621e..51c6c5d0b1 100644 --- a/xbmc/pvr/timers/PVRTimerInfoTag.h +++ b/xbmc/pvr/timers/PVRTimerInfoTag.h @@ -157,7 +157,7 @@ namespace PVR bool RenameOnClient(const std::string &strNewName); bool UpdateOnClient(); - void SetEpgInfoTag(EPG::CEpgInfoTagPtr tag); + void SetEpgInfoTag(EPG::CEpgInfoTagPtr &tag); void ClearEpgTag(void); void UpdateChannel(void); diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp index af7ba7db69..4084402c88 100644 --- a/xbmc/pvr/timers/PVRTimers.cpp +++ b/xbmc/pvr/timers/PVRTimers.cpp @@ -89,8 +89,8 @@ bool CPVRTimers::IsRecording(void) const { CSingleLock lock(m_critSection); - for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) - for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); timerIt++) + for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) + for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); ++timerIt) if ((*timerIt)->IsRecording()) return true; @@ -106,9 +106,9 @@ bool CPVRTimers::UpdateEntries(const CPVRTimers &timers) CSingleLock lock(m_critSection); /* go through the timer list and check for updated or new timers */ - for (MapTags::const_iterator it = timers.m_tags.begin(); it != timers.m_tags.end(); it++) + for (MapTags::const_iterator it = timers.m_tags.begin(); it != timers.m_tags.end(); ++it) { - for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); timerIt++) + for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); ++timerIt) { /* check if this timer is present in this container */ CPVRTimerInfoTagPtr existingTimer = GetByClient((*timerIt)->m_iClientId, (*timerIt)->m_iClientIndex); @@ -226,7 +226,7 @@ bool CPVRTimers::UpdateEntries(const CPVRTimers &timers) } /* reinsert timers with changed timer start */ - for (VecTimerInfoTag::const_iterator timerIt = timersToMove.begin(); timerIt != timersToMove.end(); timerIt++) + for (VecTimerInfoTag::const_iterator timerIt = timersToMove.begin(); timerIt != timersToMove.end(); ++timerIt) { VecTimerInfoTag* addEntry = NULL; MapTags::const_iterator itr = m_tags.find((*timerIt)->StartAsUTC()); @@ -300,9 +300,9 @@ bool CPVRTimers::UpdateFromClient(const CPVRTimerInfoTag &timer) CFileItemPtr CPVRTimers::GetNextActiveTimer(void) const { CSingleLock lock(m_critSection); - for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) + for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) { - for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); timerIt++) + for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); ++timerIt) { CPVRTimerInfoTagPtr current = *timerIt; if (current->IsActive() && !current->IsRecording()) @@ -322,9 +322,9 @@ std::vector<CFileItemPtr> CPVRTimers::GetActiveTimers(void) const std::vector<CFileItemPtr> tags; CSingleLock lock(m_critSection); - for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) + for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) { - for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); timerIt++) + for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); ++timerIt) { CPVRTimerInfoTagPtr current = *timerIt; if (current->IsActive()) @@ -343,8 +343,8 @@ int CPVRTimers::AmountActiveTimers(void) const int iReturn(0); CSingleLock lock(m_critSection); - for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) - for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); timerIt++) + for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) + for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); ++timerIt) if ((*timerIt)->IsActive()) ++iReturn; @@ -356,9 +356,9 @@ std::vector<CFileItemPtr> CPVRTimers::GetActiveRecordings(void) const std::vector<CFileItemPtr> tags; CSingleLock lock(m_critSection); - for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) + for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) { - for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); timerIt++) + for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); ++timerIt) { CPVRTimerInfoTagPtr current = *timerIt; if (current->IsRecording()) @@ -377,8 +377,8 @@ int CPVRTimers::AmountActiveRecordings(void) const int iReturn(0); CSingleLock lock(m_critSection); - for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) - for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); timerIt++) + for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) + for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); ++timerIt) if ((*timerIt)->IsRecording()) ++iReturn; @@ -388,8 +388,8 @@ int CPVRTimers::AmountActiveRecordings(void) const bool CPVRTimers::HasActiveTimers(void) const { CSingleLock lock(m_critSection); - for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) - for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); timerIt++) + for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) + for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); ++timerIt) if ((*timerIt)->IsActive()) return true; @@ -410,9 +410,9 @@ bool CPVRTimers::GetDirectory(const std::string& strPath, CFileItemList &items) items.Add(item); CSingleLock lock(m_critSection); - for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) + for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) { - for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); timerIt++) + for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); ++timerIt) { CPVRTimerInfoTagPtr current = *timerIt; if (bRadio == current->m_bIsRadio) @@ -436,7 +436,7 @@ bool CPVRTimers::DeleteTimersOnChannel(const CPVRChannel &channel, bool bDeleteR { CSingleLock lock(m_critSection); - for (MapTags::reverse_iterator it = m_tags.rbegin(); it != m_tags.rend(); it++) + for (MapTags::reverse_iterator it = m_tags.rbegin(); it != m_tags.rend(); ++it) { for (VecTimerInfoTag::iterator timerIt = it->second->begin(); timerIt != it->second->end(); ) { @@ -469,9 +469,8 @@ bool CPVRTimers::InstantTimer(const CPVRChannel &channel) if (!g_PVRManager.CheckParentalLock(channel)) return false; - CEpgInfoTag epgTag; - bool bHasEpgNow = channel.GetEPGNow(epgTag); - CPVRTimerInfoTag *newTimer = bHasEpgNow ? CPVRTimerInfoTag::CreateFromEpg(epgTag) : NULL; + CEpgInfoTagPtr epgTag(channel.GetEPGNow()); + CPVRTimerInfoTag *newTimer = epgTag ? CPVRTimerInfoTag::CreateFromEpg(*epgTag) : NULL; if (!newTimer) { newTimer = new CPVRTimerInfoTag; @@ -588,9 +587,9 @@ CPVRTimerInfoTagPtr CPVRTimers::GetByClient(int iClientId, int iClientTimerId) c { CSingleLock lock(m_critSection); - for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) + for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) { - for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); timerIt++) + for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); ++timerIt) { if ((*timerIt)->m_iClientId == iClientId && (*timerIt)->m_iClientIndex == iClientTimerId) @@ -606,9 +605,9 @@ bool CPVRTimers::IsRecordingOnChannel(const CPVRChannel &channel) const { CSingleLock lock(m_critSection); - for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) + for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) { - for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); timerIt++) + for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); ++timerIt) { if ((*timerIt)->IsRecording() && (*timerIt)->m_iClientChannelUid == channel.UniqueID() && @@ -624,13 +623,13 @@ CFileItemPtr CPVRTimers::GetTimerForEpgTag(const CFileItem *item) const { if (item && item->HasEPGInfoTag() && item->GetEPGInfoTag()->ChannelTag()) { - const CEpgInfoTag *epgTag = item->GetEPGInfoTag(); - const CPVRChannelPtr channel = epgTag->ChannelTag(); + const CEpgInfoTagPtr epgTag(item->GetEPGInfoTag()); + const CPVRChannelPtr channel(epgTag->ChannelTag()); CSingleLock lock(m_critSection); - for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) + for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) { - for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); timerIt++) + for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); ++timerIt) { CPVRTimerInfoTagPtr timer = *timerIt; if (timer->m_iClientChannelUid == channel->UniqueID() && @@ -735,9 +734,9 @@ void CPVRTimers::UpdateEpgEvent(CPVRTimerInfoTagPtr timer) void CPVRTimers::UpdateChannels(void) { CSingleLock lock(m_critSection); - for (MapTags::iterator it = m_tags.begin(); it != m_tags.end(); it++) + for (MapTags::iterator it = m_tags.begin(); it != m_tags.end(); ++it) { - for (VecTimerInfoTag::iterator timerIt = it->second->begin(); timerIt != it->second->end(); timerIt++) + for (VecTimerInfoTag::iterator timerIt = it->second->begin(); timerIt != it->second->end(); ++timerIt) (*timerIt)->UpdateChannel(); } } @@ -746,9 +745,9 @@ void CPVRTimers::GetAll(CFileItemList& items) const { CFileItemPtr item; CSingleLock lock(m_critSection); - for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) + for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) { - for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); timerIt++) + for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); ++timerIt) { item.reset(new CFileItem(**timerIt)); items.Add(item); @@ -760,9 +759,9 @@ CPVRTimerInfoTagPtr CPVRTimers::GetById(unsigned int iTimerId) const { CPVRTimerInfoTagPtr item; CSingleLock lock(m_critSection); - for (MapTags::const_iterator it = m_tags.begin(); !item && it != m_tags.end(); it++) + for (MapTags::const_iterator it = m_tags.begin(); !item && it != m_tags.end(); ++it) { - for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); !item && timerIt != it->second->end(); timerIt++) + for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); !item && timerIt != it->second->end(); ++timerIt) { if ((*timerIt)->m_iTimerId == iTimerId) item = *timerIt; diff --git a/xbmc/pvr/windows/GUIWindowPVRBase.cpp b/xbmc/pvr/windows/GUIWindowPVRBase.cpp index a47cd9965a..95d8603daa 100644 --- a/xbmc/pvr/windows/GUIWindowPVRBase.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRBase.cpp @@ -62,7 +62,7 @@ CGUIWindowPVRBase::~CGUIWindowPVRBase(void) { } -void CGUIWindowPVRBase::SetSelectedItemPath(bool bRadio, const std::string path) +void CGUIWindowPVRBase::SetSelectedItemPath(bool bRadio, const std::string &path) { m_selectedItemPaths.at(bRadio) = path; } @@ -91,7 +91,7 @@ bool CGUIWindowPVRBase::OnAction(const CAction &action) case ACTION_PREVIOUS_CHANNELGROUP: case ACTION_NEXT_CHANNELGROUP: // switch to next or previous group - SetGroup(ACTION_NEXT_CHANNELGROUP ? m_group->GetNextGroup() : m_group->GetPreviousGroup()); + SetGroup(action.GetID() == ACTION_NEXT_CHANNELGROUP ? m_group->GetNextGroup() : m_group->GetPreviousGroup()); return true; } @@ -220,7 +220,7 @@ bool CGUIWindowPVRBase::OpenGroupSelectionDialog(void) return false; CFileItemList options; - g_PVRChannelGroups->Get(m_bRadio)->GetGroupList(&options); + g_PVRChannelGroups->Get(m_bRadio)->GetGroupList(&options, true); dialog->Reset(); dialog->SetHeading(g_localizeStrings.Get(19146)); @@ -330,10 +330,8 @@ bool CGUIWindowPVRBase::StartRecordFile(const CFileItem &item) if (!item.HasEPGInfoTag()) return false; - const CEpgInfoTag *tag = item.GetEPGInfoTag(); - CPVRChannelPtr channel; - if (tag) - channel = tag->ChannelTag(); + const CEpgInfoTagPtr tag = item.GetEPGInfoTag(); + CPVRChannelPtr channel = tag->ChannelTag(); if (!channel || !g_PVRManager.CheckParentalLock(*channel)) return false; @@ -373,7 +371,7 @@ bool CGUIWindowPVRBase::StopRecordFile(const CFileItem &item) if (!item.HasEPGInfoTag()) return false; - const CEpgInfoTag *tag = item.GetEPGInfoTag(); + const CEpgInfoTagPtr tag(item.GetEPGInfoTag()); if (!tag || !tag->HasPVRChannel()) return false; @@ -473,10 +471,10 @@ void CGUIWindowPVRBase::ShowEPGInfo(CFileItem *item) } else if (item->IsPVRChannel()) { - CEpgInfoTag epgnow; + CEpgInfoTagPtr epgnow(item->GetPVRChannelInfoTag()->GetEPGNow()); channel = *item->GetPVRChannelInfoTag(); bHasChannel = true; - if (!item->GetPVRChannelInfoTag()->GetEPGNow(epgnow)) + if (!epgnow) { CGUIDialogOK::ShowAndGetInput(19033,0,19055,0); return; @@ -514,7 +512,10 @@ bool CGUIWindowPVRBase::ActionInputChannelNumber(int input) m_viewControl.GetCurrentControl() == GUIDE_VIEW_TIMELINE) { CGUIEPGGridContainer* epgGridContainer = (CGUIEPGGridContainer*) GetControl(m_viewControl.GetCurrentControl()); - epgGridContainer->SetChannel((*(*it)->GetEPGInfoTag()->ChannelTag())); + if ((*it)->HasEPGInfoTag() && (*it)->GetEPGInfoTag()->HasPVRChannel()) + epgGridContainer->SetChannel(*(*it)->GetEPGInfoTag()->ChannelTag()); + else + epgGridContainer->SetChannel(*(*it)->GetPVRChannelInfoTag()); } else m_viewControl.SetSelectedItem(itemIndex); @@ -553,8 +554,8 @@ bool CGUIWindowPVRBase::ActionPlayEpg(CFileItem *item) return false; CPVRChannelPtr channel; - CEpgInfoTag *epgTag = item->GetEPGInfoTag(); - if (epgTag->HasPVRChannel()) + CEpgInfoTagPtr epgTag(item->GetEPGInfoTag()); + if (epgTag && epgTag->HasPVRChannel()) channel = epgTag->ChannelTag(); if (!channel || !g_PVRManager.CheckParentalLock(*channel)) @@ -610,7 +611,7 @@ bool CGUIWindowPVRBase::ActionRecord(CFileItem *item) { bool bReturn = false; - CEpgInfoTag *epgTag = item->GetEPGInfoTag(); + CEpgInfoTagPtr epgTag(item->GetEPGInfoTag()); if (!epgTag) return bReturn; diff --git a/xbmc/pvr/windows/GUIWindowPVRBase.h b/xbmc/pvr/windows/GUIWindowPVRBase.h index 9df7f8b877..6bfbe38cc1 100644 --- a/xbmc/pvr/windows/GUIWindowPVRBase.h +++ b/xbmc/pvr/windows/GUIWindowPVRBase.h @@ -27,7 +27,9 @@ #define CONTROL_BTNSORTBY 3 #define CONTROL_BTNSORTASC 4 #define CONTROL_BTNGROUPITEMS 5 +#define CONTROL_BTNSHOWHIDDEN 6 #define CONTROL_BTNCHANNELGROUPS 28 +#define CONTROL_BTNFILTERCHANNELS 31 #define CONTROL_LABEL_HEADER1 29 #define CONTROL_LABEL_HEADER2 30 @@ -68,7 +70,7 @@ namespace PVR virtual void SetInvalid(); static std::string GetSelectedItemPath(bool bRadio); - static void SetSelectedItemPath(bool bRadio, const std::string path); + static void SetSelectedItemPath(bool bRadio, const std::string &path); protected: CGUIWindowPVRBase(bool bRadio, int id, const std::string &xmlFile); diff --git a/xbmc/pvr/windows/GUIWindowPVRChannels.cpp b/xbmc/pvr/windows/GUIWindowPVRChannels.cpp index 131cd6e8ac..f4704620af 100644 --- a/xbmc/pvr/windows/GUIWindowPVRChannels.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRChannels.cpp @@ -26,18 +26,18 @@ #include "dialogs/GUIDialogOK.h" #include "dialogs/GUIDialogYesNo.h" #include "guilib/GUIKeyboardFactory.h" +#include "guilib/GUIRadioButtonControl.h" #include "guilib/GUIWindowManager.h" #include "guilib/Key.h" #include "GUIInfoManager.h" -#include "profiles/ProfilesManager.h" #include "pvr/PVRManager.h" #include "pvr/channels/PVRChannelGroupsContainer.h" #include "pvr/dialogs/GUIDialogPVRGroupManager.h" +#include "pvr/dialogs/GUIDialogPVRChannelManager.h" #include "pvr/addons/PVRClients.h" #include "pvr/timers/PVRTimers.h" #include "epg/EpgContainer.h" #include "settings/Settings.h" -#include "storage/MediaManager.h" #include "utils/log.h" #include "threads/SingleLock.h" @@ -84,29 +84,16 @@ void CGUIWindowPVRChannels::GetContextButtons(int itemNumber, CContextButtons &b { buttons.Add(CONTEXT_BUTTON_INFO, 19047); /* channel info */ buttons.Add(CONTEXT_BUTTON_FIND, 19003); /* find similar program */ - buttons.Add(CONTEXT_BUTTON_PLAY_ITEM, 19000); /* switch to channel */ buttons.Add(CONTEXT_BUTTON_RECORD_ITEM, channel->IsRecording() ? 19256 : 19255); /* start/stop recording on channel */ - buttons.Add(CONTEXT_BUTTON_SET_THUMB, 19284); /* change icon */ - buttons.Add(CONTEXT_BUTTON_GROUP_MANAGER, 19048); /* group manager */ - buttons.Add(CONTEXT_BUTTON_HIDE, m_bShowHiddenChannels ? 19049 : 19054); /* show/hide channel */ - - if (m_vecItems->Size() > 1 && !m_bShowHiddenChannels) - buttons.Add(CONTEXT_BUTTON_MOVE, 116); /* move channel up or down */ - - if (m_bShowHiddenChannels || g_PVRChannelGroups->GetGroupAllTV()->GetNumHiddenChannels() > 0) - buttons.Add(CONTEXT_BUTTON_SHOW_HIDDEN, m_bShowHiddenChannels ? 19050 : 19051); /* show hidden/visible channels */ if (g_PVRClients->HasMenuHooks(pItem->GetPVRChannelInfoTag()->ClientID(), PVR_MENUHOOK_CHANNEL)) buttons.Add(CONTEXT_BUTTON_MENU_HOOKS, 19195); /* PVR client specific action */ - CPVRChannel *channel = pItem->GetPVRChannelInfoTag(); - buttons.Add(CONTEXT_BUTTON_ADD_LOCK, channel->IsLocked() ? 19258 : 19257); /* show lock/unlock channel */ - - buttons.Add(CONTEXT_BUTTON_FILTER, 19249); /* filter channels */ - buttons.Add(CONTEXT_BUTTON_UPDATE_EPG, 19251); /* update EPG information */ + // Add parent buttons before the Manage button + CGUIWindowPVRBase::GetContextButtons(itemNumber, buttons); + + buttons.Add(CONTEXT_BUTTON_EDIT, 16106); /* "Manage" submenu */ } - - CGUIWindowPVRBase::GetContextButtons(itemNumber, buttons); } std::string CGUIWindowPVRChannels::GetDirectoryPath(void) @@ -122,18 +109,12 @@ bool CGUIWindowPVRChannels::OnContextButton(int itemNumber, CONTEXT_BUTTON butto return false; CFileItemPtr pItem = m_vecItems->Get(itemNumber); - return OnContextButtonPlay(pItem.get(), button) || - OnContextButtonMove(pItem.get(), button) || - OnContextButtonHide(pItem.get(), button) || - OnContextButtonShowHidden(pItem.get(), button) || - OnContextButtonSetThumb(pItem.get(), button) || - OnContextButtonAdd(pItem.get(), button) || + return OnContextButtonAdd(pItem.get(), button) || OnContextButtonInfo(pItem.get(), button) || OnContextButtonGroupManager(pItem.get(), button) || - OnContextButtonFilter(pItem.get(), button) || OnContextButtonUpdateEpg(pItem.get(), button) || OnContextButtonRecord(pItem.get(), button) || - OnContextButtonLock(pItem.get(), button) || + OnContextButtonManage(pItem.get(), button) || CGUIWindowPVRBase::OnContextButton(itemNumber, button); } @@ -215,6 +196,25 @@ bool CGUIWindowPVRChannels::OnMessage(CGUIMessage& message) } } } + else if (message.GetSenderId() == CONTROL_BTNSHOWHIDDEN) + { + CGUIRadioButtonControl *radioButton = (CGUIRadioButtonControl*)GetControl(CONTROL_BTNSHOWHIDDEN); + if (radioButton) + { + m_bShowHiddenChannels = radioButton->IsSelected(); + Update(GetDirectoryPath()); + } + + bReturn = true; + } + else if (message.GetSenderId() == CONTROL_BTNFILTERCHANNELS) + { + std::string filter = GetProperty("filter").asString(); + CGUIKeyboardFactory::ShowAndGetFilter(filter, false); + OnFilterItems(filter); + + bReturn = true; + } break; case GUI_MSG_REFRESH_LIST: switch(message.GetParam1()) @@ -269,61 +269,6 @@ bool CGUIWindowPVRChannels::OnContextButtonGroupManager(CFileItem *item, CONTEXT return bReturn; } -bool CGUIWindowPVRChannels::OnContextButtonHide(CFileItem *item, CONTEXT_BUTTON button) -{ - bool bReturn = false; - - if (button == CONTEXT_BUTTON_HIDE) - { - CPVRChannel *channel = item->GetPVRChannelInfoTag(); - if (!channel || channel->IsRadio() != m_bRadio) - return bReturn; - - CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); - if (!pDialog) - return bReturn; - - pDialog->SetHeading(19039); - pDialog->SetLine(0, ""); - pDialog->SetLine(1, channel->ChannelName()); - pDialog->SetLine(2, ""); - pDialog->DoModal(); - - if (!pDialog->IsConfirmed()) - return bReturn; - - g_PVRManager.GetPlayingGroup(m_bRadio)->RemoveFromGroup(*channel); - Refresh(true); - - bReturn = true; - } - - return bReturn; -} - -bool CGUIWindowPVRChannels::OnContextButtonLock(CFileItem *item, CONTEXT_BUTTON button) -{ - bool bReturn = false; - - if (button == CONTEXT_BUTTON_ADD_LOCK) - { - // ask for PIN first - if (!g_PVRManager.CheckParentalPIN(g_localizeStrings.Get(19262).c_str())) - return bReturn; - - CPVRChannelGroupPtr group = g_PVRChannelGroups->GetGroupAll(m_bRadio); - if (!group) - return bReturn; - - group->ToggleChannelLocked(*item); - Refresh(true); - - bReturn = true; - } - - return bReturn; -} - bool CGUIWindowPVRChannels::OnContextButtonInfo(CFileItem *item, CONTEXT_BUTTON button) { bool bReturn = false; @@ -337,107 +282,38 @@ bool CGUIWindowPVRChannels::OnContextButtonInfo(CFileItem *item, CONTEXT_BUTTON return bReturn; } -bool CGUIWindowPVRChannels::OnContextButtonMove(CFileItem *item, CONTEXT_BUTTON button) +bool CGUIWindowPVRChannels::OnContextButtonManage(CFileItem *item, CONTEXT_BUTTON button) { bool bReturn = false; - if (button == CONTEXT_BUTTON_MOVE) + if (button == CONTEXT_BUTTON_EDIT) { - CPVRChannel *channel = item->GetPVRChannelInfoTag(); - if (!channel || channel->IsRadio() != m_bRadio) - return bReturn; - - std::string strIndex; - strIndex = StringUtils::Format("%i", channel->ChannelNumber()); - CGUIDialogNumeric::ShowAndGetNumber(strIndex, g_localizeStrings.Get(19052)); - int newIndex = atoi(strIndex.c_str()); - - if (newIndex != channel->ChannelNumber()) + // Create context sub menu + CContextButtons buttons; + buttons.Add(CONTEXT_BUTTON_GROUP_MANAGER, 19048); + buttons.Add(CONTEXT_BUTTON_CHANNEL_MANAGER, 19199); + buttons.Add(CONTEXT_BUTTON_UPDATE_EPG, 19251); + + // Get the response + int button = CGUIDialogContextMenu::ShowAndGetChoice(buttons); + if (button >= 0) { - g_PVRManager.GetPlayingGroup()->MoveChannel(channel->ChannelNumber(), newIndex); - Refresh(true); - } - - bReturn = true; - } - - return bReturn; -} - -bool CGUIWindowPVRChannels::OnContextButtonPlay(CFileItem *item, CONTEXT_BUTTON button) -{ - bool bReturn = false; - - if (button == CONTEXT_BUTTON_PLAY_ITEM) - { - /* play channel */ - bReturn = PlayFile(item, CSettings::Get().GetBool("pvrplayback.playminimized")); - } - - return bReturn; -} - -bool CGUIWindowPVRChannels::OnContextButtonSetThumb(CFileItem *item, CONTEXT_BUTTON button) -{ - bool bReturn = false; - - if (button == CONTEXT_BUTTON_SET_THUMB) - { - if (CProfilesManager::Get().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked()) - return bReturn; - else if (!g_passwordManager.IsMasterLockUnlocked(true)) - return bReturn; - - /* setup our thumb list */ - CFileItemList items; - CPVRChannel *channel = item->GetPVRChannelInfoTag(); - - if (!channel->IconPath().empty()) - { - /* add the current icon, if available */ - CFileItemPtr current(new CFileItem("thumb://Current", false)); - current->SetArt("thumb", channel->IconPath()); - current->SetLabel(g_localizeStrings.Get(19282)); - items.Add(current); - } - else if (item->HasArt("thumb")) - { - /* already have a thumb that the share doesn't know about - must be a local one, so we may as well reuse it */ - CFileItemPtr current(new CFileItem("thumb://Current", false)); - current->SetArt("thumb", item->GetArt("thumb")); - current->SetLabel(g_localizeStrings.Get(19282)); - items.Add(current); - } - - /* and add a "no thumb" entry as well */ - CFileItemPtr nothumb(new CFileItem("thumb://None", false)); - nothumb->SetIconImage(item->GetIconImage()); - nothumb->SetLabel(g_localizeStrings.Get(19283)); - items.Add(nothumb); - - std::string strThumb; - VECSOURCES shares; - if (CSettings::Get().GetString("pvrmenu.iconpath") != "") - { - CMediaSource share1; - share1.strPath = CSettings::Get().GetString("pvrmenu.iconpath"); - share1.strName = g_localizeStrings.Get(19066); - shares.push_back(share1); - } - g_mediaManager.GetLocalDrives(shares); - if (!CGUIDialogFileBrowser::ShowAndGetImage(items, shares, g_localizeStrings.Get(19285), strThumb, NULL, 19285)) - return bReturn; - - if (strThumb != "thumb://Current") - { - if (strThumb == "thumb://None") - strThumb = ""; - - CPVRChannelGroupPtr group = g_PVRChannelGroups->GetGroupAll(channel->IsRadio()); - CPVRChannelPtr channelPtr = group->GetByUniqueID(channel->UniqueID()); + switch ((CONTEXT_BUTTON)button) + { + case CONTEXT_BUTTON_GROUP_MANAGER: + ShowGroupManager(); + break; + case CONTEXT_BUTTON_CHANNEL_MANAGER: + ShowChannelManager(); + break; + case CONTEXT_BUTTON_UPDATE_EPG: + OnContextButtonUpdateEpg(item, (CONTEXT_BUTTON)button); + break; + default: + break; + } - channelPtr->SetIconPath(strThumb, true); - channelPtr->Persist(); + // Refresh the list in case anything was changed Refresh(true); } @@ -447,36 +323,6 @@ bool CGUIWindowPVRChannels::OnContextButtonSetThumb(CFileItem *item, CONTEXT_BUT return bReturn; } -bool CGUIWindowPVRChannels::OnContextButtonShowHidden(CFileItem *item, CONTEXT_BUTTON button) -{ - bool bReturn = false; - - if (button == CONTEXT_BUTTON_SHOW_HIDDEN) - { - m_bShowHiddenChannels = !m_bShowHiddenChannels; - Update(GetDirectoryPath()); - bReturn = true; - } - - return bReturn; -} - -bool CGUIWindowPVRChannels::OnContextButtonFilter(CFileItem *item, CONTEXT_BUTTON button) -{ - bool bReturn = false; - - if (button == CONTEXT_BUTTON_FILTER) - { - std::string filter = GetProperty("filter").asString(); - CGUIKeyboardFactory::ShowAndGetFilter(filter, false); - OnFilterItems(filter); - - bReturn = true; - } - - return bReturn; -} - bool CGUIWindowPVRChannels::OnContextButtonRecord(CFileItem *item, CONTEXT_BUTTON button) { bool bReturn(false); @@ -523,6 +369,13 @@ bool CGUIWindowPVRChannels::OnContextButtonUpdateEpg(CFileItem *item, CONTEXT_BU return bReturn; } +void CGUIWindowPVRChannels::ShowChannelManager() +{ + CGUIDialogPVRChannelManager *dialog = (CGUIDialogPVRChannelManager *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_CHANNEL_MANAGER); + if (dialog) + dialog->DoModal(); +} + void CGUIWindowPVRChannels::ShowGroupManager(void) { /* Load group manager dialog */ diff --git a/xbmc/pvr/windows/GUIWindowPVRChannels.h b/xbmc/pvr/windows/GUIWindowPVRChannels.h index abb0d5390c..fee49a2cea 100644 --- a/xbmc/pvr/windows/GUIWindowPVRChannels.h +++ b/xbmc/pvr/windows/GUIWindowPVRChannels.h @@ -45,17 +45,12 @@ namespace PVR private: bool OnContextButtonAdd(CFileItem *item, CONTEXT_BUTTON button); bool OnContextButtonGroupManager(CFileItem *item, CONTEXT_BUTTON button); - bool OnContextButtonHide(CFileItem *item, CONTEXT_BUTTON button); bool OnContextButtonInfo(CFileItem *item, CONTEXT_BUTTON button); - bool OnContextButtonMove(CFileItem *item, CONTEXT_BUTTON button); - bool OnContextButtonPlay(CFileItem *item, CONTEXT_BUTTON button); - bool OnContextButtonSetThumb(CFileItem *item, CONTEXT_BUTTON button); - bool OnContextButtonShowHidden(CFileItem *item, CONTEXT_BUTTON button); - bool OnContextButtonFilter(CFileItem *item, CONTEXT_BUTTON button); + bool OnContextButtonManage(CFileItem *item, CONTEXT_BUTTON button); bool OnContextButtonUpdateEpg(CFileItem *item, CONTEXT_BUTTON button); bool OnContextButtonRecord(CFileItem *item, CONTEXT_BUTTON button); - bool OnContextButtonLock(CFileItem *item, CONTEXT_BUTTON button); + void ShowChannelManager(); void ShowGroupManager(void); bool m_bShowHiddenChannels; diff --git a/xbmc/pvr/windows/GUIWindowPVRGuide.cpp b/xbmc/pvr/windows/GUIWindowPVRGuide.cpp index c8f2fc0db8..b2ec1f6c68 100644 --- a/xbmc/pvr/windows/GUIWindowPVRGuide.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRGuide.cpp @@ -42,7 +42,6 @@ CGUIWindowPVRGuide::CGUIWindowPVRGuide(bool bRadio) : CGUIWindowPVRBase(bRadio, bRadio ? WINDOW_RADIO_GUIDE : WINDOW_TV_GUIDE, "MyPVRGuide.xml") { m_bUpdateRequired = false; - m_bShowHiddenChannels = false; m_cachedTimeline = new CFileItemList; m_cachedChannelGroup = CPVRChannelGroupPtr(new CPVRChannelGroup); } @@ -79,7 +78,7 @@ void CGUIWindowPVRGuide::GetContextButtons(int itemNumber, CContextButtons &butt else buttons.Add(CONTEXT_BUTTON_STOP_RECORD, 19060); /* delete timer */ } - else if (pItem->GetEPGInfoTag()->EndAsLocalTime() > CDateTime::GetCurrentDateTime()) + else if (pItem->HasEPGInfoTag() && pItem->GetEPGInfoTag()->EndAsLocalTime() > CDateTime::GetCurrentDateTime()) { if (pItem->GetEPGInfoTag()->StartAsLocalTime() < CDateTime::GetCurrentDateTime()) buttons.Add(CONTEXT_BUTTON_START_RECORD, 264); /* record */ @@ -97,7 +96,8 @@ void CGUIWindowPVRGuide::GetContextButtons(int itemNumber, CContextButtons &butt buttons.Add(CONTEXT_BUTTON_END, 19064); /* go to end */ } - if (pItem->GetEPGInfoTag()->HasPVRChannel() && + if (pItem->HasEPGInfoTag() && + pItem->GetEPGInfoTag()->HasPVRChannel() && g_PVRClients->HasMenuHooks(pItem->GetEPGInfoTag()->ChannelTag()->ClientID(), PVR_MENUHOOK_EPG)) buttons.Add(CONTEXT_BUTTON_MENU_HOOKS, 19195); /* PVR client specific action */ diff --git a/xbmc/pvr/windows/GUIWindowPVRGuide.h b/xbmc/pvr/windows/GUIWindowPVRGuide.h index 964f6a2a38..cc6dcb6bc4 100644 --- a/xbmc/pvr/windows/GUIWindowPVRGuide.h +++ b/xbmc/pvr/windows/GUIWindowPVRGuide.h @@ -65,7 +65,6 @@ namespace PVR CFileItemList *m_cachedTimeline; CPVRChannelGroupPtr m_cachedChannelGroup; - bool m_bShowHiddenChannels; bool m_bUpdateRequired; }; } diff --git a/xbmc/pvr/windows/GUIWindowPVRSearch.cpp b/xbmc/pvr/windows/GUIWindowPVRSearch.cpp index 3a5b82e7f8..bfbbaf134e 100644 --- a/xbmc/pvr/windows/GUIWindowPVRSearch.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRSearch.cpp @@ -106,13 +106,16 @@ bool CGUIWindowPVRSearch::OnContextButton(const CFileItem &item, CONTEXT_BUTTON case CONTEXT_BUTTON_FIND: { m_searchfilter.Reset(); - CEpgInfoTag tag; // construct the search term if (item.IsEPG()) m_searchfilter.m_strSearchTerm = "\"" + item.GetEPGInfoTag()->Title() + "\""; - else if (item.IsPVRChannel() && item.GetPVRChannelInfoTag()->GetEPGNow(tag)) - m_searchfilter.m_strSearchTerm = "\"" + tag.Title() + "\""; + else if (item.IsPVRChannel()) + { + CEpgInfoTagPtr tag(item.GetPVRChannelInfoTag()->GetEPGNow()); + if (tag) + m_searchfilter.m_strSearchTerm = "\"" + tag->Title() + "\""; + } else if (item.IsPVRRecording()) m_searchfilter.m_strSearchTerm = "\"" + item.GetPVRRecordingInfoTag()->m_strTitle + "\""; else if (item.IsPVRTimer()) diff --git a/xbmc/rendering/RenderSystem.h b/xbmc/rendering/RenderSystem.h index fa64ebae36..9f4aaa47c1 100644 --- a/xbmc/rendering/RenderSystem.h +++ b/xbmc/rendering/RenderSystem.h @@ -26,8 +26,8 @@ #include "guilib/Geometry.h" #include "guilib/TransformMatrix.h" #include "guilib/DirtyRegion.h" -#include "utils/StdString.h" #include <stdint.h> +#include <string> typedef enum _RenderingSystemType { @@ -133,9 +133,9 @@ public: virtual void Project(float &x, float &y, float &z) { } void GetRenderVersion(unsigned int& major, unsigned int& minor) const; - const CStdString& GetRenderVendor() const { return m_RenderVendor; } - const CStdString& GetRenderRenderer() const { return m_RenderRenderer; } - const CStdString& GetRenderVersionString() const { return m_RenderVersion; } + const std::string& GetRenderVendor() const { return m_RenderVendor; } + const std::string& GetRenderRenderer() const { return m_RenderRenderer; } + const std::string& GetRenderVersionString() const { return m_RenderVersion; } bool SupportsDXT() const; bool SupportsBGRA() const; bool SupportsBGRAApple() const; @@ -152,9 +152,9 @@ protected: unsigned int m_maxTextureSize; unsigned int m_minDXTPitch; - CStdString m_RenderRenderer; - CStdString m_RenderVendor; - CStdString m_RenderVersion; + std::string m_RenderRenderer; + std::string m_RenderVendor; + std::string m_RenderVersion; int m_RenderVersionMinor; int m_RenderVersionMajor; unsigned int m_renderCaps; diff --git a/xbmc/rendering/gl/RenderSystemGL.cpp b/xbmc/rendering/gl/RenderSystemGL.cpp index 58840c4657..1496493853 100644 --- a/xbmc/rendering/gl/RenderSystemGL.cpp +++ b/xbmc/rendering/gl/RenderSystemGL.cpp @@ -26,6 +26,7 @@ #include "RenderSystemGL.h" #include "guilib/GraphicContext.h" #include "settings/AdvancedSettings.h" +#include "guilib/MatrixGLES.h" #include "settings/DisplaySettings.h" #include "utils/log.h" #include "utils/GLUtils.h" @@ -78,8 +79,8 @@ void CRenderSystemGL::CheckOpenGLQuirks() if (StringUtils::EqualsNoCase(m_RenderVendor, "nouveau")) m_renderQuirks |= RENDER_QUIRKS_YV12_PREFERED; - if (m_RenderVendor.Equals("Tungsten Graphics, Inc.") - || m_RenderVendor.Equals("Tungsten Graphics, Inc")) + if (StringUtils::EqualsNoCase(m_RenderVendor, "Tungsten Graphics, Inc.") + || StringUtils::EqualsNoCase(m_RenderVendor, "Tungsten Graphics, Inc")) { unsigned major, minor, micro; if (sscanf(m_RenderVersion.c_str(), "%*s Mesa %u.%u.%u", &major, &minor, µ) == 3) @@ -182,16 +183,25 @@ bool CRenderSystemGL::ResetRenderSystem(int width, int height, bool fullScreen, CalculateMaxTexturesize(); - glViewport(0, 0, width, height); - glScissor(0, 0, width, height); + CRect rect( 0, 0, width, height ); + SetViewPort( rect ); glEnable(GL_TEXTURE_2D); glEnable(GL_SCISSOR_TEST); - //ati doesn't init the texture matrix correctly - //so we have to do it ourselves - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); + glMatrixProject.Clear(); + glMatrixModview->LoadIdentity(); + glMatrixProject->Ortho(0.0f, width-1, height-1, 0.0f, -1.0f, 1.0f); + glMatrixProject.Load(); + + glMatrixModview.Clear(); + glMatrixModview->LoadIdentity(); + glMatrixModview.Load(); + + glMatrixTexture.Clear(); + glMatrixTexture->LoadIdentity(); + glMatrixTexture.Load(); + if (glewIsSupported("GL_ARB_multitexture")) { //clear error flags @@ -217,19 +227,11 @@ bool CRenderSystemGL::ResetRenderSystem(int width, int height, bool fullScreen, for (GLint i = 0; i < maxtex; i++) { glActiveTextureARB(GL_TEXTURE0 + i); - glLoadIdentity(); + glMatrixTexture.Load(); } glActiveTextureARB(GL_TEXTURE0); } - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - glOrtho(0.0f, width-1, height-1, 0.0f, -1.0f, 1.0f); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnable(GL_BLEND); // Turn Blending On glDisable(GL_DEPTH_TEST); @@ -284,7 +286,7 @@ bool CRenderSystemGL::ClearBuffers(color_t color) bool CRenderSystemGL::IsExtSupported(const char* extension) { - CStdString name; + std::string name; name = " "; name += extension; name += " "; @@ -392,15 +394,11 @@ void CRenderSystemGL::CaptureStateBlock() { if (!m_bRenderCreated) return; - - glGetIntegerv(GL_VIEWPORT, m_viewPort); - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glMatrixMode(GL_TEXTURE); - glPushMatrix(); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); + glMatrixProject.Push(); + glMatrixModview.Push(); + glMatrixTexture.Push(); + glDisable(GL_SCISSOR_TEST); // fixes FBO corruption on Macs if (glActiveTextureARB) glActiveTextureARB(GL_TEXTURE0_ARB); @@ -415,12 +413,11 @@ void CRenderSystemGL::ApplyStateBlock() return; glViewport(m_viewPort[0], m_viewPort[1], m_viewPort[2], m_viewPort[3]); - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_TEXTURE); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); + + glMatrixProject.PopLoad(); + glMatrixModview.PopLoad(); + glMatrixTexture.PopLoad(); + if (glActiveTextureARB) glActiveTextureARB(GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_2D); @@ -438,34 +435,28 @@ void CRenderSystemGL::SetCameraPosition(const CPoint &camera, int screenWidth, i CPoint offset = camera - CPoint(screenWidth*0.5f, screenHeight*0.5f); - GLint viewport[4]; - glGetIntegerv(GL_VIEWPORT, viewport); - float w = (float)viewport[2]*0.5f; - float h = (float)viewport[3]*0.5f; + float w = (float)m_viewPort[2]*0.5f; + float h = (float)m_viewPort[3]*0.5f; - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(-(w + offset.x), +(h + offset.y), 0); - gluLookAt(0.0, 0.0, -2.0*h, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum( (-w - offset.x)*0.5f, (w - offset.x)*0.5f, (-h + offset.y)*0.5f, (h + offset.y)*0.5f, h, 100*h); - glMatrixMode(GL_MODELVIEW); + glMatrixModview->LoadIdentity(); + glMatrixModview->Translatef(-(w + offset.x), +(h + offset.y), 0); + glMatrixModview->LookAt(0.0, 0.0, -2.0*h, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0); + glMatrixModview.Load(); - glGetIntegerv(GL_VIEWPORT, m_viewPort); - glGetDoublev(GL_MODELVIEW_MATRIX, m_view); - glGetDoublev(GL_PROJECTION_MATRIX, m_projection); + glMatrixProject->LoadIdentity(); + glMatrixProject->Frustum( (-w - offset.x)*0.5f, (w - offset.x)*0.5f, (-h + offset.y)*0.5f, (h + offset.y)*0.5f, h, 100*h); + glMatrixProject.Load(); g_graphicsContext.EndPaint(); } void CRenderSystemGL::Project(float &x, float &y, float &z) { - GLdouble coordX, coordY, coordZ; - if (gluProject(x, y, z, m_view, m_projection, m_viewPort, &coordX, &coordY, &coordZ) == GLU_TRUE) + GLfloat coordX, coordY, coordZ; + if (CMatrixGL::Project(x, y, z, glMatrixModview.Get(), glMatrixProject.Get(), m_viewPort, &coordX, &coordY, &coordZ)) { - x = (float)coordX; + x = coordX; y = (float)(m_viewPort[1] + m_viewPort[3] - coordY); z = 0; } @@ -494,12 +485,11 @@ void CRenderSystemGL::ApplyHardwareTransform(const TransformMatrix &finalMatrix) if (!m_bRenderCreated) return; - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); + glMatrixModview.Push(); GLfloat matrix[4][4]; - for(int i=0;i<3;i++) - for(int j=0;j<4;j++) + for(int i = 0; i < 3; i++) + for(int j = 0; j < 4; j++) matrix[j][i] = finalMatrix.m[i][j]; matrix[0][3] = 0.0f; @@ -507,7 +497,8 @@ void CRenderSystemGL::ApplyHardwareTransform(const TransformMatrix &finalMatrix) matrix[2][3] = 0.0f; matrix[3][3] = 1.0f; - glMultMatrixf(&matrix[0][0]); + glMatrixModview->MultMatrixf(&matrix[0][0]); + glMatrixModview.Load(); } void CRenderSystemGL::RestoreHardwareTransform() @@ -515,8 +506,7 @@ void CRenderSystemGL::RestoreHardwareTransform() if (!m_bRenderCreated) return; - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); + glMatrixModview.PopLoad(); } void CRenderSystemGL::CalculateMaxTexturesize() @@ -555,10 +545,10 @@ void CRenderSystemGL::CalculateMaxTexturesize() // Problem noticed on: // iMac with ATI Radeon X1600, both on 10.5.8 (GL_VERSION: 2.0 ATI-1.5.48) // and 10.6.2 (GL_VERSION: 2.0 ATI-1.6.6) - if (strcmp(m_RenderRenderer, "ATI Radeon X1600 OpenGL Engine") == 0) + if (m_RenderRenderer == "ATI Radeon X1600 OpenGL Engine") m_maxTextureSize = 2048; // Mac mini G4 with ATI Radeon 9200 (GL_VERSION: 1.3 ATI-1.5.48) - else if (strcmp(m_RenderRenderer, "ATI Radeon 9200 OpenGL Engine") == 0) + else if (m_RenderRenderer == "ATI Radeon 9200 OpenGL Engine") m_maxTextureSize = 1024; #endif @@ -570,13 +560,10 @@ void CRenderSystemGL::GetViewPort(CRect& viewPort) if (!m_bRenderCreated) return; - GLint glvp[4]; - glGetIntegerv(GL_VIEWPORT, glvp); - - viewPort.x1 = glvp[0]; - viewPort.y1 = m_height - glvp[1] - glvp[3]; - viewPort.x2 = glvp[0] + glvp[2]; - viewPort.y2 = viewPort.y1 + glvp[3]; + viewPort.x1 = m_viewPort[0]; + viewPort.y1 = m_height - m_viewPort[1] - m_viewPort[3]; + viewPort.x2 = m_viewPort[0] + m_viewPort[2]; + viewPort.y2 = viewPort.y1 + m_viewPort[3]; } void CRenderSystemGL::SetViewPort(CRect& viewPort) @@ -586,6 +573,10 @@ void CRenderSystemGL::SetViewPort(CRect& viewPort) glScissor((GLint) viewPort.x1, (GLint) (m_height - viewPort.y1 - viewPort.Height()), (GLsizei) viewPort.Width(), (GLsizei) viewPort.Height()); glViewport((GLint) viewPort.x1, (GLint) (m_height - viewPort.y1 - viewPort.Height()), (GLsizei) viewPort.Width(), (GLsizei) viewPort.Height()); + m_viewPort[0] = viewPort.x1; + m_viewPort[1] = m_height - viewPort.y1 - viewPort.Height(); + m_viewPort[2] = viewPort.Width(); + m_viewPort[3] = viewPort.Height(); } void CRenderSystemGL::SetScissors(const CRect &rect) diff --git a/xbmc/rendering/gl/RenderSystemGL.h b/xbmc/rendering/gl/RenderSystemGL.h index 28d4b783fc..d4e1bf4559 100644 --- a/xbmc/rendering/gl/RenderSystemGL.h +++ b/xbmc/rendering/gl/RenderSystemGL.h @@ -86,13 +86,11 @@ protected: int m_width; int m_height; - CStdString m_RenderExtensions; + std::string m_RenderExtensions; int m_glslMajor; int m_glslMinor; - GLdouble m_view[16]; - GLdouble m_projection[16]; GLint m_viewPort[4]; }; diff --git a/xbmc/rendering/gles/RenderSystemGLES.cpp b/xbmc/rendering/gles/RenderSystemGLES.cpp index 653c9ecf04..2aeaeeccba 100644 --- a/xbmc/rendering/gles/RenderSystemGLES.cpp +++ b/xbmc/rendering/gles/RenderSystemGLES.cpp @@ -137,14 +137,19 @@ bool CRenderSystemGLES::ResetRenderSystem(int width, int height, bool fullScreen glEnable(GL_SCISSOR_TEST); - g_matrices.MatrixMode(MM_PROJECTION); - g_matrices.LoadIdentity(); + glMatrixProject.Clear(); + glMatrixModview->LoadIdentity(); + glMatrixProject->Ortho(0.0f, width-1, height-1, 0.0f, -1.0f, 1.0f); + glMatrixProject.Load(); - g_matrices.Ortho(0.0f, width-1, height-1, 0.0f, -1.0f, 1.0f); + glMatrixModview.Clear(); + glMatrixModview->LoadIdentity(); + glMatrixModview.Load(); + + glMatrixTexture.Clear(); + glMatrixTexture->LoadIdentity(); + glMatrixTexture.Load(); - g_matrices.MatrixMode(MM_MODELVIEW); - g_matrices.LoadIdentity(); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnable(GL_BLEND); // Turn Blending On glDisable(GL_DEPTH_TEST); @@ -238,7 +243,7 @@ bool CRenderSystemGLES::IsExtSupported(const char* extension) } else { - CStdString name; + std::string name; name = " "; name += extension; name += " "; @@ -357,12 +362,10 @@ void CRenderSystemGLES::CaptureStateBlock() if (!m_bRenderCreated) return; - g_matrices.MatrixMode(MM_PROJECTION); - g_matrices.PushMatrix(); - g_matrices.MatrixMode(MM_TEXTURE); - g_matrices.PushMatrix(); - g_matrices.MatrixMode(MM_MODELVIEW); - g_matrices.PushMatrix(); + glMatrixProject.Push(); + glMatrixModview.Push(); + glMatrixTexture.Push(); + glDisable(GL_SCISSOR_TEST); // fixes FBO corruption on Macs glActiveTexture(GL_TEXTURE0); //TODO - NOTE: Only for Screensavers & Visualisations @@ -374,12 +377,9 @@ void CRenderSystemGLES::ApplyStateBlock() if (!m_bRenderCreated) return; - g_matrices.MatrixMode(MM_PROJECTION); - g_matrices.PopMatrix(); - g_matrices.MatrixMode(MM_TEXTURE); - g_matrices.PopMatrix(); - g_matrices.MatrixMode(MM_MODELVIEW); - g_matrices.PopMatrix(); + glMatrixProject.PopLoad(); + glMatrixModview.PopLoad(); + glMatrixTexture.PopLoad(); glActiveTexture(GL_TEXTURE0); glEnable(GL_BLEND); glEnable(GL_SCISSOR_TEST); @@ -398,20 +398,14 @@ void CRenderSystemGLES::SetCameraPosition(const CPoint &camera, int screenWidth, float w = (float)m_viewPort[2]*0.5f; float h = (float)m_viewPort[3]*0.5f; - g_matrices.MatrixMode(MM_MODELVIEW); - g_matrices.LoadIdentity(); - g_matrices.Translatef(-(w + offset.x), +(h + offset.y), 0); - g_matrices.LookAt(0.0, 0.0, -2.0*h, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0); - g_matrices.MatrixMode(MM_PROJECTION); - g_matrices.LoadIdentity(); - g_matrices.Frustum( (-w - offset.x)*0.5f, (w - offset.x)*0.5f, (-h + offset.y)*0.5f, (h + offset.y)*0.5f, h, 100*h); - g_matrices.MatrixMode(MM_MODELVIEW); - - GLfloat* matx; - matx = g_matrices.GetMatrix(MM_MODELVIEW); - memcpy(m_view, matx, 16 * sizeof(GLfloat)); - matx = g_matrices.GetMatrix(MM_PROJECTION); - memcpy(m_projection, matx, 16 * sizeof(GLfloat)); + glMatrixModview->LoadIdentity(); + glMatrixModview->Translatef(-(w + offset.x), +(h + offset.y), 0); + glMatrixModview->LookAt(0.0, 0.0, -2.0*h, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0); + glMatrixModview.Load(); + + glMatrixProject->LoadIdentity(); + glMatrixProject->Frustum( (-w - offset.x)*0.5f, (w - offset.x)*0.5f, (-h + offset.y)*0.5f, (h + offset.y)*0.5f, h, 100*h); + glMatrixProject.Load(); g_graphicsContext.EndPaint(); } @@ -419,7 +413,7 @@ void CRenderSystemGLES::SetCameraPosition(const CPoint &camera, int screenWidth, void CRenderSystemGLES::Project(float &x, float &y, float &z) { GLfloat coordX, coordY, coordZ; - if (g_matrices.Project(x, y, z, m_view, m_projection, m_viewPort, &coordX, &coordY, &coordZ)) + if (CMatrixGL::Project(x, y, z, glMatrixModview.Get(), glMatrixProject.Get(), m_viewPort, &coordX, &coordY, &coordZ)) { x = coordX; y = (float)(m_viewPort[1] + m_viewPort[3] - coordY); @@ -434,8 +428,8 @@ bool CRenderSystemGLES::TestRender() //RESOLUTION_INFO resInfo = CDisplaySettings::Get().GetCurrentResolutionInfo(); //glViewport(0, 0, resInfo.iWidth, resInfo.iHeight); - g_matrices.PushMatrix(); - g_matrices.Rotatef( theta, 0.0f, 0.0f, 1.0f ); + glMatrixModview.Push(); + glMatrixModview->Rotatef( theta, 0.0f, 0.0f, 1.0f ); EnableGUIShader(SM_DEFAULT); @@ -465,7 +459,7 @@ bool CRenderSystemGLES::TestRender() DisableGUIShader(); - g_matrices.PopMatrix(); + glMatrixModview.Pop(); theta += 1.0f; @@ -477,8 +471,7 @@ void CRenderSystemGLES::ApplyHardwareTransform(const TransformMatrix &finalMatri if (!m_bRenderCreated) return; - g_matrices.MatrixMode(MM_MODELVIEW); - g_matrices.PushMatrix(); + glMatrixModview.Push(); GLfloat matrix[4][4]; for(int i = 0; i < 3; i++) @@ -490,7 +483,8 @@ void CRenderSystemGLES::ApplyHardwareTransform(const TransformMatrix &finalMatri matrix[2][3] = 0.0f; matrix[3][3] = 1.0f; - g_matrices.MultMatrixf(&matrix[0][0]); + glMatrixModview->MultMatrixf(&matrix[0][0]); + glMatrixModview.Load(); } void CRenderSystemGLES::RestoreHardwareTransform() @@ -498,8 +492,7 @@ void CRenderSystemGLES::RestoreHardwareTransform() if (!m_bRenderCreated) return; - g_matrices.MatrixMode(MM_MODELVIEW); - g_matrices.PopMatrix(); + glMatrixModview.PopLoad(); } void CRenderSystemGLES::CalculateMaxTexturesize() diff --git a/xbmc/rendering/gles/RenderSystemGLES.h b/xbmc/rendering/gles/RenderSystemGLES.h index 98e398ae89..693b30991f 100644 --- a/xbmc/rendering/gles/RenderSystemGLES.h +++ b/xbmc/rendering/gles/RenderSystemGLES.h @@ -104,13 +104,11 @@ protected: int m_width; int m_height; - CStdString m_RenderExtensions; + std::string m_RenderExtensions; CGUIShader **m_pGUIshader; // One GUI shader for each method ESHADERMETHOD m_method; // Current GUI Shader method - GLfloat m_view[16]; - GLfloat m_projection[16]; GLint m_viewPort[4]; }; diff --git a/xbmc/settings/AdvancedSettings.cpp b/xbmc/settings/AdvancedSettings.cpp index 478d72589b..02ea40cfc4 100644 --- a/xbmc/settings/AdvancedSettings.cpp +++ b/xbmc/settings/AdvancedSettings.cpp @@ -169,6 +169,7 @@ void CAdvancedSettings::Initialize() m_videoFpsDetect = 1; m_videoBusyDialogDelay_ms = 500; m_stagefrightConfig.useAVCcodec = -1; + m_stagefrightConfig.useHEVCcodec = -1; m_stagefrightConfig.useVC1codec = -1; m_stagefrightConfig.useVPXcodec = -1; m_stagefrightConfig.useMP4codec = -1; @@ -406,11 +407,11 @@ void CAdvancedSettings::Initialize() m_extraLogLevels = 0; #if defined(TARGET_DARWIN) - CStdString logDir = getenv("HOME"); + std::string logDir = getenv("HOME"); #if defined(TARGET_DARWIN_OSX) logDir += "/Library/Logs/"; #else // ios/atv2 - logDir += "/" + CStdString(CDarwinUtils::GetAppRootFolder()) + "/"; + logDir += "/" + std::string(CDarwinUtils::GetAppRootFolder()) + "/"; #endif m_logFolder = logDir; #else @@ -440,7 +441,7 @@ bool CAdvancedSettings::Load() return true; } -void CAdvancedSettings::ParseSettingsFile(const CStdString &file) +void CAdvancedSettings::ParseSettingsFile(const std::string &file) { CXBMCTinyXML advancedXML; if (!CFile::Exists(file)) @@ -601,6 +602,7 @@ void CAdvancedSettings::ParseSettingsFile(const CStdString &file) if (pStagefrightElem) { XMLUtils::GetInt(pStagefrightElem,"useavccodec",m_stagefrightConfig.useAVCcodec, -1, 1); + XMLUtils::GetInt(pStagefrightElem,"usehevccodec",m_stagefrightConfig.useHEVCcodec, -1, 1); XMLUtils::GetInt(pStagefrightElem,"usevc1codec",m_stagefrightConfig.useVC1codec, -1, 1); XMLUtils::GetInt(pStagefrightElem,"usevpxcodec",m_stagefrightConfig.useVPXcodec, -1, 1); XMLUtils::GetInt(pStagefrightElem,"usemp4codec",m_stagefrightConfig.useMP4codec, -1, 1); @@ -956,7 +958,7 @@ void CAdvancedSettings::ParseSettingsFile(const CStdString &file) // TODO: Should cache path be given in terms of our predefined paths?? // Are we even going to have predefined paths?? - CStdString tmp; + std::string tmp; if (XMLUtils::GetPath(pRootElement, "cachepath", tmp)) m_cachePath = tmp; URIUtils::AddSlashAtEnd(m_cachePath); @@ -1000,7 +1002,7 @@ void CAdvancedSettings::ParseSettingsFile(const CStdString &file) TiXmlNode* pSubstitute = pPathSubstitution->FirstChildElement("substitute"); while (pSubstitute) { - CStdString strFrom, strTo; + std::string strFrom, strTo; TiXmlNode* pFrom = pSubstitute->FirstChild("from"); if (pFrom) strFrom = CSpecialProtocol::TranslatePath(pFrom->FirstChild()->Value()).c_str(); @@ -1233,18 +1235,18 @@ void CAdvancedSettings::GetCustomTVRegexps(TiXmlElement *pRootElement, SETTINGS_ int iDefaultSeason = 1; if (pRegExp->ToElement()) { - CStdString byDate = XMLUtils::GetAttribute(pRegExp->ToElement(), "bydate"); + std::string byDate = XMLUtils::GetAttribute(pRegExp->ToElement(), "bydate"); if (byDate == "true") { bByDate = true; } - CStdString defaultSeason = XMLUtils::GetAttribute(pRegExp->ToElement(), "defaultseason"); + std::string defaultSeason = XMLUtils::GetAttribute(pRegExp->ToElement(), "defaultseason"); if(!defaultSeason.empty()) { iDefaultSeason = atoi(defaultSeason.c_str()); } } - CStdString regExp = pRegExp->FirstChild()->Value(); + std::string regExp = pRegExp->FirstChild()->Value(); if (iAction == 2) settings.insert(settings.begin() + i++, 1, TVShowRegexp(bByDate,regExp,iDefaultSeason)); else @@ -1285,7 +1287,7 @@ void CAdvancedSettings::GetCustomRegexps(TiXmlElement *pRootElement, std::vector { if (pRegExp->FirstChild()) { - CStdString regExp = pRegExp->FirstChild()->Value(); + std::string regExp = pRegExp->FirstChild()->Value(); if (iAction == 2) settings.insert(settings.begin() + i++, 1, regExp); else @@ -1298,9 +1300,9 @@ void CAdvancedSettings::GetCustomRegexps(TiXmlElement *pRootElement, std::vector } } -void CAdvancedSettings::GetCustomExtensions(TiXmlElement *pRootElement, CStdString& extensions) +void CAdvancedSettings::GetCustomExtensions(TiXmlElement *pRootElement, std::string& extensions) { - CStdString extraExtensions; + std::string extraExtensions; if (XMLUtils::GetString(pRootElement, "add", extraExtensions) && !extraExtensions.empty()) extensions += "|" + extraExtensions; if (XMLUtils::GetString(pRootElement, "remove", extraExtensions) && !extraExtensions.empty()) @@ -1315,7 +1317,7 @@ void CAdvancedSettings::GetCustomExtensions(TiXmlElement *pRootElement, CStdStri } } -void CAdvancedSettings::AddSettingsFile(const CStdString &filename) +void CAdvancedSettings::AddSettingsFile(const std::string &filename) { m_settingsFiles.push_back(filename); } diff --git a/xbmc/settings/AdvancedSettings.h b/xbmc/settings/AdvancedSettings.h index ca995e3735..365fedeb7f 100644 --- a/xbmc/settings/AdvancedSettings.h +++ b/xbmc/settings/AdvancedSettings.h @@ -19,11 +19,11 @@ * */ +#include <string> #include <vector> #include "settings/lib/ISettingCallback.h" #include "settings/lib/ISettingsHandler.h" -#include "utils/StdString.h" #include "utils/GlobalsHandling.h" class CVariant; @@ -51,25 +51,25 @@ public: capath.clear(); ciphers.clear(); }; - CStdString type; - CStdString host; - CStdString port; - CStdString user; - CStdString pass; - CStdString name; - CStdString key; - CStdString cert; - CStdString ca; - CStdString capath; - CStdString ciphers; + std::string type; + std::string host; + std::string port; + std::string user; + std::string pass; + std::string name; + std::string key; + std::string cert; + std::string ca; + std::string capath; + std::string ciphers; }; struct TVShowRegexp { bool byDate; - CStdString regexp; + std::string regexp; int defaultSeason; - TVShowRegexp(bool d, const CStdString& r, int s = 1) + TVShowRegexp(bool d, const std::string& r, int s = 1) { byDate = d; regexp = r; @@ -100,6 +100,7 @@ struct RefreshVideoLatency struct StagefrightConfig { int useAVCcodec; + int useHEVCcodec; int useVC1codec; int useVPXcodec; int useMP4codec; @@ -124,20 +125,20 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler void Initialize(); bool Initialized() { return m_initialized; }; - void AddSettingsFile(const CStdString &filename); + void AddSettingsFile(const std::string &filename); bool Load(); void Clear(); static void GetCustomTVRegexps(TiXmlElement *pRootElement, SETTINGS_TVSHOWLIST& settings); static void GetCustomRegexps(TiXmlElement *pRootElement, std::vector<std::string> &settings); - static void GetCustomExtensions(TiXmlElement *pRootElement, CStdString& extensions); + static void GetCustomExtensions(TiXmlElement *pRootElement, std::string& extensions); bool CanLogComponent(int component) const; static void SettingOptionsLoggingComponentsFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t, void *data); int m_audioHeadRoom; float m_ac3Gain; - CStdString m_audioDefaultPlayer; + std::string m_audioDefaultPlayer; float m_audioPlayCountMinimumPercent; bool m_dvdplayerIgnoreDTSinWAV; float m_limiterHold; @@ -160,8 +161,8 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler int m_videoPercentSeekBackward; int m_videoPercentSeekForwardBig; int m_videoPercentSeekBackwardBig; - CStdString m_videoPPFFmpegDeint; - CStdString m_videoPPFFmpegPostProc; + std::string m_videoPPFFmpegDeint; + std::string m_videoPPFFmpegPostProc; bool m_videoVDPAUtelecine; bool m_videoVDPAUdeintSkipChromaHD; bool m_musicUseTimeSeeking; @@ -199,8 +200,8 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler StagefrightConfig m_stagefrightConfig; bool m_mediacodecForceSoftwareRendring; - CStdString m_videoDefaultPlayer; - CStdString m_videoDefaultDVDPlayer; + std::string m_videoDefaultPlayer; + std::string m_videoDefaultDVDPlayer; float m_videoPlayCountMinimumPercent; float m_slideshowBlackBarCompensation; @@ -212,7 +213,7 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler int m_logLevelHint; bool m_extraLogEnabled; int m_extraLogLevels; - CStdString m_cddbAddress; + std::string m_cddbAddress; //airtunes + airplay int m_airTunesPort; @@ -221,8 +222,8 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler bool m_handleMounting; bool m_fullScreenOnMovieStart; - CStdString m_cachePath; - CStdString m_videoCleanDateTimeRegExp; + std::string m_cachePath; + std::string m_videoCleanDateTimeRegExp; std::vector<std::string> m_videoCleanStringRegExps; std::vector<std::string> m_videoExcludeFromListingRegExps; std::vector<std::string> m_moviesExcludeFromScanRegExps; @@ -234,8 +235,8 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler std::vector<std::string> m_folderStackRegExps; std::vector<std::string> m_trailerMatchRegExps; SETTINGS_TVSHOWLIST m_tvshowEnumRegExps; - CStdString m_tvshowMultiPartEnumRegExp; - typedef std::vector< std::pair<CStdString, CStdString> > StringMapping; + std::string m_tvshowMultiPartEnumRegExp; + typedef std::vector< std::pair<std::string, std::string> > StringMapping; StringMapping m_pathSubstitutions; int m_remoteDelay; ///< \brief number of remote messages to ignore before repeating float m_controllerDeadzone; @@ -252,27 +253,27 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler bool m_useDDSFanart; int m_sambaclienttimeout; - CStdString m_sambadoscodepage; + std::string m_sambadoscodepage; bool m_sambastatfiles; bool m_bHTTPDirectoryStatFilesize; bool m_bFTPThumbs; - CStdString m_musicThumbs; - CStdString m_fanartImages; + std::string m_musicThumbs; + std::string m_fanartImages; bool m_bMusicLibraryHideAllItems; int m_iMusicLibraryRecentlyAddedItems; bool m_bMusicLibraryAllItemsOnBottom; bool m_bMusicLibraryAlbumsSortByArtistThenYear; bool m_bMusicLibraryCleanOnUpdate; - CStdString m_strMusicLibraryAlbumFormat; - CStdString m_strMusicLibraryAlbumFormatRight; + std::string m_strMusicLibraryAlbumFormat; + std::string m_strMusicLibraryAlbumFormatRight; bool m_prioritiseAPEv2tags; - CStdString m_musicItemSeparator; - CStdString m_videoItemSeparator; - std::vector<CStdString> m_musicTagsFromFileFilters; + std::string m_musicItemSeparator; + std::string m_videoItemSeparator; + std::vector<std::string> m_musicTagsFromFileFilters; bool m_bVideoLibraryHideAllItems; bool m_bVideoLibraryAllItemsOnBottom; @@ -351,11 +352,11 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler int m_karaokeStartIndex; // auto-assign numbering start from this value bool m_karaokeAlwaysEmptyOnCdgs; // always have empty background on CDG files bool m_karaokeUseSongSpecificBackground; // use song-specific video or image if available instead of default - CStdString m_karaokeDefaultBackgroundType; // empty string or "vis", "image" or "video" - CStdString m_karaokeDefaultBackgroundFilePath; // only for "image" or "video" types above + std::string m_karaokeDefaultBackgroundType; // empty string or "vis", "image" or "video" + std::string m_karaokeDefaultBackgroundFilePath; // only for "image" or "video" types above - CStdString m_cpuTempCmd; - CStdString m_gpuTempCmd; + std::string m_cpuTempCmd; + std::string m_gpuTempCmd; /* PVR/TV related advanced settings */ int m_iPVRTimeCorrection; /*!< @brief correct all times (epg tags, timer tags, recording tags) by this amount of minutes. defaults to 0. */ @@ -385,8 +386,8 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler unsigned int m_jsonTcpPort; bool m_enableMultimediaKeys; - std::vector<CStdString> m_settingsFiles; - void ParseSettingsFile(const CStdString &file); + std::vector<std::string> m_settingsFiles; + void ParseSettingsFile(const std::string &file); float GetDisplayLatency(float refreshrate); bool m_initialized; @@ -394,19 +395,19 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler void SetDebugMode(bool debug); // runtime settings which cannot be set from advancedsettings.xml - CStdString m_pictureExtensions; - CStdString m_musicExtensions; - CStdString m_videoExtensions; - CStdString m_discStubExtensions; - CStdString m_subtitlesExtensions; + std::string m_pictureExtensions; + std::string m_musicExtensions; + std::string m_videoExtensions; + std::string m_discStubExtensions; + std::string m_subtitlesExtensions; - CStdString m_stereoscopicregex_3d; - CStdString m_stereoscopicregex_sbs; - CStdString m_stereoscopicregex_tab; + std::string m_stereoscopicregex_3d; + std::string m_stereoscopicregex_sbs; + std::string m_stereoscopicregex_tab; - CStdString m_logFolder; + std::string m_logFolder; - CStdString m_userAgent; + std::string m_userAgent; private: void setExtraLogLevel(const std::vector<CVariant> &components); diff --git a/xbmc/settings/DisplaySettings.cpp b/xbmc/settings/DisplaySettings.cpp index 6902f83323..1fafd9ae5f 100644 --- a/xbmc/settings/DisplaySettings.cpp +++ b/xbmc/settings/DisplaySettings.cpp @@ -51,9 +51,9 @@ float square_error(float x, float y) return std::max(yonx, xony); } -static CStdString ModeFlagsToString(unsigned int flags, bool identifier) +static std::string ModeFlagsToString(unsigned int flags, bool identifier) { - CStdString res; + std::string res; if(flags & D3DPRESENTFLAG_INTERLACED) res += "i"; else @@ -138,7 +138,7 @@ bool CDisplaySettings::Load(const TiXmlNode *settings) bool found = false; for (ResolutionInfos::const_iterator it = m_calibrations.begin(); it != m_calibrations.end(); ++it) { - if (it->strMode.Equals(cal.strMode)) + if (StringUtils::EqualsNoCase(it->strMode, cal.strMode)) { found = true; break; @@ -447,7 +447,7 @@ void CDisplaySettings::ApplyCalibrations() { if (res == RES_WINDOW) continue; - if (itCal->strMode.Equals(m_resolutions[res].strMode)) + if (StringUtils::EqualsNoCase(itCal->strMode, m_resolutions[res].strMode)) { // overscan m_resolutions[res].Overscan.left = itCal->Overscan.left; @@ -500,7 +500,7 @@ void CDisplaySettings::UpdateCalibrations() bool found = false; for (ResolutionInfos::iterator itCal = m_calibrations.begin(); itCal != m_calibrations.end(); ++itCal) { - if (itCal->strMode.Equals(m_resolutions[res].strMode)) + if (StringUtils::EqualsNoCase(itCal->strMode, m_resolutions[res].strMode)) { // TODO: erase calibrations with default values *itCal = m_resolutions[res]; @@ -751,13 +751,13 @@ void CDisplaySettings::SettingOptionsPreferredStereoscopicViewModesFiller(const void CDisplaySettings::SettingOptionsMonitorsFiller(const CSetting *setting, std::vector< std::pair<std::string, std::string> > &list, std::string ¤t, void *data) { #if defined(HAS_GLX) - std::vector<CStdString> monitors; + std::vector<std::string> monitors; g_Windowing.GetConnectedOutputs(&monitors); std::string currentMonitor = CSettings::Get().GetString("videoscreen.monitor"); for (unsigned int i=0; i<monitors.size(); ++i) { if(currentMonitor.compare("Default") != 0 && - CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP).strOutput.Equals(monitors[i])) + StringUtils::EqualsNoCase(CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP).strOutput, monitors[i])) { current = monitors[i]; } diff --git a/xbmc/settings/MediaSettings.cpp b/xbmc/settings/MediaSettings.cpp index 973edba610..562b455437 100644 --- a/xbmc/settings/MediaSettings.cpp +++ b/xbmc/settings/MediaSettings.cpp @@ -128,7 +128,6 @@ bool CMediaSettings::Load(const TiXmlNode *settings) m_defaultVideoSettings.m_AudioDelay = 0.0f; if (!XMLUtils::GetFloat(pElement, "subtitledelay", m_defaultVideoSettings.m_SubtitleDelay, -10.0f, 10.0f)) m_defaultVideoSettings.m_SubtitleDelay = 0.0f; - XMLUtils::GetBoolean(pElement, "autocrop", m_defaultVideoSettings.m_Crop); XMLUtils::GetBoolean(pElement, "nonlinstretch", m_defaultVideoSettings.m_CustomNonLinStretch); if (!XMLUtils::GetInt(pElement, "stereomode", m_defaultVideoSettings.m_StereoMode)) m_defaultVideoSettings.m_StereoMode = 0; @@ -213,7 +212,6 @@ bool CMediaSettings::Save(TiXmlNode *settings) const XMLUtils::SetFloat(pNode, "gamma", m_defaultVideoSettings.m_Gamma); XMLUtils::SetFloat(pNode, "audiodelay", m_defaultVideoSettings.m_AudioDelay); XMLUtils::SetFloat(pNode, "subtitledelay", m_defaultVideoSettings.m_SubtitleDelay); - XMLUtils::SetBoolean(pNode, "autocrop", m_defaultVideoSettings.m_Crop); XMLUtils::SetBoolean(pNode, "nonlinstretch", m_defaultVideoSettings.m_CustomNonLinStretch); XMLUtils::SetInt(pNode, "stereomode", m_defaultVideoSettings.m_StereoMode); @@ -277,7 +275,7 @@ void CMediaSettings::OnSettingAction(const CSetting *setting) int retVal = CGUIDialogContextMenu::ShowAndGetChoice(choices); if ( retVal > 0 ) { - CStdString path(CProfilesManager::Get().GetDatabaseFolder()); + std::string path(CProfilesManager::Get().GetDatabaseFolder()); VECSOURCES shares; g_mediaManager.GetLocalDrives(shares); if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(661), path, true)) @@ -301,7 +299,7 @@ void CMediaSettings::OnSettingAction(const CSetting *setting) } else if (settingId == "karaoke.importcsv") { - CStdString path(CProfilesManager::Get().GetDatabaseFolder()); + std::string path(CProfilesManager::Get().GetDatabaseFolder()); VECSOURCES shares; g_mediaManager.GetLocalDrives(shares); if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "karaoke.csv", g_localizeStrings.Get(651) , path)) @@ -321,7 +319,7 @@ void CMediaSettings::OnSettingAction(const CSetting *setting) CBuiltins::Execute("exportlibrary(music)"); else if (settingId == "musiclibrary.import") { - CStdString path; + std::string path; VECSOURCES shares; g_mediaManager.GetLocalDrives(shares); if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "musicdb.xml", g_localizeStrings.Get(651) , path)) @@ -341,7 +339,7 @@ void CMediaSettings::OnSettingAction(const CSetting *setting) CBuiltins::Execute("exportlibrary(video)"); else if (settingId == "videolibrary.import") { - CStdString path; + std::string path; VECSOURCES shares; g_mediaManager.GetLocalDrives(shares); if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(651) , path)) diff --git a/xbmc/settings/MediaSourceSettings.cpp b/xbmc/settings/MediaSourceSettings.cpp index baef187ea8..1ad2736db3 100644 --- a/xbmc/settings/MediaSourceSettings.cpp +++ b/xbmc/settings/MediaSourceSettings.cpp @@ -324,7 +324,7 @@ bool CMediaSourceSettings::GetSource(const std::string &category, const TiXmlNod { if (pPathName->FirstChild()) { - CStdString strPath = pPathName->FirstChild()->ValueStr(); + std::string strPath = pPathName->FirstChild()->ValueStr(); // make sure there are no virtualpaths or stack paths defined in sources.xml if (!URIUtils::IsStack(strPath)) diff --git a/xbmc/settings/SettingAddon.cpp b/xbmc/settings/SettingAddon.cpp index c065a03f5a..2d093790b6 100644 --- a/xbmc/settings/SettingAddon.cpp +++ b/xbmc/settings/SettingAddon.cpp @@ -24,7 +24,6 @@ #include "utils/log.h" #include "utils/XBMCTinyXML.h" #include "utils/XMLUtils.h" -#include "utils/StdString.h" #define XML_ELM_DEFAULT "default" @@ -64,7 +63,7 @@ bool CSettingAddon::Deserialize(const TiXmlNode *node, bool update /* = false */ } bool ok = false; - CStdString strAddonType; + std::string strAddonType; const TiXmlNode *constraints = node->FirstChild("constraints"); if (constraints != NULL) { diff --git a/xbmc/settings/Settings.cpp b/xbmc/settings/Settings.cpp index 3c981a4343..8329cae589 100644 --- a/xbmc/settings/Settings.cpp +++ b/xbmc/settings/Settings.cpp @@ -786,6 +786,7 @@ void CSettings::InitializeISettingCallbacks() settingSet.clear(); settingSet.insert("pvrmanager.enabled"); settingSet.insert("pvrmanager.channelmanager"); + settingSet.insert("pvrmanager.groupmanager"); settingSet.insert("pvrmanager.channelscan"); settingSet.insert("pvrmanager.resetdb"); settingSet.insert("pvrclient.menuhook"); diff --git a/xbmc/settings/SkinSettings.cpp b/xbmc/settings/SkinSettings.cpp index 812df4ffa1..72352e0bf5 100644 --- a/xbmc/settings/SkinSettings.cpp +++ b/xbmc/settings/SkinSettings.cpp @@ -78,7 +78,7 @@ const string& CSkinSettings::GetString(int setting) const if (it != m_strings.end()) return it->second.value; - return StringUtils::EmptyString; + return StringUtils::Empty; } void CSkinSettings::SetString(int setting, const string &label) @@ -280,4 +280,4 @@ void CSkinSettings::Clear() std::string CSkinSettings::GetCurrentSkin() const { return CSettings::Get().GetString("lookandfeel.skin"); -}
\ No newline at end of file +} diff --git a/xbmc/settings/VideoSettings.cpp b/xbmc/settings/VideoSettings.cpp index 65105e8c6a..e253e8e9a4 100644 --- a/xbmc/settings/VideoSettings.cpp +++ b/xbmc/settings/VideoSettings.cpp @@ -52,11 +52,6 @@ CVideoSettings::CVideoSettings() m_AudioDelay = 0.0f; m_OutputToAllSpeakers = false; m_ResumeTime = 0; - m_Crop = false; - m_CropTop = 0; - m_CropBottom = 0; - m_CropLeft = 0; - m_CropRight = 0; } bool CVideoSettings::operator!=(const CVideoSettings &right) const @@ -84,11 +79,6 @@ bool CVideoSettings::operator!=(const CVideoSettings &right) const if (m_AudioDelay != right.m_AudioDelay) return true; if (m_OutputToAllSpeakers != right.m_OutputToAllSpeakers) return true; if (m_ResumeTime != right.m_ResumeTime) return true; - if (m_Crop != right.m_Crop) return true; - if (m_CropTop != right.m_CropTop) return true; - if (m_CropBottom != right.m_CropBottom) return true; - if (m_CropLeft != right.m_CropLeft) return true; - if (m_CropRight != right.m_CropRight) return true; if (m_StereoMode != right.m_StereoMode) return true; if (m_StereoInvert != right.m_StereoInvert) return true; return false; diff --git a/xbmc/settings/VideoSettings.h b/xbmc/settings/VideoSettings.h index 6eaef1d5ad..a88fe318e9 100644 --- a/xbmc/settings/VideoSettings.h +++ b/xbmc/settings/VideoSettings.h @@ -148,11 +148,6 @@ public: float m_Sharpness; float m_AudioDelay; int m_ResumeTime; - bool m_Crop; - int m_CropTop; - int m_CropBottom; - int m_CropLeft; - int m_CropRight; int m_StereoMode; bool m_StereoInvert; diff --git a/xbmc/settings/dialogs/GUIDialogSettingsBase.cpp b/xbmc/settings/dialogs/GUIDialogSettingsBase.cpp index 963e386b42..eba3967e33 100644 --- a/xbmc/settings/dialogs/GUIDialogSettingsBase.cpp +++ b/xbmc/settings/dialogs/GUIDialogSettingsBase.cpp @@ -375,7 +375,7 @@ void CGUIDialogSettingsBase::SetupControls(bool createSettings /* = true */) // go through the categories and create the necessary buttons int buttonIdOffset = 0; - for (SettingCategoryList::const_iterator category = m_categories.begin(); category != m_categories.end(); category++) + for (SettingCategoryList::const_iterator category = m_categories.begin(); category != m_categories.end(); ++category) { CGUIButtonControl *pButton = NULL; if (m_pOriginalCategoryButton->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON) @@ -440,7 +440,7 @@ void CGUIDialogSettingsBase::FreeSettingsControls() control->ClearAll(); } - for (std::vector<BaseSettingControlPtr>::iterator control = m_settingControls.begin(); control != m_settingControls.end(); control++) + for (std::vector<BaseSettingControlPtr>::iterator control = m_settingControls.begin(); control != m_settingControls.end(); ++control) (*control)->Clear(); m_settingControls.clear(); @@ -504,7 +504,7 @@ std::set<std::string> CGUIDialogSettingsBase::CreateSettings() const SettingGroupList& groups = category->GetGroups((SettingLevel)GetSettingLevel()); int iControlID = CONTROL_SETTINGS_START_CONTROL; bool first = true; - for (SettingGroupList::const_iterator groupIt = groups.begin(); groupIt != groups.end(); groupIt++) + for (SettingGroupList::const_iterator groupIt = groups.begin(); groupIt != groups.end(); ++groupIt) { if (*groupIt == NULL) continue; @@ -518,7 +518,7 @@ std::set<std::string> CGUIDialogSettingsBase::CreateSettings() else AddSeparator(group->GetWidth(), iControlID); - for (SettingList::const_iterator settingIt = settings.begin(); settingIt != settings.end(); settingIt++) + for (SettingList::const_iterator settingIt = settings.begin(); settingIt != settings.end(); ++settingIt) { CSetting *pSetting = *settingIt; settingMap.insert(pSetting->GetId()); @@ -541,7 +541,7 @@ std::set<std::string> CGUIDialogSettingsBase::CreateSettings() void CGUIDialogSettingsBase::UpdateSettings() { - for (vector<BaseSettingControlPtr>::iterator it = m_settingControls.begin(); it != m_settingControls.end(); it++) + for (vector<BaseSettingControlPtr>::iterator it = m_settingControls.begin(); it != m_settingControls.end(); ++it) { BaseSettingControlPtr pSettingControl = *it; CSetting *pSetting = pSettingControl->GetSetting(); @@ -717,7 +717,7 @@ void CGUIDialogSettingsBase::OnResetSettings() { if (CGUIDialogYesNo::ShowAndGetInput(10041, 0, 10042, 0)) { - for(vector<BaseSettingControlPtr>::iterator it = m_settingControls.begin(); it != m_settingControls.end(); it++) + for(vector<BaseSettingControlPtr>::iterator it = m_settingControls.begin(); it != m_settingControls.end(); ++it) { CSetting *setting = (*it)->GetSetting(); if (setting != NULL) @@ -804,7 +804,7 @@ void CGUIDialogSettingsBase::SetControlLabel(int controlId, const CVariant &labe BaseSettingControlPtr CGUIDialogSettingsBase::GetSettingControl(const std::string &strSetting) { - for (vector<BaseSettingControlPtr>::iterator control = m_settingControls.begin(); control != m_settingControls.end(); control++) + for (vector<BaseSettingControlPtr>::iterator control = m_settingControls.begin(); control != m_settingControls.end(); ++control) { if ((*control)->GetSetting() != NULL && (*control)->GetSetting()->GetId() == strSetting) return *control; diff --git a/xbmc/settings/lib/Setting.cpp b/xbmc/settings/lib/Setting.cpp index 1f951fdad0..f7cf964220 100644 --- a/xbmc/settings/lib/Setting.cpp +++ b/xbmc/settings/lib/Setting.cpp @@ -1236,7 +1236,7 @@ bool CSettingString::Deserialize(const TiXmlNode *node, bool update /* = false * } // get the default value - CStdString value; + std::string value; if (XMLUtils::GetString(node, SETTING_XML_ELM_DEFAULT, value) && (!value.empty() || m_allowEmpty)) m_value = m_default = value; diff --git a/xbmc/settings/windows/GUIControlSettings.cpp b/xbmc/settings/windows/GUIControlSettings.cpp index aa003a90ca..a395c251c3 100644 --- a/xbmc/settings/windows/GUIControlSettings.cpp +++ b/xbmc/settings/windows/GUIControlSettings.cpp @@ -535,7 +535,7 @@ bool CGUIControlButtonSetting::OnClick() { // prompt for the addon CSettingAddon *setting = (CSettingAddon *)m_pSetting; - CStdString addonID = setting->GetValue(); + std::string addonID = setting->GetValue(); if (CGUIWindowAddonBrowser::SelectAddonID(setting->GetAddonType(), addonID, setting->AllowEmpty()) != 1) return false; @@ -610,7 +610,7 @@ void CGUIControlButtonSetting::Update(bool updateDisplayOnly /* = false */) } else if (controlFormat == "path") { - CStdString shortPath; + std::string shortPath; if (CUtil::MakeShortenPath(strValue, shortPath, 30)) strText = shortPath; } @@ -649,7 +649,7 @@ bool CGUIControlButtonSetting::GetPath(CSettingPath *pathSetting) if (pathSetting == NULL) return false; - CStdString path = pathSetting->GetValue(); + std::string path = pathSetting->GetValue(); VECSOURCES shares; const std::vector<std::string>& sources = pathSetting->GetSources(); diff --git a/xbmc/settings/windows/GUIControlSettings.h b/xbmc/settings/windows/GUIControlSettings.h index 28c93c43b4..78b332b27c 100644 --- a/xbmc/settings/windows/GUIControlSettings.h +++ b/xbmc/settings/windows/GUIControlSettings.h @@ -19,8 +19,9 @@ * */ -#include "utils/StdString.h" #include "guilib/ISliderCallback.h" +#include <stdlib.h> +#include <string> class CGUIControl; class CGUIImage; diff --git a/xbmc/settings/windows/GUIWindowSettingsScreenCalibration.cpp b/xbmc/settings/windows/GUIWindowSettingsScreenCalibration.cpp index 61addfa1c0..439fa28091 100644 --- a/xbmc/settings/windows/GUIWindowSettingsScreenCalibration.cpp +++ b/xbmc/settings/windows/GUIWindowSettingsScreenCalibration.cpp @@ -75,7 +75,7 @@ bool CGUIWindowSettingsScreenCalibration::OnAction(const CAction &action) { CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); pDialog->SetHeading(20325); - CStdString strText = StringUtils::Format(g_localizeStrings.Get(20326).c_str(), g_graphicsContext.GetResInfo(m_Res[m_iCurRes]).strMode.c_str()); + std::string strText = StringUtils::Format(g_localizeStrings.Get(20326).c_str(), g_graphicsContext.GetResInfo(m_Res[m_iCurRes]).strMode.c_str()); pDialog->SetLine(0, strText); pDialog->SetLine(1, 20327); pDialog->SetChoice(0, 222); @@ -301,7 +301,7 @@ void CGUIWindowSettingsScreenCalibration::ResetControls() void CGUIWindowSettingsScreenCalibration::UpdateFromControl(int iControl) { - CStdString strStatus; + std::string strStatus; RESOLUTION_INFO info = g_graphicsContext.GetResInfo(m_Res[m_iCurRes]); if (iControl == CONTROL_PIXEL_RATIO) @@ -360,7 +360,7 @@ void CGUIWindowSettingsScreenCalibration::UpdateFromControl(int iControl) g_graphicsContext.SetResInfo(m_Res[m_iCurRes], info); // set the label control correctly - CStdString strText; + std::string strText; if (g_Windowing.IsFullScreen()) strText = StringUtils::Format("%ix%i@%.2f - %s | %s", info.iScreenWidth, diff --git a/xbmc/test/TestBasicEnvironment.cpp b/xbmc/test/TestBasicEnvironment.cpp index 0b158b28e1..18ca012945 100644 --- a/xbmc/test/TestBasicEnvironment.cpp +++ b/xbmc/test/TestBasicEnvironment.cpp @@ -27,6 +27,7 @@ #include "settings/AdvancedSettings.h" #include "settings/Settings.h" #include "Util.h" +#include "Application.h" #include <cstdio> #include <cstdlib> @@ -35,7 +36,7 @@ void TestBasicEnvironment::SetUp() { char *tmp; - CStdString xbmcTempPath; + std::string xbmcTempPath; XFILE::CFile *f; /* NOTE: The below is done to fix memleak warning about unitialized variable @@ -43,6 +44,9 @@ void TestBasicEnvironment::SetUp() */ g_advancedSettings.Initialize(); + // Need to configure the network as some tests access the network member + g_application.SetupNetwork(); + if (!CXBMCTestUtils::Instance().SetReferenceFileBasePath()) SetUpError(); CXBMCTestUtils::Instance().setTestFileFactoryWriteInputFile( @@ -52,7 +56,7 @@ void TestBasicEnvironment::SetUp() //for darwin set framework path - else we get assert //in guisettings init below #ifdef TARGET_DARWIN - CStdString frameworksPath = CUtil::GetFrameworksPath(); + std::string frameworksPath = CUtil::GetFrameworksPath(); CSpecialProtocol::SetXBMCFrameworksPath(frameworksPath); #endif /* TODO: Something should be done about all the asserts in GUISettings so @@ -101,7 +105,7 @@ void TestBasicEnvironment::SetUp() void TestBasicEnvironment::TearDown() { - CStdString xbmcTempPath = CSpecialProtocol::TranslatePath("special://temp/"); + std::string xbmcTempPath = CSpecialProtocol::TranslatePath("special://temp/"); XFILE::CDirectory::Remove(xbmcTempPath); } diff --git a/xbmc/threads/platform/win/Win32Exception.cpp b/xbmc/threads/platform/win/Win32Exception.cpp index b90db3b613..5eb1f01ddf 100644 --- a/xbmc/threads/platform/win/Win32Exception.cpp +++ b/xbmc/threads/platform/win/Win32Exception.cpp @@ -117,7 +117,7 @@ bool win32_exception::write_minidump(EXCEPTION_POINTERS* pEp) // Create the dump file where the xbmc.exe resides bool returncode = false; std::string dumpFileName; - CStdStringW dumpFileNameW; + std::wstring dumpFileNameW; SYSTEMTIME stLocalTime; GetLocalTime(&stLocalTime); @@ -190,7 +190,7 @@ bool win32_exception::write_stacktrace(EXCEPTION_POINTERS* pEp) #define STACKWALK_MAX_NAMELEN 1024 std::string dumpFileName, strOutput; - CStdStringW dumpFileNameW; + std::wstring dumpFileNameW; CHAR cTemp[STACKWALK_MAX_NAMELEN]; DWORD dwBytes; SYSTEMTIME stLocalTime; diff --git a/xbmc/utils/AMLUtils.cpp b/xbmc/utils/AMLUtils.cpp index 95537453c7..2c91094ffe 100644 --- a/xbmc/utils/AMLUtils.cpp +++ b/xbmc/utils/AMLUtils.cpp @@ -28,77 +28,22 @@ #include "AMLUtils.h" #include "utils/CPUInfo.h" #include "utils/log.h" +#include "utils/SysfsUtils.h" #include "utils/StringUtils.h" #include "utils/AMLUtils.h" #include "guilib/gui3d.h" -int aml_set_sysfs_str(const char *path, const char *val) -{ - int fd = open(path, O_CREAT | O_RDWR | O_TRUNC, 0644); - if (fd >= 0) - { - write(fd, val, strlen(val)); - close(fd); - return 0; - } - return -1; -} - -int aml_get_sysfs_str(const char *path, char *valstr, const int size) -{ - int fd = open(path, O_RDONLY); - if (fd >= 0) - { - read(fd, valstr, size - 1); - valstr[strlen(valstr)] = '\0'; - close(fd); - return 0; - } - - sprintf(valstr, "%s", "fail"); - return -1; -} - -int aml_set_sysfs_int(const char *path, const int val) -{ - int fd = open(path, O_CREAT | O_RDWR | O_TRUNC, 0644); - if (fd >= 0) - { - char bcmd[16]; - sprintf(bcmd, "%d", val); - write(fd, bcmd, strlen(bcmd)); - close(fd); - return 0; - } - return -1; -} - -int aml_get_sysfs_int(const char *path) -{ - int val = -1; - int fd = open(path, O_RDONLY); - if (fd >= 0) - { - char bcmd[16]; - read(fd, bcmd, sizeof(bcmd)); - val = strtol(bcmd, NULL, 16); - close(fd); - } - return val; -} - bool aml_present() { static int has_aml = -1; if (has_aml == -1) { - int rtn = aml_get_sysfs_int("/sys/class/audiodsp/digital_raw"); - if (rtn != -1) + if (SysfsUtils::Has("/sys/class/audiodsp/digital_raw")) has_aml = 1; else has_aml = 0; if (has_aml) - CLog::Log(LOGNOTICE, "aml_present, rtn(%d)", rtn); + CLog::Log(LOGNOTICE, "AML device detected"); } return has_aml == 1; } @@ -108,10 +53,12 @@ bool aml_hw3d_present() static int has_hw3d = -1; if (has_hw3d == -1) { - if (aml_get_sysfs_int("/sys/class/ppmgr/ppmgr_3d_mode") != -1) + if (SysfsUtils::Has("/sys/class/ppmgr/ppmgr_3d_mode")) has_hw3d = 1; else has_hw3d = 0; + if (has_hw3d) + CLog::Log(LOGNOTICE, "AML 3D support detected"); } return has_hw3d == 1; } @@ -121,8 +68,8 @@ bool aml_wired_present() static int has_wired = -1; if (has_wired == -1) { - char test[64] = {0}; - if (aml_get_sysfs_str("/sys/class/net/eth0/operstate", test, 63) != -1) + std::string test; + if (SysfsUtils::GetString("/sys/class/net/eth0/operstate", test) != -1) has_wired = 1; else has_wired = 0; @@ -159,6 +106,16 @@ void aml_permissions() } } +bool aml_support_hevc() +{ + std::string valstr; + if(SysfsUtils::GetString("/sys/class/amstream/vcodec_profile", valstr) != 0) + { + return false; + } + return (valstr.find("hevc:") != std::string::npos); +} + enum AML_DEVICE_TYPE aml_get_device_type() { static enum AML_DEVICE_TYPE aml_device_type = AML_DEVICE_TYPE_UNINIT; @@ -173,8 +130,14 @@ enum AML_DEVICE_TYPE aml_get_device_type() aml_device_type = AML_DEVICE_TYPE_M3; else if (cpu_hardware.find("Meson6") != std::string::npos) aml_device_type = AML_DEVICE_TYPE_M6; - else if (cpu_hardware.find("Meson8") != std::string::npos) - aml_device_type = AML_DEVICE_TYPE_M8; + else if ((cpu_hardware.find("Meson8") != std::string::npos) && (cpu_hardware.find("Meson8B") == std::string::npos)) + { + if (aml_support_hevc()) + aml_device_type = AML_DEVICE_TYPE_M8M2; + else + aml_device_type = AML_DEVICE_TYPE_M8; + } else if (cpu_hardware.find("Meson8B") != std::string::npos) + aml_device_type = AML_DEVICE_TYPE_M8B; else aml_device_type = AML_DEVICE_TYPE_UNKNOWN; } @@ -194,7 +157,7 @@ void aml_cpufreq_min(bool limit) if (limit) cpufreq = 600000; - aml_set_sysfs_int("/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq", cpufreq); + SysfsUtils::SetInt("/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq", cpufreq); } #endif } @@ -209,8 +172,8 @@ void aml_cpufreq_max(bool limit) if (limit) cpufreq = 800000; - aml_set_sysfs_int("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq", cpufreq); - aml_set_sysfs_str("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", "ondemand"); + SysfsUtils::SetInt("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq", cpufreq); + SysfsUtils::SetString("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", "ondemand"); } } @@ -222,7 +185,7 @@ void aml_set_audio_passthrough(bool passthrough) { // m1 uses 1, m3 and above uses 2 int raw = aml_get_device_type() == AML_DEVICE_TYPE_M1 ? 1:2; - aml_set_sysfs_int("/sys/class/audiodsp/digital_raw", passthrough ? raw:0); + SysfsUtils::SetInt("/sys/class/audiodsp/digital_raw", passthrough ? raw:0); } } @@ -292,11 +255,11 @@ void aml_probe_hdmi_audio() int aml_axis_value(AML_DISPLAY_AXIS_PARAM param) { - char axis[20] = {0}; + std::string axis; int value[8]; - aml_get_sysfs_str("/sys/class/display/axis", axis, 19); - sscanf(axis, "%d %d %d %d %d %d %d %d", &value[0], &value[1], &value[2], &value[3], &value[4], &value[5], &value[6], &value[7]); + SysfsUtils::GetString("/sys/class/display/axis", axis); + sscanf(axis.c_str(), "%d %d %d %d %d %d %d %d", &value[0], &value[1], &value[2], &value[3], &value[4], &value[5], &value[6], &value[7]); return value[param]; } @@ -312,14 +275,14 @@ bool aml_mode_to_resolution(const char *mode, RESOLUTION_INFO *res) if(!mode) return false; - CStdString fromMode = mode; + std::string fromMode = mode; StringUtils::Trim(fromMode); // strips, for example, 720p* to 720p // the * indicate the 'native' mode of the display if (StringUtils::EndsWith(fromMode, "*")) fromMode.erase(fromMode.size() - 1); - if (fromMode.Equals("panel")) + if (StringUtils::EqualsNoCase(fromMode, "panel")) { res->iWidth = aml_axis_value(AML_DISPLAY_AXIS_PARAM_WIDTH); res->iHeight= aml_axis_value(AML_DISPLAY_AXIS_PARAM_HEIGHT); @@ -328,7 +291,7 @@ bool aml_mode_to_resolution(const char *mode, RESOLUTION_INFO *res) res->fRefreshRate = 60; res->dwFlags = D3DPRESENTFLAG_PROGRESSIVE; } - else if (fromMode.Equals("720p")) + else if (StringUtils::EqualsNoCase(fromMode, "720p")) { res->iWidth = 1280; res->iHeight= 720; @@ -337,7 +300,7 @@ bool aml_mode_to_resolution(const char *mode, RESOLUTION_INFO *res) res->fRefreshRate = 60; res->dwFlags = D3DPRESENTFLAG_PROGRESSIVE; } - else if (fromMode.Equals("720p50hz")) + else if (StringUtils::EqualsNoCase(fromMode, "720p50hz")) { res->iWidth = 1280; res->iHeight= 720; @@ -346,7 +309,7 @@ bool aml_mode_to_resolution(const char *mode, RESOLUTION_INFO *res) res->fRefreshRate = 50; res->dwFlags = D3DPRESENTFLAG_PROGRESSIVE; } - else if (fromMode.Equals("1080p")) + else if (StringUtils::EqualsNoCase(fromMode, "1080p")) { res->iWidth = 1920; res->iHeight= 1080; @@ -355,7 +318,7 @@ bool aml_mode_to_resolution(const char *mode, RESOLUTION_INFO *res) res->fRefreshRate = 60; res->dwFlags = D3DPRESENTFLAG_PROGRESSIVE; } - else if (fromMode.Equals("1080p24hz")) + else if (StringUtils::EqualsNoCase(fromMode, "1080p24hz")) { res->iWidth = 1920; res->iHeight= 1080; @@ -364,7 +327,7 @@ bool aml_mode_to_resolution(const char *mode, RESOLUTION_INFO *res) res->fRefreshRate = 24; res->dwFlags = D3DPRESENTFLAG_PROGRESSIVE; } - else if (fromMode.Equals("1080p30hz")) + else if (StringUtils::EqualsNoCase(fromMode, "1080p30hz")) { res->iWidth = 1920; res->iHeight= 1080; @@ -373,7 +336,7 @@ bool aml_mode_to_resolution(const char *mode, RESOLUTION_INFO *res) res->fRefreshRate = 30; res->dwFlags = D3DPRESENTFLAG_PROGRESSIVE; } - else if (fromMode.Equals("1080p50hz")) + else if (StringUtils::EqualsNoCase(fromMode, "1080p50hz")) { res->iWidth = 1920; res->iHeight= 1080; @@ -382,7 +345,7 @@ bool aml_mode_to_resolution(const char *mode, RESOLUTION_INFO *res) res->fRefreshRate = 50; res->dwFlags = D3DPRESENTFLAG_PROGRESSIVE; } - else if (fromMode.Equals("1080i")) + else if (StringUtils::EqualsNoCase(fromMode, "1080i")) { res->iWidth = 1920; res->iHeight= 1080; @@ -391,7 +354,7 @@ bool aml_mode_to_resolution(const char *mode, RESOLUTION_INFO *res) res->fRefreshRate = 60; res->dwFlags = D3DPRESENTFLAG_INTERLACED; } - else if (fromMode.Equals("1080i50hz")) + else if (StringUtils::EqualsNoCase(fromMode, "1080i50hz")) { res->iWidth = 1920; res->iHeight= 1080; @@ -400,7 +363,7 @@ bool aml_mode_to_resolution(const char *mode, RESOLUTION_INFO *res) res->fRefreshRate = 50; res->dwFlags = D3DPRESENTFLAG_INTERLACED; } - else if (fromMode.Equals("4k2ksmpte")) + else if (StringUtils::EqualsNoCase(fromMode, "4k2ksmpte")) { res->iWidth = 1920; res->iHeight= 1080; @@ -409,7 +372,7 @@ bool aml_mode_to_resolution(const char *mode, RESOLUTION_INFO *res) res->fRefreshRate = 24; res->dwFlags = D3DPRESENTFLAG_PROGRESSIVE; } - else if (fromMode.Equals("4k2k24hz")) + else if (StringUtils::EqualsNoCase(fromMode, "4k2k24hz")) { res->iWidth = 1920; res->iHeight= 1080; @@ -418,7 +381,7 @@ bool aml_mode_to_resolution(const char *mode, RESOLUTION_INFO *res) res->fRefreshRate = 24; res->dwFlags = D3DPRESENTFLAG_PROGRESSIVE; } - else if (fromMode.Equals("4k2k25hz")) + else if (StringUtils::EqualsNoCase(fromMode, "4k2k25hz")) { res->iWidth = 1920; res->iHeight= 1080; @@ -427,7 +390,7 @@ bool aml_mode_to_resolution(const char *mode, RESOLUTION_INFO *res) res->fRefreshRate = 25; res->dwFlags = D3DPRESENTFLAG_PROGRESSIVE; } - else if (fromMode.Equals("4k2k30hz")) + else if (StringUtils::EqualsNoCase(fromMode, "4k2k30hz")) { res->iWidth = 1920; res->iHeight= 1080; diff --git a/xbmc/utils/AMLUtils.h b/xbmc/utils/AMLUtils.h index 9778e9b65d..6b0048adea 100644 --- a/xbmc/utils/AMLUtils.h +++ b/xbmc/utils/AMLUtils.h @@ -28,7 +28,9 @@ enum AML_DEVICE_TYPE AML_DEVICE_TYPE_M1, AML_DEVICE_TYPE_M3, AML_DEVICE_TYPE_M6, - AML_DEVICE_TYPE_M8 + AML_DEVICE_TYPE_M8, // S802 + AML_DEVICE_TYPE_M8B, // S805 + AML_DEVICE_TYPE_M8M2 // S812 }; enum AML_DISPLAY_AXIS_PARAM @@ -39,15 +41,11 @@ enum AML_DISPLAY_AXIS_PARAM AML_DISPLAY_AXIS_PARAM_HEIGHT }; -int aml_set_sysfs_str(const char *path, const char *val); -int aml_get_sysfs_str(const char *path, char *valstr, const int size); -int aml_set_sysfs_int(const char *path, const int val); -int aml_get_sysfs_int(const char *path); - bool aml_present(); void aml_permissions(); bool aml_hw3d_present(); bool aml_wired_present(); +bool aml_support_hevc(); enum AML_DEVICE_TYPE aml_get_device_type(); void aml_cpufreq_min(bool limit); void aml_cpufreq_max(bool limit); diff --git a/xbmc/utils/AsyncFileCopy.cpp b/xbmc/utils/AsyncFileCopy.cpp index d48a0fd3ba..15db5cce14 100644 --- a/xbmc/utils/AsyncFileCopy.cpp +++ b/xbmc/utils/AsyncFileCopy.cpp @@ -41,7 +41,7 @@ CAsyncFileCopy::~CAsyncFileCopy() StopThread(); } -bool CAsyncFileCopy::Copy(const CStdString &from, const CStdString &to, const CStdString &heading) +bool CAsyncFileCopy::Copy(const std::string &from, const std::string &to, const std::string &heading) { // reset the variables to their appropriate states m_from = from; @@ -75,7 +75,7 @@ bool CAsyncFileCopy::Copy(const CStdString &from, const CStdString &to, const CS // and update the dialog as we go if (dlg && dlg->IsDialogRunning()) { - CStdString speedString = StringUtils::Format("%2.2f KB/s", m_speed / 1024); + std::string speedString = StringUtils::Format("%2.2f KB/s", m_speed / 1024); dlg->SetHeading(heading); dlg->SetLine(0, url1.Get()); dlg->SetLine(1, url2.Get()); diff --git a/xbmc/utils/AsyncFileCopy.h b/xbmc/utils/AsyncFileCopy.h index c4bd9cde67..00b36f7545 100644 --- a/xbmc/utils/AsyncFileCopy.h +++ b/xbmc/utils/AsyncFileCopy.h @@ -20,9 +20,9 @@ * */ +#include <string> #include "threads/Thread.h" #include "filesystem/File.h" -#include "utils/StdString.h" class CAsyncFileCopy : public CThread, public XFILE::IFileCallback { @@ -32,7 +32,7 @@ public: /// \brief Main routine to copy files from one source to another. /// \return true if successful, and false if it failed or was cancelled. - bool Copy(const CStdString &from, const CStdString &to, const CStdString &heading); + bool Copy(const std::string &from, const std::string &to, const std::string &heading); /// \brief callback from CFile::Copy() virtual bool OnFileCallback(void *pContext, int ipercent, float avgSpeed); @@ -48,7 +48,7 @@ private: volatile bool m_running; ///< whether or not the copy operation is still in progress bool m_succeeded; ///< whether or not the copy operation was successful - CStdString m_from; ///< source URL to copy from - CStdString m_to; ///< destination URL to copy to + std::string m_from; ///< source URL to copy from + std::string m_to; ///< destination URL to copy to CEvent m_event; ///< event to set to force an update }; diff --git a/xbmc/utils/BitstreamConverter.cpp b/xbmc/utils/BitstreamConverter.cpp index 11d0673ec2..9de126de82 100644 --- a/xbmc/utils/BitstreamConverter.cpp +++ b/xbmc/utils/BitstreamConverter.cpp @@ -28,20 +28,48 @@ #include "BitstreamConverter.h" enum { - NAL_SLICE=1, - NAL_DPA, - NAL_DPB, - NAL_DPC, - NAL_IDR_SLICE, - NAL_SEI, - NAL_SPS, - NAL_PPS, - NAL_AUD, - NAL_END_SEQUENCE, - NAL_END_STREAM, - NAL_FILLER_DATA, - NAL_SPS_EXT, - NAL_AUXILIARY_SLICE=19 + AVC_NAL_SLICE=1, + AVC_NAL_DPA, + AVC_NAL_DPB, + AVC_NAL_DPC, + AVC_NAL_IDR_SLICE, + AVC_NAL_SEI, + AVC_NAL_SPS, + AVC_NAL_PPS, + AVC_NAL_AUD, + AVC_NAL_END_SEQUENCE, + AVC_NAL_END_STREAM, + AVC_NAL_FILLER_DATA, + AVC_NAL_SPS_EXT, + AVC_NAL_AUXILIARY_SLICE=19 +}; + +enum { + HEVC_NAL_TRAIL_N = 0, + HEVC_NAL_TRAIL_R = 1, + HEVC_NAL_TSA_N = 2, + HEVC_NAL_TSA_R = 3, + HEVC_NAL_STSA_N = 4, + HEVC_NAL_STSA_R = 5, + HEVC_NAL_RADL_N = 6, + HEVC_NAL_RADL_R = 7, + HEVC_NAL_RASL_N = 8, + HEVC_NAL_RASL_R = 9, + HEVC_NAL_BLA_W_LP = 16, + HEVC_NAL_BLA_W_RADL = 17, + HEVC_NAL_BLA_N_LP = 18, + HEVC_NAL_IDR_W_RADL = 19, + HEVC_NAL_IDR_N_LP = 20, + HEVC_NAL_CRA_NUT = 21, + HEVC_NAL_VPS = 32, + HEVC_NAL_SPS = 33, + HEVC_NAL_PPS = 34, + HEVC_NAL_AUD = 35, + HEVC_NAL_EOS_NUT = 36, + HEVC_NAL_EOB_NUT = 37, + HEVC_NAL_FD_NUT = 38, + HEVC_NAL_SEI_PREFIX = 39, + HEVC_NAL_SEI_SUFFIX = 40 }; //////////////////////////////////////////////////////////////////////////////////////////// @@ -252,20 +280,20 @@ bool CBitstreamParser::FindIdrSlice(const uint8_t *buf, int buf_size) default: CLog::Log(LOGDEBUG, "FindIdrSlice: found nal_type(%d)", state & 0x1f); break; - case NAL_SLICE: + case AVC_NAL_SLICE: CLog::Log(LOGDEBUG, "FindIdrSlice: found NAL_SLICE"); break; - case NAL_IDR_SLICE: + case AVC_NAL_IDR_SLICE: CLog::Log(LOGDEBUG, "FindIdrSlice: found NAL_IDR_SLICE"); rtn = true; break; - case NAL_SEI: + case AVC_NAL_SEI: CLog::Log(LOGDEBUG, "FindIdrSlice: found NAL_SEI"); break; - case NAL_SPS: + case AVC_NAL_SPS: CLog::Log(LOGDEBUG, "FindIdrSlice: found NAL_SPS"); break; - case NAL_PPS: + case AVC_NAL_PPS: CLog::Log(LOGDEBUG, "FindIdrSlice: found NAL_PPS"); break; } @@ -319,7 +347,7 @@ bool CBitstreamConverter::Open(enum AVCodecID codec, uint8_t *in_extradata, int m_extrasize = in_extrasize; m_extradata = (uint8_t*)av_malloc(in_extrasize); memcpy(m_extradata, in_extradata, in_extrasize); - m_convert_bitstream = BitstreamConvertInit(m_extradata, m_extrasize); + m_convert_bitstream = BitstreamConvertInitAVC(m_extradata, m_extrasize); return true; } } @@ -382,6 +410,68 @@ bool CBitstreamConverter::Open(enum AVCodecID codec, uint8_t *in_extradata, int } return false; break; + case AV_CODEC_ID_HEVC: + if (in_extrasize < 23 || in_extradata == NULL) + { + CLog::Log(LOGERROR, "CBitstreamConverter::Open hvcC data too small or missing"); + return false; + } + // valid hvcC data (bitstream) always starts with the value 1 (version) + if(m_to_annexb) + { + // TODO: from Amlogic + /* It seems the extradata is encoded as hvcC format. + * Temporarily, we support configurationVersion==0 until 14496-15 3rd + * is finalized. When finalized, configurationVersion will be 1 and we + * can recognize hvcC by checking if extradata[0]==1 or not. */ + + if (in_extradata[0] || in_extradata[1] || in_extradata[2] > 1) + { + CLog::Log(LOGINFO, "CBitstreamConverter::Open bitstream to annexb init"); + m_extrasize = in_extrasize; + m_extradata = (uint8_t*)av_malloc(in_extrasize); + memcpy(m_extradata, in_extradata, in_extrasize); + m_convert_bitstream = BitstreamConvertInitHEVC(m_extradata, m_extrasize); + return true; + } + } + else + { + // valid hvcC atom data always starts with the value 1 (version) + if ( in_extradata[0] != 1 ) + { + if ( (in_extradata[0] == 0 && in_extradata[1] == 0 && in_extradata[2] == 0 && in_extradata[3] == 1) || + (in_extradata[0] == 0 && in_extradata[1] == 0 && in_extradata[2] == 1) ) + { + CLog::Log(LOGINFO, "CBitstreamConverter::Open annexb to bitstream init"); + // TODO: convert annexb to bitstream format + return false; + } + else + { + CLog::Log(LOGNOTICE, "CBitstreamConverter::Open invalid hvcC atom data"); + return false; + } + } + else + { + if ((in_extradata[4] & 0x3) == 2) + { + CLog::Log(LOGINFO, "CBitstreamConverter::Open annexb to bitstream init 3 byte to 4 byte nal"); + // video content is from so silly encoder that think 3 byte NAL sizes + // are valid, setup to convert 3 byte NAL sizes to 4 byte. + in_extradata[4] |= 0x03; + m_convert_3byteTo4byteNALSize = true; + } + } + // valid hvcC atom + m_extradata = (uint8_t*)av_malloc(in_extrasize); + memcpy(m_extradata, in_extradata, in_extrasize); + m_extrasize = in_extrasize; + return true; + } + return false; + break; default: return false; break; @@ -423,7 +513,8 @@ bool CBitstreamConverter::Convert(uint8_t *pData, int iSize) if (pData) { - if (m_codec == AV_CODEC_ID_H264) + if (m_codec == AV_CODEC_ID_H264 || + m_codec == AV_CODEC_ID_HEVC) { if (m_to_annexb) { @@ -502,7 +593,7 @@ bool CBitstreamConverter::Convert(uint8_t *pData, int iSize) while (nal_start < end) { nal_size = BS_RB24(nal_start); - avio_wb16(pb, nal_size); + avio_wb32(pb, nal_size); nal_start += 3; avio_write(pb, nal_start, nal_size); nal_start += nal_size; @@ -550,7 +641,7 @@ int CBitstreamConverter::GetExtraSize() const return m_extrasize; } -bool CBitstreamConverter::BitstreamConvertInit(void *in_extradata, int in_extrasize) +bool CBitstreamConverter::BitstreamConvertInitAVC(void *in_extradata, int in_extrasize) { // based on h264_mp4toannexb_bsf.c (ffmpeg) // which is Copyright (c) 2007 Benoit Fouet <benoit.fouet@free.fr> @@ -632,6 +723,129 @@ pps: return true; } +bool CBitstreamConverter::BitstreamConvertInitHEVC(void *in_extradata, int in_extrasize) +{ + m_sps_pps_size = 0; + m_sps_pps_context.sps_pps_data = NULL; + + // nothing to filter + if (!in_extradata || in_extrasize < 23) + return false; + + uint16_t unit_nb, unit_size; + uint32_t total_size = 0; + uint8_t *out = NULL, array_nb, nal_type, sps_seen = 0, pps_seen = 0; + const uint8_t *extradata = (uint8_t*)in_extradata + 21; + static const uint8_t nalu_header[4] = {0, 0, 0, 1}; + + // retrieve length coded size + m_sps_pps_context.length_size = (*extradata++ & 0x3) + 1; + + array_nb = *extradata++; + while (array_nb--) + { + nal_type = *extradata++ & 0x3f; + unit_nb = extradata[0] << 8 | extradata[1]; + extradata += 2; + + if (nal_type == HEVC_NAL_SPS && unit_nb) + { + sps_seen = 1; + } + else if (nal_type == HEVC_NAL_PPS && unit_nb) + { + pps_seen = 1; + } + while (unit_nb--) + { + void *tmp; + + unit_size = extradata[0] << 8 | extradata[1]; + extradata += 2; + if (nal_type != HEVC_NAL_SPS && + nal_type != HEVC_NAL_PPS && + nal_type != HEVC_NAL_VPS) + { + extradata += unit_size; + continue; + } + total_size += unit_size + 4; + + if (total_size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE || + (extradata + unit_size) > ((uint8_t*)in_extradata + in_extrasize)) + { + av_free(out); + return false; + } + tmp = av_realloc(out, total_size + FF_INPUT_BUFFER_PADDING_SIZE); + if (!tmp) + { + av_free(out); + return false; + } + out = (uint8_t*)tmp; + memcpy(out + total_size - unit_size - 4, nalu_header, 4); + memcpy(out + total_size - unit_size, extradata, unit_size); + extradata += unit_size; + } + } + + if (out) + memset(out + total_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + + if (!sps_seen) + CLog::Log(LOGDEBUG, "SPS NALU missing or invalid. The resulting stream may not play"); + if (!pps_seen) + CLog::Log(LOGDEBUG, "PPS NALU missing or invalid. The resulting stream may not play"); + + m_sps_pps_context.sps_pps_data = out; + m_sps_pps_context.size = total_size; + m_sps_pps_context.first_idr = 1; + m_sps_pps_context.idr_sps_pps_seen = 0; + + return true; +} + +bool CBitstreamConverter::IsIDR(uint8_t unit_type) +{ + switch (m_codec) + { + case AV_CODEC_ID_H264: + return unit_type == AVC_NAL_IDR_SLICE; + case AV_CODEC_ID_HEVC: + return unit_type == HEVC_NAL_IDR_W_RADL || + unit_type == HEVC_NAL_IDR_N_LP; + default: + return false; + } +} + +bool CBitstreamConverter::IsSlice(uint8_t unit_type) +{ + switch (m_codec) + { + case AV_CODEC_ID_H264: + return unit_type == AVC_NAL_SLICE; + case AV_CODEC_ID_HEVC: + return unit_type == HEVC_NAL_TRAIL_R || + unit_type == HEVC_NAL_TRAIL_N || + unit_type == HEVC_NAL_TSA_N || + unit_type == HEVC_NAL_TSA_R || + unit_type == HEVC_NAL_STSA_N || + unit_type == HEVC_NAL_STSA_R || + unit_type == HEVC_NAL_BLA_W_LP || + unit_type == HEVC_NAL_BLA_W_RADL || + unit_type == HEVC_NAL_BLA_N_LP || + unit_type == HEVC_NAL_CRA_NUT || + unit_type == HEVC_NAL_RADL_N || + unit_type == HEVC_NAL_RADL_R || + unit_type == HEVC_NAL_RASL_N || + unit_type == HEVC_NAL_RASL_R; + default: + return false; + } +} + bool CBitstreamConverter::BitstreamConvert(uint8_t* pData, int iSize, uint8_t **poutbuf, int *poutbuf_size) { // based on h264_mp4toannexb_bsf.c (ffmpeg) @@ -641,11 +855,25 @@ bool CBitstreamConverter::BitstreamConvert(uint8_t* pData, int iSize, uint8_t ** int i; uint8_t *buf = pData; uint32_t buf_size = iSize; - uint8_t unit_type; + uint8_t unit_type, nal_sps, nal_pps; int32_t nal_size; uint32_t cumul_size = 0; const uint8_t *buf_end = buf + buf_size; + switch (m_codec) + { + case AV_CODEC_ID_H264: + nal_sps = AVC_NAL_SPS; + nal_pps = AVC_NAL_PPS; + break; + case AV_CODEC_ID_HEVC: + nal_sps = HEVC_NAL_SPS; + nal_pps = HEVC_NAL_PPS; + break; + default: + return false; + } + do { if (buf + m_sps_pps_context.length_size > buf_end) @@ -655,17 +883,24 @@ bool CBitstreamConverter::BitstreamConvert(uint8_t* pData, int iSize, uint8_t ** nal_size = (nal_size << 8) | buf[i]; buf += m_sps_pps_context.length_size; - unit_type = *buf & 0x1f; + if (m_codec == AV_CODEC_ID_H264) + { + unit_type = *buf & 0x1f; + } + else + { + unit_type = (*buf >> 1) & 0x3f; + } - if (buf + nal_size > buf_end || nal_size < 0) + if (buf + nal_size > buf_end || nal_size <= 0) goto fail; // Don't add sps/pps if the unit already contain them - if (m_sps_pps_context.first_idr && (unit_type == 7 || unit_type == 8)) + if (m_sps_pps_context.first_idr && (unit_type == nal_sps || unit_type == nal_pps)) m_sps_pps_context.idr_sps_pps_seen = 1; // prepend only to the first access unit of an IDR picture, if no sps/pps already present - if (m_sps_pps_context.first_idr && unit_type == 5 && !m_sps_pps_context.idr_sps_pps_seen) + if (m_sps_pps_context.first_idr && IsIDR(unit_type) && !m_sps_pps_context.idr_sps_pps_seen) { BitstreamAllocAndCopy(poutbuf, poutbuf_size, m_sps_pps_context.sps_pps_data, m_sps_pps_context.size, buf, nal_size); @@ -674,7 +909,7 @@ bool CBitstreamConverter::BitstreamConvert(uint8_t* pData, int iSize, uint8_t ** else { BitstreamAllocAndCopy(poutbuf, poutbuf_size, NULL, 0, buf, nal_size); - if (!m_sps_pps_context.first_idr && unit_type == 1) + if (!m_sps_pps_context.first_idr && IsSlice(unit_type)) { m_sps_pps_context.first_idr = 1; m_sps_pps_context.idr_sps_pps_seen = 0; diff --git a/xbmc/utils/BitstreamConverter.h b/xbmc/utils/BitstreamConverter.h index 9ab5ac3dea..639b3bfd2b 100644 --- a/xbmc/utils/BitstreamConverter.h +++ b/xbmc/utils/BitstreamConverter.h @@ -177,7 +177,10 @@ protected: static const int avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size); const int isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len); // bitstream to bytestream (Annex B) conversion support. - bool BitstreamConvertInit(void *in_extradata, int in_extrasize); + bool IsIDR(uint8_t unit_type); + bool IsSlice(uint8_t unit_type); + bool BitstreamConvertInitAVC(void *in_extradata, int in_extrasize); + bool BitstreamConvertInitHEVC(void *in_extradata, int in_extrasize); bool BitstreamConvert(uint8_t* pData, int iSize, uint8_t **poutbuf, int *poutbuf_size); static void BitstreamAllocAndCopy(uint8_t **poutbuf, int *poutbuf_size, const uint8_t *sps_pps, uint32_t sps_pps_size, const uint8_t *in, uint32_t in_size); diff --git a/xbmc/utils/CPUInfo.cpp b/xbmc/utils/CPUInfo.cpp index 71aa745481..95ddad9977 100644 --- a/xbmc/utils/CPUInfo.cpp +++ b/xbmc/utils/CPUInfo.cpp @@ -577,7 +577,7 @@ bool CCPUInfo::getTemperature(CTemperature& temperature) #else int ret = 0; FILE *p = NULL; - CStdString cmd = g_advancedSettings.m_cpuTempCmd; + std::string cmd = g_advancedSettings.m_cpuTempCmd; temperature.SetState(CTemperature::invalid); diff --git a/xbmc/utils/DatabaseUtils.cpp b/xbmc/utils/DatabaseUtils.cpp index f5b7ca6f10..ae523055bb 100644 --- a/xbmc/utils/DatabaseUtils.cpp +++ b/xbmc/utils/DatabaseUtils.cpp @@ -113,128 +113,128 @@ std::string DatabaseUtils::GetField(Field field, const MediaType &mediaType, Dat } else if (mediaType == MediaTypeMusicVideo) { - CStdString result; - if (field == FieldId) return "musicvideoview.idMVideo"; - else if (field == FieldTitle) result = StringUtils::Format("musicvideoview.c%02d",VIDEODB_ID_MUSICVIDEO_TITLE); - else if (field == FieldTime) result = StringUtils::Format("musicvideoview.c%02d", VIDEODB_ID_MUSICVIDEO_RUNTIME); - else if (field == FieldDirector) result = StringUtils::Format("musicvideoview.c%02d", VIDEODB_ID_MUSICVIDEO_DIRECTOR); - else if (field == FieldStudio) result = StringUtils::Format("musicvideoview.c%02d", VIDEODB_ID_MUSICVIDEO_STUDIOS); - else if (field == FieldYear) result = StringUtils::Format("musicvideoview.c%02d",VIDEODB_ID_MUSICVIDEO_YEAR); - else if (field == FieldPlot) result = StringUtils::Format("musicvideoview.c%02d", VIDEODB_ID_MUSICVIDEO_PLOT); - else if (field == FieldAlbum) result = StringUtils::Format("musicvideoview.c%02d",VIDEODB_ID_MUSICVIDEO_ALBUM); - else if (field == FieldArtist) result = StringUtils::Format("musicvideoview.c%02d", VIDEODB_ID_MUSICVIDEO_ARTIST); - else if (field == FieldGenre) result = StringUtils::Format("musicvideoview.c%02d", VIDEODB_ID_MUSICVIDEO_GENRE); - else if (field == FieldTrackNumber) result = StringUtils::Format("musicvideoview.c%02d", VIDEODB_ID_MUSICVIDEO_TRACK); - else if (field == FieldFilename) return "musicvideoview.strFilename"; - else if (field == FieldPath) return "musicvideoview.strPath"; - else if (field == FieldPlaycount) return "musicvideoview.playCount"; - else if (field == FieldLastPlayed) return "musicvideoview.lastPlayed"; - else if (field == FieldDateAdded) return "musicvideoview.dateAdded"; + std::string result; + if (field == FieldId) return "musicvideo_view.idMVideo"; + else if (field == FieldTitle) result = StringUtils::Format("musicvideo_view.c%02d",VIDEODB_ID_MUSICVIDEO_TITLE); + else if (field == FieldTime) result = StringUtils::Format("musicvideo_view.c%02d", VIDEODB_ID_MUSICVIDEO_RUNTIME); + else if (field == FieldDirector) result = StringUtils::Format("musicvideo_view.c%02d", VIDEODB_ID_MUSICVIDEO_DIRECTOR); + else if (field == FieldStudio) result = StringUtils::Format("musicvideo_view.c%02d", VIDEODB_ID_MUSICVIDEO_STUDIOS); + else if (field == FieldYear) result = StringUtils::Format("musicvideo_view.c%02d",VIDEODB_ID_MUSICVIDEO_YEAR); + else if (field == FieldPlot) result = StringUtils::Format("musicvideo_view.c%02d", VIDEODB_ID_MUSICVIDEO_PLOT); + else if (field == FieldAlbum) result = StringUtils::Format("musicvideo_view.c%02d",VIDEODB_ID_MUSICVIDEO_ALBUM); + else if (field == FieldArtist) result = StringUtils::Format("musicvideo_view.c%02d", VIDEODB_ID_MUSICVIDEO_ARTIST); + else if (field == FieldGenre) result = StringUtils::Format("musicvideo_view.c%02d", VIDEODB_ID_MUSICVIDEO_GENRE); + else if (field == FieldTrackNumber) result = StringUtils::Format("musicvideo_view.c%02d", VIDEODB_ID_MUSICVIDEO_TRACK); + else if (field == FieldFilename) return "musicvideo_view.strFilename"; + else if (field == FieldPath) return "musicvideo_view.strPath"; + else if (field == FieldPlaycount) return "musicvideo_view.playCount"; + else if (field == FieldLastPlayed) return "musicvideo_view.lastPlayed"; + else if (field == FieldDateAdded) return "musicvideo_view.dateAdded"; if (!result.empty()) return result; } else if (mediaType == MediaTypeMovie) { - CStdString result; - if (field == FieldId) return "movieview.idMovie"; + std::string result; + if (field == FieldId) return "movie_view.idMovie"; else if (field == FieldTitle) { // We need some extra logic to get the title value if sorttitle isn't set if (queryPart == DatabaseQueryPartOrderBy) - result = StringUtils::Format("CASE WHEN length(movieview.c%02d) > 0 THEN movieview.c%02d ELSE movieview.c%02d END", VIDEODB_ID_SORTTITLE, VIDEODB_ID_SORTTITLE, VIDEODB_ID_TITLE); + result = StringUtils::Format("CASE WHEN length(movie_view.c%02d) > 0 THEN movie_view.c%02d ELSE movie_view.c%02d END", VIDEODB_ID_SORTTITLE, VIDEODB_ID_SORTTITLE, VIDEODB_ID_TITLE); else - result = StringUtils::Format("movieview.c%02d", VIDEODB_ID_TITLE); + result = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_TITLE); } - else if (field == FieldPlot) result = StringUtils::Format("movieview.c%02d", VIDEODB_ID_PLOT); - else if (field == FieldPlotOutline) result = StringUtils::Format("movieview.c%02d", VIDEODB_ID_PLOTOUTLINE); - else if (field == FieldTagline) result = StringUtils::Format("movieview.c%02d", VIDEODB_ID_TAGLINE); - else if (field == FieldVotes) result = StringUtils::Format("movieview.c%02d", VIDEODB_ID_VOTES); + else if (field == FieldPlot) result = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_PLOT); + else if (field == FieldPlotOutline) result = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_PLOTOUTLINE); + else if (field == FieldTagline) result = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_TAGLINE); + else if (field == FieldVotes) result = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_VOTES); else if (field == FieldRating) { if (queryPart == DatabaseQueryPartOrderBy) - result = StringUtils::Format("CAST(movieview.c%02d as DECIMAL(5,3))", VIDEODB_ID_RATING); + result = StringUtils::Format("CAST(movie_view.c%02d as DECIMAL(5,3))", VIDEODB_ID_RATING); else - result = StringUtils::Format("movieview.c%02d", VIDEODB_ID_RATING); + result = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_RATING); } - else if (field == FieldWriter) result = StringUtils::Format("movieview.c%02d", VIDEODB_ID_CREDITS); - else if (field == FieldYear) result = StringUtils::Format("movieview.c%02d", VIDEODB_ID_YEAR); - else if (field == FieldSortTitle) result = StringUtils::Format("movieview.c%02d", VIDEODB_ID_SORTTITLE); - else if (field == FieldTime) result = StringUtils::Format("movieview.c%02d", VIDEODB_ID_RUNTIME); - else if (field == FieldMPAA) result = StringUtils::Format("movieview.c%02d", VIDEODB_ID_MPAA); - else if (field == FieldTop250) result = StringUtils::Format("movieview.c%02d", VIDEODB_ID_TOP250); - else if (field == FieldSet) return "movieview.strSet"; - else if (field == FieldGenre) result = StringUtils::Format("movieview.c%02d", VIDEODB_ID_GENRE); - else if (field == FieldDirector) result = StringUtils::Format("movieview.c%02d", VIDEODB_ID_DIRECTOR); - else if (field == FieldStudio) result = StringUtils::Format("movieview.c%02d", VIDEODB_ID_STUDIOS); - else if (field == FieldTrailer) result = StringUtils::Format("movieview.c%02d", VIDEODB_ID_TRAILER); - else if (field == FieldCountry) result = StringUtils::Format("movieview.c%02d", VIDEODB_ID_COUNTRY); - else if (field == FieldFilename) return "movieview.strFilename"; - else if (field == FieldPath) return "movieview.strPath"; - else if (field == FieldPlaycount) return "movieview.playCount"; - else if (field == FieldLastPlayed) return "movieview.lastPlayed"; - else if (field == FieldDateAdded) return "movieview.dateAdded"; + else if (field == FieldWriter) result = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_CREDITS); + else if (field == FieldYear) result = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_YEAR); + else if (field == FieldSortTitle) result = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_SORTTITLE); + else if (field == FieldTime) result = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_RUNTIME); + else if (field == FieldMPAA) result = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_MPAA); + else if (field == FieldTop250) result = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_TOP250); + else if (field == FieldSet) return "movie_view.strSet"; + else if (field == FieldGenre) result = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_GENRE); + else if (field == FieldDirector) result = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_DIRECTOR); + else if (field == FieldStudio) result = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_STUDIOS); + else if (field == FieldTrailer) result = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_TRAILER); + else if (field == FieldCountry) result = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_COUNTRY); + else if (field == FieldFilename) return "movie_view.strFilename"; + else if (field == FieldPath) return "movie_view.strPath"; + else if (field == FieldPlaycount) return "movie_view.playCount"; + else if (field == FieldLastPlayed) return "movie_view.lastPlayed"; + else if (field == FieldDateAdded) return "movie_view.dateAdded"; if (!result.empty()) return result; } else if (mediaType == MediaTypeTvShow) { - CStdString result; - if (field == FieldId) return "tvshowview.idShow"; + std::string result; + if (field == FieldId) return "tvshow_view.idShow"; else if (field == FieldTitle) { // We need some extra logic to get the title value if sorttitle isn't set if (queryPart == DatabaseQueryPartOrderBy) - result = StringUtils::Format("CASE WHEN length(tvshowview.c%02d) > 0 THEN tvshowview.c%02d ELSE tvshowview.c%02d END", VIDEODB_ID_TV_SORTTITLE, VIDEODB_ID_TV_SORTTITLE, VIDEODB_ID_TV_TITLE); + result = StringUtils::Format("CASE WHEN length(tvshow_view.c%02d) > 0 THEN tvshow_view.c%02d ELSE tvshow_view.c%02d END", VIDEODB_ID_TV_SORTTITLE, VIDEODB_ID_TV_SORTTITLE, VIDEODB_ID_TV_TITLE); else - result = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_TITLE); + result = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_TITLE); } - else if (field == FieldPlot) result = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_PLOT); - else if (field == FieldTvShowStatus) result = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_STATUS); - else if (field == FieldVotes) result = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_VOTES); - else if (field == FieldRating) result = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_RATING); - else if (field == FieldYear) result = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_PREMIERED); - else if (field == FieldGenre) result = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_GENRE); - else if (field == FieldMPAA) result = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_MPAA); - else if (field == FieldStudio) result = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_STUDIOS); - else if (field == FieldSortTitle) result = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_SORTTITLE); - else if (field == FieldPath) return "tvshowview.strPath"; - else if (field == FieldDateAdded) return "tvshowview.dateAdded"; - else if (field == FieldLastPlayed) return "tvshowview.lastPlayed"; - else if (field == FieldSeason) return "tvshowview.totalSeasons"; - else if (field == FieldNumberOfEpisodes) return "tvshowview.totalCount"; - else if (field == FieldNumberOfWatchedEpisodes) return "tvshowview.watchedcount"; + else if (field == FieldPlot) result = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_PLOT); + else if (field == FieldTvShowStatus) result = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_STATUS); + else if (field == FieldVotes) result = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_VOTES); + else if (field == FieldRating) result = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_RATING); + else if (field == FieldYear) result = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_PREMIERED); + else if (field == FieldGenre) result = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_GENRE); + else if (field == FieldMPAA) result = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_MPAA); + else if (field == FieldStudio) result = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_STUDIOS); + else if (field == FieldSortTitle) result = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_SORTTITLE); + else if (field == FieldPath) return "tvshow_view.strPath"; + else if (field == FieldDateAdded) return "tvshow_view.dateAdded"; + else if (field == FieldLastPlayed) return "tvshow_view.lastPlayed"; + else if (field == FieldSeason) return "tvshow_view.totalSeasons"; + else if (field == FieldNumberOfEpisodes) return "tvshow_view.totalCount"; + else if (field == FieldNumberOfWatchedEpisodes) return "tvshow_view.watchedcount"; if (!result.empty()) return result; } else if (mediaType == MediaTypeEpisode) { - CStdString result; - if (field == FieldId) return "episodeview.idEpisode"; - else if (field == FieldTitle) result = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_TITLE); - else if (field == FieldPlot) result = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_PLOT); - else if (field == FieldVotes) result = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_VOTES); - else if (field == FieldRating) result = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_RATING); - else if (field == FieldWriter) result = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_CREDITS); - else if (field == FieldAirDate) result = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_AIRED); - else if (field == FieldTime) result = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_RUNTIME); - else if (field == FieldDirector) result = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_DIRECTOR); - else if (field == FieldSeason) result = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_SEASON); - else if (field == FieldEpisodeNumber) result = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_EPISODE); - else if (field == FieldUniqueId) result = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_UNIQUEID); - else if (field == FieldEpisodeNumberSpecialSort) result = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_SORTEPISODE); - else if (field == FieldSeasonSpecialSort) result = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_SORTSEASON); - else if (field == FieldFilename) return "episodeview.strFilename"; - else if (field == FieldPath) return "episodeview.strPath"; - else if (field == FieldPlaycount) return "episodeview.playCount"; - else if (field == FieldLastPlayed) return "episodeview.lastPlayed"; - else if (field == FieldDateAdded) return "episodeview.dateAdded"; - else if (field == FieldTvShowTitle) return "episodeview.strTitle"; - else if (field == FieldYear) return "episodeview.premiered"; - else if (field == FieldMPAA) return "episodeview.mpaa"; - else if (field == FieldStudio) return "episodeview.strStudio"; + std::string result; + if (field == FieldId) return "episode_view.idEpisode"; + else if (field == FieldTitle) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_TITLE); + else if (field == FieldPlot) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_PLOT); + else if (field == FieldVotes) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_VOTES); + else if (field == FieldRating) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_RATING); + else if (field == FieldWriter) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_CREDITS); + else if (field == FieldAirDate) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_AIRED); + else if (field == FieldTime) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_RUNTIME); + else if (field == FieldDirector) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_DIRECTOR); + else if (field == FieldSeason) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_SEASON); + else if (field == FieldEpisodeNumber) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_EPISODE); + else if (field == FieldUniqueId) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_UNIQUEID); + else if (field == FieldEpisodeNumberSpecialSort) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_SORTEPISODE); + else if (field == FieldSeasonSpecialSort) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_SORTSEASON); + else if (field == FieldFilename) return "episode_view.strFilename"; + else if (field == FieldPath) return "episode_view.strPath"; + else if (field == FieldPlaycount) return "episode_view.playCount"; + else if (field == FieldLastPlayed) return "episode_view.lastPlayed"; + else if (field == FieldDateAdded) return "episode_view.dateAdded"; + else if (field == FieldTvShowTitle) return "episode_view.strTitle"; + else if (field == FieldYear) return "episode_view.premiered"; + else if (field == FieldMPAA) return "episode_view.mpaa"; + else if (field == FieldStudio) return "episode_view.strStudio"; if (!result.empty()) return result; diff --git a/xbmc/utils/EdenVideoArtUpdater.cpp b/xbmc/utils/EdenVideoArtUpdater.cpp index 448f390860..d50b5b3966 100644 --- a/xbmc/utils/EdenVideoArtUpdater.cpp +++ b/xbmc/utils/EdenVideoArtUpdater.cpp @@ -94,7 +94,7 @@ void CEdenVideoArtUpdater::Process() if (!db.GetArtForItem(item->GetVideoInfoTag()->m_iDbId, item->GetVideoInfoTag()->m_type, artwork) || (artwork.size() == 1 && artwork.find("thumb") != artwork.end())) { - CStdString art = CVideoInfoScanner::GetImage(item.get(), true, item->GetVideoInfoTag()->m_basePath != item->GetPath(), "thumb"); + std::string art = CVideoInfoScanner::GetImage(item.get(), true, item->GetVideoInfoTag()->m_basePath != item->GetPath(), "thumb"); std::string type; if (CacheTexture(art, cachedThumb, item->GetLabel(), type)) artwork.insert(make_pair(type, art)); @@ -128,7 +128,7 @@ void CEdenVideoArtUpdater::Process() if (!db.GetArtForItem(item->GetVideoInfoTag()->m_iDbId, item->GetVideoInfoTag()->m_type, artwork) || (artwork.size() == 1 && artwork.find("thumb") != artwork.end())) { - CStdString art = CVideoInfoScanner::GetImage(item.get(), true, item->GetVideoInfoTag()->m_basePath != item->GetPath(), "thumb"); + std::string art = CVideoInfoScanner::GetImage(item.get(), true, item->GetVideoInfoTag()->m_basePath != item->GetPath(), "thumb"); std::string type; if (CacheTexture(art, cachedThumb, item->GetLabel(), type)) artwork.insert(make_pair(type, art)); @@ -162,7 +162,7 @@ void CEdenVideoArtUpdater::Process() if (!db.GetArtForItem(item->GetVideoInfoTag()->m_iDbId, item->GetVideoInfoTag()->m_type, artwork) || (artwork.size() == 1 && artwork.find("thumb") != artwork.end())) { - CStdString art = CVideoInfoScanner::GetImage(item.get(), true, false, "thumb"); + std::string art = CVideoInfoScanner::GetImage(item.get(), true, false, "thumb"); std::string type; if (CacheTexture(art, cachedThumb, item->GetLabel(), type)) artwork.insert(make_pair(type, art)); @@ -198,7 +198,7 @@ void CEdenVideoArtUpdater::Process() // now episodes... CFileItemList items2; - db.GetEpisodesByWhere("videodb://tvshows/titles/-1/-1/", db.PrepareSQL("episodeview.idShow=%d", item->GetVideoInfoTag()->m_iDbId), items2); + db.GetEpisodesByWhere("videodb://tvshows/titles/-1/-1/", db.PrepareSQL("episode_view.idShow=%d", item->GetVideoInfoTag()->m_iDbId), items2); for (int j = 0; j < items2.Size(); j++) { handle->SetProgress(j, items2.Size()); @@ -213,7 +213,7 @@ void CEdenVideoArtUpdater::Process() if (!db.GetArtForItem(episode->GetVideoInfoTag()->m_iDbId, episode->GetVideoInfoTag()->m_type, artwork) || (artwork.size() == 1 && artwork.find("thumb") != artwork.end())) { - CStdString art = CVideoInfoScanner::GetImage(episode.get(), true, episode->GetVideoInfoTag()->m_basePath != episode->GetPath(), "thumb"); + std::string art = CVideoInfoScanner::GetImage(episode.get(), true, episode->GetVideoInfoTag()->m_basePath != episode->GetPath(), "thumb"); if (CacheTexture(art, cachedThumb, episode->GetLabel())) artwork.insert(make_pair("thumb", art)); else @@ -328,14 +328,14 @@ bool CEdenVideoArtUpdater::CacheTexture(std::string &originalUrl, const std::str return false; } -CStdString CEdenVideoArtUpdater::GetCachedActorThumb(const CFileItem &item) +std::string CEdenVideoArtUpdater::GetCachedActorThumb(const CFileItem &item) { return GetThumb("actor" + item.GetLabel(), CProfilesManager::Get().GetVideoThumbFolder(), true); } -CStdString CEdenVideoArtUpdater::GetCachedSeasonThumb(int season, const CStdString &path) +std::string CEdenVideoArtUpdater::GetCachedSeasonThumb(int season, const std::string &path) { - CStdString label; + std::string label; if (season == -1) label = g_localizeStrings.Get(20366); else if (season == 0) @@ -345,22 +345,22 @@ CStdString CEdenVideoArtUpdater::GetCachedSeasonThumb(int season, const CStdStri return GetThumb("season" + path + label, CProfilesManager::Get().GetVideoThumbFolder(), true); } -CStdString CEdenVideoArtUpdater::GetCachedEpisodeThumb(const CFileItem &item) +std::string CEdenVideoArtUpdater::GetCachedEpisodeThumb(const CFileItem &item) { // get the locally cached thumb - CStdString strCRC = StringUtils::Format("%sepisode%i", + std::string strCRC = StringUtils::Format("%sepisode%i", item.GetVideoInfoTag()->m_strFileNameAndPath.c_str(), item.GetVideoInfoTag()->m_iEpisode); return GetThumb(strCRC, CProfilesManager::Get().GetVideoThumbFolder(), true); } -CStdString CEdenVideoArtUpdater::GetCachedVideoThumb(const CFileItem &item) +std::string CEdenVideoArtUpdater::GetCachedVideoThumb(const CFileItem &item) { if (item.m_bIsFolder && !item.GetVideoInfoTag()->m_strPath.empty()) return GetThumb(item.GetVideoInfoTag()->m_strPath, CProfilesManager::Get().GetVideoThumbFolder(), true); else if (!item.GetVideoInfoTag()->m_strFileNameAndPath.empty()) { - CStdString path = item.GetVideoInfoTag()->m_strFileNameAndPath; + std::string path = item.GetVideoInfoTag()->m_strFileNameAndPath; if (URIUtils::IsStack(path)) path = CStackDirectory::GetFirstStackedFile(path); return GetThumb(path, CProfilesManager::Get().GetVideoThumbFolder(), true); @@ -368,26 +368,26 @@ CStdString CEdenVideoArtUpdater::GetCachedVideoThumb(const CFileItem &item) return GetThumb(item.GetPath(), CProfilesManager::Get().GetVideoThumbFolder(), true); } -CStdString CEdenVideoArtUpdater::GetCachedFanart(const CFileItem &item) +std::string CEdenVideoArtUpdater::GetCachedFanart(const CFileItem &item) { if (!item.GetVideoInfoTag()->m_artist.empty()) return GetThumb(StringUtils::Join(item.GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator), URIUtils::AddFileToFolder(CProfilesManager::Get().GetThumbnailsFolder(), "Music/Fanart/"), false); - CStdString path = item.GetVideoInfoTag()->GetPath(); + std::string path = item.GetVideoInfoTag()->GetPath(); if (path.empty()) return ""; return GetThumb(path, URIUtils::AddFileToFolder(CProfilesManager::Get().GetVideoThumbFolder(), "Fanart/"), false); } -CStdString CEdenVideoArtUpdater::GetThumb(const CStdString &path, const CStdString &path2, bool split) +std::string CEdenVideoArtUpdater::GetThumb(const std::string &path, const std::string &path2, bool split) { // get the locally cached thumb Crc32 crc; crc.ComputeFromLowerCase(path); - CStdString thumb; + std::string thumb; if (split) { - CStdString hex = StringUtils::Format("%08x", (__int32)crc); + std::string hex = StringUtils::Format("%08x", (__int32)crc); thumb = StringUtils::Format("%c\\%08x.tbn", hex[0], (unsigned __int32)crc); } else diff --git a/xbmc/utils/EdenVideoArtUpdater.h b/xbmc/utils/EdenVideoArtUpdater.h index 312ff593b3..184b0c6d65 100644 --- a/xbmc/utils/EdenVideoArtUpdater.h +++ b/xbmc/utils/EdenVideoArtUpdater.h @@ -22,6 +22,7 @@ #include <string> #include "threads/Thread.h" #include "TextureDatabase.h" +#include <string> class CFileItem; @@ -45,12 +46,12 @@ private: bool CacheTexture(std::string &originalUrl, const std::string &cachedFile, const std::string &label, std::string &type); bool CacheTexture(std::string &originalUrl, const std::string &oldCachedFile, const std::string &label); - CStdString GetCachedActorThumb(const CFileItem &item); - CStdString GetCachedSeasonThumb(int season, const CStdString &path); - CStdString GetCachedEpisodeThumb(const CFileItem &item); - CStdString GetCachedVideoThumb(const CFileItem &item); - CStdString GetCachedFanart(const CFileItem &item); - CStdString GetThumb(const CStdString &path, const CStdString &path2, bool split /* = false */); + std::string GetCachedActorThumb(const CFileItem &item); + std::string GetCachedSeasonThumb(int season, const std::string &path); + std::string GetCachedEpisodeThumb(const CFileItem &item); + std::string GetCachedVideoThumb(const CFileItem &item); + std::string GetCachedFanart(const CFileItem &item); + std::string GetThumb(const std::string &path, const std::string &path2, bool split /* = false */); CTextureDatabase m_textureDB; }; diff --git a/xbmc/utils/FileOperationJob.cpp b/xbmc/utils/FileOperationJob.cpp index 099ae8fb42..164c0b188a 100644 --- a/xbmc/utils/FileOperationJob.cpp +++ b/xbmc/utils/FileOperationJob.cpp @@ -51,7 +51,7 @@ CFileOperationJob::CFileOperationJob() } CFileOperationJob::CFileOperationJob(FileAction action, CFileItemList & items, - const CStdString& strDestFile, + const std::string& strDestFile, bool displayProgress, int heading, int line) { @@ -62,7 +62,7 @@ CFileOperationJob::CFileOperationJob(FileAction action, CFileItemList & items, SetFileOperation(action, items, strDestFile); } -void CFileOperationJob::SetFileOperation(FileAction action, CFileItemList &items, const CStdString &strDestFile) +void CFileOperationJob::SetFileOperation(FileAction action, CFileItemList &items, const std::string &strDestFile) { m_action = action; m_strDestFile = strDestFile; @@ -100,7 +100,7 @@ bool CFileOperationJob::DoWork() return success; } -bool CFileOperationJob::DoProcessFile(FileAction action, const CStdString& strFileA, const CStdString& strFileB, FileOperationList &fileOperations, double &totalTime) +bool CFileOperationJob::DoProcessFile(FileAction action, const std::string& strFileA, const std::string& strFileB, FileOperationList &fileOperations, double &totalTime) { int64_t time = 1; @@ -118,7 +118,7 @@ bool CFileOperationJob::DoProcessFile(FileAction action, const CStdString& strFi return true; } -bool CFileOperationJob::DoProcessFolder(FileAction action, const CStdString& strPath, const CStdString& strDestFile, FileOperationList &fileOperations, double &totalTime) +bool CFileOperationJob::DoProcessFolder(FileAction action, const std::string& strPath, const std::string& strDestFile, FileOperationList &fileOperations, double &totalTime) { // check whether this folder is a filedirectory - if so, we don't process it's contents CFileItem item(strPath, false); @@ -150,16 +150,16 @@ bool CFileOperationJob::DoProcessFolder(FileAction action, const CStdString& str return true; } -bool CFileOperationJob::DoProcess(FileAction action, CFileItemList & items, const CStdString& strDestFile, FileOperationList &fileOperations, double &totalTime) +bool CFileOperationJob::DoProcess(FileAction action, CFileItemList & items, const std::string& strDestFile, FileOperationList &fileOperations, double &totalTime) { for (int iItem = 0; iItem < items.Size(); ++iItem) { CFileItemPtr pItem = items[iItem]; if (pItem->IsSelected()) { - CStdString strNoSlash = pItem->GetPath(); + std::string strNoSlash = pItem->GetPath(); URIUtils::RemoveSlashAtEnd(strNoSlash); - CStdString strFileName = URIUtils::GetFileName(strNoSlash); + std::string strFileName = URIUtils::GetFileName(strNoSlash); // special case for upnp if (URIUtils::IsUPnP(items.GetPath()) || URIUtils::IsUPnP(pItem->GetPath())) @@ -177,7 +177,7 @@ bool CFileOperationJob::DoProcess(FileAction action, CFileItemList & items, cons strFileName = CUtil::MakeLegalFileName(strFileName); } - CStdString strnewDestFile; + std::string strnewDestFile; if(!strDestFile.empty()) // only do this if we have a destination strnewDestFile = URIUtils::ChangeBasePath(pItem->GetPath(), strFileName, strDestFile); // Convert (URL) encoding + slashes (if source / target differ) @@ -204,7 +204,7 @@ bool CFileOperationJob::DoProcess(FileAction action, CFileItemList & items, cons return true; } -CFileOperationJob::CFileOperation::CFileOperation(FileAction action, const CStdString &strFileA, const CStdString &strFileB, int64_t time) : m_action(action), m_strFileA(strFileA), m_strFileB(strFileB), m_time(time) +CFileOperationJob::CFileOperation::CFileOperation(FileAction action, const std::string &strFileA, const std::string &strFileB, int64_t time) : m_action(action), m_strFileA(strFileA), m_strFileB(strFileB), m_time(time) { } @@ -215,9 +215,9 @@ struct DataHolder double opWeight; }; -CStdString CFileOperationJob::GetActionString(FileAction action) +std::string CFileOperationJob::GetActionString(FileAction action) { - CStdString result; + std::string result; switch (action) { case ActionCopy: @@ -309,7 +309,7 @@ bool CFileOperationJob::CFileOperation::ExecuteOperation(CFileOperationJob *base return bResult; } -inline bool CFileOperationJob::CanBeRenamed(const CStdString &strFileA, const CStdString &strFileB) +inline bool CFileOperationJob::CanBeRenamed(const std::string &strFileA, const std::string &strFileB) { #ifndef TARGET_POSIX if (strFileA[1] == ':' && strFileA[0] == strFileB[0]) @@ -338,7 +338,7 @@ bool CFileOperationJob::CFileOperation::OnFileCallback(void* pContext, int iperc if (data->base->m_handle) { - CStdString line; + std::string line; line = StringUtils::Format("%s (%s)", data->base->GetCurrentFile().c_str(), data->base->GetAverageSpeed().c_str()); diff --git a/xbmc/utils/FileOperationJob.h b/xbmc/utils/FileOperationJob.h index 908da10329..6a7d4a0c7a 100644 --- a/xbmc/utils/FileOperationJob.h +++ b/xbmc/utils/FileOperationJob.h @@ -23,6 +23,8 @@ #include "FileItem.h" #include "Job.h" #include "filesystem/File.h" +#include <string> +#include <vector> class CGUIDialogProgressBarHandle; @@ -41,22 +43,22 @@ public: CFileOperationJob(); CFileOperationJob(FileAction action, CFileItemList & items, - const CStdString& strDestFile, + const std::string& strDestFile, bool displayProgress=false, int errorHeading=0, int errorLine=0); - void SetFileOperation(FileAction action, CFileItemList &items, const CStdString &strDestFile); + void SetFileOperation(FileAction action, CFileItemList &items, const std::string &strDestFile); virtual bool operator==(const CJob *job) const; - static CStdString GetActionString(FileAction action); + static std::string GetActionString(FileAction action); const char* GetType() const { return m_displayProgress?"filemanager":""; } virtual bool DoWork(); - const CStdString &GetAverageSpeed() const { return m_avgSpeed; } - const CStdString &GetCurrentOperation() const { return m_currentOperation; } - const CStdString &GetCurrentFile() const { return m_currentFile; } + const std::string &GetAverageSpeed() const { return m_avgSpeed; } + const std::string &GetCurrentOperation() const { return m_currentOperation; } + const std::string &GetCurrentFile() const { return m_currentFile; } const CFileItemList &GetItems() const { return m_items; } FileAction GetAction() const { return m_action; } int GetHeading() const { return m_heading; } @@ -65,27 +67,27 @@ private: class CFileOperation : public XFILE::IFileCallback { public: - CFileOperation(FileAction action, const CStdString &strFileA, const CStdString &strFileB, int64_t time); + CFileOperation(FileAction action, const std::string &strFileA, const std::string &strFileB, int64_t time); bool ExecuteOperation(CFileOperationJob *base, double ¤t, double opWeight); void Debug(); virtual bool OnFileCallback(void* pContext, int ipercent, float avgSpeed); private: FileAction m_action; - CStdString m_strFileA, m_strFileB; + std::string m_strFileA, m_strFileB; int64_t m_time; }; friend class CFileOperation; typedef std::vector<CFileOperation> FileOperationList; - bool DoProcess(FileAction action, CFileItemList & items, const CStdString& strDestFile, FileOperationList &fileOperations, double &totalTime); - bool DoProcessFolder(FileAction action, const CStdString& strPath, const CStdString& strDestFile, FileOperationList &fileOperations, double &totalTime); - bool DoProcessFile(FileAction action, const CStdString& strFileA, const CStdString& strFileB, FileOperationList &fileOperations, double &totalTime); + bool DoProcess(FileAction action, CFileItemList & items, const std::string& strDestFile, FileOperationList &fileOperations, double &totalTime); + bool DoProcessFolder(FileAction action, const std::string& strPath, const std::string& strDestFile, FileOperationList &fileOperations, double &totalTime); + bool DoProcessFile(FileAction action, const std::string& strFileA, const std::string& strFileB, FileOperationList &fileOperations, double &totalTime); - static inline bool CanBeRenamed(const CStdString &strFileA, const CStdString &strFileB); + static inline bool CanBeRenamed(const std::string &strFileA, const std::string &strFileB); FileAction m_action; CFileItemList m_items; - CStdString m_strDestFile; - CStdString m_avgSpeed, m_currentOperation, m_currentFile; + std::string m_strDestFile; + std::string m_avgSpeed, m_currentOperation, m_currentFile; CGUIDialogProgressBarHandle* m_handle; bool m_displayProgress; int m_heading; diff --git a/xbmc/utils/FileUtils.cpp b/xbmc/utils/FileUtils.cpp index 2b54f363f3..d9b1cffe4f 100644 --- a/xbmc/utils/FileUtils.cpp +++ b/xbmc/utils/FileUtils.cpp @@ -37,7 +37,7 @@ using namespace XFILE; using namespace std; -bool CFileUtils::DeleteItem(const CStdString &strPath, bool force) +bool CFileUtils::DeleteItem(const std::string &strPath, bool force) { CFileItemPtr item(new CFileItem(strPath)); item->SetPath(strPath); @@ -75,12 +75,12 @@ bool CFileUtils::DeleteItem(const CFileItemPtr &item, bool force) return op.DoWork(); } -bool CFileUtils::RenameFile(const CStdString &strFile) +bool CFileUtils::RenameFile(const std::string &strFile) { - CStdString strFileAndPath(strFile); + std::string strFileAndPath(strFile); URIUtils::RemoveSlashAtEnd(strFileAndPath); - CStdString strFileName = URIUtils::GetFileName(strFileAndPath); - CStdString strPath = URIUtils::GetDirectory(strFileAndPath); + std::string strFileName = URIUtils::GetFileName(strFileAndPath); + std::string strPath = URIUtils::GetDirectory(strFileAndPath); if (CGUIKeyboardFactory::ShowAndGetInput(strFileName, g_localizeStrings.Get(16013), false)) { strPath = URIUtils::AddFileToFolder(strPath, strFileName); @@ -92,7 +92,7 @@ bool CFileUtils::RenameFile(const CStdString &strFile) bool success = false; for (unsigned int i = 0; i < paths.size(); ++i) { - CStdString filePath(paths[i]); + std::string filePath(paths[i]); URIUtils::RemoveSlashAtEnd(filePath); filePath = URIUtils::GetDirectory(filePath); filePath = URIUtils::AddFileToFolder(filePath, strFileName); @@ -106,10 +106,10 @@ bool CFileUtils::RenameFile(const CStdString &strFile) return false; } -bool CFileUtils::RemoteAccessAllowed(const CStdString &strPath) +bool CFileUtils::RemoteAccessAllowed(const std::string &strPath) { const unsigned int SourcesSize = 5; - CStdString SourceNames[] = { "programs", "files", "video", "music", "pictures" }; + std::string SourceNames[] = { "programs", "files", "video", "music", "pictures" }; string realPath = URIUtils::GetRealPath(strPath); // for rar:// and zip:// paths we need to extract the path to the archive diff --git a/xbmc/utils/FileUtils.h b/xbmc/utils/FileUtils.h index a73ab62401..fdf4a8ee4b 100644 --- a/xbmc/utils/FileUtils.h +++ b/xbmc/utils/FileUtils.h @@ -25,7 +25,8 @@ class CFileUtils { public: static bool DeleteItem(const CFileItemPtr &item, bool force=false); - static bool DeleteItem(const CStdString &strPath, bool force=false); - static bool RenameFile(const CStdString &strFile); - static bool RemoteAccessAllowed(const CStdString &strPath); + static bool DeleteItem(const std::string &strPath, bool force=false); + static bool RenameFile(const std::string &strFile); + static bool RemoteAccessAllowed(const std::string &strPath); + static unsigned int LoadFile(const std::string &filename, void* &outputBuffer); }; diff --git a/xbmc/utils/LabelFormatter.cpp b/xbmc/utils/LabelFormatter.cpp index c54856964f..163fe9de3a 100644 --- a/xbmc/utils/LabelFormatter.cpp +++ b/xbmc/utils/LabelFormatter.cpp @@ -284,7 +284,7 @@ std::string CLabelFormatter::GetMaskContent(const CMaskString &mask, const CFile } break; case 'O': - if (movie && movie->m_strMPAARating) + if (movie) {// MPAA Rating value = movie->m_strMPAARating; } diff --git a/xbmc/utils/Makefile.in b/xbmc/utils/Makefile.in index e2034470c6..2d89fcd0aa 100644 --- a/xbmc/utils/Makefile.in +++ b/xbmc/utils/Makefile.in @@ -79,6 +79,7 @@ SRCS += XMLUtils.cpp SRCS += Utf8Utils.cpp SRCS += XSLTUtils.cpp SRCS += ActorProtocol.cpp +SRCS += SysfsUtils.cpp ifeq (@USE_OPENGLES@,1) SRCS += AMLUtils.cpp diff --git a/xbmc/utils/Mime.cpp b/xbmc/utils/Mime.cpp index 874085f5b1..f18d2d4438 100644 --- a/xbmc/utils/Mime.cpp +++ b/xbmc/utils/Mime.cpp @@ -22,7 +22,6 @@ #include "Mime.h" #include "FileItem.h" -#include "StdString.h" #include "URIUtils.h" #include "music/tags/MusicInfoTag.h" #include "video/VideoInfoTag.h" @@ -531,7 +530,7 @@ string CMime::GetMimeType(const string &extension) string CMime::GetMimeType(const CFileItem &item) { - CStdString path = item.GetPath(); + std::string path = item.GetPath(); if (item.HasVideoInfoTag() && !item.GetVideoInfoTag()->GetPath().empty()) path = item.GetVideoInfoTag()->GetPath(); else if (item.HasMusicInfoTag() && !item.GetMusicInfoTag()->GetURL().empty()) @@ -551,7 +550,7 @@ string CMime::GetMimeType(const CURL &url, bool lookup) if (!lookup) return strMimeType; - CStdString strmime; + std::string strmime; XFILE::CCurlFile::GetMimeType(url, strmime); // try to get mime-type again but with an NSPlayer User-Agent diff --git a/xbmc/utils/RecentlyAddedJob.cpp b/xbmc/utils/RecentlyAddedJob.cpp index f4770c714f..1f8ec36232 100644 --- a/xbmc/utils/RecentlyAddedJob.cpp +++ b/xbmc/utils/RecentlyAddedJob.cpp @@ -63,8 +63,8 @@ bool CRecentlyAddedJob::UpdateVideo() for (; i < items.Size(); ++i) { CFileItemPtr item = items.Get(i); - CStdString value = StringUtils::Format("%i", i + 1); - CStdString strRating = StringUtils::Format("%.1f", item->GetVideoInfoTag()->m_fRating);; + std::string value = StringUtils::Format("%i", i + 1); + std::string strRating = StringUtils::Format("%.1f", item->GetVideoInfoTag()->m_fRating);; home->SetProperty("LatestMovie." + value + ".Title" , item->GetLabel()); home->SetProperty("LatestMovie." + value + ".Rating" , strRating); @@ -83,7 +83,7 @@ bool CRecentlyAddedJob::UpdateVideo() } for (; i < NUM_ITEMS; ++i) { - CStdString value = StringUtils::Format("%i", i + 1); + std::string value = StringUtils::Format("%i", i + 1); home->SetProperty("LatestMovie." + value + ".Title" , ""); home->SetProperty("LatestMovie." + value + ".Thumb" , ""); home->SetProperty("LatestMovie." + value + ".Rating" , ""); @@ -105,9 +105,9 @@ bool CRecentlyAddedJob::UpdateVideo() CFileItemPtr item = TVShowItems.Get(i); int EpisodeSeason = item->GetVideoInfoTag()->m_iSeason; int EpisodeNumber = item->GetVideoInfoTag()->m_iEpisode; - CStdString EpisodeNo = StringUtils::Format("s%02de%02d", EpisodeSeason, EpisodeNumber); - CStdString value = StringUtils::Format("%i", i + 1); - CStdString strRating = StringUtils::Format("%.1f", item->GetVideoInfoTag()->m_fRating); + std::string EpisodeNo = StringUtils::Format("s%02de%02d", EpisodeSeason, EpisodeNumber); + std::string value = StringUtils::Format("%i", i + 1); + std::string strRating = StringUtils::Format("%.1f", item->GetVideoInfoTag()->m_fRating); home->SetProperty("LatestEpisode." + value + ".ShowTitle" , item->GetVideoInfoTag()->m_strShowTitle); home->SetProperty("LatestEpisode." + value + ".EpisodeTitle" , item->GetVideoInfoTag()->m_strTitle); @@ -133,7 +133,7 @@ bool CRecentlyAddedJob::UpdateVideo() } for (; i < NUM_ITEMS; ++i) { - CStdString value = StringUtils::Format("%i", i + 1); + std::string value = StringUtils::Format("%i", i + 1); home->SetProperty("LatestEpisode." + value + ".ShowTitle" , ""); home->SetProperty("LatestEpisode." + value + ".EpisodeTitle" , ""); home->SetProperty("LatestEpisode." + value + ".Rating" , ""); @@ -156,7 +156,7 @@ bool CRecentlyAddedJob::UpdateVideo() for (; i < MusicVideoItems.Size(); ++i) { CFileItemPtr item = MusicVideoItems.Get(i); - CStdString value = StringUtils::Format("%i", i + 1); + std::string value = StringUtils::Format("%i", i + 1); home->SetProperty("LatestMusicVideo." + value + ".Title" , item->GetLabel()); home->SetProperty("LatestMusicVideo." + value + ".Year" , item->GetVideoInfoTag()->m_iYear); @@ -174,7 +174,7 @@ bool CRecentlyAddedJob::UpdateVideo() } for (; i < NUM_ITEMS; ++i) { - CStdString value = StringUtils::Format("%i", i + 1); + std::string value = StringUtils::Format("%i", i + 1); home->SetProperty("LatestMusicVideo." + value + ".Title" , ""); home->SetProperty("LatestMusicVideo." + value + ".Thumb" , ""); home->SetProperty("LatestMusicVideo." + value + ".Year" , ""); @@ -209,16 +209,16 @@ bool CRecentlyAddedJob::UpdateMusic() if (musicdatabase.GetRecentlyAddedAlbumSongs("musicdb://songs/", musicItems, NUM_ITEMS)) { long idAlbum = -1; - CStdString strAlbumThumb; - CStdString strAlbumFanart; + std::string strAlbumThumb; + std::string strAlbumFanart; for (; i < musicItems.Size(); ++i) { CFileItemPtr item = musicItems.Get(i); - CStdString value = StringUtils::Format("%i", i + 1); + std::string value = StringUtils::Format("%i", i + 1); - CStdString strRating; - CStdString strAlbum = item->GetMusicInfoTag()->GetAlbum(); - CStdString strArtist = StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator); + std::string strRating; + std::string strAlbum = item->GetMusicInfoTag()->GetAlbum(); + std::string strArtist = StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator); if (idAlbum != item->GetMusicInfoTag()->GetAlbumId()) { @@ -247,7 +247,7 @@ bool CRecentlyAddedJob::UpdateMusic() } for (; i < NUM_ITEMS; ++i) { - CStdString value = StringUtils::Format("%i", i + 1); + std::string value = StringUtils::Format("%i", i + 1); home->SetProperty("LatestSong." + value + ".Title" , ""); home->SetProperty("LatestSong." + value + ".Year" , ""); home->SetProperty("LatestSong." + value + ".Artist" , ""); @@ -266,12 +266,12 @@ bool CRecentlyAddedJob::UpdateMusic() for (; i < (int)albums.size(); ++i) { CAlbum& album=albums[i]; - CStdString value = StringUtils::Format("%i", i + 1); - CStdString strThumb = musicdatabase.GetArtForItem(album.idAlbum, MediaTypeAlbum, "thumb"); - CStdString strFanart = musicdatabase.GetArtistArtForItem(album.idAlbum, MediaTypeAlbum, "fanart"); - CStdString strDBpath = StringUtils::Format("musicdb://albums/%li/", album.idAlbum); - CStdString strSQLAlbum = StringUtils::Format("idAlbum=%li", album.idAlbum); - CStdString strArtist = musicdatabase.GetSingleValue("albumview", "strArtists", strSQLAlbum); + std::string value = StringUtils::Format("%i", i + 1); + std::string strThumb = musicdatabase.GetArtForItem(album.idAlbum, MediaTypeAlbum, "thumb"); + std::string strFanart = musicdatabase.GetArtistArtForItem(album.idAlbum, MediaTypeAlbum, "fanart"); + std::string strDBpath = StringUtils::Format("musicdb://albums/%li/", album.idAlbum); + std::string strSQLAlbum = StringUtils::Format("idAlbum=%li", album.idAlbum); + std::string strArtist = musicdatabase.GetSingleValue("albumview", "strArtists", strSQLAlbum); home->SetProperty("LatestAlbum." + value + ".Title" , album.strAlbum); home->SetProperty("LatestAlbum." + value + ".Year" , album.iYear); @@ -284,7 +284,7 @@ bool CRecentlyAddedJob::UpdateMusic() } for (; i < NUM_ITEMS; ++i) { - CStdString value = StringUtils::Format("%i", i + 1); + std::string value = StringUtils::Format("%i", i + 1); home->SetProperty("LatestAlbum." + value + ".Title" , ""); home->SetProperty("LatestAlbum." + value + ".Year" , ""); home->SetProperty("LatestAlbum." + value + ".Artist" , ""); @@ -317,14 +317,14 @@ bool CRecentlyAddedJob::UpdateTotal() musicdatabase.Close(); videodatabase.Open(); - int tvShowCount = atoi(videodatabase.GetSingleValue("tvshowview" , "count(1)").c_str()); - int movieTotals = atoi(videodatabase.GetSingleValue("movieview" , "count(1)").c_str()); - int movieWatched = atoi(videodatabase.GetSingleValue("movieview" , "count(playCount)").c_str()); - int MusVidTotals = atoi(videodatabase.GetSingleValue("musicvideoview" , "count(1)").c_str()); - int MusVidWatched = atoi(videodatabase.GetSingleValue("musicvideoview" , "count(playCount)").c_str()); - int EpWatched = atoi(videodatabase.GetSingleValue("tvshowview" , "sum(watchedcount)").c_str()); - int EpCount = atoi(videodatabase.GetSingleValue("tvshowview" , "sum(totalcount)").c_str()); - int TvShowsWatched = atoi(videodatabase.GetSingleValue("tvshowview" , "sum(watchedcount = totalcount)").c_str()); + int tvShowCount = atoi(videodatabase.GetSingleValue("tvshow_view" , "count(1)").c_str()); + int movieTotals = atoi(videodatabase.GetSingleValue("movie_view" , "count(1)").c_str()); + int movieWatched = atoi(videodatabase.GetSingleValue("movie_view" , "count(playCount)").c_str()); + int MusVidTotals = atoi(videodatabase.GetSingleValue("musicvideo_view" , "count(1)").c_str()); + int MusVidWatched = atoi(videodatabase.GetSingleValue("musicvideo_view" , "count(playCount)").c_str()); + int EpWatched = atoi(videodatabase.GetSingleValue("tvshow_view" , "sum(watchedcount)").c_str()); + int EpCount = atoi(videodatabase.GetSingleValue("tvshow_view" , "sum(totalcount)").c_str()); + int TvShowsWatched = atoi(videodatabase.GetSingleValue("tvshow_view" , "sum(watchedcount = totalcount)").c_str()); videodatabase.Close(); home->SetProperty("TVShows.Count" , tvShowCount); diff --git a/xbmc/utils/RegExp.cpp b/xbmc/utils/RegExp.cpp index 97a8bcbec9..c9cceb44f4 100644 --- a/xbmc/utils/RegExp.cpp +++ b/xbmc/utils/RegExp.cpp @@ -22,7 +22,6 @@ #include <string.h> #include <algorithm> #include "RegExp.h" -#include "StdString.h" #include "log.h" #include "utils/StringUtils.h" #include "utils/Utf8Utils.h" @@ -543,11 +542,11 @@ void CRegExp::DumpOvector(int iLog /* = LOGDEBUG */) if (iLog < LOGDEBUG || iLog > LOGNONE) return; - CStdString str = "{"; + std::string str = "{"; int size = GetSubCount(); // past the subpatterns is junk for (int i = 0; i <= size; i++) { - CStdString t = StringUtils::Format("[%i,%i]", m_iOvector[(i*2)], m_iOvector[(i*2)+1]); + std::string t = StringUtils::Format("[%i,%i]", m_iOvector[(i*2)], m_iOvector[(i*2)+1]); if (i != size) t += ","; str += t; diff --git a/xbmc/utils/SortUtils.cpp b/xbmc/utils/SortUtils.cpp index a2601ddd50..3d1f347e3c 100644 --- a/xbmc/utils/SortUtils.cpp +++ b/xbmc/utils/SortUtils.cpp @@ -24,7 +24,6 @@ #include "XBDateTime.h" #include "settings/AdvancedSettings.h" #include "utils/CharsetConverter.h" -#include "utils/StdString.h" #include "utils/StringUtils.h" #include "utils/Variant.h" @@ -120,7 +119,7 @@ string ByAlbum(SortAttribute attributes, const SortItem &values) if (attributes & SortAttributeIgnoreArticle) album = SortUtils::RemoveArticles(album); - CStdString label = StringUtils::Format("%s %s", album.c_str(), ArrayToString(attributes, values.at(FieldArtist)).c_str()); + std::string label = StringUtils::Format("%s %s", album.c_str(), ArrayToString(attributes, values.at(FieldArtist)).c_str()); const CVariant &track = values.at(FieldTrackNumber); if (!track.isNull()) @@ -136,7 +135,7 @@ string ByAlbumType(SortAttribute attributes, const SortItem &values) string ByArtist(SortAttribute attributes, const SortItem &values) { - CStdString label = ArrayToString(attributes, values.at(FieldArtist)); + std::string label = ArrayToString(attributes, values.at(FieldArtist)); const CVariant &year = values.at(FieldYear); if (g_advancedSettings.m_bMusicLibraryAlbumsSortByArtistThenYear && @@ -161,7 +160,7 @@ string ByTrackNumber(SortAttribute attributes, const SortItem &values) string ByTime(SortAttribute attributes, const SortItem &values) { - CStdString label; + std::string label; const CVariant &time = values.at(FieldTime); if (time.isInteger()) label = StringUtils::Format("%i", (int)time.asInteger()); @@ -193,7 +192,7 @@ string ByCountry(SortAttribute attributes, const SortItem &values) string ByYear(SortAttribute attributes, const SortItem &values) { - CStdString label; + std::string label; const CVariant &airDate = values.at(FieldAirDate); if (!airDate.isNull() && !airDate.asString().empty()) label = airDate.asString() + " "; @@ -656,7 +655,7 @@ void SortUtils::Sort(SortBy sortBy, SortOrder sortOrder, SortAttribute attribute item->insert(pair<Field, CVariant>(*field, CVariant::ConstNullVariant)); } - CStdStringW sortLabel; + std::wstring sortLabel; g_charsetConverter.utf8ToW(preparator(attributes, *item), sortLabel, false); item->insert(pair<Field, CVariant>(FieldSort, CVariant(sortLabel))); } @@ -695,7 +694,7 @@ void SortUtils::Sort(SortBy sortBy, SortOrder sortOrder, SortAttribute attribute (*item)->insert(pair<Field, CVariant>(*field, CVariant::ConstNullVariant)); } - CStdStringW sortLabel; + std::wstring sortLabel; g_charsetConverter.utf8ToW(preparator(attributes, **item), sortLabel, false); (*item)->insert(pair<Field, CVariant>(FieldSort, CVariant(sortLabel))); } diff --git a/xbmc/utils/SortUtils.h b/xbmc/utils/SortUtils.h index 0984af0e4b..5eda3c6fad 100644 --- a/xbmc/utils/SortUtils.h +++ b/xbmc/utils/SortUtils.h @@ -108,12 +108,12 @@ typedef struct SortDescription { { } } SortDescription; -typedef struct +typedef struct GUIViewSortDetails { SortDescription m_sortDescription; int m_buttonLabel; LABEL_MASKS m_labelMasks; -} SORT_METHOD_DETAILS; +} GUIViewSortDetails; typedef DatabaseResult SortItem; typedef boost::shared_ptr<SortItem> SortItemPtr; diff --git a/xbmc/utils/StdString.h b/xbmc/utils/StdString.h deleted file mode 100644 index 6430f1008a..0000000000 --- a/xbmc/utils/StdString.h +++ /dev/null @@ -1,3154 +0,0 @@ -#pragma once -#include <string> -#include <stdint.h> -#include <vector> - -#if defined(TARGET_WINDOWS) && !defined(va_copy) -#define va_copy(dst, src) ((dst) = (src)) -#endif - -// ============================================================================= -// FILE: StdString.h -// AUTHOR: Joe O'Leary (with outside help noted in comments) -// -// If you find any bugs in this code, please let me know: -// -// jmoleary@earthlink.net -// http://www.joeo.net/stdstring.htm (a bit outdated) -// -// The latest version of this code should always be available at the -// following link: -// -// http://www.joeo.net/code/StdString.zip (Dec 6, 2003) -// -// -// REMARKS: -// This header file declares the CStdStr template. This template derives -// the Standard C++ Library basic_string<> template and add to it the -// the following conveniences: -// - The full MFC CString set of functions (including implicit cast) -// - writing to/reading from COM IStream interfaces -// - Functional objects for use in STL algorithms -// -// From this template, we intstantiate two classes: CStdStringA and -// CStdStringW. The name "CStdString" is just a #define of one of these, -// based upone the UNICODE macro setting -// -// This header also declares our own version of the MFC/ATL UNICODE-MBCS -// conversion macros. Our version looks exactly like the Microsoft's to -// facilitate portability. -// -// NOTE: -// If you you use this in an MFC or ATL build, you should include either -// afx.h or atlbase.h first, as appropriate. -// -// PEOPLE WHO HAVE CONTRIBUTED TO THIS CLASS: -// -// Several people have helped me iron out problems and othewise improve -// this class. OK, this is a long list but in my own defense, this code -// has undergone two major rewrites. Many of the improvements became -// necessary after I rewrote the code as a template. Others helped me -// improve the CString facade. -// -// Anyway, these people are (in chronological order): -// -// - Pete the Plumber (???) -// - Julian Selman -// - Chris (of Melbsys) -// - Dave Plummer -// - John C Sipos -// - Chris Sells -// - Nigel Nunn -// - Fan Xia -// - Matthew Williams -// - Carl Engman -// - Mark Zeren -// - Craig Watson -// - Rich Zuris -// - Karim Ratib -// - Chris Conti -// - Baptiste Lepilleur -// - Greg Pickles -// - Jim Cline -// - Jeff Kohn -// - Todd Heckel -// - Ullrich Poll�hne -// - Joe Vitaterna -// - Joe Woodbury -// - Aaron (no last name) -// - Joldakowski (???) -// - Scott Hathaway -// - Eric Nitzche -// - Pablo Presedo -// - Farrokh Nejadlotfi -// - Jason Mills -// - Igor Kholodov -// - Mike Crusader -// - John James -// - Wang Haifeng -// - Tim Dowty -// - Arnt Witteveen -// - Glen Maynard -// - Paul DeMarco -// - Bagira (full name?) -// - Ronny Schulz -// - Jakko Van Hunen -// - Charles Godwin -// - Henk Demper -// - Greg Marr -// - Bill Carducci -// - Brian Groose -// - MKingman -// - Don Beusee -// -// REVISION HISTORY -// -// 2005-JAN-10 - Thanks to Don Beusee for pointing out the danger in mapping -// length-checked formatting functions to non-length-checked -// CRT equivalents. Also thanks to him for motivating me to -// optimize my implementation of Replace() -// -// 2004-APR-22 - A big, big thank you to "MKingman" (whoever you are) for -// finally spotting a silly little error in StdCodeCvt that -// has been causing me (and users of CStdString) problems for -// years in some relatively rare conversions. I had reversed -// two length arguments. -// -// 2003-NOV-24 - Thanks to a bunch of people for helping me clean up many -// compiler warnings (and yes, even a couple of actual compiler -// errors). These include Henk Demper for figuring out how -// to make the Intellisense work on with CStdString on VC6, -// something I was never able to do. Greg Marr pointed out -// a compiler warning about an unreferenced symbol and a -// problem with my version of Load in MFC builds. Bill -// Carducci took a lot of time with me to help me figure out -// why some implementations of the Standard C++ Library were -// returning error codes for apparently successful conversions -// between ASCII and UNICODE. Finally thanks to Brian Groose -// for helping me fix compiler signed unsigned warnings in -// several functions. -// -// 2003-JUL-10 - Thanks to Charles Godwin for making me realize my 'FmtArg' -// fixes had inadvertently broken the DLL-export code (which is -// normally commented out. I had to move it up higher. Also -// this helped me catch a bug in ssicoll that would prevent -// compilation, otherwise. -// -// 2003-MAR-14 - Thanks to Jakko Van Hunen for pointing out a copy-and-paste -// bug in one of the overloads of FmtArg. -// -// 2003-MAR-10 - Thanks to Ronny Schulz for (twice!) sending me some changes -// to help CStdString build on SGI and for pointing out an -// error in placement of my preprocessor macros for ssfmtmsg. -// -// 2002-NOV-26 - Thanks to Bagira for pointing out that my implementation of -// SpanExcluding was not properly handling the case in which -// the string did NOT contain any of the given characters -// -// 2002-OCT-21 - Many thanks to Paul DeMarco who was invaluable in helping me -// get this code working with Borland's free compiler as well -// as the Dev-C++ compiler (available free at SourceForge). -// -// 2002-SEP-13 - Thanks to Glen Maynard who helped me get rid of some loud -// but harmless warnings that were showing up on g++. Glen -// also pointed out that some pre-declarations of FmtArg<> -// specializations were unnecessary (and no good on G++) -// -// 2002-JUN-26 - Thanks to Arnt Witteveen for pointing out that I was using -// static_cast<> in a place in which I should have been using -// reinterpret_cast<> (the ctor for unsigned char strings). -// That's what happens when I don't unit-test properly! -// Arnt also noticed that CString was silently correcting the -// 'nCount' argument to Left() and Right() where CStdString was -// not (and crashing if it was bad). That is also now fixed! -// -// 2002-FEB-25 - Thanks to Tim Dowty for pointing out (and giving me the fix -// for) a conversion problem with non-ASCII MBCS characters. -// CStdString is now used in my favorite commercial MP3 player! -// -// 2001-DEC-06 - Thanks to Wang Haifeng for spotting a problem in one of the -// assignment operators (for _bstr_t) that would cause compiler -// errors when refcounting protection was turned off. -// -// 2001-NOV-27 - Remove calls to operator!= which involve reverse_iterators -// due to a conflict with the rel_ops operator!=. Thanks to -// John James for pointing this out. -// -// 2001-OCT-29 - Added a minor range checking fix for the Mid function to -// make it as forgiving as CString's version is. Thanks to -// Igor Kholodov for noticing this. -// - Added a specialization of std::swap for CStdString. Thanks -// to Mike Crusader for suggesting this! It's commented out -// because you're not supposed to inject your own code into the -// 'std' namespace. But if you don't care about that, it's -// there if you want it -// - Thanks to Jason Mills for catching a case where CString was -// more forgiving in the Delete() function than I was. -// -// 2001-JUN-06 - I was violating the Standard name lookup rules stated -// in [14.6.2(3)]. None of the compilers I've tried so -// far apparently caught this but HP-UX aCC 3.30 did. The -// fix was to add 'this->' prefixes in many places. -// Thanks to Farrokh Nejadlotfi for this! -// -// 2001-APR-27 - StreamLoad was calculating the number of BYTES in one -// case, not characters. Thanks to Pablo Presedo for this. -// -// 2001-FEB-23 - Replace() had a bug which caused infinite loops if the -// source string was empty. Fixed thanks to Eric Nitzsche. -// -// 2001-FEB-23 - Scott Hathaway was a huge help in providing me with the -// ability to build CStdString on Sun Unix systems. He -// sent me detailed build reports about what works and what -// does not. If CStdString compiles on your Unix box, you -// can thank Scott for it. -// -// 2000-DEC-29 - Joldakowski noticed one overload of Insert failed to do a -// range check as CString's does. Now fixed -- thanks! -// -// 2000-NOV-07 - Aaron pointed out that I was calling static member -// functions of char_traits via a temporary. This was not -// technically wrong, but it was unnecessary and caused -// problems for poor old buggy VC5. Thanks Aaron! -// -// 2000-JUL-11 - Joe Woodbury noted that the CString::Find docs don't match -// what the CString::Find code really ends up doing. I was -// trying to match the docs. Now I match the CString code -// - Joe also caught me truncating strings for GetBuffer() calls -// when the supplied length was less than the current length. -// -// 2000-MAY-25 - Better support for STLPORT's Standard library distribution -// - Got rid of the NSP macro - it interfered with Koenig lookup -// - Thanks to Joe Woodbury for catching a TrimLeft() bug that -// I introduced in January. Empty strings were not getting -// trimmed -// -// 2000-APR-17 - Thanks to Joe Vitaterna for pointing out that ReverseFind -// is supposed to be a const function. -// -// 2000-MAR-07 - Thanks to Ullrich Poll�hne for catching a range bug in one -// of the overloads of assign. -// -// 2000-FEB-01 - You can now use CStdString on the Mac with CodeWarrior! -// Thanks to Todd Heckel for helping out with this. -// -// 2000-JAN-23 - Thanks to Jim Cline for pointing out how I could make the -// Trim() function more efficient. -// - Thanks to Jeff Kohn for prompting me to find and fix a typo -// in one of the addition operators that takes _bstr_t. -// - Got rid of the .CPP file - you only need StdString.h now! -// -// 1999-DEC-22 - Thanks to Greg Pickles for helping me identify a problem -// with my implementation of CStdString::FormatV in which -// resulting string might not be properly NULL terminated. -// -// 1999-DEC-06 - Chris Conti pointed yet another basic_string<> assignment -// bug that MS has not fixed. CStdString did nothing to fix -// it either but it does now! The bug was: create a string -// longer than 31 characters, get a pointer to it (via c_str()) -// and then assign that pointer to the original string object. -// The resulting string would be empty. Not with CStdString! -// -// 1999-OCT-06 - BufferSet was erasing the string even when it was merely -// supposed to shrink it. Fixed. Thanks to Chris Conti. -// - Some of the Q172398 fixes were not checking for assignment- -// to-self. Fixed. Thanks to Baptiste Lepilleur. -// -// 1999-AUG-20 - Improved Load() function to be more efficient by using -// SizeOfResource(). Thanks to Rich Zuris for this. -// - Corrected resource ID constructor, again thanks to Rich. -// - Fixed a bug that occurred with UNICODE characters above -// the first 255 ANSI ones. Thanks to Craig Watson. -// - Added missing overloads of TrimLeft() and TrimRight(). -// Thanks to Karim Ratib for pointing them out -// -// 1999-JUL-21 - Made all calls to GetBuf() with no args check length first. -// -// 1999-JUL-10 - Improved MFC/ATL independence of conversion macros -// - Added SS_NO_REFCOUNT macro to allow you to disable any -// reference-counting your basic_string<> impl. may do. -// - Improved ReleaseBuffer() to be as forgiving as CString. -// Thanks for Fan Xia for helping me find this and to -// Matthew Williams for pointing it out directly. -// -// 1999-JUL-06 - Thanks to Nigel Nunn for catching a very sneaky bug in -// ToLower/ToUpper. They should call GetBuf() instead of -// data() in order to ensure the changed string buffer is not -// reference-counted (in those implementations that refcount). -// -// 1999-JUL-01 - Added a true CString facade. Now you can use CStdString as -// a drop-in replacement for CString. If you find this useful, -// you can thank Chris Sells for finally convincing me to give -// in and implement it. -// - Changed operators << and >> (for MFC CArchive) to serialize -// EXACTLY as CString's do. So now you can send a CString out -// to a CArchive and later read it in as a CStdString. I have -// no idea why you would want to do this but you can. -// -// 1999-JUN-21 - Changed the CStdString class into the CStdStr template. -// - Fixed FormatV() to correctly decrement the loop counter. -// This was harmless bug but a bug nevertheless. Thanks to -// Chris (of Melbsys) for pointing it out -// - Changed Format() to try a normal stack-based array before -// using to _alloca(). -// - Updated the text conversion macros to properly use code -// pages and to fit in better in MFC/ATL builds. In other -// words, I copied Microsoft's conversion stuff again. -// - Added equivalents of CString::GetBuffer, GetBufferSetLength -// - new sscpy() replacement of CStdString::CopyString() -// - a Trim() function that combines TrimRight() and TrimLeft(). -// -// 1999-MAR-13 - Corrected the "NotSpace" functional object to use _istpace() -// instead of _isspace() Thanks to Dave Plummer for this. -// -// 1999-FEB-26 - Removed errant line (left over from testing) that #defined -// _MFC_VER. Thanks to John C Sipos for noticing this. -// -// 1999-FEB-03 - Fixed a bug in a rarely-used overload of operator+() that -// caused infinite recursion and stack overflow -// - Added member functions to simplify the process of -// persisting CStdStrings to/from DCOM IStream interfaces -// - Added functional objects (e.g. StdStringLessNoCase) that -// allow CStdStrings to be used as keys STL map objects with -// case-insensitive comparison -// - Added array indexing operators (i.e. operator[]). I -// originally assumed that these were unnecessary and would be -// inherited from basic_string. However, without them, Visual -// C++ complains about ambiguous overloads when you try to use -// them. Thanks to Julian Selman to pointing this out. -// -// 1998-FEB-?? - Added overloads of assign() function to completely account -// for Q172398 bug. Thanks to "Pete the Plumber" for this -// -// 1998-FEB-?? - Initial submission -// -// COPYRIGHT: -// 2002 Joseph M. O'Leary. This code is 100% free. Use it anywhere you -// want. Rewrite it, restructure it, whatever. If you can write software -// that makes money off of it, good for you. I kinda like capitalism. -// Please don't blame me if it causes your $30 billion dollar satellite -// explode in orbit. If you redistribute it in any form, I'd appreciate it -// if you would leave this notice here. -// ============================================================================= - -// Avoid multiple inclusion - -#ifndef STDSTRING_H -#define STDSTRING_H - -// When using VC, turn off browser references -// Turn off unavoidable compiler warnings - -#if defined(_MSC_VER) && (_MSC_VER > 1100) - #pragma component(browser, off, references, "CStdString") - #pragma warning (disable : 4290) // C++ Exception Specification ignored - #pragma warning (disable : 4127) // Conditional expression is constant - #pragma warning (disable : 4097) // typedef name used as synonym for class name -#endif - -// Borland warnings to turn off - -#ifdef __BORLANDC__ - #pragma option push -w-inl -// #pragma warn -inl // Turn off inline function warnings -#endif - -// SS_IS_INTRESOURCE -// ----------------- -// A copy of IS_INTRESOURCE from VC7. Because old VC6 version of winuser.h -// doesn't have this. - -#define SS_IS_INTRESOURCE(_r) (false) - -#if !defined (SS_ANSI) && defined(_MSC_VER) - #undef SS_IS_INTRESOURCE - #if defined(_WIN64) - #define SS_IS_INTRESOURCE(_r) (((uint64_t)(_r) >> 16) == 0) - #else - #define SS_IS_INTRESOURCE(_r) (((unsigned long)(_r) >> 16) == 0) - #endif -#endif - - -// MACRO: SS_UNSIGNED -// ------------------ -// This macro causes the addition of a constructor and assignment operator -// which take unsigned characters. CString has such functions and in order -// to provide maximum CString-compatability, this code needs them as well. -// In practice you will likely never need these functions... - -//#define SS_UNSIGNED - -#ifdef SS_ALLOW_UNSIGNED_CHARS - #define SS_UNSIGNED -#endif - -// MACRO: SS_SAFE_FORMAT -// --------------------- -// This macro provides limited compatability with a questionable CString -// "feature". You can define it in order to avoid a common problem that -// people encounter when switching from CString to CStdString. -// -// To illustrate the problem -- With CString, you can do this: -// -// CString sName("Joe"); -// CString sTmp; -// sTmp.Format("My name is %s", sName); // WORKS! -// -// However if you were to try this with CStdString, your program would -// crash. -// -// CStdString sName("Joe"); -// CStdString sTmp; -// sTmp.Format("My name is %s", sName); // CRASHES! -// -// You must explicitly call c_str() or cast the object to the proper type -// -// sTmp.Format("My name is %s", sName.c_str()); // WORKS! -// sTmp.Format("My name is %s", static_cast<PCSTR>(sName));// WORKS! -// sTmp.Format("My name is %s", (PCSTR)sName); // WORKS! -// -// This is because it is illegal to pass anything but a POD type as a -// variadic argument to a variadic function (i.e. as one of the "..." -// arguments). The type const char* is a POD type. The type CStdString -// is not. Of course, neither is the type CString, but CString lets you do -// it anyway due to the way they laid out the class in binary. I have no -// control over this in CStdString since I derive from whatever -// implementation of basic_string is available. -// -// However if you have legacy code (which does this) that you want to take -// out of the MFC world and you don't want to rewrite all your calls to -// Format(), then you can define this flag and it will no longer crash. -// -// Note however that this ONLY works for Format(), not sprintf, fprintf, -// etc. If you pass a CStdString object to one of those functions, your -// program will crash. Not much I can do to get around this, short of -// writing substitutes for those functions as well. - -#define SS_SAFE_FORMAT // use new template style Format() function - - -// MACRO: SS_NO_IMPLICIT_CAST -// -------------------------- -// Some people don't like the implicit cast to const char* (or rather to -// const CT*) that CStdString (and MFC's CString) provide. That was the -// whole reason I created this class in the first place, but hey, whatever -// bakes your cake. Just #define this macro to get rid of the the implicit -// cast. - -//#define SS_NO_IMPLICIT_CAST // gets rid of operator const CT*() - - -// MACRO: SS_NO_REFCOUNT -// --------------------- -// turns off reference counting at the assignment level. Only needed -// for the version of basic_string<> that comes with Visual C++ versions -// 6.0 or earlier, and only then in some heavily multithreaded scenarios. -// Uncomment it if you feel you need it. - -//#define SS_NO_REFCOUNT - -// MACRO: SS_WIN32 -// --------------- -// When this flag is set, we are building code for the Win32 platform and -// may use Win32 specific functions (such as LoadString). This gives us -// a couple of nice extras for the code. -// -// Obviously, Microsoft's is not the only compiler available for Win32 out -// there. So I can't just check to see if _MSC_VER is defined to detect -// if I'm building on Win32. So for now, if you use MS Visual C++ or -// Borland's compiler, I turn this on. Otherwise you may turn it on -// yourself, if you prefer - -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WIN32) - #define SS_WIN32 -#endif - -// MACRO: SS_ANSI -// -------------- -// When this macro is defined, the code attempts only to use ANSI/ISO -// standard library functions to do it's work. It will NOT attempt to use -// any Win32 of Visual C++ specific functions -- even if they are -// available. You may define this flag yourself to prevent any Win32 -// of VC++ specific functions from being called. - -// If we're not on Win32, we MUST use an ANSI build - -#ifndef SS_WIN32 - #if !defined(SS_NO_ANSI) - #define SS_ANSI - #endif -#endif - -// MACRO: SS_ALLOCA -// ---------------- -// Some implementations of the Standard C Library have a non-standard -// function known as alloca(). This functions allows one to allocate a -// variable amount of memory on the stack. It is needed to implement -// the ASCII/MBCS conversion macros. -// -// I wanted to find some way to determine automatically if alloca() is -// available on this platform via compiler flags but that is asking for -// trouble. The crude test presented here will likely need fixing on -// other platforms. Therefore I'll leave it up to you to fiddle with -// this test to determine if it exists. Just make sure SS_ALLOCA is or -// is not defined as appropriate and you control this feature. - -#if defined(_MSC_VER) && !defined(SS_ANSI) - #define SS_ALLOCA -#endif - - -// MACRO: SS_MBCS -// -------------- -// Setting this macro means you are using MBCS characters. In MSVC builds, -// this macro gets set automatically by detection of the preprocessor flag -// _MBCS. For other platforms you may set it manually if you wish. The -// only effect it currently has is to cause the allocation of more space -// for wchar_t --> char conversions. -// Note that MBCS does not mean UNICODE. -// -// #define SS_MBCS -// - -#ifdef _MBCS - #define SS_MBCS -#endif - - -// MACRO SS_NO_LOCALE -// ------------------ -// If your implementation of the Standard C++ Library lacks the <locale> header, -// you can #define this macro to make your code build properly. Note that this -// is some of my newest code and frankly I'm not very sure of it, though it does -// pass my unit tests. - -// #define SS_NO_LOCALE - - -// Compiler Error regarding _UNICODE and UNICODE -// ----------------------------------------------- -// Microsoft header files are screwy. Sometimes they depend on a preprocessor -// flag named "_UNICODE". Other times they check "UNICODE" (note the lack of -// leading underscore in the second version". In several places, they silently -// "synchronize" these two flags this by defining one of the other was defined. -// In older version of this header, I used to try to do the same thing. -// -// However experience has taught me that this is a bad idea. You get weird -// compiler errors that seem to indicate things like LPWSTR and LPTSTR not being -// equivalent in UNICODE builds, stuff like that (when they MUST be in a proper -// UNICODE build). You end up scratching your head and saying, "But that HAS -// to compile!". -// -// So what should you do if you get this error? -// -// Make sure that both macros (_UNICODE and UNICODE) are defined before this -// file is included. You can do that by either -// -// a) defining both yourself before any files get included -// b) including the proper MS headers in the proper order -// c) including this file before any other file, uncommenting -// the #defines below, and commenting out the #errors -// -// Personally I recommend solution a) but it's your call. - -#ifdef _MSC_VER - #if defined (_UNICODE) && !defined (UNICODE) - #error UNICODE defined but not UNICODE - // #define UNICODE // no longer silently fix this - #endif - #if defined (UNICODE) && !defined (_UNICODE) - #error Warning, UNICODE defined but not _UNICODE - // #define _UNICODE // no longer silently fix this - #endif -#endif - - -// ----------------------------------------------------------------------------- -// MIN and MAX. The Standard C++ template versions go by so many names (at -// at least in the MS implementation) that you never know what's available -// ----------------------------------------------------------------------------- -template<class Type> -inline const Type& SSMIN(const Type& arg1, const Type& arg2) -{ - return arg2 < arg1 ? arg2 : arg1; -} -template<class Type> -inline const Type& SSMAX(const Type& arg1, const Type& arg2) -{ - return arg2 > arg1 ? arg2 : arg1; -} - -// If they have not #included W32Base.h (part of my W32 utility library) then -// we need to define some stuff. Otherwise, this is all defined there. - -#if !defined(W32BASE_H) - - // If they want us to use only standard C++ stuff (no Win32 stuff) - - #ifdef SS_ANSI - - // On Win32 we have TCHAR.H so just include it. This is NOT violating - // the spirit of SS_ANSI as we are not calling any Win32 functions here. - - #ifdef SS_WIN32 - - #include <TCHAR.H> - #include <WTYPES.H> - #ifndef STRICT - #define STRICT - #endif - - // ... but on non-Win32 platforms, we must #define the types we need. - - #else - - typedef const char* PCSTR; - typedef char* PSTR; - typedef const wchar_t* PCWSTR; - typedef wchar_t* PWSTR; - #ifdef UNICODE - typedef wchar_t TCHAR; - #else - typedef char TCHAR; - #endif - typedef wchar_t OLECHAR; - - #endif // #ifndef _WIN32 - - - // Make sure ASSERT and verify are defined using only ANSI stuff - - #ifndef ASSERT - #include <assert.h> - #define ASSERT(f) assert((f)) - #endif - #ifndef VERIFY - #ifdef _DEBUG - #define VERIFY(x) ASSERT((x)) - #else - #define VERIFY(x) x - #endif - #endif - - #else // ...else SS_ANSI is NOT defined - - #include <TCHAR.H> - #include <WTYPES.H> - #ifndef STRICT - #define STRICT - #endif - - // Make sure ASSERT and verify are defined - - #ifndef ASSERT - #include <crtdbg.h> - #define ASSERT(f) _ASSERTE((f)) - #endif - #ifndef VERIFY - #ifdef _DEBUG - #define VERIFY(x) ASSERT((x)) - #else - #define VERIFY(x) x - #endif - #endif - - #endif // #ifdef SS_ANSI - - #ifndef UNUSED - #define UNUSED(x) x - #endif - -#endif // #ifndef W32BASE_H - -// Standard headers needed - -#include <string> // basic_string -#include <algorithm> // for_each, etc. -#include <functional> // for StdStringLessNoCase, et al -#ifndef SS_NO_LOCALE - #include <locale> // for various facets -#endif - -// If this is a recent enough version of VC include comdef.h, so we can write -// member functions to deal with COM types & compiler support classes e.g. -// _bstr_t - -#if defined (_MSC_VER) && (_MSC_VER >= 1100) - #include <comdef.h> - #define SS_INC_COMDEF // signal that we #included MS comdef.h file - #define STDSTRING_INC_COMDEF - #define SS_NOTHROW __declspec(nothrow) -#else - #define SS_NOTHROW -#endif - -#ifndef TRACE - #define TRACE_DEFINED_HERE - #define TRACE -#endif - -// Microsoft defines PCSTR, PCWSTR, etc, but no PCTSTR. I hate to use the -// versions with the "L" in front of them because that's a leftover from Win 16 -// days, even though it evaluates to the same thing. Therefore, Define a PCSTR -// as an LPCTSTR. - -#if !defined(PCTSTR) && !defined(PCTSTR_DEFINED) - typedef const TCHAR* PCTSTR; - #define PCTSTR_DEFINED -#endif - -#if !defined(PCOLESTR) && !defined(PCOLESTR_DEFINED) - typedef const OLECHAR* PCOLESTR; - #define PCOLESTR_DEFINED -#endif - -#if !defined(POLESTR) && !defined(POLESTR_DEFINED) - typedef OLECHAR* POLESTR; - #define POLESTR_DEFINED -#endif - -#if !defined(PCUSTR) && !defined(PCUSTR_DEFINED) - typedef const unsigned char* PCUSTR; - typedef unsigned char* PUSTR; - #define PCUSTR_DEFINED -#endif - - -// SGI compiler 7.3 doesnt know these types - oh and btw, remember to use -// -LANG:std in the CXX Flags -#if defined(__sgi) - typedef unsigned long DWORD; - typedef void * LPCVOID; -#endif - - -// SS_USE_FACET macro and why we need it: -// -// Since I'm a good little Standard C++ programmer, I use locales. Thus, I -// need to make use of the use_facet<> template function here. Unfortunately, -// this need is complicated by the fact the MS' implementation of the Standard -// C++ Library has a non-standard version of use_facet that takes more -// arguments than the standard dictates. Since I'm trying to write CStdString -// to work with any version of the Standard library, this presents a problem. -// -// The upshot of this is that I can't do 'use_facet' directly. The MS' docs -// tell me that I have to use a macro, _USE() instead. Since _USE obviously -// won't be available in other implementations, this means that I have to write -// my OWN macro -- SS_USE_FACET -- that evaluates either to _USE or to the -// standard, use_facet. -// -// If you are having trouble with the SS_USE_FACET macro, in your implementation -// of the Standard C++ Library, you can define your own version of SS_USE_FACET. - -#ifndef schMSG - #define schSTR(x) #x - #define schSTR2(x) schSTR(x) - #define schMSG(desc) message(__FILE__ "(" schSTR2(__LINE__) "):" #desc) -#endif - -#ifndef SS_USE_FACET - - // STLPort #defines a macro (__STL_NO_EXPLICIT_FUNCTION_TMPL_ARGS) for - // all MSVC builds, erroneously in my opinion. It causes problems for - // my SS_ANSI builds. In my code, I always comment out that line. You'll - // find it in \stlport\config\stl_msvc.h - - #if defined(__SGI_STL_PORT) && (__SGI_STL_PORT >= 0x400 ) - - #if defined(__STL_NO_EXPLICIT_FUNCTION_TMPL_ARGS) && defined(_MSC_VER) - #ifdef SS_ANSI - #pragma schMSG(__STL_NO_EXPLICIT_FUNCTION_TMPL_ARGS defined!!) - #endif - #endif - #define SS_USE_FACET(loc, fac) std::use_facet<fac >(loc) - - #elif defined(_MSC_VER ) - - #define SS_USE_FACET(loc, fac) std::_USE(loc, fac) - - // ...and - #elif defined(_RWSTD_NO_TEMPLATE_ON_RETURN_TYPE) - - #define SS_USE_FACET(loc, fac) std::use_facet(loc, (fac*)0) - - #else - - #define SS_USE_FACET(loc, fac) std::use_facet<fac >(loc) - - #endif - -#endif - -// ============================================================================= -// UNICODE/MBCS conversion macros. Made to work just like the MFC/ATL ones. -// ============================================================================= - -#include <wchar.h> // Added to Std Library with Amendment #1. - -// First define the conversion helper functions. We define these regardless of -// any preprocessor macro settings since their names won't collide. - -// Not sure if we need all these headers. I believe ANSI says we do. - -#include <stdio.h> -#include <stdarg.h> -#include <wctype.h> -#include <ctype.h> -#include <stdlib.h> -#ifndef va_start - #include <varargs.h> -#endif - - -#ifdef SS_NO_LOCALE - - #if defined(_WIN32) || defined (_WIN32_WCE) - - inline PWSTR StdCodeCvt(PWSTR pDstW, int nDst, PCSTR pSrcA, int nSrc, - UINT acp=CP_ACP) - { - ASSERT(0 != pSrcA); - ASSERT(0 != pDstW); - pDstW[0] = '\0'; - MultiByteToWideChar(acp, 0, pSrcA, nSrc, pDstW, nDst); - return pDstW; - } - inline PWSTR StdCodeCvt(PWSTR pDstW, int nDst, PCUSTR pSrcA, int nSrc, - UINT acp=CP_ACP) - { - return StdCodeCvt(pDstW, nDst, (PCSTR)pSrcA, nSrc, acp); - } - - inline PSTR StdCodeCvt(PSTR pDstA, int nDst, PCWSTR pSrcW, int nSrc, - UINT acp=CP_ACP) - { - ASSERT(0 != pDstA); - ASSERT(0 != pSrcW); - pDstA[0] = '\0'; - WideCharToMultiByte(acp, 0, pSrcW, nSrc, pDstA, nDst, 0, 0); - return pDstA; - } - inline PUSTR StdCodeCvt(PUSTR pDstA, int nDst, PCWSTR pSrcW, int nSrc, - UINT acp=CP_ACP) - { - return (PUSTR)StdCodeCvt((PSTR)pDstA, nDst, pSrcW, nSrc, acp); - } - #else - #endif - -#else - - // StdCodeCvt - made to look like Win32 functions WideCharToMultiByte - // and MultiByteToWideChar but uses locales in SS_ANSI - // builds. There are a number of overloads. - // First argument is the destination buffer. - // Second argument is the source buffer - //#if defined (SS_ANSI) || !defined (SS_WIN32) - - // 'SSCodeCvt' - shorthand name for the codecvt facet we use - - typedef std::codecvt<wchar_t, char, mbstate_t> SSCodeCvt; - - inline PWSTR StdCodeCvt(PWSTR pDstW, int nDst, PCSTR pSrcA, int nSrc, - const std::locale& loc=std::locale()) - { - ASSERT(0 != pSrcA); - ASSERT(0 != pDstW); - - pDstW[0] = '\0'; - - if ( nSrc > 0 ) - { - PCSTR pNextSrcA = pSrcA; - PWSTR pNextDstW = pDstW; - const SSCodeCvt& conv = SS_USE_FACET(loc, SSCodeCvt); - SSCodeCvt::state_type st= {}; - SSCodeCvt::result res = conv.in(st, - pSrcA, pSrcA + nSrc, pNextSrcA, - pDstW, pDstW + nDst, pNextDstW); -#ifdef TARGET_POSIX -#define ASSERT2(a) if (!(a)) {fprintf(stderr, "StdString: Assertion Failed on line %d\n", __LINE__);} -#else -#define ASSERT2 ASSERT -#endif - ASSERT2(SSCodeCvt::ok == res); - ASSERT2(SSCodeCvt::error != res); - ASSERT2(pNextDstW >= pDstW); - ASSERT2(pNextSrcA >= pSrcA); -#undef ASSERT2 - // Null terminate the converted string - - if ( pNextDstW - pDstW > nDst ) - *(pDstW + nDst) = '\0'; - else - *pNextDstW = '\0'; - } - return pDstW; - } - inline PWSTR StdCodeCvt(PWSTR pDstW, int nDst, PCUSTR pSrcA, int nSrc, - const std::locale& loc=std::locale()) - { - return StdCodeCvt(pDstW, nDst, (PCSTR)pSrcA, nSrc, loc); - } - - inline PSTR StdCodeCvt(PSTR pDstA, int nDst, PCWSTR pSrcW, int nSrc, - const std::locale& loc=std::locale()) - { - ASSERT(0 != pDstA); - ASSERT(0 != pSrcW); - - pDstA[0] = '\0'; - - if ( nSrc > 0 ) - { - PSTR pNextDstA = pDstA; - PCWSTR pNextSrcW = pSrcW; - const SSCodeCvt& conv = SS_USE_FACET(loc, SSCodeCvt); - SSCodeCvt::state_type st= {}; - SSCodeCvt::result res = conv.out(st, - pSrcW, pSrcW + nSrc, pNextSrcW, - pDstA, pDstA + nDst, pNextDstA); -#ifdef TARGET_POSIX -#define ASSERT2(a) if (!(a)) {fprintf(stderr, "StdString: Assertion Failed on line %d\n", __LINE__);} -#else -#define ASSERT2 ASSERT -#endif - ASSERT2(SSCodeCvt::error != res); - ASSERT2(SSCodeCvt::ok == res); // strict, comment out for sanity - ASSERT2(pNextDstA >= pDstA); - ASSERT2(pNextSrcW >= pSrcW); -#undef ASSERT2 - - // Null terminate the converted string - - if ( pNextDstA - pDstA > nDst ) - *(pDstA + nDst) = '\0'; - else - *pNextDstA = '\0'; - } - return pDstA; - } - - inline PUSTR StdCodeCvt(PUSTR pDstA, int nDst, PCWSTR pSrcW, int nSrc, - const std::locale& loc=std::locale()) - { - return (PUSTR)StdCodeCvt((PSTR)pDstA, nDst, pSrcW, nSrc, loc); - } - -#endif - - - -// Unicode/MBCS conversion macros are only available on implementations of -// the "C" library that have the non-standard _alloca function. As far as I -// know that's only Microsoft's though I've heard that the function exists -// elsewhere. - -#if defined(SS_ALLOCA) && !defined SS_NO_CONVERSION - - #include <malloc.h> // needed for _alloca - - // Define our conversion macros to look exactly like Microsoft's to - // facilitate using this stuff both with and without MFC/ATL - - #ifdef _CONVERSION_USES_THREAD_LOCALE - - #ifndef _DEBUG - #define SSCVT int _cvt; _cvt; UINT _acp=GetACP(); \ - _acp; PCWSTR _pw; _pw; PCSTR _pa; _pa - #else - #define SSCVT int _cvt = 0; _cvt; UINT _acp=GetACP();\ - _acp; PCWSTR _pw=0; _pw; PCSTR _pa=0; _pa - #endif - #define SSA2W(pa) (\ - ((_pa = pa) == 0) ? 0 : (\ - _cvt = (sslen(_pa)),\ - StdCodeCvt((PWSTR) _alloca((_cvt+1)*2), (_cvt+1)*2, \ - _pa, _cvt, _acp))) - #define SSW2A(pw) (\ - ((_pw = pw) == 0) ? 0 : (\ - _cvt = sslen(_pw), \ - StdCodeCvt((LPSTR) _alloca((_cvt+1)*2), (_cvt+1)*2, \ - _pw, _cvt, _acp))) - #else - - #ifndef _DEBUG - #define SSCVT int _cvt; _cvt; UINT _acp=CP_ACP; _acp;\ - PCWSTR _pw; _pw; PCSTR _pa; _pa - #else - #define SSCVT int _cvt = 0; _cvt; UINT _acp=CP_ACP; \ - _acp; PCWSTR _pw=0; _pw; PCSTR _pa=0; _pa - #endif - #define SSA2W(pa) (\ - ((_pa = pa) == 0) ? 0 : (\ - _cvt = (sslen(_pa)),\ - StdCodeCvt((PWSTR) _alloca((_cvt+1)*2), (_cvt+1)*2, \ - _pa, _cvt))) - #define SSW2A(pw) (\ - ((_pw = pw) == 0) ? 0 : (\ - _cvt = (sslen(_pw)),\ - StdCodeCvt((LPSTR) _alloca((_cvt+1)*2), (_cvt+1)*2, \ - _pw, _cvt))) - #endif - - #define SSA2CW(pa) ((PCWSTR)SSA2W((pa))) - #define SSW2CA(pw) ((PCSTR)SSW2A((pw))) - - #ifdef UNICODE - #define SST2A SSW2A - #define SSA2T SSA2W - #define SST2CA SSW2CA - #define SSA2CT SSA2CW - // (Did you get a compiler error here about not being able to convert - // PTSTR into PWSTR? Then your _UNICODE and UNICODE flags are messed - // up. Best bet: #define BOTH macros before including any MS headers.) - inline PWSTR SST2W(PTSTR p) { return p; } - inline PTSTR SSW2T(PWSTR p) { return p; } - inline PCWSTR SST2CW(PCTSTR p) { return p; } - inline PCTSTR SSW2CT(PCWSTR p) { return p; } - #else - #define SST2W SSA2W - #define SSW2T SSW2A - #define SST2CW SSA2CW - #define SSW2CT SSW2CA - inline PSTR SST2A(PTSTR p) { return p; } - inline PTSTR SSA2T(PSTR p) { return p; } - inline PCSTR SST2CA(PCTSTR p) { return p; } - inline PCTSTR SSA2CT(PCSTR p) { return p; } - #endif // #ifdef UNICODE - - #if defined(UNICODE) - // in these cases the default (TCHAR) is the same as OLECHAR - inline PCOLESTR SST2COLE(PCTSTR p) { return p; } - inline PCTSTR SSOLE2CT(PCOLESTR p) { return p; } - inline POLESTR SST2OLE(PTSTR p) { return p; } - inline PTSTR SSOLE2T(POLESTR p) { return p; } - #elif defined(OLE2ANSI) - // in these cases the default (TCHAR) is the same as OLECHAR - inline PCOLESTR SST2COLE(PCTSTR p) { return p; } - inline PCTSTR SSOLE2CT(PCOLESTR p) { return p; } - inline POLESTR SST2OLE(PTSTR p) { return p; } - inline PTSTR SSOLE2T(POLESTR p) { return p; } - #else - //CharNextW doesn't work on Win95 so we use this - #define SST2COLE(pa) SSA2CW((pa)) - #define SST2OLE(pa) SSA2W((pa)) - #define SSOLE2CT(po) SSW2CA((po)) - #define SSOLE2T(po) SSW2A((po)) - #endif - - #ifdef OLE2ANSI - #define SSW2OLE SSW2A - #define SSOLE2W SSA2W - #define SSW2COLE SSW2CA - #define SSOLE2CW SSA2CW - inline POLESTR SSA2OLE(PSTR p) { return p; } - inline PSTR SSOLE2A(POLESTR p) { return p; } - inline PCOLESTR SSA2COLE(PCSTR p) { return p; } - inline PCSTR SSOLE2CA(PCOLESTR p){ return p; } - #else - #define SSA2OLE SSA2W - #define SSOLE2A SSW2A - #define SSA2COLE SSA2CW - #define SSOLE2CA SSW2CA - inline POLESTR SSW2OLE(PWSTR p) { return p; } - inline PWSTR SSOLE2W(POLESTR p) { return p; } - inline PCOLESTR SSW2COLE(PCWSTR p) { return p; } - inline PCWSTR SSOLE2CW(PCOLESTR p){ return p; } - #endif - - // Above we've defined macros that look like MS' but all have - // an 'SS' prefix. Now we need the real macros. We'll either - // get them from the macros above or from MFC/ATL. - - #if defined (USES_CONVERSION) - - #define _NO_STDCONVERSION // just to be consistent - - #else - - #ifdef _MFC_VER - - #include <afxconv.h> - #define _NO_STDCONVERSION // just to be consistent - - #else - - #define USES_CONVERSION SSCVT - #define A2CW SSA2CW - #define W2CA SSW2CA - #define T2A SST2A - #define A2T SSA2T - #define T2W SST2W - #define W2T SSW2T - #define T2CA SST2CA - #define A2CT SSA2CT - #define T2CW SST2CW - #define W2CT SSW2CT - #define ocslen sslen - #define ocscpy sscpy - #define T2COLE SST2COLE - #define OLE2CT SSOLE2CT - #define T2OLE SST2COLE - #define OLE2T SSOLE2CT - #define A2OLE SSA2OLE - #define OLE2A SSOLE2A - #define W2OLE SSW2OLE - #define OLE2W SSOLE2W - #define A2COLE SSA2COLE - #define OLE2CA SSOLE2CA - #define W2COLE SSW2COLE - #define OLE2CW SSOLE2CW - - #endif // #ifdef _MFC_VER - #endif // #ifndef USES_CONVERSION -#endif // #ifndef SS_NO_CONVERSION - -// Define ostring - generic name for std::basic_string<OLECHAR> - -#if !defined(ostring) && !defined(OSTRING_DEFINED) - typedef std::basic_string<OLECHAR> ostring; - #define OSTRING_DEFINED -#endif - -// StdCodeCvt when there's no conversion to be done -template <typename T> -inline T* StdCodeCvt(T* pDst, int nDst, const T* pSrc, int nSrc) -{ - int nChars = SSMIN(nSrc, nDst); - - if ( nChars > 0 ) - { - pDst[0] = '\0'; - std::basic_string<T>::traits_type::copy(pDst, pSrc, nChars); -// std::char_traits<T>::copy(pDst, pSrc, nChars); - pDst[nChars] = '\0'; - } - - return pDst; -} -inline PSTR StdCodeCvt(PSTR pDst, int nDst, PCUSTR pSrc, int nSrc) -{ - return StdCodeCvt(pDst, nDst, (PCSTR)pSrc, nSrc); -} -inline PUSTR StdCodeCvt(PUSTR pDst, int nDst, PCSTR pSrc, int nSrc) -{ - return (PUSTR)StdCodeCvt((PSTR)pDst, nDst, pSrc, nSrc); -} - -// Define tstring -- generic name for std::basic_string<TCHAR> - -#if !defined(tstring) && !defined(TSTRING_DEFINED) - typedef std::basic_string<TCHAR> tstring; - #define TSTRING_DEFINED -#endif - -// a very shorthand way of applying the fix for KB problem Q172398 -// (basic_string assignment bug) - -#if defined ( _MSC_VER ) && ( _MSC_VER < 1200 ) - #define Q172398(x) (x).erase() -#else - #define Q172398(x) -#endif - -// ============================================================================= -// INLINE FUNCTIONS ON WHICH CSTDSTRING RELIES -// -// Usually for generic text mapping, we rely on preprocessor macro definitions -// to map to string functions. However the CStdStr<> template cannot use -// macro-based generic text mappings because its character types do not get -// resolved until template processing which comes AFTER macro processing. In -// other words, the preprocessor macro UNICODE is of little help to us in the -// CStdStr template -// -// Therefore, to keep the CStdStr declaration simple, we have these inline -// functions. The template calls them often. Since they are inline (and NOT -// exported when this is built as a DLL), they will probably be resolved away -// to nothing. -// -// Without these functions, the CStdStr<> template would probably have to broken -// out into two, almost identical classes. Either that or it would be a huge, -// convoluted mess, with tons of "if" statements all over the place checking the -// size of template parameter CT. -// ============================================================================= - -#ifdef SS_NO_LOCALE - - // -------------------------------------------------------------------------- - // Win32 GetStringTypeEx wrappers - // -------------------------------------------------------------------------- - inline bool wsGetStringType(LCID lc, DWORD dwT, PCSTR pS, int nSize, - WORD* pWd) - { - return FALSE != GetStringTypeExA(lc, dwT, pS, nSize, pWd); - } - inline bool wsGetStringType(LCID lc, DWORD dwT, PCWSTR pS, int nSize, - WORD* pWd) - { - return FALSE != GetStringTypeExW(lc, dwT, pS, nSize, pWd); - } - - - template<typename CT> - inline bool ssisspace (CT t) - { - WORD toYourMother; - return wsGetStringType(GetThreadLocale(), CT_CTYPE1, &t, 1, &toYourMother) - && 0 != (C1_BLANK & toYourMother); - } - -#endif - -// If they defined SS_NO_REFCOUNT, then we must convert all assignments - -#if defined (_MSC_VER) && (_MSC_VER < 1300) - #ifdef SS_NO_REFCOUNT - #define SSREF(x) (x).c_str() - #else - #define SSREF(x) (x) - #endif -#else - #define SSREF(x) (x) -#endif - -// ----------------------------------------------------------------------------- -// sslen: strlen/wcslen wrappers -// ----------------------------------------------------------------------------- -template<typename CT> inline int sslen(const CT* pT) -{ - return 0 == pT ? 0 : (int)std::basic_string<CT>::traits_type::length(pT); -// return 0 == pT ? 0 : std::char_traits<CT>::length(pT); -} -inline SS_NOTHROW int sslen(const std::string& s) -{ - return static_cast<int>(s.length()); -} -inline SS_NOTHROW int sslen(const std::wstring& s) -{ - return static_cast<int>(s.length()); -} - -// ----------------------------------------------------------------------------- -// sstolower/sstoupper -- convert characters to upper/lower case -// ----------------------------------------------------------------------------- - -#ifdef SS_NO_LOCALE - inline char sstoupper(char ch) { return (char)::toupper(ch); } - inline wchar_t sstoupper(wchar_t ch){ return (wchar_t)::towupper(ch); } - inline char sstolower(char ch) { return (char)::tolower(ch); } - inline wchar_t sstolower(wchar_t ch){ return (wchar_t)::tolower(ch); } -#else - template<typename CT> - inline CT sstolower(const CT& t, const std::locale& loc = std::locale()) - { - return std::tolower<CT>(t, loc); - } - template<typename CT> - inline CT sstoupper(const CT& t, const std::locale& loc = std::locale()) - { - return std::toupper<CT>(t, loc); - } -#endif - -// ----------------------------------------------------------------------------- -// ssasn: assignment functions -- assign "sSrc" to "sDst" -// ----------------------------------------------------------------------------- -typedef std::string::size_type SS_SIZETYPE; // just for shorthand, really -typedef std::string::pointer SS_PTRTYPE; -typedef std::wstring::size_type SW_SIZETYPE; -typedef std::wstring::pointer SW_PTRTYPE; - - -template <typename T> -inline void ssasn(std::basic_string<T>& sDst, const std::basic_string<T>& sSrc) -{ - if ( sDst.c_str() != sSrc.c_str() ) - { - sDst.erase(); - sDst.assign(SSREF(sSrc)); - } -} -template <typename T> -inline void ssasn(std::basic_string<T>& sDst, const T *pA) -{ - // Watch out for NULLs, as always. - - if ( 0 == pA ) - { - sDst.erase(); - } - - // If pA actually points to part of sDst, we must NOT erase(), but - // rather take a substring - - else if ( pA >= sDst.c_str() && pA <= sDst.c_str() + sDst.size() ) - { - sDst =sDst.substr(static_cast<typename std::basic_string<T>::size_type>(pA-sDst.c_str())); - } - - // Otherwise (most cases) apply the assignment bug fix, if applicable - // and do the assignment - - else - { - Q172398(sDst); - sDst.assign(pA); - } -} -inline void ssasn(std::string& sDst, const std::wstring& sSrc) -{ - if ( sSrc.empty() ) - { - sDst.erase(); - } - else - { - int nDst = static_cast<int>(sSrc.size()); - - // In MBCS builds, pad the buffer to account for the possibility of - // some 3 byte characters. Not perfect but should get most cases. - -#ifdef SS_MBCS - // In MBCS builds, we don't know how long the destination string will be. - nDst = static_cast<int>(static_cast<double>(nDst) * 1.3); - sDst.resize(nDst+1); - PCSTR szCvt = StdCodeCvt(const_cast<SS_PTRTYPE>(sDst.data()), nDst, - sSrc.c_str(), static_cast<int>(sSrc.size())); - sDst.resize(sslen(szCvt)); -#else - sDst.resize(nDst+1); - StdCodeCvt(const_cast<SS_PTRTYPE>(sDst.data()), nDst, - sSrc.c_str(), static_cast<int>(sSrc.size())); - sDst.resize(sSrc.size()); -#endif - } -} -inline void ssasn(std::string& sDst, PCWSTR pW) -{ - int nSrc = sslen(pW); - if ( nSrc > 0 ) - { - int nSrc = sslen(pW); - int nDst = nSrc; - - // In MBCS builds, pad the buffer to account for the possibility of - // some 3 byte characters. Not perfect but should get most cases. - -#ifdef SS_MBCS - nDst = static_cast<int>(static_cast<double>(nDst) * 1.3); - // In MBCS builds, we don't know how long the destination string will be. - sDst.resize(nDst + 1); - PCSTR szCvt = StdCodeCvt(const_cast<SS_PTRTYPE>(sDst.data()), nDst, - pW, nSrc); - sDst.resize(sslen(szCvt)); -#else - sDst.resize(nDst + 1); - StdCodeCvt(const_cast<SS_PTRTYPE>(sDst.data()), nDst, pW, nSrc); - sDst.resize(nDst); -#endif - } - else - { - sDst.erase(); - } -} -inline void ssasn(std::string& sDst, const int nNull) -{ - //UNUSED(nNull); - ASSERT(nNull==0); - sDst.assign(""); -} -#undef StrSizeType -inline void ssasn(std::wstring& sDst, const std::string& sSrc) -{ - if ( sSrc.empty() ) - { - sDst.erase(); - } - else - { - int nSrc = static_cast<int>(sSrc.size()); - int nDst = nSrc; - - sDst.resize(nSrc+1); - PCWSTR szCvt = StdCodeCvt(const_cast<SW_PTRTYPE>(sDst.data()), nDst, - sSrc.c_str(), nSrc); - - sDst.resize(sslen(szCvt)); - } -} -inline void ssasn(std::wstring& sDst, PCSTR pA) -{ - int nSrc = sslen(pA); - - if ( 0 == nSrc ) - { - sDst.erase(); - } - else - { - int nDst = nSrc; - sDst.resize(nDst+1); - PCWSTR szCvt = StdCodeCvt(const_cast<SW_PTRTYPE>(sDst.data()), nDst, pA, - nSrc); - - sDst.resize(sslen(szCvt)); - } -} -inline void ssasn(std::wstring& sDst, const int nNull) -{ - //UNUSED(nNull); - ASSERT(nNull==0); - sDst.assign(L""); -} - -// ----------------------------------------------------------------------------- -// ssadd: string object concatenation -- add second argument to first -// ----------------------------------------------------------------------------- -inline void ssadd(std::string& sDst, const std::wstring& sSrc) -{ - int nSrc = static_cast<int>(sSrc.size()); - - if ( nSrc > 0 ) - { - int nDst = static_cast<int>(sDst.size()); - int nAdd = nSrc; - - // In MBCS builds, pad the buffer to account for the possibility of - // some 3 byte characters. Not perfect but should get most cases. - -#ifdef SS_MBCS - nAdd = static_cast<int>(static_cast<double>(nAdd) * 1.3); - sDst.resize(nDst+nAdd+1); - PCSTR szCvt = StdCodeCvt(const_cast<SS_PTRTYPE>(sDst.data()+nDst), - nAdd, sSrc.c_str(), nSrc); - sDst.resize(nDst + sslen(szCvt)); -#else - sDst.resize(nDst+nAdd+1); - StdCodeCvt(const_cast<SS_PTRTYPE>(sDst.data()+nDst), nAdd, sSrc.c_str(), nSrc); - sDst.resize(nDst + nAdd); -#endif - } -} -template <typename T> -inline void ssadd(typename std::basic_string<T>& sDst, const typename std::basic_string<T>& sSrc) -{ - sDst += sSrc; -} -inline void ssadd(std::string& sDst, PCWSTR pW) -{ - int nSrc = sslen(pW); - if ( nSrc > 0 ) - { - int nDst = static_cast<int>(sDst.size()); - int nAdd = nSrc; - -#ifdef SS_MBCS - nAdd = static_cast<int>(static_cast<double>(nAdd) * 1.3); - sDst.resize(nDst + nAdd + 1); - PCSTR szCvt = StdCodeCvt(const_cast<SS_PTRTYPE>(sDst.data()+nDst), - nAdd, pW, nSrc); - sDst.resize(nDst + sslen(szCvt)); -#else - sDst.resize(nDst + nAdd + 1); - StdCodeCvt(const_cast<SS_PTRTYPE>(sDst.data()+nDst), nAdd, pW, nSrc); - sDst.resize(nDst + nSrc); -#endif - } -} -template <typename T> -inline void ssadd(typename std::basic_string<T>& sDst, const T *pA) -{ - if ( pA ) - { - // If the string being added is our internal string or a part of our - // internal string, then we must NOT do any reallocation without - // first copying that string to another object (since we're using a - // direct pointer) - - if ( pA >= sDst.c_str() && pA <= sDst.c_str()+sDst.length()) - { - if ( sDst.capacity() <= sDst.size()+sslen(pA) ) - sDst.append(std::basic_string<T>(pA)); - else - sDst.append(pA); - } - else - { - sDst.append(pA); - } - } -} -inline void ssadd(std::wstring& sDst, const std::string& sSrc) -{ - if ( !sSrc.empty() ) - { - int nSrc = static_cast<int>(sSrc.size()); - int nDst = static_cast<int>(sDst.size()); - - sDst.resize(nDst + nSrc + 1); -#ifdef SS_MBCS - PCWSTR szCvt = StdCodeCvt(const_cast<SW_PTRTYPE>(sDst.data()+nDst), - nSrc, sSrc.c_str(), nSrc+1); - sDst.resize(nDst + sslen(szCvt)); -#else - StdCodeCvt(const_cast<SW_PTRTYPE>(sDst.data()+nDst), nSrc, sSrc.c_str(), nSrc+1); - sDst.resize(nDst + nSrc); -#endif - } -} -inline void ssadd(std::wstring& sDst, PCSTR pA) -{ - int nSrc = sslen(pA); - - if ( nSrc > 0 ) - { - int nDst = static_cast<int>(sDst.size()); - - sDst.resize(nDst + nSrc + 1); -#ifdef SS_MBCS - PCWSTR szCvt = StdCodeCvt(const_cast<SW_PTRTYPE>(sDst.data()+nDst), - nSrc, pA, nSrc+1); - sDst.resize(nDst + sslen(szCvt)); -#else - StdCodeCvt(const_cast<SW_PTRTYPE>(sDst.data()+nDst), nSrc, pA, nSrc+1); - sDst.resize(nDst + nSrc); -#endif - } -} - -// ----------------------------------------------------------------------------- -// sscmp: comparison (case sensitive, not affected by locale) -// ----------------------------------------------------------------------------- -template<typename CT> -inline int sscmp(const CT* pA1, const CT* pA2) -{ - CT f; - CT l; - - do - { - f = *(pA1++); - l = *(pA2++); - } while ( (f) && (f == l) ); - - return (int)(f - l); -} - -// ----------------------------------------------------------------------------- -// ssicmp: comparison (case INsensitive, not affected by locale) -// ----------------------------------------------------------------------------- -template<typename CT> -inline int ssicmp(const CT* pA1, const CT* pA2) -{ - // Using the "C" locale = "not affected by locale" - - std::locale loc = std::locale::classic(); - const std::ctype<CT>& ct = SS_USE_FACET(loc, std::ctype<CT>); - CT f; - CT l; - - do - { - f = ct.tolower(*(pA1++)); - l = ct.tolower(*(pA2++)); - } while ( (f) && (f == l) ); - - return (int)(f - l); -} - -// ----------------------------------------------------------------------------- -// ssupr/sslwr: Uppercase/Lowercase conversion functions -// ----------------------------------------------------------------------------- - -template<typename CT> -inline void sslwr(CT* pT, size_t nLen, const std::locale& loc=std::locale()) -{ - SS_USE_FACET(loc, std::ctype<CT>).tolower(pT, pT+nLen); -} -template<typename CT> -inline void ssupr(CT* pT, size_t nLen, const std::locale& loc=std::locale()) -{ - SS_USE_FACET(loc, std::ctype<CT>).toupper(pT, pT+nLen); -} - -// ----------------------------------------------------------------------------- -// vsprintf/vswprintf or _vsnprintf/_vsnwprintf equivalents. In standard -// builds we can't use _vsnprintf/_vsnwsprintf because they're MS extensions. -// -// ----------------------------------------------------------------------------- -// Borland's headers put some ANSI "C" functions in the 'std' namespace. -// Promote them to the global namespace so we can use them here. - -#if defined(__BORLANDC__) - using std::vsprintf; - using std::vswprintf; -#endif - - // GNU is supposed to have vsnprintf and vsnwprintf. But only the newer - // distributions do. - -#if defined(__GNUC__) - - inline int ssvsprintf(PSTR pA, size_t nCount, PCSTR pFmtA, va_list vl) - { - return vsnprintf(pA, nCount, pFmtA, vl); - } - inline int ssvsprintf(PWSTR pW, size_t nCount, PCWSTR pFmtW, va_list vl) - { - return vswprintf(pW, nCount, pFmtW, vl); - } - - // Microsofties can use -#elif defined(_MSC_VER) && !defined(SS_ANSI) - - inline int ssvsprintf(PSTR pA, size_t nCount, PCSTR pFmtA, va_list vl) - { - return _vsnprintf(pA, nCount, pFmtA, vl); - } - inline int ssvsprintf(PWSTR pW, size_t nCount, PCWSTR pFmtW, va_list vl) - { - return _vsnwprintf(pW, nCount, pFmtW, vl); - } - -#elif defined (SS_DANGEROUS_FORMAT) // ignore buffer size parameter if needed? - - inline int ssvsprintf(PSTR pA, size_t /*nCount*/, PCSTR pFmtA, va_list vl) - { - return vsprintf(pA, pFmtA, vl); - } - - inline int ssvsprintf(PWSTR pW, size_t nCount, PCWSTR pFmtW, va_list vl) - { - // JMO: Some distributions of the "C" have a version of vswprintf that - // takes 3 arguments (e.g. Microsoft, Borland, GNU). Others have a - // version which takes 4 arguments (an extra "count" argument in the - // second position. The best stab I can take at this so far is that if - // you are NOT running with MS, Borland, or GNU, then I'll assume you - // have the version that takes 4 arguments. - // - // I'm sure that these checks don't catch every platform correctly so if - // you get compiler errors on one of the lines immediately below, it's - // probably because your implemntation takes a different number of - // arguments. You can comment out the offending line (and use the - // alternate version) or you can figure out what compiler flag to check - // and add that preprocessor check in. Regardless, if you get an error - // on these lines, I'd sure like to hear from you about it. - // - // Thanks to Ronny Schulz for the SGI-specific checks here. - -// #if !defined(__MWERKS__) && !defined(__SUNPRO_CC_COMPAT) && !defined(__SUNPRO_CC) - #if !defined(_MSC_VER) \ - && !defined (__BORLANDC__) \ - && !defined(__GNUC__) \ - && !defined(__sgi) - - return vswprintf(pW, nCount, pFmtW, vl); - - // suddenly with the current SGI 7.3 compiler there is no such function as - // vswprintf and the substitute needs explicit casts to compile - - #elif defined(__sgi) - - nCount; - return vsprintf( (char *)pW, (char *)pFmtW, vl); - - #else - - nCount; - return vswprintf(pW, pFmtW, vl); - - #endif - - } - -#endif - - // GOT COMPILER PROBLEMS HERE? - // --------------------------- - // Does your compiler choke on one or more of the following 2 functions? It - // probably means that you don't have have either vsnprintf or vsnwprintf in - // your version of the CRT. This is understandable since neither is an ANSI - // "C" function. However it still leaves you in a dilemma. In order to make - // this code build, you're going to have to to use some non-length-checked - // formatting functions that every CRT has: vsprintf and vswprintf. - // - // This is very dangerous. With the proper erroneous (or malicious) code, it - // can lead to buffer overlows and crashing your PC. Use at your own risk - // In order to use them, just #define SS_DANGEROUS_FORMAT at the top of - // this file. - // - // Even THEN you might not be all the way home due to some non-conforming - // distributions. More on this in the comments below. - - inline int ssnprintf(PSTR pA, size_t nCount, PCSTR pFmtA, va_list vl) - { - #ifdef _MSC_VER - return _vsnprintf(pA, nCount, pFmtA, vl); - #else - return vsnprintf(pA, nCount, pFmtA, vl); - #endif - } - inline int ssnprintf(PWSTR pW, size_t nCount, PCWSTR pFmtW, va_list vl) - { - #ifdef _MSC_VER - return _vsnwprintf(pW, nCount, pFmtW, vl); - #else - return vswprintf(pW, nCount, pFmtW, vl); - #endif - } - - - - -// ----------------------------------------------------------------------------- -// ssload: Type safe, overloaded ::LoadString wrappers -// There is no equivalent of these in non-Win32-specific builds. However, I'm -// thinking that with the message facet, there might eventually be one -// ----------------------------------------------------------------------------- -#if defined (SS_WIN32) && !defined(SS_ANSI) - inline int ssload(HMODULE hInst, UINT uId, PSTR pBuf, int nMax) - { - return ::LoadStringA(hInst, uId, pBuf, nMax); - } - inline int ssload(HMODULE hInst, UINT uId, PWSTR pBuf, int nMax) - { - return ::LoadStringW(hInst, uId, pBuf, nMax); - } -#if defined ( _MSC_VER ) && ( _MSC_VER >= 1500 ) - inline int ssload(HMODULE hInst, UINT uId, uint16_t *pBuf, int nMax) - { - return 0; - } - inline int ssload(HMODULE hInst, UINT uId, uint32_t *pBuf, int nMax) - { - return 0; - } -#endif -#endif - - -// ----------------------------------------------------------------------------- -// sscoll/ssicoll: Collation wrappers -// Note -- with MSVC I have reversed the arguments order here because the -// functions appear to return the opposite of what they should -// ----------------------------------------------------------------------------- -#ifndef SS_NO_LOCALE -template <typename CT> -inline int sscoll(const CT* sz1, int nLen1, const CT* sz2, int nLen2) -{ - const std::collate<CT>& coll = - SS_USE_FACET(std::locale(), std::collate<CT>); - - return coll.compare(sz2, sz2+nLen2, sz1, sz1+nLen1); -} -template <typename CT> -inline int ssicoll(const CT* sz1, int nLen1, const CT* sz2, int nLen2) -{ - const std::locale loc; - const std::collate<CT>& coll = SS_USE_FACET(loc, std::collate<CT>); - - // Some implementations seem to have trouble using the collate<> - // facet typedefs so we'll just default to basic_string and hope - // that's what the collate facet uses (which it generally should) - -// std::collate<CT>::string_type s1(sz1); -// std::collate<CT>::string_type s2(sz2); - const std::basic_string<CT> sEmpty; - std::basic_string<CT> s1(sz1 ? sz1 : sEmpty.c_str()); - std::basic_string<CT> s2(sz2 ? sz2 : sEmpty.c_str()); - - sslwr(const_cast<CT*>(s1.c_str()), nLen1, loc); - sslwr(const_cast<CT*>(s2.c_str()), nLen2, loc); - return coll.compare(s2.c_str(), s2.c_str()+nLen2, - s1.c_str(), s1.c_str()+nLen1); -} -#endif - - -// ----------------------------------------------------------------------------- -// ssfmtmsg: FormatMessage equivalents. Needed because I added a CString facade -// Again -- no equivalent of these on non-Win32 builds but their might one day -// be one if the message facet gets implemented -// ----------------------------------------------------------------------------- -#if defined (SS_WIN32) && !defined(SS_ANSI) - inline DWORD ssfmtmsg(DWORD dwFlags, LPCVOID pSrc, DWORD dwMsgId, - DWORD dwLangId, PSTR pBuf, DWORD nSize, - va_list* vlArgs) - { - return FormatMessageA(dwFlags, pSrc, dwMsgId, dwLangId, - pBuf, nSize,vlArgs); - } - inline DWORD ssfmtmsg(DWORD dwFlags, LPCVOID pSrc, DWORD dwMsgId, - DWORD dwLangId, PWSTR pBuf, DWORD nSize, - va_list* vlArgs) - { - return FormatMessageW(dwFlags, pSrc, dwMsgId, dwLangId, - pBuf, nSize,vlArgs); - } -#else -#endif - - - -// FUNCTION: sscpy. Copies up to 'nMax' characters from pSrc to pDst. -// ----------------------------------------------------------------------------- -// FUNCTION: sscpy -// inline int sscpy(PSTR pDst, PCSTR pSrc, int nMax=-1); -// inline int sscpy(PUSTR pDst, PCSTR pSrc, int nMax=-1) -// inline int sscpy(PSTR pDst, PCWSTR pSrc, int nMax=-1); -// inline int sscpy(PWSTR pDst, PCWSTR pSrc, int nMax=-1); -// inline int sscpy(PWSTR pDst, PCSTR pSrc, int nMax=-1); -// -// DESCRIPTION: -// This function is very much (but not exactly) like strcpy. These -// overloads simplify copying one C-style string into another by allowing -// the caller to specify two different types of strings if necessary. -// -// The strings must NOT overlap -// -// "Character" is expressed in terms of the destination string, not -// the source. If no 'nMax' argument is supplied, then the number of -// characters copied will be sslen(pSrc). A NULL terminator will -// also be added so pDst must actually be big enough to hold nMax+1 -// characters. The return value is the number of characters copied, -// not including the NULL terminator. -// -// PARAMETERS: -// pSrc - the string to be copied FROM. May be a char based string, an -// MBCS string (in Win32 builds) or a wide string (wchar_t). -// pSrc - the string to be copied TO. Also may be either MBCS or wide -// nMax - the maximum number of characters to be copied into szDest. Note -// that this is expressed in whatever a "character" means to pDst. -// If pDst is a wchar_t type string than this will be the maximum -// number of wchar_ts that my be copied. The pDst string must be -// large enough to hold least nMaxChars+1 characters. -// If the caller supplies no argument for nMax this is a signal to -// the routine to copy all the characters in pSrc, regardless of -// how long it is. -// -// RETURN VALUE: none -// ----------------------------------------------------------------------------- - -template<typename CT1, typename CT2> -inline int sscpycvt(CT1* pDst, const CT2* pSrc, int nMax) -{ - // Note -- we assume pDst is big enough to hold pSrc. If not, we're in - // big trouble. No bounds checking. Caveat emptor. - - int nSrc = sslen(pSrc); - - const CT1* szCvt = StdCodeCvt(pDst, nMax, pSrc, nSrc); - - // If we're copying the same size characters, then all the "code convert" - // just did was basically memcpy so the #of characters copied is the same - // as the number requested. I should probably specialize this function - // template to achieve this purpose as it is silly to do a runtime check - // of a fact known at compile time. I'll get around to it. - - return sslen(szCvt); -} - -template<typename T> -inline int sscpycvt(T* pDst, const T* pSrc, int nMax) -{ - int nCount = nMax; - for (; nCount > 0 && *pSrc; ++pSrc, ++pDst, --nCount) - std::basic_string<T>::traits_type::assign(*pDst, *pSrc); - - *pDst = 0; - return nMax - nCount; -} - -inline int sscpycvt(PWSTR pDst, PCSTR pSrc, int nMax) -{ - // Note -- we assume pDst is big enough to hold pSrc. If not, we're in - // big trouble. No bounds checking. Caveat emptor. - - const PWSTR szCvt = StdCodeCvt(pDst, nMax, pSrc, nMax); - return sslen(szCvt); -} - -template<typename CT1, typename CT2> -inline int sscpy(CT1* pDst, const CT2* pSrc, int nMax, int nLen) -{ - return sscpycvt(pDst, pSrc, SSMIN(nMax, nLen)); -} -template<typename CT1, typename CT2> -inline int sscpy(CT1* pDst, const CT2* pSrc, int nMax) -{ - return sscpycvt(pDst, pSrc, SSMIN(nMax, sslen(pSrc))); -} -template<typename CT1, typename CT2> -inline int sscpy(CT1* pDst, const CT2* pSrc) -{ - return sscpycvt(pDst, pSrc, sslen(pSrc)); -} -template<typename CT1, typename CT2> -inline int sscpy(CT1* pDst, const std::basic_string<CT2>& sSrc, int nMax) -{ - return sscpycvt(pDst, sSrc.c_str(), SSMIN(nMax, (int)sSrc.length())); -} -template<typename CT1, typename CT2> -inline int sscpy(CT1* pDst, const std::basic_string<CT2>& sSrc) -{ - return sscpycvt(pDst, sSrc.c_str(), (int)sSrc.length()); -} - -#ifdef SS_INC_COMDEF - template<typename CT1> - inline int sscpy(CT1* pDst, const _bstr_t& bs, int nMax) - { - return sscpycvt(pDst, static_cast<PCOLESTR>(bs), - SSMIN(nMax, static_cast<int>(bs.length()))); - } - template<typename CT1> - inline int sscpy(CT1* pDst, const _bstr_t& bs) - { - return sscpy(pDst, bs, static_cast<int>(bs.length())); - } -#endif - - -// ----------------------------------------------------------------------------- -// Functional objects for changing case. They also let you pass locales -// ----------------------------------------------------------------------------- - -#ifdef SS_NO_LOCALE - template<typename CT> - struct SSToUpper : public std::unary_function<CT, CT> - { - inline CT operator()(const CT& t) const - { - return sstoupper(t); - } - }; - template<typename CT> - struct SSToLower : public std::unary_function<CT, CT> - { - inline CT operator()(const CT& t) const - { - return sstolower(t); - } - }; -#else - template<typename CT> - struct SSToUpper : public std::binary_function<CT, std::locale, CT> - { - inline CT operator()(const CT& t, const std::locale& loc) const - { - return sstoupper<CT>(t, loc); - } - }; - template<typename CT> - struct SSToLower : public std::binary_function<CT, std::locale, CT> - { - inline CT operator()(const CT& t, const std::locale& loc) const - { - return sstolower<CT>(t, loc); - } - }; -#endif - -// This struct is used for TrimRight() and TrimLeft() function implementations. -//template<typename CT> -//struct NotSpace : public std::unary_function<CT, bool> -//{ -// const std::locale& loc; -// inline NotSpace(const std::locale& locArg) : loc(locArg) {} -// inline bool operator() (CT t) { return !std::isspace(t, loc); } -//}; -template<typename CT> -struct NotSpace : public std::unary_function<CT, bool> -{ - // DINKUMWARE BUG: - // Note -- using std::isspace in a COM DLL gives us access violations - // because it causes the dynamic addition of a function to be called - // when the library shuts down. Unfortunately the list is maintained - // in DLL memory but the function is in static memory. So the COM DLL - // goes away along with the function that was supposed to be called, - // and then later when the DLL CRT shuts down it unloads the list and - // tries to call the long-gone function. - // This is DinkumWare's implementation problem. If you encounter this - // problem, you may replace the calls here with good old isspace() and - // iswspace() from the CRT unless they specify SS_ANSI - -#ifdef SS_NO_LOCALE - - bool operator() (CT t) const { return !ssisspace(t); } - -#else - const std::locale loc; - NotSpace(const std::locale& locArg=std::locale()) : loc(locArg) {} - bool operator() (CT t) const { return !std::isspace(t, loc); } -#endif -}; - - - - -// Now we can define the template (finally!) -// ============================================================================= -// TEMPLATE: CStdStr -// template<typename CT> class CStdStr : public std::basic_string<CT> -// -// REMARKS: -// This template derives from basic_string<CT> and adds some MFC CString- -// like functionality -// -// Basically, this is my attempt to make Standard C++ library strings as -// easy to use as the MFC CString class. -// -// Note that although this is a template, it makes the assumption that the -// template argument (CT, the character type) is either char or wchar_t. -// ============================================================================= - -//#define CStdStr _SS // avoid compiler warning 4786 - -// template<typename ARG> ARG& FmtArg(ARG& arg) { return arg; } -// PCSTR FmtArg(const std::string& arg) { return arg.c_str(); } -// PCWSTR FmtArg(const std::wstring& arg) { return arg.c_str(); } - -template<typename ARG> -struct FmtArg -{ - explicit FmtArg(const ARG& arg) : a_(arg) {} - const ARG& operator()() const { return a_; } - const ARG& a_; -private: - FmtArg& operator=(const FmtArg&) { return *this; } -}; - -template<typename CT> -class CStdStr : public std::basic_string<CT> -{ - // Typedefs for shorter names. Using these names also appears to help - // us avoid some ambiguities that otherwise arise on some platforms - - #define MYBASE std::basic_string<CT> // my base class - //typedef typename std::basic_string<CT> MYBASE; // my base class - typedef CStdStr<CT> MYTYPE; // myself - typedef typename MYBASE::const_pointer PCMYSTR; // PCSTR or PCWSTR - typedef typename MYBASE::pointer PMYSTR; // PSTR or PWSTR - typedef typename MYBASE::iterator MYITER; // my iterator type - typedef typename MYBASE::const_iterator MYCITER; // you get the idea... - typedef typename MYBASE::reverse_iterator MYRITER; - typedef typename MYBASE::size_type MYSIZE; - typedef typename MYBASE::value_type MYVAL; - typedef typename MYBASE::allocator_type MYALLOC; - -public: - // shorthand conversion from PCTSTR to string resource ID - #define SSRES(pctstr) LOWORD(reinterpret_cast<unsigned long>(pctstr)) - - bool TryLoad(const void* pT) - { - bool bLoaded = false; - -#if defined(SS_WIN32) && !defined(SS_ANSI) - if ( ( pT != NULL ) && SS_IS_INTRESOURCE(pT) ) - { - UINT nId = LOWORD(reinterpret_cast<unsigned long>(pT)); - if ( !LoadString(nId) ) - { - TRACE(_T("Can't load string %u\n"), SSRES(pT)); - } - bLoaded = true; - } -#endif - - return bLoaded; - } - - - // CStdStr inline constructors - CStdStr() - { - } - - CStdStr(const MYTYPE& str) : MYBASE(SSREF(str)) - { - } - - CStdStr(const std::string& str) - { - ssasn(*this, SSREF(str)); - } - - CStdStr(const std::wstring& str) - { - ssasn(*this, SSREF(str)); - } - - CStdStr(PCMYSTR pT, MYSIZE n) : MYBASE(pT, n) - { - } - - CStdStr(PCSTR pA) - { - #ifdef SS_ANSI - *this = pA; - #else - if ( !TryLoad(pA) ) - *this = pA; - #endif - } - - CStdStr(PCWSTR pW) - { - #ifdef SS_ANSI - *this = pW; - #else - if ( !TryLoad(pW) ) - *this = pW; - #endif - } - - CStdStr(MYCITER first, MYCITER last) - : MYBASE(first, last) - { - } - - CStdStr(MYSIZE nSize, MYVAL ch, const MYALLOC& al=MYALLOC()) - : MYBASE(nSize, ch, al) - { - } - - #ifdef SS_INC_COMDEF - CStdStr(const _bstr_t& bstr) - { - if ( bstr.length() > 0 ) - this->append(static_cast<PCMYSTR>(bstr), bstr.length()); - } - #endif - - // CStdStr inline assignment operators -- the ssasn function now takes care - // of fixing the MSVC assignment bug (see knowledge base article Q172398). - MYTYPE& operator=(const MYTYPE& str) - { - ssasn(*this, str); - return *this; - } - - MYTYPE& operator=(const std::string& str) - { - ssasn(*this, str); - return *this; - } - - MYTYPE& operator=(const std::wstring& str) - { - ssasn(*this, str); - return *this; - } - - MYTYPE& operator=(PCSTR pA) - { - ssasn(*this, pA); - return *this; - } - - MYTYPE& operator=(PCWSTR pW) - { - ssasn(*this, pW); - return *this; - } - - // Overloads also needed to fix the MSVC assignment bug (KB: Q172398) - // *** Thanks to Pete The Plumber for catching this one *** - // They also are compiled if you have explicitly turned off refcounting - #if ( defined(_MSC_VER) && ( _MSC_VER < 1200 ) ) || defined(SS_NO_REFCOUNT) - - MYTYPE& assign(const MYTYPE& str) - { - Q172398(*this); - sscpy(GetBuffer(str.size()+1), SSREF(str)); - this->ReleaseBuffer(str.size()); - return *this; - } - - MYTYPE& assign(const MYTYPE& str, MYSIZE nStart, MYSIZE nChars) - { - // This overload of basic_string::assign is supposed to assign up to - // <nChars> or the NULL terminator, whichever comes first. Since we - // are about to call a less forgiving overload (in which <nChars> - // must be a valid length), we must adjust the length here to a safe - // value. Thanks to Ullrich Poll�hne for catching this bug - - nChars = SSMIN(nChars, str.length() - nStart); - MYTYPE strTemp(str.c_str()+nStart, nChars); - Q172398(*this); - this->assign(strTemp); - return *this; - } - - MYTYPE& assign(const MYBASE& str) - { - ssasn(*this, str); - return *this; - } - - MYTYPE& assign(const MYBASE& str, MYSIZE nStart, MYSIZE nChars) - { - // This overload of basic_string::assign is supposed to assign up to - // <nChars> or the NULL terminator, whichever comes first. Since we - // are about to call a less forgiving overload (in which <nChars> - // must be a valid length), we must adjust the length here to a safe - // value. Thanks to Ullrich Poll�hne for catching this bug - - nChars = SSMIN(nChars, str.length() - nStart); - - // Watch out for assignment to self - - if ( this == &str ) - { - MYTYPE strTemp(str.c_str() + nStart, nChars); - static_cast<MYBASE*>(this)->assign(strTemp); - } - else - { - Q172398(*this); - static_cast<MYBASE*>(this)->assign(str.c_str()+nStart, nChars); - } - return *this; - } - - MYTYPE& assign(const CT* pC, MYSIZE nChars) - { - // Q172398 only fix -- erase before assigning, but not if we're - // assigning from our own buffer - - #if defined ( _MSC_VER ) && ( _MSC_VER < 1200 ) - if ( !this->empty() && - ( pC < this->data() || pC > this->data() + this->capacity() ) ) - { - this->erase(); - } - #endif - Q172398(*this); - static_cast<MYBASE*>(this)->assign(pC, nChars); - return *this; - } - - MYTYPE& assign(MYSIZE nChars, MYVAL val) - { - Q172398(*this); - static_cast<MYBASE*>(this)->assign(nChars, val); - return *this; - } - - MYTYPE& assign(const CT* pT) - { - return this->assign(pT, MYBASE::traits_type::length(pT)); - } - - MYTYPE& assign(MYCITER iterFirst, MYCITER iterLast) - { - #if defined ( _MSC_VER ) && ( _MSC_VER < 1200 ) - // Q172398 fix. don't call erase() if we're assigning from ourself - if ( iterFirst < this->begin() || - iterFirst > this->begin() + this->size() ) - { - this->erase() - } - #endif - this->replace(this->begin(), this->end(), iterFirst, iterLast); - return *this; - } - #endif - - - // ------------------------------------------------------------------------- - // CStdStr inline concatenation. - // ------------------------------------------------------------------------- - MYTYPE& operator+=(const MYTYPE& str) - { - ssadd(*this, str); - return *this; - } - - MYTYPE& operator+=(const std::string& str) - { - ssadd(*this, str); - return *this; - } - - MYTYPE& operator+=(const std::wstring& str) - { - ssadd(*this, str); - return *this; - } - - MYTYPE& operator+=(PCSTR pA) - { - ssadd(*this, pA); - return *this; - } - - MYTYPE& operator+=(PCWSTR pW) - { - ssadd(*this, pW); - return *this; - } - - MYTYPE& operator+=(CT t) - { - this->append(1, t); - return *this; - } - - // ------------------------------------------------------------------------- - // CStdStr -- Direct access to character buffer. In the MS' implementation, - // the at() function that we use here also calls _Freeze() providing us some - // protection from multithreading problems associated with ref-counting. - // In VC 7 and later, of course, the ref-counting stuff is gone. - // ------------------------------------------------------------------------- - - CT* GetBuf(int nMinLen=-1) - { - if ( static_cast<int>(this->size()) < nMinLen ) - this->resize(static_cast<MYSIZE>(nMinLen)); - - return this->empty() ? const_cast<CT*>(this->data()) : &(this->at(0)); - } - - CT* SetBuf(int nLen) - { - nLen = ( nLen > 0 ? nLen : 0 ); - if ( this->capacity() < 1 && nLen == 0 ) - this->resize(1); - - this->resize(static_cast<MYSIZE>(nLen)); - return const_cast<CT*>(this->data()); - } - void RelBuf(int nNewLen=-1) - { - this->resize(static_cast<MYSIZE>(nNewLen > -1 ? nNewLen : - sslen(this->c_str()))); - } - - void BufferRel() { RelBuf(); } // backwards compatability - CT* Buffer() { return GetBuf(); } // backwards compatability - CT* BufferSet(int nLen) { return SetBuf(nLen);}// backwards compatability - - bool Equals(const CT* pT, bool bUseCase=false) const - { - return 0 == (bUseCase ? this->compare(pT) : ssicmp(this->c_str(), pT)); - } - - // ------------------------------------------------------------------------- - // FUNCTION: CStdStr::Load - // REMARKS: - // Loads string from resource specified by nID - // - // PARAMETERS: - // nID - resource Identifier. Purely a Win32 thing in this case - // - // RETURN VALUE: - // true if successful, false otherwise - // ------------------------------------------------------------------------- - -#ifndef SS_ANSI - - bool Load(UINT nId, HMODULE hModule=NULL) - { - bool bLoaded = false; // set to true of we succeed. - - #ifdef _MFC_VER // When in Rome (or MFC land)... - - // If they gave a resource handle, use it. Note - this is archaic - // and not really what I would recommend. But then again, in MFC - // land, you ought to be using CString for resources anyway since - // it walks the resource chain for you. - - HMODULE hModuleOld = NULL; - - if ( NULL != hModule ) - { - hModuleOld = AfxGetResourceHandle(); - AfxSetResourceHandle(hModule); - } - - // ...load the string - - CString strRes; - bLoaded = FALSE != strRes.LoadString(nId); - - // ...and if we set the resource handle, restore it. - - if ( NULL != hModuleOld ) - AfxSetResourceHandle(hModule); - - if ( bLoaded ) - *this = strRes; - - #else // otherwise make our own hackneyed version of CString's Load - - // Get the resource name and module handle - - if ( NULL == hModule ) - hModule = GetResourceHandle(); - - PCTSTR szName = MAKEINTRESOURCE((nId>>4)+1); // lifted - DWORD dwSize = 0; - - // No sense continuing if we can't find the resource - - HRSRC hrsrc = ::FindResource(hModule, szName, RT_STRING); - - if ( NULL == hrsrc ) - { - TRACE(_T("Cannot find resource %d: 0x%X"), nId, ::GetLastError()); - } - else if ( 0 == (dwSize = ::SizeofResource(hModule, hrsrc) / sizeof(CT))) - { - TRACE(_T("Cant get size of resource %d 0x%X\n"),nId,GetLastError()); - } - else - { - bLoaded = 0 != ssload(hModule, nId, GetBuf(dwSize), dwSize); - ReleaseBuffer(); - } - - #endif // #ifdef _MFC_VER - - if ( !bLoaded ) - TRACE(_T("String not loaded 0x%X\n"), ::GetLastError()); - - return bLoaded; - } - -#endif // #ifdef SS_ANSI - - // ------------------------------------------------------------------------- - // CString Facade Functions: - // - // The following methods are intended to allow you to use this class as a - // near drop-in replacement for CString. - // ------------------------------------------------------------------------- - #ifdef SS_WIN32 - BSTR AllocSysString() const - { - ostring os; - ssasn(os, *this); - return ::SysAllocString(os.c_str()); - } - #endif - -#ifndef SS_NO_LOCALE - int Collate(PCMYSTR szThat) const - { - return sscoll(this->c_str(), this->length(), szThat, sslen(szThat)); - } - - int CollateNoCase(PCMYSTR szThat) const - { - return ssicoll(this->c_str(), this->length(), szThat, sslen(szThat)); - } -#endif - int FindOneOf(PCMYSTR szCharSet) const - { - MYSIZE nIdx = this->find_first_of(szCharSet); - return static_cast<int>(MYBASE::npos == nIdx ? -1 : nIdx); - } - -#ifndef SS_ANSI - void FormatMessage(PCMYSTR szFormat, ...) throw(std::exception) - { - va_list argList; - va_start(argList, szFormat); - PMYSTR szTemp; - if ( ssfmtmsg(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ALLOCATE_BUFFER, - szFormat, 0, 0, - reinterpret_cast<PMYSTR>(&szTemp), 0, &argList) == 0 || - szTemp == 0 ) - { - throw std::runtime_error("out of memory"); - } - *this = szTemp; - LocalFree(szTemp); - va_end(argList); - } - - void FormatMessage(UINT nFormatId, ...) throw(std::exception) - { - MYTYPE sFormat; - VERIFY(sFormat.LoadString(nFormatId)); - va_list argList; - va_start(argList, nFormatId); - PMYSTR szTemp; - if ( ssfmtmsg(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ALLOCATE_BUFFER, - sFormat, 0, 0, - reinterpret_cast<PMYSTR>(&szTemp), 0, &argList) == 0 || - szTemp == 0) - { - throw std::runtime_error("out of memory"); - } - *this = szTemp; - LocalFree(szTemp); - va_end(argList); - } -#endif - - // GetAllocLength -- an MSVC7 function but it costs us nothing to add it. - - int GetAllocLength() - { - return static_cast<int>(this->capacity()); - } - - // ------------------------------------------------------------------------- - // GetXXXX -- Direct access to character buffer - // ------------------------------------------------------------------------- - CT* GetBuffer(int nMinLen=-1) - { - return GetBuf(nMinLen); - } - - CT* GetBufferSetLength(int nLen) - { - return BufferSet(nLen); - } - -#ifndef SS_ANSI - bool LoadString(UINT nId) - { - return this->Load(nId); - } -#endif - - void MakeReverse() - { - std::reverse(this->begin(), this->end()); - } - - void ReleaseBuffer(int nNewLen=-1) - { - RelBuf(nNewLen); - } - -#ifndef SS_ANSI - BSTR SetSysString(BSTR* pbstr) const - { - ostring os; - ssasn(os, *this); - if ( !::SysReAllocStringLen(pbstr, os.c_str(), os.length()) ) - throw std::runtime_error("out of memory"); - - ASSERT(*pbstr != 0); - return *pbstr; - } -#endif - - MYTYPE SpanExcluding(PCMYSTR szCharSet) const - { - MYSIZE pos = this->find_first_of(szCharSet); - return pos == MYBASE::npos ? *this : Left(pos); - } - - MYTYPE SpanIncluding(PCMYSTR szCharSet) const - { - MYSIZE pos = this->find_first_not_of(szCharSet); - return pos == MYBASE::npos ? *this : Left(pos); - } - -#if defined SS_WIN32 && !defined(UNICODE) && !defined(SS_ANSI) - - // CString's OemToAnsi and AnsiToOem functions are available only in - // Unicode builds. However since we're a template we also need a - // runtime check of CT and a reinterpret_cast to account for the fact - // that CStdStringW gets instantiated even in non-Unicode builds. - - void AnsiToOem() - { - if ( sizeof(CT) == sizeof(char) && !empty() ) - { - ::CharToOem(reinterpret_cast<PCSTR>(this->c_str()), - reinterpret_cast<PSTR>(GetBuf())); - } - else - { - ASSERT(false); - } - } - - void OemToAnsi() - { - if ( sizeof(CT) == sizeof(char) && !empty() ) - { - ::OemToChar(reinterpret_cast<PCSTR>(this->c_str()), - reinterpret_cast<PSTR>(GetBuf())); - } - else - { - ASSERT(false); - } - } - -#endif - - void FreeExtra() - { - MYTYPE mt; - this->swap(mt); - if ( !mt.empty() ) - this->assign(mt.c_str(), mt.size()); - } - - // I have intentionally not implemented the following CString - // functions. You cannot make them work without taking advantage - // of implementation specific behavior. However if you absolutely - // MUST have them, uncomment out these lines for "sort-of-like" - // their behavior. You're on your own. - -// CT* LockBuffer() { return GetBuf(); }// won't really lock -// void UnlockBuffer(); { } // why have UnlockBuffer w/o LockBuffer? - - // Array-indexing operators. Required because we defined an implicit cast - // to operator const CT* (Thanks to Julian Selman for pointing this out) - - CT& operator[](int nIdx) - { - return static_cast<MYBASE*>(this)->operator[](static_cast<MYSIZE>(nIdx)); - } - - const CT& operator[](int nIdx) const - { - return static_cast<const MYBASE*>(this)->operator[](static_cast<MYSIZE>(nIdx)); - } - - CT& operator[](unsigned int nIdx) - { - return static_cast<MYBASE*>(this)->operator[](static_cast<MYSIZE>(nIdx)); - } - - const CT& operator[](unsigned int nIdx) const - { - return static_cast<const MYBASE*>(this)->operator[](static_cast<MYSIZE>(nIdx)); - } - - CT& operator[](unsigned long nIdx) - { - return static_cast<MYBASE*>(this)->operator[](static_cast<MYSIZE>(nIdx)); - } - - const CT& operator[](unsigned long nIdx) const - { - return static_cast<const MYBASE*>(this)->operator[](static_cast<MYSIZE>(nIdx)); - } - -#ifndef SS_NO_IMPLICIT_CAST - operator const CT*() const - { - return this->c_str(); - } -#endif - - // IStream related functions. Useful in IPersistStream implementations - -#ifdef SS_INC_COMDEF - - // struct SSSHDR - useful for non Std C++ persistence schemes. - typedef struct SSSHDR - { - BYTE byCtrl; - ULONG nChars; - } SSSHDR; // as in "Standard String Stream Header" - - #define SSSO_UNICODE 0x01 // the string is a wide string - #define SSSO_COMPRESS 0x02 // the string is compressed - - // ------------------------------------------------------------------------- - // FUNCTION: StreamSize - // REMARKS: - // Returns how many bytes it will take to StreamSave() this CStdString - // object to an IStream. - // ------------------------------------------------------------------------- - ULONG StreamSize() const - { - // Control header plus string - ASSERT(this->size()*sizeof(CT) < 0xffffffffUL - sizeof(SSSHDR)); - return (this->size() * sizeof(CT)) + sizeof(SSSHDR); - } - - // ------------------------------------------------------------------------- - // FUNCTION: StreamSave - // REMARKS: - // Saves this CStdString object to a COM IStream. - // ------------------------------------------------------------------------- - HRESULT StreamSave(IStream* pStream) const - { - ASSERT(this->size()*sizeof(CT) < 0xffffffffUL - sizeof(SSSHDR)); - HRESULT hr = E_FAIL; - ASSERT(pStream != 0); - SSSHDR hdr; - hdr.byCtrl = sizeof(CT) == 2 ? SSSO_UNICODE : 0; - hdr.nChars = this->size(); - - - if ( FAILED(hr=pStream->Write(&hdr, sizeof(SSSHDR), 0)) ) - { - TRACE(_T("StreamSave: Cannot write control header, ERR=0x%X\n"),hr); - } - else if ( empty() ) - { - ; // nothing to write - } - else if ( FAILED(hr=pStream->Write(this->c_str(), - this->size()*sizeof(CT), 0)) ) - { - TRACE(_T("StreamSave: Cannot write string to stream 0x%X\n"), hr); - } - - return hr; - } - - - // ------------------------------------------------------------------------- - // FUNCTION: StreamLoad - // REMARKS: - // This method loads the object from an IStream. - // ------------------------------------------------------------------------- - HRESULT StreamLoad(IStream* pStream) - { - ASSERT(pStream != 0); - SSSHDR hdr; - HRESULT hr = E_FAIL; - - if ( FAILED(hr=pStream->Read(&hdr, sizeof(SSSHDR), 0)) ) - { - TRACE(_T("StreamLoad: Cant read control header, ERR=0x%X\n"), hr); - } - else if ( hdr.nChars > 0 ) - { - ULONG nRead = 0; - PMYSTR pMyBuf = BufferSet(hdr.nChars); - - // If our character size matches the character size of the string - // we're trying to read, then we can read it directly into our - // buffer. Otherwise, we have to read into an intermediate buffer - // and convert. - - if ( (hdr.byCtrl & SSSO_UNICODE) != 0 ) - { - ULONG nBytes = hdr.nChars * sizeof(wchar_t); - if ( sizeof(CT) == sizeof(wchar_t) ) - { - if ( FAILED(hr=pStream->Read(pMyBuf, nBytes, &nRead)) ) - TRACE(_T("StreamLoad: Cannot read string: 0x%X\n"), hr); - } - else - { - PWSTR pBufW = reinterpret_cast<PWSTR>(_alloca((nBytes)+1)); - if ( FAILED(hr=pStream->Read(pBufW, nBytes, &nRead)) ) - TRACE(_T("StreamLoad: Cannot read string: 0x%X\n"), hr); - else - sscpy(pMyBuf, pBufW, hdr.nChars); - } - } - else - { - ULONG nBytes = hdr.nChars * sizeof(char); - if ( sizeof(CT) == sizeof(char) ) - { - if ( FAILED(hr=pStream->Read(pMyBuf, nBytes, &nRead)) ) - TRACE(_T("StreamLoad: Cannot read string: 0x%X\n"), hr); - } - else - { - PSTR pBufA = reinterpret_cast<PSTR>(_alloca(nBytes)); - if ( FAILED(hr=pStream->Read(pBufA, hdr.nChars, &nRead)) ) - TRACE(_T("StreamLoad: Cannot read string: 0x%X\n"), hr); - else - sscpy(pMyBuf, pBufA, hdr.nChars); - } - } - } - else - { - this->erase(); - } - return hr; - } -#endif // #ifdef SS_INC_COMDEF - -#ifndef SS_ANSI - - // SetResourceHandle/GetResourceHandle. In MFC builds, these map directly - // to AfxSetResourceHandle and AfxGetResourceHandle. In non-MFC builds they - // point to a single static HINST so that those who call the member - // functions that take resource IDs can provide an alternate HINST of a DLL - // to search. This is not exactly the list of HMODULES that MFC provides - // but it's better than nothing. - - #ifdef _MFC_VER - static void SetResourceHandle(HMODULE hNew) - { - AfxSetResourceHandle(hNew); - } - static HMODULE GetResourceHandle() - { - return AfxGetResourceHandle(); - } - #else - static void SetResourceHandle(HMODULE hNew) - { - SSResourceHandle() = hNew; - } - static HMODULE GetResourceHandle() - { - return SSResourceHandle(); - } - #endif - -#endif -}; - -// ----------------------------------------------------------------------------- -// MSVC USERS: HOW TO EXPORT CSTDSTRING FROM A DLL -// -// If you are using MS Visual C++ and you want to export CStdStringA and -// CStdStringW from a DLL, then all you need to -// -// 1. make sure that all components link to the same DLL version -// of the CRT (not the static one). -// 2. Uncomment the 3 lines of code below -// 3. #define 2 macros per the instructions in MS KnowledgeBase -// article Q168958. The macros are: -// -// MACRO DEFINTION WHEN EXPORTING DEFINITION WHEN IMPORTING -// ----- ------------------------ ------------------------- -// SSDLLEXP (nothing, just #define it) extern -// SSDLLSPEC __declspec(dllexport) __declspec(dllimport) -// -// Note that these macros must be available to ALL clients who want to -// link to the DLL and use the class. If they -// -// A word of advice: Don't bother. -// -// Really, it is not necessary to export CStdString functions from a DLL. I -// never do. In my projects, I do generally link to the DLL version of the -// Standard C++ Library, but I do NOT attempt to export CStdString functions. -// I simply include the header where it is needed and allow for the code -// redundancy. -// -// That redundancy is a lot less than you think. This class does most of its -// work via the Standard C++ Library, particularly the base_class basic_string<> -// member functions. Most of the functions here are small enough to be inlined -// anyway. Besides, you'll find that in actual practice you use less than 1/2 -// of the code here, even in big projects and different modules will use as -// little as 10% of it. That means a lot less functions actually get linked -// your binaries. If you export this code from a DLL, it ALL gets linked in. -// -// I've compared the size of the binaries from exporting vs NOT exporting. Take -// my word for it -- exporting this code is not worth the hassle. -// -// ----------------------------------------------------------------------------- -//#pragma warning(disable:4231) // non-standard extension ("extern template") -// SSDLLEXP template class SSDLLSPEC CStdStr<char>; -// SSDLLEXP template class SSDLLSPEC CStdStr<wchar_t>; - - -// ============================================================================= -// END OF CStdStr INLINE FUNCTION DEFINITIONS -// ============================================================================= - -// Now typedef our class names based upon this humongous template - -typedef CStdStr<char> CStdStringA; // a better std::string -typedef CStdStr<wchar_t> CStdStringW; // a better std::wstring -typedef CStdStr<uint16_t> CStdString16; // a 16bit char string -typedef CStdStr<uint32_t> CStdString32; // a 32bit char string -typedef CStdStr<OLECHAR> CStdStringO; // almost always CStdStringW - -// ----------------------------------------------------------------------------- -// CStdStr addition functions defined as inline -// ----------------------------------------------------------------------------- - - -inline CStdStringA operator+(const CStdStringA& s1, const CStdStringA& s2) -{ - CStdStringA sRet(SSREF(s1)); - sRet.append(s2); - return sRet; -} -inline CStdStringA operator+(const CStdStringA& s1, CStdStringA::value_type t) -{ - CStdStringA sRet(SSREF(s1)); - sRet.append(1, t); - return sRet; -} -inline CStdStringA operator+(const CStdStringA& s1, PCSTR pA) -{ - CStdStringA sRet(SSREF(s1)); - sRet.append(pA); - return sRet; -} -inline CStdStringA operator+(PCSTR pA, const CStdStringA& sA) -{ - CStdStringA sRet; - CStdStringA::size_type nObjSize = sA.size(); - CStdStringA::size_type nLitSize = - static_cast<CStdStringA::size_type>(sslen(pA)); - - sRet.reserve(nLitSize + nObjSize); - sRet.assign(pA); - sRet.append(sA); - return sRet; -} - - -inline CStdStringA operator+(const CStdStringA& s1, const CStdStringW& s2) -{ - return s1 + CStdStringA(s2); -} -inline CStdStringW operator+(const CStdStringW& s1, const CStdStringW& s2) -{ - CStdStringW sRet(SSREF(s1)); - sRet.append(s2); - return sRet; -} -inline CStdStringA operator+(const CStdStringA& s1, PCWSTR pW) -{ - return s1 + CStdStringA(pW); -} - -#ifdef UNICODE - inline CStdStringW operator+(PCWSTR pW, const CStdStringA& sA) - { - return CStdStringW(pW) + CStdStringW(SSREF(sA)); - } - inline CStdStringW operator+(PCSTR pA, const CStdStringW& sW) - { - return CStdStringW(pA) + sW; - } -#else - inline CStdStringA operator+(PCWSTR pW, const CStdStringA& sA) - { - return CStdStringA(pW) + sA; - } - inline CStdStringA operator+(PCSTR pA, const CStdStringW& sW) - { - return pA + CStdStringA(sW); - } -#endif - -// ...Now the wide string versions. -inline CStdStringW operator+(const CStdStringW& s1, CStdStringW::value_type t) -{ - CStdStringW sRet(SSREF(s1)); - sRet.append(1, t); - return sRet; -} -inline CStdStringW operator+(const CStdStringW& s1, PCWSTR pW) -{ - CStdStringW sRet(SSREF(s1)); - sRet.append(pW); - return sRet; -} -inline CStdStringW operator+(PCWSTR pW, const CStdStringW& sW) -{ - CStdStringW sRet; - CStdStringW::size_type nObjSize = sW.size(); - CStdStringA::size_type nLitSize = - static_cast<CStdStringW::size_type>(sslen(pW)); - - sRet.reserve(nLitSize + nObjSize); - sRet.assign(pW); - sRet.append(sW); - return sRet; -} - -inline CStdStringW operator+(const CStdStringW& s1, const CStdStringA& s2) -{ - return s1 + CStdStringW(s2); -} -inline CStdStringW operator+(const CStdStringW& s1, PCSTR pA) -{ - return s1 + CStdStringW(pA); -} - - -// New-style format function is a template - -#ifdef SS_SAFE_FORMAT - -template<> -struct FmtArg<CStdStringA> -{ - explicit FmtArg(const CStdStringA& arg) : a_(arg) {} - PCSTR operator()() const { return a_.c_str(); } - const CStdStringA& a_; -private: - FmtArg<CStdStringA>& operator=(const FmtArg<CStdStringA>&) { return *this; } -}; -template<> -struct FmtArg<CStdStringW> -{ - explicit FmtArg(const CStdStringW& arg) : a_(arg) {} - PCWSTR operator()() const { return a_.c_str(); } - const CStdStringW& a_; -private: - FmtArg<CStdStringW>& operator=(const FmtArg<CStdStringW>&) { return *this; } -}; - -template<> -struct FmtArg<std::string> -{ - explicit FmtArg(const std::string& arg) : a_(arg) {} - PCSTR operator()() const { return a_.c_str(); } - const std::string& a_; -private: - FmtArg<std::string>& operator=(const FmtArg<std::string>&) { return *this; } -}; -template<> -struct FmtArg<std::wstring> -{ - explicit FmtArg(const std::wstring& arg) : a_(arg) {} - PCWSTR operator()() const { return a_.c_str(); } - const std::wstring& a_; -private: - FmtArg<std::wstring>& operator=(const FmtArg<std::wstring>&) {return *this;} -}; -#endif // #ifdef SS_SAFEFORMAT - -#ifndef SS_ANSI - // SSResourceHandle: our MFC-like resource handle - inline HMODULE& SSResourceHandle() - { - static HMODULE hModuleSS = GetModuleHandle(0); - return hModuleSS; - } -#endif - - -// In MFC builds, define some global serialization operators -// Special operators that allow us to serialize CStdStrings to CArchives. -// Note that we use an intermediate CString object in order to ensure that -// we use the exact same format. - -#ifdef _MFC_VER - inline CArchive& AFXAPI operator<<(CArchive& ar, const CStdStringA& strA) - { - CString strTemp = strA; - return ar << strTemp; - } - inline CArchive& AFXAPI operator<<(CArchive& ar, const CStdStringW& strW) - { - CString strTemp = strW; - return ar << strTemp; - } - - inline CArchive& AFXAPI operator>>(CArchive& ar, CStdStringA& strA) - { - CString strTemp; - ar >> strTemp; - strA = strTemp; - return ar; - } - inline CArchive& AFXAPI operator>>(CArchive& ar, CStdStringW& strW) - { - CString strTemp; - ar >> strTemp; - strW = strTemp; - return ar; - } -#endif // #ifdef _MFC_VER -- (i.e. is this MFC?) - - -// Define TCHAR based friendly names for some of these functions - -#ifdef UNICODE - //#define CStdString CStdStringW - typedef CStdStringW CStdString; -#else - //#define CStdString CStdStringA - typedef CStdStringA CStdString; -#endif - -// ...and some shorter names for the space-efficient - -// ----------------------------------------------------------------------------- -// FUNCTIONAL COMPARATORS: -// REMARKS: -// These structs are derived from the std::binary_function template. They -// give us functional classes (which may be used in Standard C++ Library -// collections and algorithms) that perform case-insensitive comparisons of -// CStdString objects. This is useful for maps in which the key may be the -// proper string but in the wrong case. -// ----------------------------------------------------------------------------- -#define StdStringLessNoCaseW SSLNCW // avoid VC compiler warning 4786 -#define StdStringEqualsNoCaseW SSENCW -#define StdStringLessNoCaseA SSLNCA -#define StdStringEqualsNoCaseA SSENCA - -#ifdef UNICODE - #define StdStringLessNoCase SSLNCW - #define StdStringEqualsNoCase SSENCW -#else - #define StdStringLessNoCase SSLNCA - #define StdStringEqualsNoCase SSENCA -#endif - -struct StdStringLessNoCaseW - : std::binary_function<CStdStringW, CStdStringW, bool> -{ - inline - bool operator()(const CStdStringW& sLeft, const CStdStringW& sRight) const - { return ssicmp(sLeft.c_str(), sRight.c_str()) < 0; } -}; -struct StdStringEqualsNoCaseW - : std::binary_function<CStdStringW, CStdStringW, bool> -{ - inline - bool operator()(const CStdStringW& sLeft, const CStdStringW& sRight) const - { return ssicmp(sLeft.c_str(), sRight.c_str()) == 0; } -}; -struct StdStringLessNoCaseA - : std::binary_function<CStdStringA, CStdStringA, bool> -{ - inline - bool operator()(const CStdStringA& sLeft, const CStdStringA& sRight) const - { return ssicmp(sLeft.c_str(), sRight.c_str()) < 0; } -}; -struct StdStringEqualsNoCaseA - : std::binary_function<CStdStringA, CStdStringA, bool> -{ - inline - bool operator()(const CStdStringA& sLeft, const CStdStringA& sRight) const - { return ssicmp(sLeft.c_str(), sRight.c_str()) == 0; } -}; - -// If we had to define our own version of TRACE above, get rid of it now - -#ifdef TRACE_DEFINED_HERE - #undef TRACE - #undef TRACE_DEFINED_HERE -#endif - - -// These std::swap specializations come courtesy of Mike Crusader. - -//namespace std -//{ -// inline void swap(CStdStringA& s1, CStdStringA& s2) throw() -// { -// s1.swap(s2); -// } -// template<> -// inline void swap(CStdStringW& s1, CStdStringW& s2) throw() -// { -// s1.swap(s2); -// } -//} - -// Turn back on any Borland warnings we turned off. - -#ifdef __BORLANDC__ - #pragma option pop // Turn back on inline function warnings -// #pragma warn +inl // Turn back on inline function warnings -#endif - -#endif // #ifndef STDSTRING_H diff --git a/xbmc/utils/StringUtils.cpp b/xbmc/utils/StringUtils.cpp index 56bb28ef99..508dde89e8 100644 --- a/xbmc/utils/StringUtils.cpp +++ b/xbmc/utils/StringUtils.cpp @@ -24,21 +24,26 @@ // Purpose: ATL split string utility // Author: Paul J. Weiss // -// Modified to use J O'Leary's CStdString class by kraqh3d +// Modified to use J O'Leary's std::string class by kraqh3d // //------------------------------------------------------------------------ #include "StringUtils.h" -#include "utils/RegExp.h" #include "utils/fstrcmp.h" #include "Util.h" #include <locale> +#include <assert.h> #include <math.h> #include <sstream> #include <time.h> #include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <memory.h> +#include <algorithm> +#include "utils/RegExp.h" // don't move or std functions end up in PCRE namespace #define FORMAT_BLOCK_SIZE 512 // # of bytes for initial allocation for printf @@ -47,9 +52,8 @@ using namespace std; const char* ADDON_GUID_RE = "^(\\{){0,1}[0-9a-fA-F]{8}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{12}(\\}){0,1}$"; /* empty string for use in returns by ref */ -const CStdString StringUtils::EmptyString = ""; const std::string StringUtils::Empty = ""; -CStdString StringUtils::m_lastUUID = ""; +std::string StringUtils::m_lastUUID = ""; // Copyright (c) Leigh Brasington 2012. All rights reserved. // This code may be used and reproduced without written permission. @@ -350,7 +354,7 @@ wchar_t toupperUnicode(const wchar_t& c) void StringUtils::ToUpper(string &str) { - transform(str.begin(), str.end(), str.begin(), ::toupper); + std::transform(str.begin(), str.end(), str.begin(), ::toupper); } void StringUtils::ToUpper(wstring &str) @@ -423,7 +427,7 @@ string StringUtils::Mid(const string &str, size_t first, size_t count /* = strin if (first > str.size()) return string(); - ASSERT(first + count <= str.size()); + assert(first + count <= str.size()); return str.substr(first, count); } @@ -713,7 +717,7 @@ std::vector<std::string> StringUtils::Split(const std::string& input, const char // returns the number of occurrences of strFind in strInput. -int StringUtils::FindNumber(const CStdString& strInput, const CStdString &strFind) +int StringUtils::FindNumber(const std::string& strInput, const std::string &strFind) { size_t pos = strInput.find(strFind, 0); int numfound = 0; @@ -791,7 +795,7 @@ int64_t StringUtils::AlphaNumericCompare(const wchar_t *left, const wchar_t *rig return 0; // files are the same } -int StringUtils::DateStringToYYYYMMDD(const CStdString &dateString) +int StringUtils::DateStringToYYYYMMDD(const std::string &dateString) { vector<string> days = StringUtils::Split(dateString, '-'); if (days.size() == 1) @@ -804,9 +808,9 @@ int StringUtils::DateStringToYYYYMMDD(const CStdString &dateString) return -1; } -long StringUtils::TimeStringToSeconds(const CStdString &timeString) +long StringUtils::TimeStringToSeconds(const std::string &timeString) { - CStdString strCopy(timeString); + std::string strCopy(timeString); StringUtils::Trim(strCopy); if(StringUtils::EndsWithNoCase(strCopy, " min")) { @@ -826,7 +830,7 @@ long StringUtils::TimeStringToSeconds(const CStdString &timeString) } } -CStdString StringUtils::SecondsToTimeString(long lSeconds, TIME_FORMAT format) +std::string StringUtils::SecondsToTimeString(long lSeconds, TIME_FORMAT format) { int hh = lSeconds / 3600; lSeconds = lSeconds % 3600; @@ -835,7 +839,7 @@ CStdString StringUtils::SecondsToTimeString(long lSeconds, TIME_FORMAT format) if (format == TIME_FORMAT_GUESS) format = (hh >= 1) ? TIME_FORMAT_HH_MM_SS : TIME_FORMAT_MM_SS; - CStdString strHMS; + std::string strHMS; if (format & TIME_FORMAT_HH) strHMS += StringUtils::Format("%02.2i", hh); else if (format & TIME_FORMAT_H) @@ -847,7 +851,7 @@ CStdString StringUtils::SecondsToTimeString(long lSeconds, TIME_FORMAT format) return strHMS; } -bool StringUtils::IsNaturalNumber(const CStdString& str) +bool StringUtils::IsNaturalNumber(const std::string& str) { size_t i = 0, n = 0; // allow whitespace,digits,whitespace @@ -862,7 +866,7 @@ bool StringUtils::IsNaturalNumber(const CStdString& str) return i == str.size() && n > 0; } -bool StringUtils::IsInteger(const CStdString& str) +bool StringUtils::IsInteger(const std::string& str) { size_t i = 0, n = 0; // allow whitespace,-,digits,whitespace @@ -906,9 +910,9 @@ void StringUtils::RemoveCRLF(std::string& strLine) StringUtils::TrimRight(strLine, "\n\r"); } -CStdString StringUtils::SizeToString(int64_t size) +std::string StringUtils::SizeToString(int64_t size) { - CStdString strLabel; + std::string strLabel; const char prefixes[] = {' ','k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'}; unsigned int i = 0; double s = (double)size; @@ -999,11 +1003,11 @@ size_t StringUtils::FindWords(const char *str, const char *wordLowerCase) // and repeat until we're done } while (*s); - return CStdString::npos; + return std::string::npos; } // assumes it is called from after the first open bracket is found -int StringUtils::FindEndBracket(const CStdString &str, char opener, char closer, int startPos) +int StringUtils::FindEndBracket(const std::string &str, char opener, char closer, int startPos) { int blocks = 1; for (unsigned int i = startPos; i < str.size(); i++) @@ -1018,7 +1022,7 @@ int StringUtils::FindEndBracket(const CStdString &str, char opener, char closer, } } - return (int)CStdString::npos; + return (int)std::string::npos; } void StringUtils::WordToDigits(std::string &word) @@ -1039,7 +1043,7 @@ void StringUtils::WordToDigits(std::string &word) } } -CStdString StringUtils::CreateUUID() +std::string StringUtils::CreateUUID() { /* This function generate a DCE 1.1, ISO/IEC 11578:1996 and IETF RFC-4122 * Version 4 conform local unique UUID based upon random number generation. @@ -1086,19 +1090,19 @@ CStdString StringUtils::CreateUUID() return UuidStrTmp; } -bool StringUtils::ValidateUUID(const CStdString &uuid) +bool StringUtils::ValidateUUID(const std::string &uuid) { CRegExp guidRE; guidRE.RegComp(ADDON_GUID_RE); return (guidRE.RegFind(uuid.c_str()) == 0); } -double StringUtils::CompareFuzzy(const CStdString &left, const CStdString &right) +double StringUtils::CompareFuzzy(const std::string &left, const std::string &right) { return (0.5 + fstrcmp(left.c_str(), right.c_str(), 0.0) * (left.length() + right.length())) / 2.0; } -int StringUtils::FindBestMatch(const CStdString &str, const vector<string> &strings, double &matchscore) +int StringUtils::FindBestMatch(const std::string &str, const vector<string> &strings, double &matchscore) { int best = -1; matchscore = 0; @@ -1117,7 +1121,7 @@ int StringUtils::FindBestMatch(const CStdString &str, const vector<string> &stri return best; } -bool StringUtils::ContainsKeyword(const CStdString &str, const vector<string> &keywords) +bool StringUtils::ContainsKeyword(const std::string &str, const vector<string> &keywords) { for (vector<string>::const_iterator it = keywords.begin(); it != keywords.end(); ++it) { diff --git a/xbmc/utils/StringUtils.h b/xbmc/utils/StringUtils.h index 998fae2442..5ed81a5646 100644 --- a/xbmc/utils/StringUtils.h +++ b/xbmc/utils/StringUtils.h @@ -25,16 +25,16 @@ // Purpose: ATL split string utility // Author: Paul J. Weiss // -// Modified to support J O'Leary's CStdString class by kraqh3d +// Modified to support J O'Leary's std::string class by kraqh3d // //------------------------------------------------------------------------ -#include <vector> +#include <stdarg.h> #include <stdint.h> #include <string> +#include <vector> #include "XBDateTime.h" -#include "utils/StdString.h" #include "utils/params_check_macros.h" class StringUtils @@ -100,9 +100,9 @@ public: */ static std::vector<std::string> Split(const std::string& input, const std::string& delimiter, unsigned int iMaxStrings = 0); static std::vector<std::string> Split(const std::string& input, const char delimiter, size_t iMaxStrings = 0); - static int FindNumber(const CStdString& strInput, const CStdString &strFind); + static int FindNumber(const std::string& strInput, const std::string &strFind); static int64_t AlphaNumericCompare(const wchar_t *left, const wchar_t *right); - static long TimeStringToSeconds(const CStdString &timeString); + static long TimeStringToSeconds(const std::string &timeString); static void RemoveCRLF(std::string& strLine); /*! \brief utf8 version of strlen - skips any non-starting bytes in the count, thus returning the number of utf8 characters @@ -117,21 +117,21 @@ public: \return the formatted time \sa TIME_FORMAT */ - static CStdString SecondsToTimeString(long seconds, TIME_FORMAT format = TIME_FORMAT_GUESS); + static std::string SecondsToTimeString(long seconds, TIME_FORMAT format = TIME_FORMAT_GUESS); /*! \brief check whether a string is a natural number. Matches [ \t]*[0-9]+[ \t]* \param str the string to check \return true if the string is a natural number, false otherwise. */ - static bool IsNaturalNumber(const CStdString& str); + static bool IsNaturalNumber(const std::string& str); /*! \brief check whether a string is an integer. Matches [ \t]*[\-]*[0-9]+[ \t]* \param str the string to check \return true if the string is an integer, false otherwise. */ - static bool IsInteger(const CStdString& str); + static bool IsInteger(const std::string& str); /* The next several isasciiXX and asciiXXvalue functions are locale independent (US-ASCII only), * as opposed to standard ::isXX (::isalpha, ::isdigit...) which are locale dependent. @@ -158,18 +158,17 @@ public: { return isasciiuppercaseletter(chr) || isasciilowercaseletter(chr) || isasciidigit(chr); } - static CStdString SizeToString(int64_t size); - static const CStdString EmptyString; + static std::string SizeToString(int64_t size); static const std::string Empty; static size_t FindWords(const char *str, const char *wordLowerCase); - static int FindEndBracket(const CStdString &str, char opener, char closer, int startPos = 0); - static int DateStringToYYYYMMDD(const CStdString &dateString); + static int FindEndBracket(const std::string &str, char opener, char closer, int startPos = 0); + static int DateStringToYYYYMMDD(const std::string &dateString); static void WordToDigits(std::string &word); - static CStdString CreateUUID(); - static bool ValidateUUID(const CStdString &uuid); // NB only validates syntax - static double CompareFuzzy(const CStdString &left, const CStdString &right); - static int FindBestMatch(const CStdString &str, const std::vector<std::string> &strings, double &matchscore); - static bool ContainsKeyword(const CStdString &str, const std::vector<std::string> &keywords); + static std::string CreateUUID(); + static bool ValidateUUID(const std::string &uuid); // NB only validates syntax + static double CompareFuzzy(const std::string &left, const std::string &right); + static int FindBestMatch(const std::string &str, const std::vector<std::string> &strings, double &matchscore); + static bool ContainsKeyword(const std::string &str, const std::vector<std::string> &keywords); /*! \brief Escapes the given string to be able to be used as a parameter. @@ -193,5 +192,5 @@ public: static std::vector<std::string> Tokenize(const std::string& input, const char delimiter); static void Tokenize(const std::string& input, std::vector<std::string>& tokens, const char delimiter); private: - static CStdString m_lastUUID; + static std::string m_lastUUID; }; diff --git a/xbmc/utils/SysfsUtils.cpp b/xbmc/utils/SysfsUtils.cpp new file mode 100644 index 0000000000..ca629865b6 --- /dev/null +++ b/xbmc/utils/SysfsUtils.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2011-2014 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "SysfsUtils.h" +#include "utils/log.h" + +#include <unistd.h> +#include <stdio.h> +#include <stdlib.h> +#include <fcntl.h> +#include <string.h> + +int SysfsUtils::SetString(const std::string& path, const std::string& valstr) +{ + int fd = open(path.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0644); + if (fd >= 0) + { + write(fd, valstr.c_str(), valstr.size()); + close(fd); + return 0; + } + CLog::Log(LOGERROR, "%s: error writing %s",__FUNCTION__, path.c_str()); + return -1; +} + +int SysfsUtils::GetString(const std::string& path, std::string& valstr) +{ + int len; + char buf[256] = {0}; + + int fd = open(path.c_str(), O_RDONLY); + if (fd >= 0) + { + valstr.clear(); + while ((len = read(fd, buf, 256)) > 0) + valstr.append(buf, len); + close(fd); + return 0; + } + + CLog::Log(LOGERROR, "%s: error reading %s",__FUNCTION__, path.c_str()); + valstr = "fail"; + return -1; +} + +int SysfsUtils::SetInt(const std::string& path, const int val) +{ + int fd = open(path.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0644); + if (fd >= 0) + { + char bcmd[16]; + sprintf(bcmd, "%d", val); + write(fd, bcmd, strlen(bcmd)); + close(fd); + return 0; + } + + CLog::Log(LOGERROR, "%s: error writing %s",__FUNCTION__, path.c_str()); + return -1; +} + +int SysfsUtils::GetInt(const std::string& path, int& val) +{ + int fd = open(path.c_str(), O_RDONLY); + if (fd >= 0) + { + char bcmd[16]; + read(fd, bcmd, sizeof(bcmd)); + val = strtol(bcmd, NULL, 16); + close(fd); + return 0; + } + + CLog::Log(LOGERROR, "%s: error reading %s",__FUNCTION__, path.c_str()); + return -1; +} + +bool SysfsUtils::Has(const std::string &path) +{ + int fd = open(path.c_str(), O_RDONLY); + if (fd >= 0) + { + close(fd); + return true; + } + return false; +} diff --git a/xbmc/utils/test/TestStdString.cpp b/xbmc/utils/SysfsUtils.h index c613db28b3..fe038bf5ef 100644 --- a/xbmc/utils/test/TestStdString.cpp +++ b/xbmc/utils/SysfsUtils.h @@ -1,5 +1,6 @@ +#pragma once /* - * Copyright (C) 2005-2013 Team XBMC + * Copyright (C) 2011-2013 Team XBMC * http://xbmc.org * * This Program is free software; you can redistribute it and/or modify @@ -18,33 +19,14 @@ * */ -#include "utils/StdString.h" +#include <string> -#include "gtest/gtest.h" - -TEST(TestStdString, CStdString) -{ - CStdString ref, var; - - ref = "CStdString test"; - var = ref; - EXPECT_STREQ(ref.c_str(), var.c_str()); -} - -TEST(TestStdString, CStdStringA) +class SysfsUtils { - CStdStringA ref, var; - - ref = "CStdStringA test"; - var = ref; - EXPECT_STREQ(ref.c_str(), var.c_str()); -} - -TEST(TestStdString, CStdStringW) -{ - CStdStringW ref, var; - - ref = L"CStdStringW test"; - var = ref; - EXPECT_STREQ(ref.c_str(), var.c_str()); -} +public: + static int SetString(const std::string& path, const std::string& valstr); + static int GetString(const std::string& path, std::string& valstr); + static int SetInt(const std::string& path, const int val); + static int GetInt(const std::string& path, int& val); + static bool Has(const std::string& path); +}; diff --git a/xbmc/utils/TextSearch.cpp b/xbmc/utils/TextSearch.cpp index ef0c6ae3aa..ec5bc9ba57 100644 --- a/xbmc/utils/TextSearch.cpp +++ b/xbmc/utils/TextSearch.cpp @@ -19,10 +19,11 @@ */ #include "TextSearch.h" +#include "StringUtils.h" using namespace std; -CTextSearch::CTextSearch(const CStdString &strSearchTerms, bool bCaseSensitive /* = false */, TextSearchDefault defaultSearchMode /* = SEARCH_DEFAULT_OR */) +CTextSearch::CTextSearch(const std::string &strSearchTerms, bool bCaseSensitive /* = false */, TextSearchDefault defaultSearchMode /* = SEARCH_DEFAULT_OR */) { m_bCaseSensitive = bCaseSensitive; ExtractSearchTerms(strSearchTerms, defaultSearchMode); @@ -40,12 +41,12 @@ bool CTextSearch::IsValid(void) const return m_AND.size() > 0 || m_OR.size() > 0 || m_NOT.size() > 0; } -bool CTextSearch::Search(const CStdString &strHaystack) const +bool CTextSearch::Search(const std::string &strHaystack) const { if (strHaystack.empty() || !IsValid()) return false; - CStdString strSearch(strHaystack); + std::string strSearch(strHaystack); if (!m_bCaseSensitive) StringUtils::ToLower(strSearch); @@ -80,9 +81,9 @@ bool CTextSearch::Search(const CStdString &strHaystack) const return true; } -void CTextSearch::GetAndCutNextTerm(CStdString &strSearchTerm, CStdString &strNextTerm) +void CTextSearch::GetAndCutNextTerm(std::string &strSearchTerm, std::string &strNextTerm) { - CStdString strFindNext(" "); + std::string strFindNext(" "); if (StringUtils::EndsWith(strSearchTerm, "\"")) { @@ -103,9 +104,9 @@ void CTextSearch::GetAndCutNextTerm(CStdString &strSearchTerm, CStdString &strNe } } -void CTextSearch::ExtractSearchTerms(const CStdString &strSearchTerm, TextSearchDefault defaultSearchMode) +void CTextSearch::ExtractSearchTerms(const std::string &strSearchTerm, TextSearchDefault defaultSearchMode) { - CStdString strParsedSearchTerm(strSearchTerm); + std::string strParsedSearchTerm(strSearchTerm); StringUtils::Trim(strParsedSearchTerm); if (!m_bCaseSensitive) @@ -121,25 +122,25 @@ void CTextSearch::ExtractSearchTerms(const CStdString &strSearchTerm, TextSearch if (StringUtils::StartsWith(strParsedSearchTerm, "!") || StringUtils::StartsWithNoCase(strParsedSearchTerm, "not")) { - CStdString strDummy; + std::string strDummy; GetAndCutNextTerm(strParsedSearchTerm, strDummy); bNextNOT = true; } else if (StringUtils::StartsWith(strParsedSearchTerm, "+") || StringUtils::StartsWithNoCase(strParsedSearchTerm, "and")) { - CStdString strDummy; + std::string strDummy; GetAndCutNextTerm(strParsedSearchTerm, strDummy); bNextAND = true; } else if (StringUtils::StartsWith(strParsedSearchTerm, "|") || StringUtils::StartsWithNoCase(strParsedSearchTerm, "or")) { - CStdString strDummy; + std::string strDummy; GetAndCutNextTerm(strParsedSearchTerm, strDummy); bNextOR = true; } else { - CStdString strTerm; + std::string strTerm; GetAndCutNextTerm(strParsedSearchTerm, strTerm); if (strTerm.length() > 0) { diff --git a/xbmc/utils/TextSearch.h b/xbmc/utils/TextSearch.h index 034bb9fd5f..b058f99ea8 100644 --- a/xbmc/utils/TextSearch.h +++ b/xbmc/utils/TextSearch.h @@ -19,8 +19,8 @@ * */ +#include <string> #include <vector> -#include "StringUtils.h" typedef enum TextSearchDefault { @@ -32,18 +32,18 @@ typedef enum TextSearchDefault class CTextSearch { public: - CTextSearch(const CStdString &strSearchTerms, bool bCaseSensitive = false, TextSearchDefault defaultSearchMode = SEARCH_DEFAULT_OR); + CTextSearch(const std::string &strSearchTerms, bool bCaseSensitive = false, TextSearchDefault defaultSearchMode = SEARCH_DEFAULT_OR); virtual ~CTextSearch(void); - bool Search(const CStdString &strHaystack) const; + bool Search(const std::string &strHaystack) const; bool IsValid(void) const; private: - static void GetAndCutNextTerm(CStdString &strSearchTerm, CStdString &strNextTerm); - void ExtractSearchTerms(const CStdString &strSearchTerm, TextSearchDefault defaultSearchMode); + static void GetAndCutNextTerm(std::string &strSearchTerm, std::string &strNextTerm); + void ExtractSearchTerms(const std::string &strSearchTerm, TextSearchDefault defaultSearchMode); bool m_bCaseSensitive; - std::vector<CStdString> m_AND; - std::vector<CStdString> m_OR; - std::vector<CStdString> m_NOT; + std::vector<std::string> m_AND; + std::vector<std::string> m_OR; + std::vector<std::string> m_NOT; }; diff --git a/xbmc/utils/URIUtils.cpp b/xbmc/utils/URIUtils.cpp index 6ab3dbb9b2..2699a9d145 100644 --- a/xbmc/utils/URIUtils.cpp +++ b/xbmc/utils/URIUtils.cpp @@ -38,10 +38,10 @@ using namespace std; using namespace XFILE; -bool URIUtils::IsInPath(const CStdString &uri, const CStdString &baseURI) +bool URIUtils::IsInPath(const std::string &uri, const std::string &baseURI) { - CStdString uriPath = CSpecialProtocol::TranslatePath(uri); - CStdString basePath = CSpecialProtocol::TranslatePath(baseURI); + std::string uriPath = CSpecialProtocol::TranslatePath(uri); + std::string basePath = CSpecialProtocol::TranslatePath(baseURI); return !basePath.empty() && StringUtils::StartsWith(uriPath, basePath); } @@ -62,12 +62,12 @@ std::string URIUtils::GetExtension(const std::string& strFileName) size_t period = strFileName.find_last_of("./\\"); if (period == string::npos || strFileName[period] != '.') - return CStdString(); + return std::string(); return strFileName.substr(period); } -bool URIUtils::HasExtension(const CStdString& strFileName) +bool URIUtils::HasExtension(const std::string& strFileName) { if (IsURL(strFileName)) { @@ -79,12 +79,12 @@ bool URIUtils::HasExtension(const CStdString& strFileName) return iPeriod != string::npos && strFileName[iPeriod] == '.'; } -bool URIUtils::HasExtension(const CURL& url, const CStdString& strExtensions) +bool URIUtils::HasExtension(const CURL& url, const std::string& strExtensions) { return HasExtension(url.GetFileName(), strExtensions); } -bool URIUtils::HasExtension(const CStdString& strFileName, const CStdString& strExtensions) +bool URIUtils::HasExtension(const std::string& strFileName, const std::string& strExtensions) { if (IsURL(strFileName)) { @@ -93,11 +93,11 @@ bool URIUtils::HasExtension(const CStdString& strFileName, const CStdString& str } // Search backwards so that '.' can be used as a search terminator. - CStdString::const_reverse_iterator itExtensions = strExtensions.rbegin(); + std::string::const_reverse_iterator itExtensions = strExtensions.rbegin(); while (itExtensions != strExtensions.rend()) { // Iterate backwards over strFileName untill we hit a '.' or a mismatch - for (CStdString::const_reverse_iterator itFileName = strFileName.rbegin(); + for (std::string::const_reverse_iterator itFileName = strFileName.rbegin(); itFileName != strFileName.rend() && itExtensions != strExtensions.rend() && tolower(*itFileName) == *itExtensions; ++itFileName, ++itExtensions) @@ -132,11 +132,11 @@ void URIUtils::RemoveExtension(std::string& strFileName) size_t period = strFileName.find_last_of("./\\"); if (period != string::npos && strFileName[period] == '.') { - CStdString strExtension = strFileName.substr(period); + std::string strExtension = strFileName.substr(period); StringUtils::ToLower(strExtension); strExtension += "|"; - CStdString strFileMask; + std::string strFileMask; strFileMask = g_advancedSettings.m_pictureExtensions; strFileMask += "|" + g_advancedSettings.m_musicExtensions; strFileMask += "|" + g_advancedSettings.m_videoExtensions; @@ -153,8 +153,8 @@ void URIUtils::RemoveExtension(std::string& strFileName) } } -CStdString URIUtils::ReplaceExtension(const CStdString& strFile, - const CStdString& strNewExtension) +std::string URIUtils::ReplaceExtension(const std::string& strFile, + const std::string& strNewExtension) { if(IsURL(strFile)) { @@ -163,8 +163,8 @@ CStdString URIUtils::ReplaceExtension(const CStdString& strFile, return url.Get(); } - CStdString strChangedFile; - CStdString strExtension = GetExtension(strFile); + std::string strChangedFile; + std::string strExtension = GetExtension(strFile); if ( strExtension.size() ) { strChangedFile = strFile.substr(0, strFile.size() - strExtension.size()) ; @@ -178,14 +178,14 @@ CStdString URIUtils::ReplaceExtension(const CStdString& strFile, return strChangedFile; } -const CStdString URIUtils::GetFileName(const CURL& url) +const std::string URIUtils::GetFileName(const CURL& url) { return GetFileName(url.GetFileName()); } /* returns a filename given an url */ /* handles both / and \, and options in urls*/ -const CStdString URIUtils::GetFileName(const CStdString& strFileNameAndPath) +const std::string URIUtils::GetFileName(const std::string& strFileNameAndPath) { if(IsURL(strFileNameAndPath)) { @@ -223,18 +223,18 @@ void URIUtils::Split(const std::string& strFileNameAndPath, strFileName = strFileNameAndPath.substr(i+1); } -std::vector<std::string> URIUtils::SplitPath(const CStdString& strPath) +std::vector<std::string> URIUtils::SplitPath(const std::string& strPath) { CURL url(strPath); - // silly CStdString can't take a char in the constructor - CStdString sep(1, url.GetDirectorySeparator()); + // silly std::string can't take a char in the constructor + std::string sep(1, url.GetDirectorySeparator()); // split the filename portion of the URL up into separate dirs vector<string> dirs = StringUtils::Split(url.GetFileName(), sep); // we start with the root path - CStdString dir = url.GetWithoutFilename(); + std::string dir = url.GetWithoutFilename(); if (!dir.empty()) dirs.insert(dirs.begin(), dir); @@ -448,17 +448,17 @@ std::string URIUtils::ChangeBasePath(const std::string &fromPath, const std::str CURL URIUtils::SubstitutePath(const CURL& url, bool reverse /* = false */) { - const CStdString pathToUrl = url.Get(); + const std::string pathToUrl = url.Get(); return CURL(SubstitutePath(pathToUrl, reverse)); } -CStdString URIUtils::SubstitutePath(const CStdString& strPath, bool reverse /* = false */) +std::string URIUtils::SubstitutePath(const std::string& strPath, bool reverse /* = false */) { for (CAdvancedSettings::StringMapping::iterator i = g_advancedSettings.m_pathSubstitutions.begin(); i != g_advancedSettings.m_pathSubstitutions.end(); ++i) { - CStdString fromPath; - CStdString toPath; + std::string fromPath; + std::string toPath; if (!reverse) { @@ -475,7 +475,7 @@ CStdString URIUtils::SubstitutePath(const CStdString& strPath, bool reverse /* = { if (strPath.size() > fromPath.size()) { - CStdString strSubPathAndFileName = strPath.substr(fromPath.size()); + std::string strSubPathAndFileName = strPath.substr(fromPath.size()); return ChangeBasePath(fromPath, strSubPathAndFileName, toPath); // Fix encoding + slash direction } else @@ -497,12 +497,20 @@ bool URIUtils::PathStarts(const std::string& url, const char *start) return StringUtils::StartsWith(url, start); } -bool URIUtils::PathEquals(const std::string& url, const std::string &start) +bool URIUtils::PathEquals(const std::string& url, const std::string &start, bool ignoreTrailingSlash /* = false */) { - return url == start; + std::string path1 = url; + std::string path2 = start; + if (ignoreTrailingSlash) + { + RemoveSlashAtEnd(path1); + RemoveSlashAtEnd(path2); + } + + return path1 == path2; } -bool URIUtils::IsRemote(const CStdString& strFile) +bool URIUtils::IsRemote(const std::string& strFile) { if (IsCDDA(strFile) || IsISO9660(strFile)) return false; @@ -534,7 +542,7 @@ bool URIUtils::IsRemote(const CStdString& strFile) return false; } -bool URIUtils::IsOnDVD(const CStdString& strFile) +bool URIUtils::IsOnDVD(const std::string& strFile) { #ifdef TARGET_WINDOWS if (strFile.size() >= 2 && strFile.substr(1,1) == ":") @@ -556,7 +564,7 @@ bool URIUtils::IsOnDVD(const CStdString& strFile) return false; } -bool URIUtils::IsOnLAN(const CStdString& strPath) +bool URIUtils::IsOnLAN(const std::string& strPath) { if(IsMultiPath(strPath)) return IsOnLAN(CMultiPathDirectory::GetFirstPath(strPath)); @@ -586,7 +594,7 @@ bool URIUtils::IsOnLAN(const CStdString& strPath) if(!IsRemote(strPath)) return false; - CStdString host = url.GetHostName(); + std::string host = url.GetHostName(); return IsHostOnLAN(host); } @@ -598,7 +606,7 @@ static bool addr_match(uint32_t addr, const char* target, const char* submask) return (addr & mask) == (addr2 & mask); } -bool URIUtils::IsHostOnLAN(const CStdString& host, bool offLineCheck) +bool URIUtils::IsHostOnLAN(const std::string& host, bool offLineCheck) { if(host.length() == 0) return false; @@ -611,7 +619,7 @@ bool URIUtils::IsHostOnLAN(const CStdString& host, bool offLineCheck) uint32_t address = ntohl(inet_addr(host.c_str())); if(address == INADDR_NONE) { - CStdString ip; + std::string ip; if(CDNSNameCache::Lookup(host, ip)) address = ntohl(inet_addr(ip.c_str())); } @@ -638,12 +646,12 @@ bool URIUtils::IsHostOnLAN(const CStdString& host, bool offLineCheck) return false; } -bool URIUtils::IsMultiPath(const CStdString& strPath) +bool URIUtils::IsMultiPath(const std::string& strPath) { return IsProtocol(strPath, "multipath"); } -bool URIUtils::IsHD(const CStdString& strFileName) +bool URIUtils::IsHD(const std::string& strFileName) { CURL url(strFileName); @@ -659,9 +667,9 @@ bool URIUtils::IsHD(const CStdString& strFileName) return url.GetProtocol().empty() || url.IsProtocol("file"); } -bool URIUtils::IsDVD(const CStdString& strFile) +bool URIUtils::IsDVD(const std::string& strFile) { - CStdString strFileLow = strFile; + std::string strFileLow = strFile; StringUtils::ToLower(strFileLow); if (strFileLow.find("video_ts.ifo") != std::string::npos && IsOnDVD(strFile)) return true; @@ -683,16 +691,16 @@ bool URIUtils::IsDVD(const CStdString& strFile) return false; } -bool URIUtils::IsStack(const CStdString& strFile) +bool URIUtils::IsStack(const std::string& strFile) { return IsProtocol(strFile, "stack"); } -bool URIUtils::IsRAR(const CStdString& strFile) +bool URIUtils::IsRAR(const std::string& strFile) { - CStdString strExtension = GetExtension(strFile); + std::string strExtension = GetExtension(strFile); - if (strExtension.Equals(".001") && !StringUtils::EndsWithNoCase(strFile, ".ts.001")) + if (strExtension == ".001" && !StringUtils::EndsWithNoCase(strFile, ".ts.001")) return true; if (StringUtils::EqualsNoCase(strExtension, ".cbr")) @@ -704,50 +712,50 @@ bool URIUtils::IsRAR(const CStdString& strFile) return false; } -bool URIUtils::IsInArchive(const CStdString &strFile) +bool URIUtils::IsInArchive(const std::string &strFile) { return IsInZIP(strFile) || IsInRAR(strFile) || IsInAPK(strFile); } -bool URIUtils::IsInAPK(const CStdString& strFile) +bool URIUtils::IsInAPK(const std::string& strFile) { CURL url(strFile); return url.IsProtocol("apk") && !url.GetFileName().empty(); } -bool URIUtils::IsInZIP(const CStdString& strFile) +bool URIUtils::IsInZIP(const std::string& strFile) { CURL url(strFile); return url.IsProtocol("zip") && !url.GetFileName().empty(); } -bool URIUtils::IsInRAR(const CStdString& strFile) +bool URIUtils::IsInRAR(const std::string& strFile) { CURL url(strFile); return url.IsProtocol("rar") && !url.GetFileName().empty(); } -bool URIUtils::IsAPK(const CStdString& strFile) +bool URIUtils::IsAPK(const std::string& strFile) { return HasExtension(strFile, ".apk"); } -bool URIUtils::IsZIP(const CStdString& strFile) // also checks for comic books! +bool URIUtils::IsZIP(const std::string& strFile) // also checks for comic books! { return HasExtension(strFile, ".zip|.cbz"); } -bool URIUtils::IsArchive(const CStdString& strFile) +bool URIUtils::IsArchive(const std::string& strFile) { return HasExtension(strFile, ".zip|.rar|.apk|.cbz|.cbr"); } -bool URIUtils::IsSpecial(const CStdString& strFile) +bool URIUtils::IsSpecial(const std::string& strFile) { - CStdString strFile2(strFile); + std::string strFile2(strFile); if (IsStack(strFile)) strFile2 = CStackDirectory::GetFirstStackedFile(strFile); @@ -755,43 +763,43 @@ bool URIUtils::IsSpecial(const CStdString& strFile) return IsProtocol(strFile2, "special"); } -bool URIUtils::IsPlugin(const CStdString& strFile) +bool URIUtils::IsPlugin(const std::string& strFile) { CURL url(strFile); return url.IsProtocol("plugin"); } -bool URIUtils::IsScript(const CStdString& strFile) +bool URIUtils::IsScript(const std::string& strFile) { CURL url(strFile); return url.IsProtocol("script"); } -bool URIUtils::IsAddonsPath(const CStdString& strFile) +bool URIUtils::IsAddonsPath(const std::string& strFile) { CURL url(strFile); return url.IsProtocol("addons"); } -bool URIUtils::IsSourcesPath(const CStdString& strPath) +bool URIUtils::IsSourcesPath(const std::string& strPath) { CURL url(strPath); return url.IsProtocol("sources"); } -bool URIUtils::IsCDDA(const CStdString& strFile) +bool URIUtils::IsCDDA(const std::string& strFile) { return IsProtocol(strFile, "cdda"); } -bool URIUtils::IsISO9660(const CStdString& strFile) +bool URIUtils::IsISO9660(const std::string& strFile) { return IsProtocol(strFile, "iso9660"); } -bool URIUtils::IsSmb(const CStdString& strFile) +bool URIUtils::IsSmb(const std::string& strFile) { - CStdString strFile2(strFile); + std::string strFile2(strFile); if (IsStack(strFile)) strFile2 = CStackDirectory::GetFirstStackedFile(strFile); @@ -799,14 +807,14 @@ bool URIUtils::IsSmb(const CStdString& strFile) return IsProtocol(strFile2, "smb"); } -bool URIUtils::IsURL(const CStdString& strFile) +bool URIUtils::IsURL(const std::string& strFile) { return strFile.find("://") != std::string::npos; } -bool URIUtils::IsFTP(const CStdString& strFile) +bool URIUtils::IsFTP(const std::string& strFile) { - CStdString strFile2(strFile); + std::string strFile2(strFile); if (IsStack(strFile)) strFile2 = CStackDirectory::GetFirstStackedFile(strFile); @@ -815,9 +823,9 @@ bool URIUtils::IsFTP(const CStdString& strFile) IsProtocol(strFile2, "ftps"); } -bool URIUtils::IsUDP(const CStdString& strFile) +bool URIUtils::IsUDP(const std::string& strFile) { - CStdString strFile2(strFile); + std::string strFile2(strFile); if (IsStack(strFile)) strFile2 = CStackDirectory::GetFirstStackedFile(strFile); @@ -825,9 +833,9 @@ bool URIUtils::IsUDP(const CStdString& strFile) return IsProtocol(strFile2, "udp"); } -bool URIUtils::IsTCP(const CStdString& strFile) +bool URIUtils::IsTCP(const std::string& strFile) { - CStdString strFile2(strFile); + std::string strFile2(strFile); if (IsStack(strFile)) strFile2 = CStackDirectory::GetFirstStackedFile(strFile); @@ -835,9 +843,9 @@ bool URIUtils::IsTCP(const CStdString& strFile) return IsProtocol(strFile2, "tcp"); } -bool URIUtils::IsPVRChannel(const CStdString& strFile) +bool URIUtils::IsPVRChannel(const std::string& strFile) { - CStdString strFile2(strFile); + std::string strFile2(strFile); if (IsStack(strFile)) strFile2 = CStackDirectory::GetFirstStackedFile(strFile); @@ -845,9 +853,9 @@ bool URIUtils::IsPVRChannel(const CStdString& strFile) return StringUtils::StartsWithNoCase(strFile2, "pvr://channels"); } -bool URIUtils::IsDAV(const CStdString& strFile) +bool URIUtils::IsDAV(const std::string& strFile) { - CStdString strFile2(strFile); + std::string strFile2(strFile); if (IsStack(strFile)) strFile2 = CStackDirectory::GetFirstStackedFile(strFile); @@ -891,49 +899,49 @@ bool URIUtils::IsInternetStream(const CURL& url, bool bStrictCheck /* = false */ return false; } -bool URIUtils::IsDAAP(const CStdString& strFile) +bool URIUtils::IsDAAP(const std::string& strFile) { return IsProtocol(strFile, "daap"); } -bool URIUtils::IsUPnP(const CStdString& strFile) +bool URIUtils::IsUPnP(const std::string& strFile) { return IsProtocol(strFile, "upnp"); } -bool URIUtils::IsTuxBox(const CStdString& strFile) +bool URIUtils::IsTuxBox(const std::string& strFile) { return IsProtocol(strFile, "tuxbox"); } -bool URIUtils::IsMythTV(const CStdString& strFile) +bool URIUtils::IsMythTV(const std::string& strFile) { return IsProtocol(strFile, "myth"); } -bool URIUtils::IsHDHomeRun(const CStdString& strFile) +bool URIUtils::IsHDHomeRun(const std::string& strFile) { return IsProtocol(strFile, "hdhomerun"); } -bool URIUtils::IsSlingbox(const CStdString& strFile) +bool URIUtils::IsSlingbox(const std::string& strFile) { return IsProtocol(strFile, "sling"); } -bool URIUtils::IsVTP(const CStdString& strFile) +bool URIUtils::IsVTP(const std::string& strFile) { return IsProtocol(strFile, "vtp"); } -bool URIUtils::IsHTSP(const CStdString& strFile) +bool URIUtils::IsHTSP(const std::string& strFile) { return IsProtocol(strFile, "htsp"); } -bool URIUtils::IsLiveTV(const CStdString& strFile) +bool URIUtils::IsLiveTV(const std::string& strFile) { - CStdString strFileWithoutSlash(strFile); + std::string strFileWithoutSlash(strFile); RemoveSlashAtEnd(strFileWithoutSlash); if(IsTuxBox(strFile) @@ -951,23 +959,23 @@ bool URIUtils::IsLiveTV(const CStdString& strFile) return false; } -bool URIUtils::IsPVRRecording(const CStdString& strFile) +bool URIUtils::IsPVRRecording(const std::string& strFile) { - CStdString strFileWithoutSlash(strFile); + std::string strFileWithoutSlash(strFile); RemoveSlashAtEnd(strFileWithoutSlash); return StringUtils::EndsWithNoCase(strFileWithoutSlash, ".pvr") && PathStarts(strFile, "pvr://recordings"); } -bool URIUtils::IsMusicDb(const CStdString& strFile) +bool URIUtils::IsMusicDb(const std::string& strFile) { return IsProtocol(strFile, "musicdb"); } -bool URIUtils::IsNfs(const CStdString& strFile) +bool URIUtils::IsNfs(const std::string& strFile) { - CStdString strFile2(strFile); + std::string strFile2(strFile); if (IsStack(strFile)) strFile2 = CStackDirectory::GetFirstStackedFile(strFile); @@ -975,9 +983,9 @@ bool URIUtils::IsNfs(const CStdString& strFile) return IsProtocol(strFile2, "nfs"); } -bool URIUtils::IsAfp(const CStdString& strFile) +bool URIUtils::IsAfp(const std::string& strFile) { - CStdString strFile2(strFile); + std::string strFile2(strFile); if (IsStack(strFile)) strFile2 = CStackDirectory::GetFirstStackedFile(strFile); @@ -986,22 +994,22 @@ bool URIUtils::IsAfp(const CStdString& strFile) } -bool URIUtils::IsVideoDb(const CStdString& strFile) +bool URIUtils::IsVideoDb(const std::string& strFile) { return IsProtocol(strFile, "videodb"); } -bool URIUtils::IsBluray(const CStdString& strFile) +bool URIUtils::IsBluray(const std::string& strFile) { return IsProtocol(strFile, "bluray"); } -bool URIUtils::IsAndroidApp(const CStdString &path) +bool URIUtils::IsAndroidApp(const std::string &path) { return IsProtocol(path, "androidapp"); } -bool URIUtils::IsLibraryFolder(const CStdString& strFile) +bool URIUtils::IsLibraryFolder(const std::string& strFile) { CURL url(strFile); return url.IsProtocol("library"); @@ -1015,7 +1023,7 @@ bool URIUtils::IsLibraryContent(const std::string &strFile) StringUtils::EndsWith(strFile, ".xsp")); } -bool URIUtils::IsDOSPath(const CStdString &path) +bool URIUtils::IsDOSPath(const std::string &path) { if (path.size() > 1 && path[1] == ':' && isalpha(path[0])) return true; @@ -1057,7 +1065,7 @@ bool URIUtils::HasSlashAtEnd(const std::string& strFile, bool checkURL /* = fals if (checkURL && IsURL(strFile)) { CURL url(strFile); - CStdString file = url.GetFileName(); + std::string file = url.GetFileName(); return file.empty() || HasSlashAtEnd(file, false); } char kar = strFile.c_str()[strFile.size() - 1]; @@ -1089,12 +1097,12 @@ void URIUtils::RemoveSlashAtEnd(std::string& strFolder) strFolder.erase(strFolder.size()-1, 1); } -bool URIUtils::CompareWithoutSlashAtEnd(const CStdString& strPath1, const CStdString& strPath2) +bool URIUtils::CompareWithoutSlashAtEnd(const std::string& strPath1, const std::string& strPath2) { - CStdString strc1 = strPath1, strc2 = strPath2; + std::string strc1 = strPath1, strc2 = strPath2; RemoveSlashAtEnd(strc1); RemoveSlashAtEnd(strc2); - return strc1.Equals(strc2); + return StringUtils::EqualsNoCase(strc1, strc2); } @@ -1161,8 +1169,8 @@ std::string URIUtils::CanonicalizePath(const std::string& path, const char slash return result; } -CStdString URIUtils::AddFileToFolder(const CStdString& strFolder, - const CStdString& strFile) +std::string URIUtils::AddFileToFolder(const std::string& strFolder, + const std::string& strFile) { if (IsURL(strFolder)) { @@ -1174,7 +1182,7 @@ CStdString URIUtils::AddFileToFolder(const CStdString& strFolder, } } - CStdString strResult = strFolder; + std::string strResult = strFolder; if (!strResult.empty()) AddSlashAtEnd(strResult); @@ -1193,7 +1201,7 @@ CStdString URIUtils::AddFileToFolder(const CStdString& strFolder, return strResult; } -CStdString URIUtils::GetDirectory(const CStdString &strFilePath) +std::string URIUtils::GetDirectory(const std::string &strFilePath) { // Will from a full filename return the directory the file resides in. // Keeps the final slash at end and possible |option=foo options. @@ -1271,7 +1279,7 @@ std::string URIUtils::resolvePath(const std::string &path) realParts.push_back(*part); } - CStdString realPath; + std::string realPath; // re-add any / or \ at the beginning for (std::string::const_iterator itPath = path.begin(); itPath != path.end(); ++itPath) { @@ -1305,7 +1313,7 @@ bool URIUtils::UpdateUrlEncoding(std::string &strFilename) for (vector<string>::iterator file = files.begin(); file != files.end(); file++) UpdateUrlEncoding(*file); - CStdString stackPath; + std::string stackPath; if (!CStackDirectory::ConstructStackPath(files, stackPath)) return false; @@ -1329,7 +1337,7 @@ bool URIUtils::UpdateUrlEncoding(std::string &strFilename) return true; } -bool URIUtils::IsUsingFastSwitch(const CStdString& strFile) +bool URIUtils::IsUsingFastSwitch(const std::string& strFile) { return IsUDP(strFile) || IsTCP(strFile) || IsPVRChannel(strFile); } diff --git a/xbmc/utils/URIUtils.h b/xbmc/utils/URIUtils.h index 0094709d0c..dc280fc77b 100644 --- a/xbmc/utils/URIUtils.h +++ b/xbmc/utils/URIUtils.h @@ -19,7 +19,8 @@ */ #pragma once -#include "StdString.h" +#include <string> +#include <vector> class CURL; @@ -28,12 +29,12 @@ class URIUtils public: URIUtils(void); virtual ~URIUtils(void); - static bool IsInPath(const CStdString &uri, const CStdString &baseURI); + static bool IsInPath(const std::string &uri, const std::string &baseURI); - static CStdString GetDirectory(const CStdString &strFilePath); + static std::string GetDirectory(const std::string &strFilePath); - static const CStdString GetFileName(const CURL& url); - static const CStdString GetFileName(const CStdString& strFileNameAndPath); + static const std::string GetFileName(const CURL& url); + static const std::string GetFileName(const std::string& strFileNameAndPath); static std::string GetExtension(const CURL& url); static std::string GetExtension(const std::string& strFileName); @@ -45,7 +46,7 @@ public: \note Returns false when strFileName is empty. \sa GetExtension */ - static bool HasExtension(const CStdString& strFileName); + static bool HasExtension(const std::string& strFileName); /*! \brief Check if filename have any of the listed extensions @@ -57,15 +58,15 @@ public: strExtensions is empty. \sa GetExtension */ - static bool HasExtension(const CStdString& strFileName, const CStdString& strExtensions); - static bool HasExtension(const CURL& url, const CStdString& strExtensions); + static bool HasExtension(const std::string& strFileName, const std::string& strExtensions); + static bool HasExtension(const CURL& url, const std::string& strExtensions); static void RemoveExtension(std::string& strFileName); - static CStdString ReplaceExtension(const CStdString& strFile, - const CStdString& strNewExtension); + static std::string ReplaceExtension(const std::string& strFile, + const std::string& strNewExtension); static void Split(const std::string& strFileNameAndPath, std::string& strPath, std::string& strFileName); - static std::vector<std::string> SplitPath(const CStdString& strPath); + static std::vector<std::string> SplitPath(const std::string& strPath); static void GetCommonPath(std::string& strPath, const std::string& strPath2); static std::string GetParentPath(const std::string& strPath); @@ -81,7 +82,7 @@ public: static std::string ChangeBasePath(const std::string &fromPath, const std::string &fromFile, const std::string &toPath); static CURL SubstitutePath(const CURL& url, bool reverse = false); - static CStdString SubstitutePath(const CStdString& strPath, bool reverse = false); + static std::string SubstitutePath(const std::string& strPath, bool reverse = false); /*! \brief Check whether a URL is a given URL scheme. Comparison is case-insensitve as per RFC1738 @@ -106,68 +107,69 @@ public: Comparison is case-sensitive. \param path1 a std::string path. \param path2 the second path the path should be compared against. + \param ignoreTrailingSlash ignore any trailing slashes in both paths \return true if the paths are equal, false otherwise. \sa IsProtocol, PathStarts */ - static bool PathEquals(const std::string& path1, const std::string &path2); - - static bool IsAddonsPath(const CStdString& strFile); - static bool IsSourcesPath(const CStdString& strFile); - static bool IsCDDA(const CStdString& strFile); - static bool IsDAAP(const CStdString& strFile); - static bool IsDAV(const CStdString& strFile); - static bool IsDOSPath(const CStdString &path); - static bool IsDVD(const CStdString& strFile); - static bool IsFTP(const CStdString& strFile); - static bool IsUDP(const CStdString& strFile); - static bool IsTCP(const CStdString& strFile); - static bool IsHD(const CStdString& strFileName); - static bool IsHDHomeRun(const CStdString& strFile); - static bool IsSlingbox(const CStdString& strFile); - static bool IsHTSP(const CStdString& strFile); - static bool IsInArchive(const CStdString& strFile); - static bool IsInRAR(const CStdString& strFile); + static bool PathEquals(const std::string& path1, const std::string &path2, bool ignoreTrailingSlash = false); + + static bool IsAddonsPath(const std::string& strFile); + static bool IsSourcesPath(const std::string& strFile); + static bool IsCDDA(const std::string& strFile); + static bool IsDAAP(const std::string& strFile); + static bool IsDAV(const std::string& strFile); + static bool IsDOSPath(const std::string &path); + static bool IsDVD(const std::string& strFile); + static bool IsFTP(const std::string& strFile); + static bool IsUDP(const std::string& strFile); + static bool IsTCP(const std::string& strFile); + static bool IsHD(const std::string& strFileName); + static bool IsHDHomeRun(const std::string& strFile); + static bool IsSlingbox(const std::string& strFile); + static bool IsHTSP(const std::string& strFile); + static bool IsInArchive(const std::string& strFile); + static bool IsInRAR(const std::string& strFile); static bool IsInternetStream(const std::string& path, bool bStrictCheck = false); static bool IsInternetStream(const CURL& url, bool bStrictCheck = false); - static bool IsInAPK(const CStdString& strFile); - static bool IsInZIP(const CStdString& strFile); - static bool IsISO9660(const CStdString& strFile); - static bool IsLiveTV(const CStdString& strFile); - static bool IsPVRRecording(const CStdString& strFile); - static bool IsMultiPath(const CStdString& strPath); - static bool IsMusicDb(const CStdString& strFile); - static bool IsMythTV(const CStdString& strFile); - static bool IsNfs(const CStdString& strFile); - static bool IsAfp(const CStdString& strFile); - static bool IsOnDVD(const CStdString& strFile); - static bool IsOnLAN(const CStdString& strFile); - static bool IsHostOnLAN(const CStdString& hostName, bool offLineCheck = false); - static bool IsPlugin(const CStdString& strFile); - static bool IsScript(const CStdString& strFile); - static bool IsRAR(const CStdString& strFile); - static bool IsRemote(const CStdString& strFile); - static bool IsSmb(const CStdString& strFile); - static bool IsSpecial(const CStdString& strFile); - static bool IsStack(const CStdString& strFile); - static bool IsTuxBox(const CStdString& strFile); - static bool IsUPnP(const CStdString& strFile); - static bool IsURL(const CStdString& strFile); - static bool IsVideoDb(const CStdString& strFile); - static bool IsVTP(const CStdString& strFile); - static bool IsAPK(const CStdString& strFile); - static bool IsZIP(const CStdString& strFile); - static bool IsArchive(const CStdString& strFile); - static bool IsBluray(const CStdString& strFile); - static bool IsAndroidApp(const CStdString& strFile); - static bool IsLibraryFolder(const CStdString& strFile); + static bool IsInAPK(const std::string& strFile); + static bool IsInZIP(const std::string& strFile); + static bool IsISO9660(const std::string& strFile); + static bool IsLiveTV(const std::string& strFile); + static bool IsPVRRecording(const std::string& strFile); + static bool IsMultiPath(const std::string& strPath); + static bool IsMusicDb(const std::string& strFile); + static bool IsMythTV(const std::string& strFile); + static bool IsNfs(const std::string& strFile); + static bool IsAfp(const std::string& strFile); + static bool IsOnDVD(const std::string& strFile); + static bool IsOnLAN(const std::string& strFile); + static bool IsHostOnLAN(const std::string& hostName, bool offLineCheck = false); + static bool IsPlugin(const std::string& strFile); + static bool IsScript(const std::string& strFile); + static bool IsRAR(const std::string& strFile); + static bool IsRemote(const std::string& strFile); + static bool IsSmb(const std::string& strFile); + static bool IsSpecial(const std::string& strFile); + static bool IsStack(const std::string& strFile); + static bool IsTuxBox(const std::string& strFile); + static bool IsUPnP(const std::string& strFile); + static bool IsURL(const std::string& strFile); + static bool IsVideoDb(const std::string& strFile); + static bool IsVTP(const std::string& strFile); + static bool IsAPK(const std::string& strFile); + static bool IsZIP(const std::string& strFile); + static bool IsArchive(const std::string& strFile); + static bool IsBluray(const std::string& strFile); + static bool IsAndroidApp(const std::string& strFile); + static bool IsLibraryFolder(const std::string& strFile); static bool IsLibraryContent(const std::string& strFile); - static bool IsPVRChannel(const CStdString& strFile); - static bool IsUsingFastSwitch(const CStdString& strFile); + static bool IsPVRChannel(const std::string& strFile); + static bool IsUsingFastSwitch(const std::string& strFile); static void AddSlashAtEnd(std::string& strFolder); static bool HasSlashAtEnd(const std::string& strFile, bool checkURL = false); static void RemoveSlashAtEnd(std::string& strFolder); - static bool CompareWithoutSlashAtEnd(const CStdString& strPath1, const CStdString& strPath2); + static bool CompareWithoutSlashAtEnd(const std::string& strPath1, const std::string& strPath2); static std::string FixSlashesAndDups(const std::string& path, const char slashCharacter = '/', const size_t startFrom = 0); /** * Convert path to form without duplicated slashes and without relative directories @@ -187,7 +189,7 @@ public: const std::string& pathInArchive = "", const std::string& password = ""); - static CStdString AddFileToFolder(const CStdString &strFolder, const CStdString &strFile); + static std::string AddFileToFolder(const std::string &strFolder, const std::string &strFile); static bool HasParentInHostname(const CURL& url); static bool HasEncodedHostname(const CURL& url); diff --git a/xbmc/utils/test/Makefile b/xbmc/utils/test/Makefile index 2c38acd74f..d7cf819189 100644 --- a/xbmc/utils/test/Makefile +++ b/xbmc/utils/test/Makefile @@ -38,7 +38,6 @@ SRCS= \ TestScraperParser.cpp \ TestScraperUrl.cpp \ TestSortUtils.cpp \ - TestStdString.cpp \ TestStopwatch.cpp \ TestStreamDetails.cpp \ TestStreamUtils.cpp \ diff --git a/xbmc/utils/test/TestArchive.cpp b/xbmc/utils/test/TestArchive.cpp index 9d082dcd86..fe9abe92f8 100644 --- a/xbmc/utils/test/TestArchive.cpp +++ b/xbmc/utils/test/TestArchive.cpp @@ -21,7 +21,6 @@ #include "utils/Archive.h" #include "utils/Variant.h" #include "filesystem/File.h" -#include "utils/StdString.h" #include "test/TestUtils.h" @@ -195,38 +194,38 @@ TEST_F(TestArchive, CharArchive) EXPECT_EQ(char_ref, char_var); } -TEST_F(TestArchive, CStdStringArchive) +TEST_F(TestArchive, WStringArchive) { ASSERT_TRUE(file); - CStdStringW CStdStringW_ref = L"test CStdStringW", CStdStringW_var = L""; + std::wstring wstring_ref = L"test wstring", wstring_var; CArchive arstore(file, CArchive::store); - arstore << CStdStringW_ref; + arstore << wstring_ref; arstore.Close(); ASSERT_TRUE((file->Seek(0, SEEK_SET) == 0)); CArchive arload(file, CArchive::load); - arload >> CStdStringW_var; + arload >> wstring_var; arload.Close(); - EXPECT_STREQ(CStdStringW_ref.c_str(), CStdStringW_var.c_str()); + EXPECT_STREQ(wstring_ref.c_str(), wstring_var.c_str()); } -TEST_F(TestArchive, CStdStringWArchive) +TEST_F(TestArchive, StringArchive) { ASSERT_TRUE(file); - CStdString CStdString_ref = "test CStdString", CStdString_var = ""; + std::string string_ref = "test string", string_var; CArchive arstore(file, CArchive::store); - arstore << CStdString_ref; + arstore << string_ref; arstore.Close(); ASSERT_TRUE((file->Seek(0, SEEK_SET) == 0)); CArchive arload(file, CArchive::load); - arload >> CStdString_var; + arload >> string_var; arload.Close(); - EXPECT_STREQ(CStdString_ref.c_str(), CStdString_var.c_str()); + EXPECT_STREQ(string_ref.c_str(), string_var.c_str()); } TEST_F(TestArchive, SYSTEMTIMEArchive) @@ -342,8 +341,8 @@ TEST_F(TestArchive, MultiTypeArchive) uint64_t uint64_t_ref = 6, uint64_t_var = 0; bool bool_ref = true, bool_var = false; char char_ref = 'A', char_var = '\0'; - CStdString CStdString_ref = "test CStdString", CStdString_var = ""; - CStdStringW CStdStringW_ref = L"test CStdStringW", CStdStringW_var = L""; + std::string string_ref = "test string", string_var; + std::wstring wstring_ref = L"test wstring", wstring_var; SYSTEMTIME SYSTEMTIME_ref = { 1, 2, 3, 4, 5, 6, 7, 8 }; SYSTEMTIME SYSTEMTIME_var = { 0, 0, 0, 0, 0, 0, 0, 0 }; CVariant CVariant_ref((int)1), CVariant_var; @@ -369,8 +368,8 @@ TEST_F(TestArchive, MultiTypeArchive) arstore << uint64_t_ref; arstore << bool_ref; arstore << char_ref; - arstore << CStdString_ref; - arstore << CStdStringW_ref; + arstore << string_ref; + arstore << wstring_ref; arstore << SYSTEMTIME_ref; arstore << CVariant_ref; arstore << strArray_ref; @@ -389,8 +388,8 @@ TEST_F(TestArchive, MultiTypeArchive) arload >> uint64_t_var; arload >> bool_var; arload >> char_var; - arload >> CStdString_var; - arload >> CStdStringW_var; + arload >> string_var; + arload >> wstring_var; arload >> SYSTEMTIME_var; arload >> CVariant_var; arload >> strArray_var; @@ -405,8 +404,8 @@ TEST_F(TestArchive, MultiTypeArchive) EXPECT_EQ(uint64_t_ref, uint64_t_var); EXPECT_EQ(bool_ref, bool_var); EXPECT_EQ(char_ref, char_var); - EXPECT_STREQ(CStdString_ref.c_str(), CStdString_var.c_str()); - EXPECT_STREQ(CStdStringW_ref.c_str(), CStdStringW_var.c_str()); + EXPECT_STREQ(string_ref.c_str(), string_var.c_str()); + EXPECT_STREQ(wstring_ref.c_str(), wstring_var.c_str()); EXPECT_TRUE(!memcmp(&SYSTEMTIME_ref, &SYSTEMTIME_var, sizeof(SYSTEMTIME))); EXPECT_TRUE(CVariant_var.isInteger()); EXPECT_STREQ("test strArray_ref 0", strArray_var.at(0).c_str()); diff --git a/xbmc/utils/test/TestCharsetConverter.cpp b/xbmc/utils/test/TestCharsetConverter.cpp index aceb0fbee7..f38b730c5d 100644 --- a/xbmc/utils/test/TestCharsetConverter.cpp +++ b/xbmc/utils/test/TestCharsetConverter.cpp @@ -20,7 +20,6 @@ #include "settings/Settings.h" #include "utils/CharsetConverter.h" -#include "utils/StdString.h" #include "utils/Utf8Utils.h" #include "system.h" @@ -115,11 +114,9 @@ protected: CSettings::Get().Unload(); } - CStdStringA refstra1, refstra2, varstra1; - CStdStringW refstrw1, varstrw1; - CStdString16 refstr16_1, varstr16_1; - CStdString32 refstr32_1, varstr32_1; - CStdString refstr1; + std::string refstra1, refstra2, varstra1; + std::wstring refstrw1, varstrw1; + std::string refstr1; }; TEST_F(TestCharsetConverter, utf8ToW) @@ -131,15 +128,17 @@ TEST_F(TestCharsetConverter, utf8ToW) EXPECT_STREQ(refstrw1.c_str(), varstrw1.c_str()); } -TEST_F(TestCharsetConverter, utf16LEtoW) -{ - refstrw1 = L"test_utf16LEtï½ï½—"; - /* TODO: Should be able to use '=' operator instead of assign() */ - refstr16_1.assign(refutf16LE1); - varstrw1.clear(); - g_charsetConverter.utf16LEtoW(refstr16_1, varstrw1); - EXPECT_STREQ(refstrw1.c_str(), varstrw1.c_str()); -} + +//TEST_F(TestCharsetConverter, utf16LEtoW) +//{ +// refstrw1 = L"test_utf16LEtï½ï½—"; +// /* TODO: Should be able to use '=' operator instead of assign() */ +// std::wstring refstr16_1; +// refstr16_1.assign(refutf16LE1); +// varstrw1.clear(); +// g_charsetConverter.utf16LEtoW(refstr16_1, varstrw1); +// EXPECT_STREQ(refstrw1.c_str(), varstrw1.c_str()); +//} TEST_F(TestCharsetConverter, subtitleCharsetToUtf8) { @@ -177,12 +176,13 @@ TEST_F(TestCharsetConverter, utf8ToSystem) TEST_F(TestCharsetConverter, utf8To_ASCII) { - refstra1 = "test utf8To: charset ASCII, CStdStringA"; + refstra1 = "test utf8To: charset ASCII, std::string"; varstra1.clear(); g_charsetConverter.utf8To("ASCII", refstra1, varstra1); EXPECT_STREQ(refstra1.c_str(), varstra1.c_str()); } +/* TEST_F(TestCharsetConverter, utf8To_UTF16LE) { refstra1 = "test_utf8Tï½ï¼šï¼¿ï½ƒï½ˆï½ï½’set_UTFï¼ï¼‘6LE,_" @@ -193,26 +193,27 @@ TEST_F(TestCharsetConverter, utf8To_UTF16LE) EXPECT_TRUE(!memcmp(refstr16_1.c_str(), varstr16_1.c_str(), refstr16_1.length() * sizeof(uint16_t))); } - -TEST_F(TestCharsetConverter, utf8To_UTF32LE) -{ - refstra1 = "test_utf8Tï½ï¼šï¼¿ï½ƒï½ˆï½ï½’set_UTFï¼ï¼“2LE,_" -#ifdef TARGET_DARWIN -/* OSX has it's own 'special' utf-8 charset which we use (see UTF8_SOURCE in CharsetConverter.cpp) - which is basically NFD (decomposed) utf-8. The trouble is, it fails on the COW FACE and MOUSE FACE - characters for some reason (possibly anything over 0x100000, or maybe there's a decomposed form of these - that I couldn't find???) If UTF8_SOURCE is switched to UTF-8 then this test would pass as-is, but then - some filenames stored in utf8-mac wouldn't display correctly in the UI. */ - "CStdString32_"; -#else - "CStdString32_ðŸðŸ®"; -#endif - refstr32_1.assign(refutf32LE1); - varstr32_1.clear(); - g_charsetConverter.utf8To("UTF-32LE", refstra1, varstr32_1); - EXPECT_TRUE(!memcmp(refstr32_1.c_str(), varstr32_1.c_str(), - sizeof(refutf32LE1))); -} +*/ + +//TEST_F(TestCharsetConverter, utf8To_UTF32LE) +//{ +// refstra1 = "test_utf8Tï½ï¼šï¼¿ï½ƒï½ˆï½ï½’set_UTFï¼ï¼“2LE,_" +//#ifdef TARGET_DARWIN +///* OSX has it's own 'special' utf-8 charset which we use (see UTF8_SOURCE in CharsetConverter.cpp) +// which is basically NFD (decomposed) utf-8. The trouble is, it fails on the COW FACE and MOUSE FACE +// characters for some reason (possibly anything over 0x100000, or maybe there's a decomposed form of these +// that I couldn't find???) If UTF8_SOURCE is switched to UTF-8 then this test would pass as-is, but then +// some filenames stored in utf8-mac wouldn't display correctly in the UI. */ +// "CStdString32_"; +//#else +// "CStdString32_ðŸðŸ®"; +//#endif +// refstr32_1.assign(refutf32LE1); +// varstr32_1.clear(); +// g_charsetConverter.utf8To("UTF-32LE", refstra1, varstr32_1); +// EXPECT_TRUE(!memcmp(refstr32_1.c_str(), varstr32_1.c_str(), +// sizeof(refutf32LE1))); +//} TEST_F(TestCharsetConverter, stringCharsetToUtf8) { @@ -250,8 +251,8 @@ TEST_F(TestCharsetConverter, isValidUtf8_4) /* TODO: Resolve correct input/output for this function */ // TEST_F(TestCharsetConverter, ucs2CharsetToStringCharset) // { -// void ucs2CharsetToStringCharset(const CStdStringW& strSource, -// CStdStringA& strDest, bool swap = false); +// void ucs2CharsetToStringCharset(const std::wstring& strSource, +// std::string& strDest, bool swap = false); // } TEST_F(TestCharsetConverter, wToUTF8) @@ -263,32 +264,32 @@ TEST_F(TestCharsetConverter, wToUTF8) EXPECT_STREQ(refstra1.c_str(), varstra1.c_str()); } -TEST_F(TestCharsetConverter, utf16BEtoUTF8) -{ - refstr16_1.assign(refutf16BE); - refstra1 = "test_utf16BEtï½ï¼µï¼´ï¼¦ï¼˜"; - varstra1.clear(); - g_charsetConverter.utf16BEtoUTF8(refstr16_1, varstra1); - EXPECT_STREQ(refstra1.c_str(), varstra1.c_str()); -} - -TEST_F(TestCharsetConverter, utf16LEtoUTF8) -{ - refstr16_1.assign(refutf16LE4); - refstra1 = "test_utf16LEtï½ï¼µï¼´ï¼¦ï¼˜"; - varstra1.clear(); - g_charsetConverter.utf16LEtoUTF8(refstr16_1, varstra1); - EXPECT_STREQ(refstra1.c_str(), varstra1.c_str()); -} - -TEST_F(TestCharsetConverter, ucs2ToUTF8) -{ - refstr16_1.assign(refucs2); - refstra1 = "test_ucs2tï½ï¼µï¼´ï¼¦ï¼˜"; - varstra1.clear(); - g_charsetConverter.ucs2ToUTF8(refstr16_1, varstra1); - EXPECT_STREQ(refstra1.c_str(), varstra1.c_str()); -} +//TEST_F(TestCharsetConverter, utf16BEtoUTF8) +//{ +// refstr16_1.assign(refutf16BE); +// refstra1 = "test_utf16BEtï½ï¼µï¼´ï¼¦ï¼˜"; +// varstra1.clear(); +// g_charsetConverter.utf16BEtoUTF8(refstr16_1, varstra1); +// EXPECT_STREQ(refstra1.c_str(), varstra1.c_str()); +//} + +//TEST_F(TestCharsetConverter, utf16LEtoUTF8) +//{ +// refstr16_1.assign(refutf16LE4); +// refstra1 = "test_utf16LEtï½ï¼µï¼´ï¼¦ï¼˜"; +// varstra1.clear(); +// g_charsetConverter.utf16LEtoUTF8(refstr16_1, varstra1); +// EXPECT_STREQ(refstra1.c_str(), varstra1.c_str()); +//} + +//TEST_F(TestCharsetConverter, ucs2ToUTF8) +//{ +// refstr16_1.assign(refucs2); +// refstra1 = "test_ucs2tï½ï¼µï¼´ï¼¦ï¼˜"; +// varstra1.clear(); +// g_charsetConverter.ucs2ToUTF8(refstr16_1, varstra1); +// EXPECT_STREQ(refstra1.c_str(), varstra1.c_str()); +//} TEST_F(TestCharsetConverter, utf8logicalToVisualBiDi) { @@ -302,12 +303,12 @@ TEST_F(TestCharsetConverter, utf8logicalToVisualBiDi) /* TODO: Resolve correct input/output for this function */ // TEST_F(TestCharsetConverter, utf32ToStringCharset) // { -// void utf32ToStringCharset(const unsigned long* strSource, CStdStringA& strDest); +// void utf32ToStringCharset(const unsigned long* strSource, std::string& strDest); // } TEST_F(TestCharsetConverter, getCharsetLabels) { - std::vector<CStdString> reflabels; + std::vector<std::string> reflabels; reflabels.push_back("Western Europe (ISO)"); reflabels.push_back("Central Europe (ISO)"); reflabels.push_back("South Europe (ISO)"); @@ -345,7 +346,7 @@ TEST_F(TestCharsetConverter, getCharsetLabels) TEST_F(TestCharsetConverter, getCharsetLabelByName) { - CStdString varstr = + std::string varstr = g_charsetConverter.getCharsetLabelByName("ISO-8859-1"); EXPECT_STREQ("Western Europe (ISO)", varstr.c_str()); varstr.clear(); @@ -355,7 +356,7 @@ TEST_F(TestCharsetConverter, getCharsetLabelByName) TEST_F(TestCharsetConverter, getCharsetNameByLabel) { - CStdString varstr = + std::string varstr = g_charsetConverter.getCharsetNameByLabel("Western Europe (ISO)"); EXPECT_STREQ("ISO-8859-1", varstr.c_str()); varstr.clear(); diff --git a/xbmc/utils/test/TestDatabaseUtils.cpp b/xbmc/utils/test/TestDatabaseUtils.cpp index 5d846772f3..c26e881ae0 100644 --- a/xbmc/utils/test/TestDatabaseUtils.cpp +++ b/xbmc/utils/test/TestDatabaseUtils.cpp @@ -308,84 +308,84 @@ TEST(TestDatabaseUtils, GetField_MediaTypeSong) TEST(TestDatabaseUtils, GetField_MediaTypeMusicVideo) { - CStdString refstr, varstr; + std::string refstr, varstr; - refstr = "musicvideoview.idMVideo"; + refstr = "musicvideo_view.idMVideo"; varstr = DatabaseUtils::GetField(FieldId, MediaTypeMusicVideo, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("musicvideoview.c%02d",VIDEODB_ID_MUSICVIDEO_TITLE); + refstr = StringUtils::Format("musicvideo_view.c%02d",VIDEODB_ID_MUSICVIDEO_TITLE); varstr = DatabaseUtils::GetField(FieldTitle, MediaTypeMusicVideo, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("musicvideoview.c%02d",VIDEODB_ID_MUSICVIDEO_RUNTIME); + refstr = StringUtils::Format("musicvideo_view.c%02d",VIDEODB_ID_MUSICVIDEO_RUNTIME); varstr = DatabaseUtils::GetField(FieldTime, MediaTypeMusicVideo, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("musicvideoview.c%02d",VIDEODB_ID_MUSICVIDEO_DIRECTOR); + refstr = StringUtils::Format("musicvideo_view.c%02d",VIDEODB_ID_MUSICVIDEO_DIRECTOR); varstr = DatabaseUtils::GetField(FieldDirector, MediaTypeMusicVideo, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("musicvideoview.c%02d",VIDEODB_ID_MUSICVIDEO_STUDIOS); + refstr = StringUtils::Format("musicvideo_view.c%02d",VIDEODB_ID_MUSICVIDEO_STUDIOS); varstr = DatabaseUtils::GetField(FieldStudio, MediaTypeMusicVideo, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("musicvideoview.c%02d",VIDEODB_ID_MUSICVIDEO_YEAR); + refstr = StringUtils::Format("musicvideo_view.c%02d",VIDEODB_ID_MUSICVIDEO_YEAR); varstr = DatabaseUtils::GetField(FieldYear, MediaTypeMusicVideo, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("musicvideoview.c%02d",VIDEODB_ID_MUSICVIDEO_PLOT); + refstr = StringUtils::Format("musicvideo_view.c%02d",VIDEODB_ID_MUSICVIDEO_PLOT); varstr = DatabaseUtils::GetField(FieldPlot, MediaTypeMusicVideo, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("musicvideoview.c%02d",VIDEODB_ID_MUSICVIDEO_ALBUM); + refstr = StringUtils::Format("musicvideo_view.c%02d",VIDEODB_ID_MUSICVIDEO_ALBUM); varstr = DatabaseUtils::GetField(FieldAlbum, MediaTypeMusicVideo, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("musicvideoview.c%02d",VIDEODB_ID_MUSICVIDEO_ARTIST); + refstr = StringUtils::Format("musicvideo_view.c%02d",VIDEODB_ID_MUSICVIDEO_ARTIST); varstr = DatabaseUtils::GetField(FieldArtist, MediaTypeMusicVideo, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("musicvideoview.c%02d",VIDEODB_ID_MUSICVIDEO_GENRE); + refstr = StringUtils::Format("musicvideo_view.c%02d",VIDEODB_ID_MUSICVIDEO_GENRE); varstr = DatabaseUtils::GetField(FieldGenre, MediaTypeMusicVideo, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("musicvideoview.c%02d",VIDEODB_ID_MUSICVIDEO_TRACK); + refstr = StringUtils::Format("musicvideo_view.c%02d",VIDEODB_ID_MUSICVIDEO_TRACK); varstr = DatabaseUtils::GetField(FieldTrackNumber, MediaTypeMusicVideo, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "musicvideoview.strFilename"; + refstr = "musicvideo_view.strFilename"; varstr = DatabaseUtils::GetField(FieldFilename, MediaTypeMusicVideo, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "musicvideoview.strPath"; + refstr = "musicvideo_view.strPath"; varstr = DatabaseUtils::GetField(FieldPath, MediaTypeMusicVideo, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "musicvideoview.playCount"; + refstr = "musicvideo_view.playCount"; varstr = DatabaseUtils::GetField(FieldPlaycount, MediaTypeMusicVideo, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "musicvideoview.lastPlayed"; + refstr = "musicvideo_view.lastPlayed"; varstr = DatabaseUtils::GetField(FieldLastPlayed, MediaTypeMusicVideo, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "musicvideoview.dateAdded"; + refstr = "musicvideo_view.dateAdded"; varstr = DatabaseUtils::GetField(FieldDateAdded, MediaTypeMusicVideo, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); @@ -395,12 +395,12 @@ TEST(TestDatabaseUtils, GetField_MediaTypeMusicVideo) DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "musicvideoview.strPath"; + refstr = "musicvideo_view.strPath"; varstr = DatabaseUtils::GetField(FieldPath, MediaTypeMusicVideo, DatabaseQueryPartWhere); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "musicvideoview.strPath"; + refstr = "musicvideo_view.strPath"; varstr = DatabaseUtils::GetField(FieldPath, MediaTypeMusicVideo, DatabaseQueryPartOrderBy); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); @@ -408,131 +408,131 @@ TEST(TestDatabaseUtils, GetField_MediaTypeMusicVideo) TEST(TestDatabaseUtils, GetField_MediaTypeMovie) { - CStdString refstr, varstr; + std::string refstr, varstr; - refstr = "movieview.idMovie"; + refstr = "movie_view.idMovie"; varstr = DatabaseUtils::GetField(FieldId, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("movieview.c%02d", VIDEODB_ID_TITLE); + refstr = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_TITLE); varstr = DatabaseUtils::GetField(FieldTitle, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("CASE WHEN length(movieview.c%02d) > 0 THEN movieview.c%02d " - "ELSE movieview.c%02d END", VIDEODB_ID_SORTTITLE, - VIDEODB_ID_SORTTITLE, VIDEODB_ID_TITLE, VIDEODB_ID_TITLE); + refstr = StringUtils::Format("CASE WHEN length(movie_view.c%02d) > 0 THEN movie_view.c%02d " + "ELSE movie_view.c%02d END", VIDEODB_ID_SORTTITLE, + VIDEODB_ID_SORTTITLE, VIDEODB_ID_TITLE); varstr = DatabaseUtils::GetField(FieldTitle, MediaTypeMovie, DatabaseQueryPartOrderBy); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("movieview.c%02d", VIDEODB_ID_PLOT); + refstr = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_PLOT); varstr = DatabaseUtils::GetField(FieldPlot, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("movieview.c%02d", VIDEODB_ID_PLOTOUTLINE); + refstr = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_PLOTOUTLINE); varstr = DatabaseUtils::GetField(FieldPlotOutline, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("movieview.c%02d", VIDEODB_ID_TAGLINE); + refstr = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_TAGLINE); varstr = DatabaseUtils::GetField(FieldTagline, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("movieview.c%02d", VIDEODB_ID_VOTES); + refstr = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_VOTES); varstr = DatabaseUtils::GetField(FieldVotes, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("movieview.c%02d", VIDEODB_ID_RATING); + refstr = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_RATING); varstr = DatabaseUtils::GetField(FieldRating, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("CAST(movieview.c%02d as DECIMAL(5,3))", VIDEODB_ID_RATING); + refstr = StringUtils::Format("CAST(movie_view.c%02d as DECIMAL(5,3))", VIDEODB_ID_RATING); varstr = DatabaseUtils::GetField(FieldRating, MediaTypeMovie, DatabaseQueryPartOrderBy); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("movieview.c%02d", VIDEODB_ID_CREDITS); + refstr = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_CREDITS); varstr = DatabaseUtils::GetField(FieldWriter, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("movieview.c%02d", VIDEODB_ID_YEAR); + refstr = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_YEAR); varstr = DatabaseUtils::GetField(FieldYear, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("movieview.c%02d", VIDEODB_ID_SORTTITLE); + refstr = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_SORTTITLE); varstr = DatabaseUtils::GetField(FieldSortTitle, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("movieview.c%02d", VIDEODB_ID_RUNTIME); + refstr = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_RUNTIME); varstr = DatabaseUtils::GetField(FieldTime, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("movieview.c%02d", VIDEODB_ID_MPAA); + refstr = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_MPAA); varstr = DatabaseUtils::GetField(FieldMPAA, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("movieview.c%02d", VIDEODB_ID_TOP250); + refstr = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_TOP250); varstr = DatabaseUtils::GetField(FieldTop250, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("movieview.c%02d", VIDEODB_ID_GENRE); + refstr = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_GENRE); varstr = DatabaseUtils::GetField(FieldGenre, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("movieview.c%02d", VIDEODB_ID_DIRECTOR); + refstr = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_DIRECTOR); varstr = DatabaseUtils::GetField(FieldDirector, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("movieview.c%02d", VIDEODB_ID_STUDIOS); + refstr = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_STUDIOS); varstr = DatabaseUtils::GetField(FieldStudio, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("movieview.c%02d", VIDEODB_ID_TRAILER); + refstr = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_TRAILER); varstr = DatabaseUtils::GetField(FieldTrailer, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("movieview.c%02d", VIDEODB_ID_COUNTRY); + refstr = StringUtils::Format("movie_view.c%02d", VIDEODB_ID_COUNTRY); varstr = DatabaseUtils::GetField(FieldCountry, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "movieview.strFilename"; + refstr = "movie_view.strFilename"; varstr = DatabaseUtils::GetField(FieldFilename, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "movieview.strPath"; + refstr = "movie_view.strPath"; varstr = DatabaseUtils::GetField(FieldPath, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "movieview.playCount"; + refstr = "movie_view.playCount"; varstr = DatabaseUtils::GetField(FieldPlaycount, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "movieview.lastPlayed"; + refstr = "movie_view.lastPlayed"; varstr = DatabaseUtils::GetField(FieldLastPlayed, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "movieview.dateAdded"; + refstr = "movie_view.dateAdded"; varstr = DatabaseUtils::GetField(FieldDateAdded, MediaTypeMovie, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); @@ -545,91 +545,91 @@ TEST(TestDatabaseUtils, GetField_MediaTypeMovie) TEST(TestDatabaseUtils, GetField_MediaTypeTvShow) { - CStdString refstr, varstr; + std::string refstr, varstr; - refstr = "tvshowview.idShow"; + refstr = "tvshow_view.idShow"; varstr = DatabaseUtils::GetField(FieldId, MediaTypeTvShow, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("CASE WHEN length(tvshowview.c%02d) > 0 THEN tvshowview.c%02d " - "ELSE tvshowview.c%02d END", VIDEODB_ID_TV_SORTTITLE, + refstr = StringUtils::Format("CASE WHEN length(tvshow_view.c%02d) > 0 THEN tvshow_view.c%02d " + "ELSE tvshow_view.c%02d END", VIDEODB_ID_TV_SORTTITLE, VIDEODB_ID_TV_SORTTITLE, VIDEODB_ID_TV_TITLE); varstr = DatabaseUtils::GetField(FieldTitle, MediaTypeTvShow, DatabaseQueryPartOrderBy); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_TITLE); + refstr = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_TITLE); varstr = DatabaseUtils::GetField(FieldTitle, MediaTypeTvShow, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_PLOT); + refstr = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_PLOT); varstr = DatabaseUtils::GetField(FieldPlot, MediaTypeTvShow, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_STATUS); + refstr = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_STATUS); varstr = DatabaseUtils::GetField(FieldTvShowStatus, MediaTypeTvShow, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_VOTES); + refstr = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_VOTES); varstr = DatabaseUtils::GetField(FieldVotes, MediaTypeTvShow, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_RATING); + refstr = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_RATING); varstr = DatabaseUtils::GetField(FieldRating, MediaTypeTvShow, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_PREMIERED); + refstr = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_PREMIERED); varstr = DatabaseUtils::GetField(FieldYear, MediaTypeTvShow, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_GENRE); + refstr = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_GENRE); varstr = DatabaseUtils::GetField(FieldGenre, MediaTypeTvShow, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_MPAA); + refstr = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_MPAA); varstr = DatabaseUtils::GetField(FieldMPAA, MediaTypeTvShow, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_STUDIOS); + refstr = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_STUDIOS); varstr = DatabaseUtils::GetField(FieldStudio, MediaTypeTvShow, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("tvshowview.c%02d", VIDEODB_ID_TV_SORTTITLE); + refstr = StringUtils::Format("tvshow_view.c%02d", VIDEODB_ID_TV_SORTTITLE); varstr = DatabaseUtils::GetField(FieldSortTitle, MediaTypeTvShow, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "tvshowview.strPath"; + refstr = "tvshow_view.strPath"; varstr = DatabaseUtils::GetField(FieldPath, MediaTypeTvShow, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "tvshowview.dateAdded"; + refstr = "tvshow_view.dateAdded"; varstr = DatabaseUtils::GetField(FieldDateAdded, MediaTypeTvShow, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "tvshowview.totalSeasons"; + refstr = "tvshow_view.totalSeasons"; varstr = DatabaseUtils::GetField(FieldSeason, MediaTypeTvShow, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "tvshowview.totalCount"; + refstr = "tvshow_view.totalCount"; varstr = DatabaseUtils::GetField(FieldNumberOfEpisodes, MediaTypeTvShow, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "tvshowview.watchedcount"; + refstr = "tvshow_view.watchedcount"; varstr = DatabaseUtils::GetField(FieldNumberOfWatchedEpisodes, MediaTypeTvShow, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); @@ -642,104 +642,104 @@ TEST(TestDatabaseUtils, GetField_MediaTypeTvShow) TEST(TestDatabaseUtils, GetField_MediaTypeEpisode) { - CStdString refstr, varstr; + std::string refstr, varstr; - refstr = "episodeview.idEpisode"; + refstr = "episode_view.idEpisode"; varstr = DatabaseUtils::GetField(FieldId, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_TITLE); + refstr = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_TITLE); varstr = DatabaseUtils::GetField(FieldTitle, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_PLOT); + refstr = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_PLOT); varstr = DatabaseUtils::GetField(FieldPlot, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_VOTES); + refstr = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_VOTES); varstr = DatabaseUtils::GetField(FieldVotes, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_RATING); + refstr = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_RATING); varstr = DatabaseUtils::GetField(FieldRating, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_CREDITS); + refstr = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_CREDITS); varstr = DatabaseUtils::GetField(FieldWriter, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_AIRED); + refstr = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_AIRED); varstr = DatabaseUtils::GetField(FieldAirDate, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_RUNTIME); + refstr = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_RUNTIME); varstr = DatabaseUtils::GetField(FieldTime, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_DIRECTOR); + refstr = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_DIRECTOR); varstr = DatabaseUtils::GetField(FieldDirector, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_SEASON); + refstr = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_SEASON); varstr = DatabaseUtils::GetField(FieldSeason, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = StringUtils::Format("episodeview.c%02d", VIDEODB_ID_EPISODE_EPISODE); + refstr = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_EPISODE); varstr = DatabaseUtils::GetField(FieldEpisodeNumber, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "episodeview.strFilename"; + refstr = "episode_view.strFilename"; varstr = DatabaseUtils::GetField(FieldFilename, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "episodeview.strPath"; + refstr = "episode_view.strPath"; varstr = DatabaseUtils::GetField(FieldPath, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "episodeview.playCount"; + refstr = "episode_view.playCount"; varstr = DatabaseUtils::GetField(FieldPlaycount, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "episodeview.lastPlayed"; + refstr = "episode_view.lastPlayed"; varstr = DatabaseUtils::GetField(FieldLastPlayed, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "episodeview.dateAdded"; + refstr = "episode_view.dateAdded"; varstr = DatabaseUtils::GetField(FieldDateAdded, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "episodeview.strTitle"; + refstr = "episode_view.strTitle"; varstr = DatabaseUtils::GetField(FieldTvShowTitle, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "episodeview.premiered"; + refstr = "episode_view.premiered"; varstr = DatabaseUtils::GetField(FieldYear, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "episodeview.mpaa"; + refstr = "episode_view.mpaa"; varstr = DatabaseUtils::GetField(FieldMPAA, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); - refstr = "episodeview.strStudio"; + refstr = "episode_view.strStudio"; varstr = DatabaseUtils::GetField(FieldStudio, MediaTypeEpisode, DatabaseQueryPartSelect); EXPECT_STREQ(refstr.c_str(), varstr.c_str()); diff --git a/xbmc/utils/test/TestFileOperationJob.cpp b/xbmc/utils/test/TestFileOperationJob.cpp index 47a12e02e9..9643bd92c7 100644 --- a/xbmc/utils/test/TestFileOperationJob.cpp +++ b/xbmc/utils/test/TestFileOperationJob.cpp @@ -30,7 +30,7 @@ TEST(TestFileOperationJob, ActionCopy) { XFILE::CFile *tmpfile; - CStdString tmpfilepath, destfile; + std::string tmpfilepath, destfile; CFileItemList items; CFileOperationJob job; @@ -44,7 +44,7 @@ TEST(TestFileOperationJob, ActionCopy) item->Select(true); items.Add(item); - CStdString destpath = URIUtils::GetDirectory(tmpfilepath); + std::string destpath = URIUtils::GetDirectory(tmpfilepath); destpath = URIUtils::AddFileToFolder(destpath, "copy"); destfile = URIUtils::AddFileToFolder(destpath, URIUtils::GetFileName(tmpfilepath)); ASSERT_FALSE(XFILE::CFile::Exists(destfile)); @@ -64,7 +64,7 @@ TEST(TestFileOperationJob, ActionCopy) TEST(TestFileOperationJob, ActionMove) { XFILE::CFile *tmpfile; - CStdString tmpfilepath, destfile; + std::string tmpfilepath, destfile; CFileItemList items; CFileOperationJob job; @@ -78,7 +78,7 @@ TEST(TestFileOperationJob, ActionMove) item->Select(true); items.Add(item); - CStdString destpath = URIUtils::GetDirectory(tmpfilepath); + std::string destpath = URIUtils::GetDirectory(tmpfilepath); destpath = URIUtils::AddFileToFolder(destpath, "move"); destfile = URIUtils::AddFileToFolder(destpath, URIUtils::GetFileName(tmpfilepath)); ASSERT_FALSE(XFILE::CFile::Exists(destfile)); @@ -98,7 +98,7 @@ TEST(TestFileOperationJob, ActionMove) TEST(TestFileOperationJob, ActionDelete) { XFILE::CFile *tmpfile; - CStdString tmpfilepath, destfile; + std::string tmpfilepath, destfile; CFileItemList items; CFileOperationJob job; @@ -112,7 +112,7 @@ TEST(TestFileOperationJob, ActionDelete) item->Select(true); items.Add(item); - CStdString destpath = URIUtils::GetDirectory(tmpfilepath); + std::string destpath = URIUtils::GetDirectory(tmpfilepath); destpath = URIUtils::AddFileToFolder(destpath, "delete"); destfile = URIUtils::AddFileToFolder(destpath, URIUtils::GetFileName(tmpfilepath)); ASSERT_FALSE(XFILE::CFile::Exists(destfile)); @@ -148,7 +148,7 @@ TEST(TestFileOperationJob, ActionDelete) TEST(TestFileOperationJob, ActionReplace) { XFILE::CFile *tmpfile; - CStdString tmpfilepath, destfile; + std::string tmpfilepath, destfile; CFileItemList items; CFileOperationJob job; @@ -162,7 +162,7 @@ TEST(TestFileOperationJob, ActionReplace) item->Select(true); items.Add(item); - CStdString destpath = URIUtils::GetDirectory(tmpfilepath); + std::string destpath = URIUtils::GetDirectory(tmpfilepath); destpath = URIUtils::AddFileToFolder(destpath, "replace"); destfile = URIUtils::AddFileToFolder(destpath, URIUtils::GetFileName(tmpfilepath)); ASSERT_FALSE(XFILE::CFile::Exists(destfile)); @@ -188,14 +188,14 @@ TEST(TestFileOperationJob, ActionReplace) TEST(TestFileOperationJob, ActionCreateFolder) { XFILE::CFile *tmpfile; - CStdString tmpfilepath, destpath; + std::string tmpfilepath, destpath; CFileItemList items; CFileOperationJob job; ASSERT_TRUE((tmpfile = XBMC_CREATETEMPFILE(""))); tmpfilepath = XBMC_TEMPFILEPATH(tmpfile); - CStdString tmpfiledirectory = + std::string tmpfiledirectory = CXBMCTestUtils::Instance().TempFileDirectory(tmpfile); tmpfile->Close(); @@ -224,14 +224,14 @@ TEST(TestFileOperationJob, ActionCreateFolder) TEST(TestFileOperationJob, ActionDeleteFolder) { XFILE::CFile *tmpfile; - CStdString tmpfilepath, destpath; + std::string tmpfilepath, destpath; CFileItemList items; CFileOperationJob job; ASSERT_TRUE((tmpfile = XBMC_CREATETEMPFILE(""))); tmpfilepath = XBMC_TEMPFILEPATH(tmpfile); - CStdString tmpfiledirectory = + std::string tmpfiledirectory = CXBMCTestUtils::Instance().TempFileDirectory(tmpfile); tmpfile->Close(); @@ -264,7 +264,7 @@ TEST(TestFileOperationJob, ActionDeleteFolder) TEST(TestFileOperationJob, GetFunctions) { XFILE::CFile *tmpfile; - CStdString tmpfilepath, destfile; + std::string tmpfilepath, destfile; CFileItemList items; CFileOperationJob job; @@ -278,7 +278,7 @@ TEST(TestFileOperationJob, GetFunctions) item->Select(true); items.Add(item); - CStdString destpath = URIUtils::GetDirectory(tmpfilepath); + std::string destpath = URIUtils::GetDirectory(tmpfilepath); destpath = URIUtils::AddFileToFolder(destpath, "getfunctions"); destfile = URIUtils::AddFileToFolder(destpath, URIUtils::GetFileName(tmpfilepath)); ASSERT_FALSE(XFILE::CFile::Exists(destfile)); diff --git a/xbmc/utils/test/TestFileUtils.cpp b/xbmc/utils/test/TestFileUtils.cpp index 45f9682892..4e91b8f7ae 100644 --- a/xbmc/utils/test/TestFileUtils.cpp +++ b/xbmc/utils/test/TestFileUtils.cpp @@ -28,7 +28,7 @@ TEST(TestFileUtils, DeleteItem_CFileItemPtr) { XFILE::CFile *tmpfile; - CStdString tmpfilepath; + std::string tmpfilepath; ASSERT_TRUE((tmpfile = XBMC_CREATETEMPFILE(""))); tmpfilepath = XBMC_TEMPFILEPATH(tmpfile); @@ -41,7 +41,7 @@ TEST(TestFileUtils, DeleteItem_CFileItemPtr) EXPECT_TRUE(CFileUtils::DeleteItem(item)); } -TEST(TestFileUtils, DeleteItem_CStdString) +TEST(TestFileUtils, DeleteItemString) { XFILE::CFile *tmpfile; @@ -50,4 +50,4 @@ TEST(TestFileUtils, DeleteItem_CStdString) } /* Executing RenameFile() requires input from the user */ -// static bool RenameFile(const CStdString &strFile); +// static bool RenameFile(const std::string &strFile); diff --git a/xbmc/utils/test/TestHttpParser.cpp b/xbmc/utils/test/TestHttpParser.cpp index 75977f617b..480c03fe85 100644 --- a/xbmc/utils/test/TestHttpParser.cpp +++ b/xbmc/utils/test/TestHttpParser.cpp @@ -19,14 +19,13 @@ */ #include "utils/HttpParser.h" -#include "utils/StdString.h" #include "gtest/gtest.h" TEST(TestHttpParser, General) { HttpParser a; - CStdString str = "POST /path/script.cgi HTTP/1.0\r\n" + std::string str = "POST /path/script.cgi HTTP/1.0\r\n" "From: amejia@xbmc.org\r\n" "User-Agent: XBMC/snapshot (compatible; MSIE 5.5; Windows NT" " 4.0)\r\n" @@ -34,7 +33,7 @@ TEST(TestHttpParser, General) "Content-Length: 35\r\n" "\r\n" "home=amejia&favorite+flavor=orange\r\n"; - CStdString refstr, varstr; + std::string refstr, varstr; EXPECT_EQ(a.Done, a.addBytes(str.c_str(), str.length())); diff --git a/xbmc/utils/test/TestRegExp.cpp b/xbmc/utils/test/TestRegExp.cpp index e4231afa29..c161affebb 100644 --- a/xbmc/utils/test/TestRegExp.cpp +++ b/xbmc/utils/test/TestRegExp.cpp @@ -25,7 +25,6 @@ #include "utils/RegExp.h" #include "utils/log.h" -#include "utils/StdString.h" #include "filesystem/File.h" #include "filesystem/SpecialProtocol.h" #include "utils/StringUtils.h" @@ -148,7 +147,7 @@ protected: TEST_F(TestRegExpLog, DumpOvector) { CRegExp regex; - CStdString logfile, logstring; + std::string logfile, logstring; char buf[100]; unsigned int bytesread; XFILE::CFile file; diff --git a/xbmc/utils/test/TestStringUtils.cpp b/xbmc/utils/test/TestStringUtils.cpp index f9e25831c0..f0adec0b15 100644 --- a/xbmc/utils/test/TestStringUtils.cpp +++ b/xbmc/utils/test/TestStringUtils.cpp @@ -201,7 +201,7 @@ TEST(TestStringUtils, EndsWith) TEST(TestStringUtils, Join) { - CStdString refstr, varstr; + std::string refstr, varstr; std::vector<std::string> strarray; strarray.push_back("a"); @@ -297,7 +297,7 @@ TEST(TestStringUtils, TimeStringToSeconds) TEST(TestStringUtils, RemoveCRLF) { - CStdString refstr, varstr; + std::string refstr, varstr; refstr = "test\r\nstring\nblah blah"; varstr = "test\r\nstring\nblah blah\n"; @@ -316,7 +316,7 @@ TEST(TestStringUtils, utf8_strlen) TEST(TestStringUtils, SecondsToTimeString) { - CStdString ref, var; + std::string ref, var; ref = "21:30:55"; var = StringUtils::SecondsToTimeString(77455); @@ -355,7 +355,7 @@ TEST(TestStringUtils, IsInteger) TEST(TestStringUtils, SizeToString) { - CStdString ref, var; + std::string ref, var; ref = "2.00 GB"; var = StringUtils::SizeToString(2147483647); @@ -364,7 +364,7 @@ TEST(TestStringUtils, SizeToString) TEST(TestStringUtils, EmptyString) { - EXPECT_STREQ("", StringUtils::EmptyString.c_str()); + EXPECT_STREQ("", StringUtils::Empty.c_str()); } TEST(TestStringUtils, FindWords) diff --git a/xbmc/utils/test/TestURIUtils.cpp b/xbmc/utils/test/TestURIUtils.cpp index cd6dbec802..8c6b780fcb 100644 --- a/xbmc/utils/test/TestURIUtils.cpp +++ b/xbmc/utils/test/TestURIUtils.cpp @@ -45,18 +45,18 @@ TEST_F(TestURIUtils, IsInPath) TEST_F(TestURIUtils, GetDirectory) { - EXPECT_STREQ("/path/to/", URIUtils::GetDirectory("/path/to/movie.avi")); - EXPECT_STREQ("/path/to/", URIUtils::GetDirectory("/path/to/")); - EXPECT_STREQ("/path/to/|option=foo", URIUtils::GetDirectory("/path/to/movie.avi|option=foo")); - EXPECT_STREQ("/path/to/|option=foo", URIUtils::GetDirectory("/path/to/|option=foo")); - EXPECT_STREQ("", URIUtils::GetDirectory("movie.avi")); - EXPECT_STREQ("", URIUtils::GetDirectory("movie.avi|option=foo")); - EXPECT_STREQ("", URIUtils::GetDirectory("")); + EXPECT_STREQ("/path/to/", URIUtils::GetDirectory("/path/to/movie.avi").c_str()); + EXPECT_STREQ("/path/to/", URIUtils::GetDirectory("/path/to/").c_str()); + EXPECT_STREQ("/path/to/|option=foo", URIUtils::GetDirectory("/path/to/movie.avi|option=foo").c_str()); + EXPECT_STREQ("/path/to/|option=foo", URIUtils::GetDirectory("/path/to/|option=foo").c_str()); + EXPECT_STREQ("", URIUtils::GetDirectory("movie.avi").c_str()); + EXPECT_STREQ("", URIUtils::GetDirectory("movie.avi|option=foo").c_str()); + EXPECT_STREQ("", URIUtils::GetDirectory("").c_str()); // Make sure it works when assigning to the same str as the reference parameter - CStdString var = "/path/to/movie.avi|option=foo"; + std::string var = "/path/to/movie.avi|option=foo"; var = URIUtils::GetDirectory(var); - EXPECT_STREQ("/path/to/|option=foo", var); + EXPECT_STREQ("/path/to/|option=foo", var.c_str()); } TEST_F(TestURIUtils, GetExtension) @@ -92,7 +92,7 @@ TEST_F(TestURIUtils, GetFileName) TEST_F(TestURIUtils, RemoveExtension) { - CStdString ref, var; + std::string ref, var; /* NOTE: CSettings need to be set to find other extensions. */ ref = "/path/to/file"; @@ -103,7 +103,7 @@ TEST_F(TestURIUtils, RemoveExtension) TEST_F(TestURIUtils, ReplaceExtension) { - CStdString ref, var; + std::string ref, var; ref = "/path/to/file.xsd"; var = URIUtils::ReplaceExtension("/path/to/file.xml", ".xsd"); @@ -112,7 +112,7 @@ TEST_F(TestURIUtils, ReplaceExtension) TEST_F(TestURIUtils, Split) { - CStdString refpath, reffile, varpath, varfile; + std::string refpath, reffile, varpath, varfile; refpath = "/path/to/"; reffile = "movie.avi"; @@ -156,7 +156,7 @@ TEST_F(TestURIUtils, SplitPathLocal) TEST_F(TestURIUtils, GetCommonPath) { - CStdString ref, var; + std::string ref, var; ref = "/path/"; var = "/path/2/movie.avi"; @@ -166,7 +166,7 @@ TEST_F(TestURIUtils, GetCommonPath) TEST_F(TestURIUtils, GetParentPath) { - CStdString ref, var; + std::string ref, var; ref = "/path/to/"; var = URIUtils::GetParentPath("/path/to/movie.avi"); @@ -179,7 +179,7 @@ TEST_F(TestURIUtils, GetParentPath) TEST_F(TestURIUtils, SubstitutePath) { - CStdString from, to, ref, var; + std::string from, to, ref, var; from = "C:\\My Videos"; to = "https://myserver/some%20other%20path"; @@ -470,7 +470,7 @@ TEST_F(TestURIUtils, IsBluray) TEST_F(TestURIUtils, AddSlashAtEnd) { - CStdString ref, var; + std::string ref, var; ref = "bluray://path/to/file/"; var = "bluray://path/to/file/"; @@ -486,7 +486,7 @@ TEST_F(TestURIUtils, HasSlashAtEnd) TEST_F(TestURIUtils, RemoveSlashAtEnd) { - CStdString ref, var; + std::string ref, var; ref = "bluray://path/to/file"; var = "bluray://path/to/file/"; @@ -496,7 +496,7 @@ TEST_F(TestURIUtils, RemoveSlashAtEnd) TEST_F(TestURIUtils, CreateArchivePath) { - CStdString ref, var; + std::string ref, var; ref = "zip://%2fpath%2fto%2f/file"; var = URIUtils::CreateArchivePath("zip", CURL("/path/to/"), "file").Get(); @@ -505,8 +505,8 @@ TEST_F(TestURIUtils, CreateArchivePath) TEST_F(TestURIUtils, AddFileToFolder) { - CStdString ref = "/path/to/file"; - CStdString var = URIUtils::AddFileToFolder("/path/to", "file"); + std::string ref = "/path/to/file"; + std::string var = URIUtils::AddFileToFolder("/path/to", "file"); EXPECT_STREQ(ref.c_str(), var.c_str()); } diff --git a/xbmc/utils/test/Testfft.cpp b/xbmc/utils/test/Testfft.cpp index 25bd324f3f..f4260a8da2 100644 --- a/xbmc/utils/test/Testfft.cpp +++ b/xbmc/utils/test/Testfft.cpp @@ -19,7 +19,6 @@ */ #include "utils/fft.h" -#include "utils/StdString.h" #include "utils/StringUtils.h" #include "gtest/gtest.h" @@ -272,7 +271,7 @@ TEST(Testfft, twochannelrfft) { int i; float vardata[REFDATA_NUMELEMENTS]; - CStdString refstr, varstr; + std::string refstr, varstr; memcpy(vardata, refdata, sizeof(refdata)); twochannelrfft(vardata, REFDATA_NUMELEMENTS/2); @@ -288,7 +287,7 @@ TEST(Testfft, twochanwithwindow) { int i; float vardata[REFDATA_NUMELEMENTS]; - CStdString refstr, varstr; + std::string refstr, varstr; memcpy(vardata, refdata, sizeof(refdata)); twochanwithwindow(vardata, REFDATA_NUMELEMENTS/2); diff --git a/xbmc/utils/test/Testfstrcmp.cpp b/xbmc/utils/test/Testfstrcmp.cpp index be4605f8d8..3600389109 100644 --- a/xbmc/utils/test/Testfstrcmp.cpp +++ b/xbmc/utils/test/Testfstrcmp.cpp @@ -19,14 +19,13 @@ */ #include "utils/fstrcmp.h" -#include "utils/StdString.h" #include "utils/StringUtils.h" #include "gtest/gtest.h" TEST(Testfstrcmp, General) { - CStdString refstr, varstr, refresult, varresult; + std::string refstr, varstr, refresult, varresult; refstr = "Testfstrcmp test string"; varstr = refstr; diff --git a/xbmc/utils/test/Testlog.cpp b/xbmc/utils/test/Testlog.cpp index 656201f959..cbcd391e91 100644 --- a/xbmc/utils/test/Testlog.cpp +++ b/xbmc/utils/test/Testlog.cpp @@ -22,7 +22,6 @@ #include "utils/RegExp.h" #include "filesystem/File.h" #include "filesystem/SpecialProtocol.h" -#include "utils/StdString.h" #include "utils/StringUtils.h" #include "CompileInfo.h" @@ -42,7 +41,7 @@ protected: TEST_F(Testlog, Log) { - CStdString logfile, logstring; + std::string logfile, logstring; char buf[100]; unsigned int bytesread; XFILE::CFile file; @@ -97,7 +96,7 @@ TEST_F(Testlog, Log) TEST_F(Testlog, MemDump) { - CStdString logfile, logstring; + std::string logfile, logstring; char buf[100]; unsigned int bytesread; XFILE::CFile file; @@ -136,7 +135,7 @@ TEST_F(Testlog, MemDump) TEST_F(Testlog, SetLogLevel) { - CStdString logfile; + std::string logfile; std::string appName = CCompileInfo::GetAppName(); StringUtils::ToLower(appName); diff --git a/xbmc/video/Bookmark.h b/xbmc/video/Bookmark.h index 882c2e6e9a..35a574dfec 100644 --- a/xbmc/video/Bookmark.h +++ b/xbmc/video/Bookmark.h @@ -19,10 +19,9 @@ * */ +#include <string> #include <vector> -#include "utils/StdString.h" - class CBookmark { public: @@ -42,9 +41,9 @@ public: double timeInSeconds; double totalTimeInSeconds; long partNumber; - CStdString thumbNailImage; - CStdString playerState; - CStdString player; + std::string thumbNailImage; + std::string playerState; + std::string player; long seasonNumber; long episodeNumber; diff --git a/xbmc/video/FFmpegVideoDecoder.cpp b/xbmc/video/FFmpegVideoDecoder.cpp index f25e147b48..f6c58edb3a 100644 --- a/xbmc/video/FFmpegVideoDecoder.cpp +++ b/xbmc/video/FFmpegVideoDecoder.cpp @@ -125,7 +125,7 @@ const AVCodec * FFmpegVideoDecoder::getAVCodec() const return m_pCodec; } -CStdString FFmpegVideoDecoder::getErrorMsg() const +std::string FFmpegVideoDecoder::getErrorMsg() const { return m_errorMsg; } @@ -136,7 +136,7 @@ double FFmpegVideoDecoder::getLastFrameTime() const } -bool FFmpegVideoDecoder::open( const CStdString& filename ) +bool FFmpegVideoDecoder::open( const std::string& filename ) { // See http://dranger.com/ffmpeg/tutorial01.html close(); diff --git a/xbmc/video/FFmpegVideoDecoder.h b/xbmc/video/FFmpegVideoDecoder.h index 5ce3f72ee8..510b9e18b9 100644 --- a/xbmc/video/FFmpegVideoDecoder.h +++ b/xbmc/video/FFmpegVideoDecoder.h @@ -21,7 +21,7 @@ * */ -#include "utils/StdString.h" +#include <string> class CBaseTexture; @@ -58,7 +58,7 @@ public: * * @param filename The video file name, which must be translated through CSpecialProtocol::TranslatePath() */ - bool open( const CStdString& filename ); + bool open( const std::string& filename ); /** * Returns true if the decoder has the video file opened. @@ -110,7 +110,7 @@ public: /** * Returns the error message text if opening the video failed */ - CStdString getErrorMsg() const; + std::string getErrorMsg() const; /** * Decodes and renders the next video frame into the provided texture which @@ -152,7 +152,7 @@ private: unsigned int m_frameRGBwidth; unsigned int m_frameRGBheight; - CStdString m_errorMsg; + std::string m_errorMsg; }; #endif diff --git a/xbmc/video/GUIViewStateVideo.cpp b/xbmc/video/GUIViewStateVideo.cpp index d5a0348423..21cc661a8e 100644 --- a/xbmc/video/GUIViewStateVideo.cpp +++ b/xbmc/video/GUIViewStateVideo.cpp @@ -206,7 +206,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll) AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T", "%V", "%T", "%V")); // Title, Playcount | Title, Playcount - SetSortMethod(SortByLabel, SortAttributeIgnoreArticle); + SetSortMethod(SortByLabel); const CViewState *viewState = CViewStateSettings::Get().Get("videonavgenres"); SetViewAsControl(viewState->m_viewMode); @@ -216,7 +216,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it case NODE_TYPE_TAGS: { AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%T","", "%T","")); // Title, empty | Title, empty - SetSortMethod(SortByLabel, sortAttributes); + SetSortMethod(SortByLabel); const CViewState *viewState = CViewStateSettings::Get().Get("videonavgenres"); SetViewAsControl(viewState->m_viewMode); diff --git a/xbmc/video/PlayerController.cpp b/xbmc/video/PlayerController.cpp index fd9a1b689b..3f5fc25bdf 100644 --- a/xbmc/video/PlayerController.cpp +++ b/xbmc/video/PlayerController.cpp @@ -20,7 +20,6 @@ #include "PlayerController.h" #include "dialogs/GUIDialogSlider.h" -#include "utils/StdString.h" #include "settings/AdvancedSettings.h" #include "settings/DisplaySettings.h" #include "settings/MediaSettings.h" @@ -65,7 +64,7 @@ bool CPlayerController::OnAction(const CAction &action) bool subsOn = !g_application.m_pPlayer->GetSubtitleVisible(); g_application.m_pPlayer->SetSubtitleVisible(subsOn); - CStdString sub, lang; + std::string sub, lang; if (subsOn) { SPlayerSubtitleStreamInfo info; @@ -112,7 +111,7 @@ bool CPlayerController::OnAction(const CAction &action) g_application.m_pPlayer->SetSubtitleVisible(true); } - CStdString sub, lang; + std::string sub, lang; if (currentSubVisible) { SPlayerSubtitleStreamInfo info; @@ -209,8 +208,8 @@ bool CPlayerController::OnAction(const CAction &action) if (++currentAudio >= g_application.m_pPlayer->GetAudioStreamCount()) currentAudio = 0; g_application.m_pPlayer->SetAudioStream(currentAudio); // Set the audio stream to the one selected - CStdString aud; - CStdString lan; + std::string aud; + std::string lan; SPlayerAudioStreamInfo info; g_application.m_pPlayer->GetAudioStreamInfo(currentAudio, info); if (!g_LangCodeExpander.Lookup(lan, info.language)) @@ -419,7 +418,7 @@ void CPlayerController::OnSliderChange(void *data, CGUISliderControl *slider) m_sliderAction == ACTION_VSHIFT_UP || m_sliderAction == ACTION_VSHIFT_DOWN || m_sliderAction == ACTION_SUBTITLE_VSHIFT_UP || m_sliderAction == ACTION_SUBTITLE_VSHIFT_DOWN) { - CStdString strValue = StringUtils::Format("%1.2f",slider->GetFloatValue()); + std::string strValue = StringUtils::Format("%1.2f",slider->GetFloatValue()); slider->SetTextValue(strValue); } else if (m_sliderAction == ACTION_VOLAMP_UP || m_sliderAction == ACTION_VOLAMP_DOWN) diff --git a/xbmc/video/Teletext.h b/xbmc/video/Teletext.h index e4f6c177bf..8c26243f8b 100644 --- a/xbmc/video/Teletext.h +++ b/xbmc/video/Teletext.h @@ -135,7 +135,7 @@ private: static FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *aface); - CStdString m_teletextFont; /* Path to teletext font */ + std::string m_teletextFont; /* Path to teletext font */ int m_YOffset; /* Swap position for Front buffer and Back buffer */ color_t *m_TextureBuffer; /* Texture buffer to hold generated data */ bool m_updateTexture; /* Update the texture if set */ diff --git a/xbmc/video/TeletextDefines.h b/xbmc/video/TeletextDefines.h index 0e8e75dc84..74e674ed73 100644 --- a/xbmc/video/TeletextDefines.h +++ b/xbmc/video/TeletextDefines.h @@ -20,7 +20,7 @@ * */ -#include "utils/StdString.h" +#include <string> #define FLOFSIZE 4 #define SUBTITLE_CACHESIZE 50 @@ -431,7 +431,7 @@ typedef struct TextCacheStruct_t short pop, gpop, drcs, gdrcs; unsigned short *ColorTable; - CStdString line30; + std::string line30; } TextCacheStruct_t; /* struct for all Information needed for Page Rendering */ diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index 21391dd3ab..31060e349a 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -95,27 +95,23 @@ void CVideoDatabase::CreateTables() m_pDS->exec("CREATE TABLE settings ( idFile integer, Deinterlace bool," "ViewMode integer,ZoomAmount float, PixelRatio float, VerticalShift float, AudioStream integer, SubtitleStream integer," "SubtitleDelay float, SubtitlesOn bool, Brightness float, Contrast float, Gamma float," - "VolumeAmplification float, AudioDelay float, OutputToAllSpeakers bool, ResumeTime integer, Crop bool, CropLeft integer," - "CropRight integer, CropTop integer, CropBottom integer, Sharpness float, NoiseReduction float, NonLinStretch bool, PostProcess bool," + "VolumeAmplification float, AudioDelay float, OutputToAllSpeakers bool, ResumeTime integer," + "Sharpness float, NoiseReduction float, NonLinStretch bool, PostProcess bool," "ScalingMethod integer, DeinterlaceMode integer, StereoMode integer, StereoInvert bool)\n"); CLog::Log(LOGINFO, "create stacktimes table"); m_pDS->exec("CREATE TABLE stacktimes (idFile integer, times text)\n"); CLog::Log(LOGINFO, "create genre table"); - m_pDS->exec("CREATE TABLE genre ( idGenre integer primary key, strGenre text)\n"); - - CLog::Log(LOGINFO, "create genrelinkmovie table"); - m_pDS->exec("CREATE TABLE genrelinkmovie ( idGenre integer, idMovie integer)\n"); + m_pDS->exec("CREATE TABLE genre ( genre_id integer primary key, name TEXT)\n"); + m_pDS->exec("CREATE TABLE genre_link (genre_id integer, media_id integer, media_type TEXT)"); CLog::Log(LOGINFO, "create country table"); - m_pDS->exec("CREATE TABLE country ( idCountry integer primary key, strCountry text)\n"); - - CLog::Log(LOGINFO, "create countrylinkmovie table"); - m_pDS->exec("CREATE TABLE countrylinkmovie ( idCountry integer, idMovie integer)\n"); + m_pDS->exec("CREATE TABLE country ( country_id integer primary key, name TEXT)"); + m_pDS->exec("CREATE TABLE country_link (country_id integer, media_id integer, media_type TEXT)"); CLog::Log(LOGINFO, "create movie table"); - CStdString columns = "CREATE TABLE movie ( idMovie integer primary key, idFile integer"; + std::string columns = "CREATE TABLE movie ( idMovie integer primary key, idFile integer"; for (int i = 0; i < VIDEODB_MAX_COLUMNS; i++) columns += StringUtils::Format(",c%02d text", i); @@ -123,17 +119,11 @@ void CVideoDatabase::CreateTables() columns += ", idSet integer)"; m_pDS->exec(columns.c_str()); - CLog::Log(LOGINFO, "create actorlinkmovie table"); - m_pDS->exec("CREATE TABLE actorlinkmovie ( idActor integer, idMovie integer, strRole text, iOrder integer)\n"); - - CLog::Log(LOGINFO, "create directorlinkmovie table"); - m_pDS->exec("CREATE TABLE directorlinkmovie ( idDirector integer, idMovie integer)\n"); - - CLog::Log(LOGINFO, "create writerlinkmovie table"); - m_pDS->exec("CREATE TABLE writerlinkmovie ( idWriter integer, idMovie integer)\n"); - - CLog::Log(LOGINFO, "create actors table"); - m_pDS->exec("CREATE TABLE actors ( idActor integer primary key, strActor text, strThumb text )\n"); + CLog::Log(LOGINFO, "create actor table"); + m_pDS->exec("CREATE TABLE actor ( actor_id INTEGER PRIMARY KEY, name TEXT, art_urls TEXT )"); + m_pDS->exec("CREATE TABLE actor_link(actor_id INTEGER, media_id INTEGER, media_type TEXT, role TEXT, cast_order INTEGER)"); + m_pDS->exec("CREATE TABLE director_link(actor_id INTEGER, media_id INTEGER, media_type TEXT)"); + m_pDS->exec("CREATE TABLE writer_link(actor_id INTEGER, media_id INTEGER, media_type TEXT)"); CLog::Log(LOGINFO, "create path table"); m_pDS->exec("CREATE TABLE path ( idPath integer primary key, strPath text, strContent text, strScraper text, strHash text, scanRecursive integer, useFolderNames bool, strSettings text, noUpdate bool, exclude bool, dateAdded text, idParentPath integer)"); @@ -150,20 +140,11 @@ void CVideoDatabase::CreateTables() columns += ")"; m_pDS->exec(columns.c_str()); - CLog::Log(LOGINFO, "create directorlinktvshow table"); - m_pDS->exec("CREATE TABLE directorlinktvshow ( idDirector integer, idShow integer)\n"); - - CLog::Log(LOGINFO, "create actorlinktvshow table"); - m_pDS->exec("CREATE TABLE actorlinktvshow ( idActor integer, idShow integer, strRole text, iOrder integer)\n"); - - CLog::Log(LOGINFO, "create studiolinktvshow table"); - m_pDS->exec("CREATE TABLE studiolinktvshow ( idStudio integer, idShow integer)\n"); - CLog::Log(LOGINFO, "create episode table"); columns = "CREATE TABLE episode ( idEpisode integer primary key, idFile integer"; for (int i = 0; i < VIDEODB_MAX_COLUMNS; i++) { - CStdString column; + std::string column; if ( i == VIDEODB_ID_EPISODE_SEASON || i == VIDEODB_ID_EPISODE_EPISODE || i == VIDEODB_ID_EPISODE_BOOKMARK) column = StringUtils::Format(",c%02d varchar(24)", i); else @@ -177,26 +158,12 @@ void CVideoDatabase::CreateTables() CLog::Log(LOGINFO, "create tvshowlinkpath table"); m_pDS->exec("CREATE TABLE tvshowlinkpath (idShow integer, idPath integer)\n"); - CLog::Log(LOGINFO, "create actorlinkepisode table"); - m_pDS->exec("CREATE TABLE actorlinkepisode ( idActor integer, idEpisode integer, strRole text, iOrder integer)\n"); - - CLog::Log(LOGINFO, "create directorlinkepisode table"); - m_pDS->exec("CREATE TABLE directorlinkepisode ( idDirector integer, idEpisode integer)\n"); - - CLog::Log(LOGINFO, "create writerlinkepisode table"); - m_pDS->exec("CREATE TABLE writerlinkepisode ( idWriter integer, idEpisode integer)\n"); - - CLog::Log(LOGINFO, "create genrelinktvshow table"); - m_pDS->exec("CREATE TABLE genrelinktvshow ( idGenre integer, idShow integer)\n"); - CLog::Log(LOGINFO, "create movielinktvshow table"); m_pDS->exec("CREATE TABLE movielinktvshow ( idMovie integer, IdShow integer)\n"); CLog::Log(LOGINFO, "create studio table"); - m_pDS->exec("CREATE TABLE studio ( idStudio integer primary key, strStudio text)\n"); - - CLog::Log(LOGINFO, "create studiolinkmovie table"); - m_pDS->exec("CREATE TABLE studiolinkmovie ( idStudio integer, idMovie integer)\n"); + m_pDS->exec("CREATE TABLE studio ( studio_id integer primary key, name TEXT)\n"); + m_pDS->exec("CREATE TABLE studio_link (studio_id integer, media_id integer, media_type TEXT)"); CLog::Log(LOGINFO, "create musicvideo table"); columns = "CREATE TABLE musicvideo ( idMVideo integer primary key, idFile integer"; @@ -206,18 +173,6 @@ void CVideoDatabase::CreateTables() columns += ")"; m_pDS->exec(columns.c_str()); - CLog::Log(LOGINFO, "create artistlinkmusicvideo table"); - m_pDS->exec("CREATE TABLE artistlinkmusicvideo ( idArtist integer, idMVideo integer)\n"); - - CLog::Log(LOGINFO, "create genrelinkmusicvideo table"); - m_pDS->exec("CREATE TABLE genrelinkmusicvideo ( idGenre integer, idMVideo integer)\n"); - - CLog::Log(LOGINFO, "create studiolinkmusicvideo table"); - m_pDS->exec("CREATE TABLE studiolinkmusicvideo ( idStudio integer, idMVideo integer)\n"); - - CLog::Log(LOGINFO, "create directorlinkmusicvideo table"); - m_pDS->exec("CREATE TABLE directorlinkmusicvideo ( idDirector integer, idMVideo integer)\n"); - CLog::Log(LOGINFO, "create streaminfo table"); m_pDS->exec("CREATE TABLE streamdetails (idFile integer, iStreamType integer, " "strVideoCodec text, fVideoAspect float, iVideoWidth integer, iVideoHeight integer, " @@ -233,10 +188,23 @@ void CVideoDatabase::CreateTables() m_pDS->exec("CREATE TABLE art(art_id INTEGER PRIMARY KEY, media_id INTEGER, media_type TEXT, type TEXT, url TEXT)"); CLog::Log(LOGINFO, "create tag table"); - m_pDS->exec("CREATE TABLE tag (idTag integer primary key, strTag text)"); + m_pDS->exec("CREATE TABLE tag (tag_id integer primary key, name TEXT)"); + m_pDS->exec("CREATE TABLE tag_link (tag_id integer, media_id integer, media_type TEXT)"); +} + +void CVideoDatabase::CreateLinkIndex(const char *table) +{ + m_pDS->exec(PrepareSQL("CREATE UNIQUE INDEX ix_%s_1 ON %s (name(255))", table, table)); + m_pDS->exec(PrepareSQL("CREATE UNIQUE INDEX ix_%s_link_1 ON %s_link (%s_id, media_type(20), media_id)", table, table, table)); + m_pDS->exec(PrepareSQL("CREATE UNIQUE INDEX ix_%s_link_2 ON %s_link (media_id, media_type(20), %s_id)", table, table, table)); + m_pDS->exec(PrepareSQL("CREATE INDEX ix_%s_link_3 ON %s_link (media_type(20))", table, table)); +} - CLog::Log(LOGINFO, "create taglinks table"); - m_pDS->exec("CREATE TABLE taglinks (idTag integer, idMedia integer, media_type TEXT)"); +void CVideoDatabase::CreateForeignLinkIndex(const char *table, const char *foreignkey) +{ + m_pDS->exec(PrepareSQL("CREATE UNIQUE INDEX ix_%s_link_1 ON %s_link (%s_id, media_type(20), media_id)", table, table, foreignkey)); + m_pDS->exec(PrepareSQL("CREATE UNIQUE INDEX ix_%s_link_2 ON %s_link (media_id, media_type(20), %s_id)", table, table, foreignkey)); + m_pDS->exec(PrepareSQL("CREATE INDEX ix_%s_link_3 ON %s_link (media_type(20))", table, table)); } void CVideoDatabase::CreateAnalytics() @@ -248,9 +216,9 @@ void CVideoDatabase::CreateAnalytics() /* order of indexes are important, for an index to be considered all */ /* columns up to the column in question have to have been specified */ - /* select * from actorlinkmovie where idMovie = 1, can not take */ - /* advantage of a index that has been created on ( idGenre, idMovie ) */ - /*, hower on on ( idMovie, idGenre ) will be considered for use */ + /* select * from foolink where foo_id = 1, can not take */ + /* advantage of a index that has been created on ( bar_id, foo_id ) */ + /* however an index on ( foo_id, bar_id ) will be considered for use */ CLog::Log(LOGINFO, "%s - creating indicies", __FUNCTION__); m_pDS->exec("CREATE INDEX ix_bookmark ON bookmark (idFile, type)"); @@ -260,27 +228,9 @@ void CVideoDatabase::CreateAnalytics() m_pDS->exec("CREATE INDEX ix_path2 ON path ( idParentPath )"); m_pDS->exec("CREATE INDEX ix_files ON files ( idPath, strFilename(255) )"); - m_pDS->exec("CREATE UNIQUE INDEX ix_genrelinkmovie_1 ON genrelinkmovie ( idGenre, idMovie)\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_genrelinkmovie_2 ON genrelinkmovie ( idMovie, idGenre)\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_countrylinkmovie_1 ON countrylinkmovie ( idCountry, idMovie)\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_countrylinkmovie_2 ON countrylinkmovie ( idMovie, idCountry)\n"); m_pDS->exec("CREATE UNIQUE INDEX ix_movie_file_1 ON movie (idFile, idMovie)"); m_pDS->exec("CREATE UNIQUE INDEX ix_movie_file_2 ON movie (idMovie, idFile)"); - m_pDS->exec("CREATE UNIQUE INDEX ix_actorlinkmovie_1 ON actorlinkmovie ( idActor, idMovie )\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_actorlinkmovie_2 ON actorlinkmovie ( idMovie, idActor )\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_directorlinkmovie_1 ON directorlinkmovie ( idDirector, idMovie )\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_directorlinkmovie_2 ON directorlinkmovie ( idMovie, idDirector )\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_writerlinkmovie_1 ON writerlinkmovie ( idWriter, idMovie )\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_writerlinkmovie_2 ON writerlinkmovie ( idMovie, idWriter )\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_studiolinkmovie_1 ON studiolinkmovie ( idStudio, idMovie)\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_studiolinkmovie_2 ON studiolinkmovie ( idMovie, idStudio)\n"); - - m_pDS->exec("CREATE UNIQUE INDEX ix_directorlinktvshow_1 ON directorlinktvshow ( idDirector, idShow )\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_directorlinktvshow_2 ON directorlinktvshow ( idShow, idDirector )\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_actorlinktvshow_1 ON actorlinktvshow ( idActor, idShow )\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_actorlinktvshow_2 ON actorlinktvshow ( idShow, idActor )\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_studiolinktvshow_1 ON studiolinktvshow ( idStudio, idShow)\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_studiolinktvshow_2 ON studiolinktvshow ( idShow, idStudio)\n"); + m_pDS->exec("CREATE UNIQUE INDEX ix_tvshowlinkpath_1 ON tvshowlinkpath ( idShow, idPath )\n"); m_pDS->exec("CREATE UNIQUE INDEX ix_tvshowlinkpath_2 ON tvshowlinkpath ( idPath, idShow )\n"); m_pDS->exec("CREATE UNIQUE INDEX ix_movielinktvshow_1 ON movielinktvshow ( idShow, idMovie)\n"); @@ -288,31 +238,15 @@ void CVideoDatabase::CreateAnalytics() m_pDS->exec("CREATE UNIQUE INDEX ix_episode_file_1 on episode (idEpisode, idFile)"); m_pDS->exec("CREATE UNIQUE INDEX id_episode_file_2 on episode (idFile, idEpisode)"); - CStdString createColIndex = StringUtils::Format("CREATE INDEX ix_episode_season_episode on episode (c%02d, c%02d)", VIDEODB_ID_EPISODE_SEASON, VIDEODB_ID_EPISODE_EPISODE); + std::string createColIndex = StringUtils::Format("CREATE INDEX ix_episode_season_episode on episode (c%02d, c%02d)", VIDEODB_ID_EPISODE_SEASON, VIDEODB_ID_EPISODE_EPISODE); m_pDS->exec(createColIndex.c_str()); createColIndex = StringUtils::Format("CREATE INDEX ix_episode_bookmark on episode (c%02d)", VIDEODB_ID_EPISODE_BOOKMARK); m_pDS->exec(createColIndex.c_str()); m_pDS->exec("CREATE INDEX ix_episode_show1 on episode(idEpisode,idShow)"); m_pDS->exec("CREATE INDEX ix_episode_show2 on episode(idShow,idEpisode)"); - m_pDS->exec("CREATE UNIQUE INDEX ix_actorlinkepisode_1 ON actorlinkepisode ( idActor, idEpisode )\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_actorlinkepisode_2 ON actorlinkepisode ( idEpisode, idActor )\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_directorlinkepisode_1 ON directorlinkepisode ( idDirector, idEpisode )\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_directorlinkepisode_2 ON directorlinkepisode ( idEpisode, idDirector )\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_writerlinkepisode_1 ON writerlinkepisode ( idWriter, idEpisode )\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_writerlinkepisode_2 ON writerlinkepisode ( idEpisode, idWriter )\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_genrelinktvshow_1 ON genrelinktvshow ( idGenre, idShow)\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_genrelinktvshow_2 ON genrelinktvshow ( idShow, idGenre)\n"); m_pDS->exec("CREATE UNIQUE INDEX ix_musicvideo_file_1 on musicvideo (idMVideo, idFile)"); m_pDS->exec("CREATE UNIQUE INDEX ix_musicvideo_file_2 on musicvideo (idFile, idMVideo)"); - m_pDS->exec("CREATE UNIQUE INDEX ix_artistlinkmusicvideo_1 ON artistlinkmusicvideo ( idArtist, idMVideo)\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_artistlinkmusicvideo_2 ON artistlinkmusicvideo ( idMVideo, idArtist)\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_genrelinkmusicvideo_1 ON genrelinkmusicvideo ( idGenre, idMVideo)\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_genrelinkmusicvideo_2 ON genrelinkmusicvideo ( idMVideo, idGenre)\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_studiolinkmusicvideo_1 ON studiolinkmusicvideo ( idStudio, idMVideo)\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_studiolinkmusicvideo_2 ON studiolinkmusicvideo ( idMVideo, idStudio)\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_directorlinkmusicvideo_1 ON directorlinkmusicvideo ( idDirector, idMVideo )\n"); - m_pDS->exec("CREATE UNIQUE INDEX ix_directorlinkmusicvideo_2 ON directorlinkmusicvideo ( idMVideo, idDirector )\n"); m_pDS->exec("CREATE INDEX ixMovieBasePath ON movie ( c23(12) )"); m_pDS->exec("CREATE INDEX ixMusicVideoBasePath ON musicvideo ( c14(12) )"); @@ -322,45 +256,49 @@ void CVideoDatabase::CreateAnalytics() m_pDS->exec("CREATE INDEX ix_seasons ON seasons (idShow, season)"); m_pDS->exec("CREATE INDEX ix_art ON art(media_id, media_type(20), type(20))"); - m_pDS->exec("CREATE UNIQUE INDEX ix_tag_1 ON tag (strTag(255))"); - m_pDS->exec("CREATE UNIQUE INDEX ix_taglinks_1 ON taglinks (idTag, media_type(20), idMedia)"); - m_pDS->exec("CREATE UNIQUE INDEX ix_taglinks_2 ON taglinks (idMedia, media_type(20), idTag)"); - m_pDS->exec("CREATE INDEX ix_taglinks_3 ON taglinks (media_type(20))"); + CreateLinkIndex("tag"); + CreateLinkIndex("actor"); + CreateForeignLinkIndex("director", "actor"); + CreateForeignLinkIndex("writer", "actor"); + CreateLinkIndex("studio"); + CreateLinkIndex("genre"); + CreateLinkIndex("country"); CLog::Log(LOGINFO, "%s - creating triggers", __FUNCTION__); m_pDS->exec("CREATE TRIGGER delete_movie AFTER DELETE ON movie FOR EACH ROW BEGIN " - "DELETE FROM genrelinkmovie WHERE idMovie=old.idMovie; " - "DELETE FROM actorlinkmovie WHERE idMovie=old.idMovie; " - "DELETE FROM directorlinkmovie WHERE idMovie=old.idMovie; " - "DELETE FROM studiolinkmovie WHERE idMovie=old.idMovie; " - "DELETE FROM countrylinkmovie WHERE idMovie=old.idMovie; " - "DELETE FROM writerlinkmovie WHERE idMovie=old.idMovie; " + "DELETE FROM genre_link WHERE media_id=old.idMovie AND media_type='movie'; " + "DELETE FROM actor_link WHERE media_id=old.idMovie AND media_type='movie'; " + "DELETE FROM director_link WHERE media_id=old.idMovie AND media_type='movie'; " + "DELETE FROM studio_link WHERE media_id=old.idMovie AND media_type='movie'; " + "DELETE FROM country_link WHERE media_id=old.idMovie AND media_type='movie'; " + "DELETE FROM writer_link WHERE media_id=old.idMovie AND media_type='movie'; " "DELETE FROM movielinktvshow WHERE idMovie=old.idMovie; " "DELETE FROM art WHERE media_id=old.idMovie AND media_type='movie'; " - "DELETE FROM taglinks WHERE idMedia=old.idMovie AND media_type='movie'; " + "DELETE FROM tag_link WHERE media_id=old.idMovie AND media_type='movie'; " "END"); m_pDS->exec("CREATE TRIGGER delete_tvshow AFTER DELETE ON tvshow FOR EACH ROW BEGIN " - "DELETE FROM actorlinktvshow WHERE idShow=old.idShow; " - "DELETE FROM directorlinktvshow WHERE idShow=old.idShow; " + "DELETE FROM actor_link WHERE media_id=old.idShow AND media_type='tvshow'; " + "DELETE FROM director_link WHERE media_id=old.idShow AND media_type='tvshow'; " + "DELETE FROM studio_link WHERE media_id=old.idShow AND media_type='tvshow'; " "DELETE FROM tvshowlinkpath WHERE idShow=old.idShow; " - "DELETE FROM genrelinktvshow WHERE idShow=old.idShow; " + "DELETE FROM genre_link WHERE media_id=old.idShow AND media_type='tvshow'; " "DELETE FROM movielinktvshow WHERE idShow=old.idShow; " "DELETE FROM seasons WHERE idShow=old.idShow; " "DELETE FROM art WHERE media_id=old.idShow AND media_type='tvshow'; " - "DELETE FROM taglinks WHERE idMedia=old.idShow AND media_type='tvshow'; " + "DELETE FROM tag_link WHERE media_id=old.idShow AND media_type='tvshow'; " "END"); m_pDS->exec("CREATE TRIGGER delete_musicvideo AFTER DELETE ON musicvideo FOR EACH ROW BEGIN " - "DELETE FROM artistlinkmusicvideo WHERE idMVideo=old.idMVideo; " - "DELETE FROM directorlinkmusicvideo WHERE idMVideo=old.idMVideo; " - "DELETE FROM genrelinkmusicvideo WHERE idMVideo=old.idMVideo; " - "DELETE FROM studiolinkmusicvideo WHERE idMVideo=old.idMVideo; " + "DELETE FROM actor_link WHERE media_id=old.idMVideo AND media_type='musicvideo'; " + "DELETE FROM director_link WHERE media_id=old.idMVideo AND media_type='musicvideo'; " + "DELETE FROM genre_link WHERE media_id=old.idMVideo AND media_type='musicvideo'; " + "DELETE FROM studio_link WHERE media_id=old.idMVideo AND media_type='musicvideo'; " "DELETE FROM art WHERE media_id=old.idMVideo AND media_type='musicvideo'; " - "DELETE FROM taglinks WHERE idMedia=old.idMVideo AND media_type='musicvideo'; " + "DELETE FROM tag_link WHERE media_id=old.idMVideo AND media_type='musicvideo'; " "END"); m_pDS->exec("CREATE TRIGGER delete_episode AFTER DELETE ON episode FOR EACH ROW BEGIN " - "DELETE FROM actorlinkepisode WHERE idEpisode=old.idEpisode; " - "DELETE FROM directorlinkepisode WHERE idEpisode=old.idEpisode; " - "DELETE FROM writerlinkepisode WHERE idEpisode=old.idEpisode; " + "DELETE FROM actor_link WHERE media_id=old.idEpisode AND media_type='episode'; " + "DELETE FROM director_link WHERE media_id=old.idEpisode AND media_type='episode'; " + "DELETE FROM writer_link WHERE media_id=old.idEpisode AND media_type='episode'; " "DELETE FROM art WHERE media_id=old.idEpisode AND media_type='episode'; " "END"); m_pDS->exec("CREATE TRIGGER delete_season AFTER DELETE ON seasons FOR EACH ROW BEGIN " @@ -369,11 +307,11 @@ void CVideoDatabase::CreateAnalytics() m_pDS->exec("CREATE TRIGGER delete_set AFTER DELETE ON sets FOR EACH ROW BEGIN " "DELETE FROM art WHERE media_id=old.idSet AND media_type='set'; " "END"); - m_pDS->exec("CREATE TRIGGER delete_person AFTER DELETE ON actors FOR EACH ROW BEGIN " - "DELETE FROM art WHERE media_id=old.idActor AND media_type IN ('actor','artist','writer','director'); " + m_pDS->exec("CREATE TRIGGER delete_person AFTER DELETE ON actor FOR EACH ROW BEGIN " + "DELETE FROM art WHERE media_id=old.actor_id AND media_type IN ('actor','artist','writer','director'); " "END"); - m_pDS->exec("CREATE TRIGGER delete_tag AFTER DELETE ON taglinks FOR EACH ROW BEGIN " - "DELETE FROM tag WHERE idTag=old.idTag AND idTag NOT IN (SELECT DISTINCT idTag FROM taglinks); " + m_pDS->exec("CREATE TRIGGER delete_tag AFTER DELETE ON tag_link FOR EACH ROW BEGIN " + "DELETE FROM tag WHERE tag_id=old.tag_id AND tag_id NOT IN (SELECT DISTINCT tag_id FROM tag_link); " "END"); CreateViews(); @@ -381,8 +319,8 @@ void CVideoDatabase::CreateAnalytics() void CVideoDatabase::CreateViews() { - CLog::Log(LOGINFO, "create episodeview"); - CStdString episodeview = PrepareSQL("CREATE VIEW episodeview AS SELECT " + CLog::Log(LOGINFO, "create episode_view"); + std::string episodeview = PrepareSQL("CREATE VIEW episode_view AS SELECT " " episode.*," " files.strFileName AS strFileName," " path.strPath AS strPath," @@ -390,7 +328,7 @@ void CVideoDatabase::CreateViews() " files.lastPlayed AS lastPlayed," " files.dateAdded AS dateAdded," " tvshow.c%02d AS strTitle," - " tvshow.c%02d AS strStudio," + " tvshow.c%02d AS studio," " tvshow.c%02d AS premiered," " tvshow.c%02d AS mpaa," " bookmark.timeInSeconds AS resumeTimeInSeconds, " @@ -410,7 +348,7 @@ void CVideoDatabase::CreateViews() m_pDS->exec(episodeview.c_str()); CLog::Log(LOGINFO, "create tvshowcounts"); - CStdString tvshowcounts = PrepareSQL("CREATE VIEW tvshowcounts AS SELECT " + std::string tvshowcounts = PrepareSQL("CREATE VIEW tvshowcounts AS SELECT " " tvshow.idShow AS idShow," " MAX(files.lastPlayed) AS lastPlayed," " NULLIF(COUNT(episode.c12), 0) AS totalCount," @@ -425,8 +363,8 @@ void CVideoDatabase::CreateViews() " GROUP BY tvshow.idShow"); m_pDS->exec(tvshowcounts.c_str()); - CLog::Log(LOGINFO, "create tvshowview"); - CStdString tvshowview = PrepareSQL("CREATE VIEW tvshowview AS SELECT " + CLog::Log(LOGINFO, "create tvshow_view"); + std::string tvshowview = PrepareSQL("CREATE VIEW tvshow_view AS SELECT " " tvshow.*," " path.idParentPath AS idParentPath," " path.strPath AS strPath," @@ -442,33 +380,33 @@ void CVideoDatabase::CreateViews() "GROUP BY tvshow.idShow"); m_pDS->exec(tvshowview.c_str()); - CLog::Log(LOGINFO, "create seasonview"); - CStdString seasonview = PrepareSQL("CREATE VIEW seasonview AS SELECT " + CLog::Log(LOGINFO, "create season_view"); + std::string seasonview = PrepareSQL("CREATE VIEW season_view AS SELECT " " seasons.*, " - " tvshowview.strPath AS strPath," - " tvshowview.c%02d AS showTitle," - " tvshowview.c%02d AS plot," - " tvshowview.c%02d AS premiered," - " tvshowview.c%02d AS genre," - " tvshowview.c%02d AS strStudio," - " tvshowview.c%02d AS mpaa," - " count(DISTINCT episodeview.idEpisode) AS episodes," + " tvshow_view.strPath AS strPath," + " tvshow_view.c%02d AS showTitle," + " tvshow_view.c%02d AS plot," + " tvshow_view.c%02d AS premiered," + " tvshow_view.c%02d AS genre," + " tvshow_view.c%02d AS studio," + " tvshow_view.c%02d AS mpaa," + " count(DISTINCT episode_view.idEpisode) AS episodes," " count(files.playCount) AS playCount " "FROM seasons" - " JOIN tvshowview ON" - " tvshowview.idShow = seasons.idShow" - " JOIN episodeview ON" - " episodeview.idShow = seasons.idShow AND episodeview.c%02d = seasons.season" + " JOIN tvshow_view ON" + " tvshow_view.idShow = seasons.idShow" + " JOIN episode_view ON" + " episode_view.idShow = seasons.idShow AND episode_view.c%02d = seasons.season" " JOIN files ON" - " files.idFile = episodeview.idFile " + " files.idFile = episode_view.idFile " "GROUP BY seasons.idSeason", VIDEODB_ID_TV_TITLE, VIDEODB_ID_TV_PLOT, VIDEODB_ID_TV_PREMIERED, VIDEODB_ID_TV_GENRE, VIDEODB_ID_TV_STUDIOS, VIDEODB_ID_TV_MPAA, VIDEODB_ID_EPISODE_SEASON); m_pDS->exec(seasonview.c_str()); - CLog::Log(LOGINFO, "create musicvideoview"); - m_pDS->exec("CREATE VIEW musicvideoview AS SELECT" + CLog::Log(LOGINFO, "create musicvideo_view"); + m_pDS->exec("CREATE VIEW musicvideo_view AS SELECT" " musicvideo.*," " files.strFileName as strFileName," " path.strPath as strPath," @@ -485,8 +423,8 @@ void CVideoDatabase::CreateViews() " LEFT JOIN bookmark ON" " bookmark.idFile=musicvideo.idFile AND bookmark.type=1"); - CLog::Log(LOGINFO, "create movieview"); - m_pDS->exec("CREATE VIEW movieview AS SELECT" + CLog::Log(LOGINFO, "create movie_view"); + m_pDS->exec("CREATE VIEW movie_view AS SELECT" " movie.*," " sets.strSet AS strSet," " files.strFileName AS strFileName," @@ -508,16 +446,16 @@ void CVideoDatabase::CreateViews() } //******************************************************************************************************************************** -int CVideoDatabase::GetPathId(const CStdString& strPath) +int CVideoDatabase::GetPathId(const std::string& strPath) { - CStdString strSQL; + std::string strSQL; try { int idPath=-1; if (NULL == m_pDB.get()) return -1; if (NULL == m_pDS.get()) return -1; - CStdString strPath1(strPath); + std::string strPath1(strPath); if (URIUtils::IsStack(strPath) || StringUtils::StartsWithNoCase(strPath, "rar://") || StringUtils::StartsWithNoCase(strPath, "zip://")) URIUtils::GetParentPath(strPath,strPath1); @@ -538,7 +476,7 @@ int CVideoDatabase::GetPathId(const CStdString& strPath) return -1; } -bool CVideoDatabase::GetPaths(set<CStdString> &paths) +bool CVideoDatabase::GetPaths(set<std::string> &paths) { try { @@ -631,7 +569,7 @@ bool CVideoDatabase::GetPathsLinkedToTvShow(int idShow, vector<string> &paths) bool CVideoDatabase::GetPathsForTvShow(int idShow, set<int>& paths) { - CStdString strSQL; + std::string strSQL; try { if (NULL == m_pDB.get()) return false; @@ -653,7 +591,7 @@ bool CVideoDatabase::GetPathsForTvShow(int idShow, set<int>& paths) return false; } -int CVideoDatabase::RunQuery(const CStdString &sql) +int CVideoDatabase::RunQuery(const std::string &sql) { unsigned int time = XbmcThreads::SystemClockMillis(); int rows = -1; @@ -667,15 +605,15 @@ int CVideoDatabase::RunQuery(const CStdString &sql) return rows; } -bool CVideoDatabase::GetSubPaths(const CStdString &basepath, vector< pair<int,string> >& subpaths) +bool CVideoDatabase::GetSubPaths(const std::string &basepath, vector< pair<int,string> >& subpaths) { - CStdString sql; + std::string sql; try { if (!m_pDB.get() || !m_pDS.get()) return false; - CStdString path(basepath); + std::string path(basepath); URIUtils::AddSlashAtEnd(path); sql = PrepareSQL("SELECT idPath,strPath FROM path WHERE SUBSTR(strPath,1,%i)='%s'" " AND idPath NOT IN (SELECT idPath FROM files WHERE strFileName LIKE 'video_ts.ifo')" @@ -698,9 +636,9 @@ bool CVideoDatabase::GetSubPaths(const CStdString &basepath, vector< pair<int,st return false; } -int CVideoDatabase::AddPath(const CStdString& strPath, const CStdString &parentPath /*= "" */, const CStdString &strDateAdded /*= "" */) +int CVideoDatabase::AddPath(const std::string& strPath, const std::string &parentPath /*= "" */, const std::string &strDateAdded /*= "" */) { - CStdString strSQL; + std::string strSQL; try { int idPath = GetPathId(strPath); @@ -710,13 +648,13 @@ int CVideoDatabase::AddPath(const CStdString& strPath, const CStdString &parentP if (NULL == m_pDB.get()) return -1; if (NULL == m_pDS.get()) return -1; - CStdString strPath1(strPath); + std::string strPath1(strPath); if (URIUtils::IsStack(strPath) || StringUtils::StartsWithNoCase(strPath, "rar://") || StringUtils::StartsWithNoCase(strPath, "zip://")) URIUtils::GetParentPath(strPath,strPath1); URIUtils::AddSlashAtEnd(strPath1); - int idParentPath = GetPathId(parentPath.empty() ? (CStdString)URIUtils::GetParentPath(strPath1) : parentPath); + int idParentPath = GetPathId(parentPath.empty() ? (std::string)URIUtils::GetParentPath(strPath1) : parentPath); // add the path if (idParentPath < 0) @@ -744,14 +682,14 @@ int CVideoDatabase::AddPath(const CStdString& strPath, const CStdString &parentP return -1; } -bool CVideoDatabase::GetPathHash(const CStdString &path, CStdString &hash) +bool CVideoDatabase::GetPathHash(const std::string &path, std::string &hash) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL=PrepareSQL("select strHash from path where strPath='%s'", path.c_str()); + std::string strSQL=PrepareSQL("select strHash from path where strPath='%s'", path.c_str()); m_pDS->query(strSQL.c_str()); if (m_pDS->num_rows() == 0) return false; @@ -811,7 +749,7 @@ bool CVideoDatabase::GetSourcePath(const std::string &path, std::string &sourceP } // look for parent paths until there is one which is a source - CStdString strParent; + std::string strParent; bool found = false; while (URIUtils::GetParentPath(strPath1, strParent)) { @@ -849,23 +787,23 @@ bool CVideoDatabase::GetSourcePath(const std::string &path, std::string &sourceP } //******************************************************************************************************************************** -int CVideoDatabase::AddFile(const CStdString& strFileNameAndPath) +int CVideoDatabase::AddFile(const std::string& strFileNameAndPath) { - CStdString strSQL = ""; + std::string strSQL = ""; try { int idFile; if (NULL == m_pDB.get()) return -1; if (NULL == m_pDS.get()) return -1; - CStdString strFileName, strPath; + std::string strFileName, strPath; SplitPath(strFileNameAndPath,strPath,strFileName); int idPath = AddPath(strPath); if (idPath < 0) return -1; - CStdString strSQL=PrepareSQL("select idFile from files where strFileName='%s' and idPath=%i", strFileName.c_str(),idPath); + std::string strSQL=PrepareSQL("select idFile from files where strFileName='%s' and idPath=%i", strFileName.c_str(),idPath); m_pDS->query(strSQL.c_str()); if (m_pDS->num_rows() > 0) @@ -900,18 +838,18 @@ int CVideoDatabase::AddFile(const CFileItem& item) return AddFile(item.GetPath()); } -void CVideoDatabase::UpdateFileDateAdded(int idFile, const CStdString& strFileNameAndPath) +void CVideoDatabase::UpdateFileDateAdded(int idFile, const std::string& strFileNameAndPath) { if (idFile < 0 || strFileNameAndPath.empty()) return; - CStdString strSQL = ""; + std::string strSQL = ""; try { if (NULL == m_pDB.get()) return; if (NULL == m_pDS.get()) return; - CStdString file = strFileNameAndPath; + std::string file = strFileNameAndPath; if (URIUtils::IsStack(strFileNameAndPath)) file = CStackDirectory::GetFirstStackedFile(strFileNameAndPath); @@ -973,7 +911,7 @@ void CVideoDatabase::UpdateFileDateAdded(int idFile, const CStdString& strFileNa } } -bool CVideoDatabase::SetPathHash(const CStdString &path, const CStdString &hash) +bool CVideoDatabase::SetPathHash(const std::string &path, const std::string &hash) { try { @@ -983,7 +921,7 @@ bool CVideoDatabase::SetPathHash(const CStdString &path, const CStdString &hash) int idPath = AddPath(path); if (idPath < 0) return false; - CStdString strSQL=PrepareSQL("update path set strHash='%s' where idPath=%ld", hash.c_str(), idPath); + std::string strSQL=PrepareSQL("update path set strHash='%s' where idPath=%ld", hash.c_str(), idPath); m_pDS->exec(strSQL.c_str()); return true; @@ -1005,12 +943,12 @@ bool CVideoDatabase::LinkMovieToTvshow(int idMovie, int idShow, bool bRemove) if (bRemove) // delete link { - CStdString strSQL=PrepareSQL("delete from movielinktvshow where idMovie=%i and idShow=%i", idMovie, idShow); + std::string strSQL=PrepareSQL("delete from movielinktvshow where idMovie=%i and idShow=%i", idMovie, idShow); m_pDS->exec(strSQL.c_str()); return true; } - CStdString strSQL=PrepareSQL("insert into movielinktvshow (idShow,idMovie) values (%i,%i)", idShow,idMovie); + std::string strSQL=PrepareSQL("insert into movielinktvshow (idShow,idMovie) values (%i,%i)", idShow,idMovie); m_pDS->exec(strSQL.c_str()); return true; @@ -1030,7 +968,7 @@ bool CVideoDatabase::IsLinkedToTvshow(int idMovie) if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL=PrepareSQL("select * from movielinktvshow where idMovie=%i", idMovie); + std::string strSQL=PrepareSQL("select * from movielinktvshow where idMovie=%i", idMovie); m_pDS->query(strSQL.c_str()); if (m_pDS->eof()) { @@ -1056,7 +994,7 @@ bool CVideoDatabase::GetLinksToTvShow(int idMovie, vector<int>& ids) if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL=PrepareSQL("select * from movielinktvshow where idMovie=%i", idMovie); + std::string strSQL=PrepareSQL("select * from movielinktvshow where idMovie=%i", idMovie); m_pDS2->query(strSQL.c_str()); while (!m_pDS2->eof()) { @@ -1077,19 +1015,19 @@ bool CVideoDatabase::GetLinksToTvShow(int idMovie, vector<int>& ids) //******************************************************************************************************************************** -int CVideoDatabase::GetFileId(const CStdString& strFilenameAndPath) +int CVideoDatabase::GetFileId(const std::string& strFilenameAndPath) { try { if (NULL == m_pDB.get()) return -1; if (NULL == m_pDS.get()) return -1; - CStdString strPath, strFileName; + std::string strPath, strFileName; SplitPath(strFilenameAndPath,strPath,strFileName); int idPath = GetPathId(strPath); if (idPath >= 0) { - CStdString strSQL; + std::string strSQL; strSQL=PrepareSQL("select idFile from files where strFileName='%s' and idPath=%i", strFileName.c_str(),idPath); m_pDS->query(strSQL.c_str()); if (m_pDS->num_rows() > 0) @@ -1120,7 +1058,7 @@ int CVideoDatabase::GetFileId(const CFileItem &item) } //******************************************************************************************************************************** -int CVideoDatabase::GetMovieId(const CStdString& strFilenameAndPath) +int CVideoDatabase::GetMovieId(const std::string& strFilenameAndPath) { try { @@ -1131,10 +1069,10 @@ int CVideoDatabase::GetMovieId(const CStdString& strFilenameAndPath) // needed for query parameters int idFile = GetFileId(strFilenameAndPath); int idPath=-1; - CStdString strPath; + std::string strPath; if (idFile < 0) { - CStdString strFile; + std::string strFile; SplitPath(strFilenameAndPath,strPath,strFile); // have to join movieinfo table for correct results @@ -1146,7 +1084,7 @@ int CVideoDatabase::GetMovieId(const CStdString& strFilenameAndPath) if (idFile == -1 && strPath != strFilenameAndPath) return -1; - CStdString strSQL; + std::string strSQL; if (idFile == -1) strSQL=PrepareSQL("select idMovie from movie join files on files.idFile=movie.idFile where files.idPath=%i",idPath); else @@ -1167,7 +1105,7 @@ int CVideoDatabase::GetMovieId(const CStdString& strFilenameAndPath) return -1; } -int CVideoDatabase::GetTvShowId(const CStdString& strPath) +int CVideoDatabase::GetTvShowId(const std::string& strPath) { try { @@ -1180,13 +1118,13 @@ int CVideoDatabase::GetTvShowId(const CStdString& strPath) if (idPath < 0) return -1; - CStdString strSQL; - CStdString strPath1=strPath; - CStdString strParent; + std::string strSQL; + std::string strPath1=strPath; + std::string strParent; int iFound=0; strSQL=PrepareSQL("select idShow from tvshowlinkpath where tvshowlinkpath.idPath=%i",idPath); - m_pDS->query(strSQL); + m_pDS->query(strSQL.c_str()); if (!m_pDS->eof()) iFound = 1; @@ -1216,7 +1154,7 @@ int CVideoDatabase::GetTvShowId(const CStdString& strPath) return -1; } -int CVideoDatabase::GetEpisodeId(const CStdString& strFilenameAndPath, int idEpisode, int idSeason) // input value is episode/season number hint - for multiparters +int CVideoDatabase::GetEpisodeId(const std::string& strFilenameAndPath, int idEpisode, int idSeason) // input value is episode/season number hint - for multiparters { try { @@ -1232,7 +1170,7 @@ int CVideoDatabase::GetEpisodeId(const CStdString& strFilenameAndPath, int idEpi if (idFile < 0) return -1; - CStdString strSQL=PrepareSQL("select idEpisode from episode where idFile=%i", idFile); + std::string strSQL=PrepareSQL("select idEpisode from episode where idFile=%i", idFile); CLog::Log(LOGDEBUG, "%s (%s), query = %s", __FUNCTION__, CURL::GetRedacted(strFilenameAndPath).c_str(), strSQL.c_str()); pDS->query(strSQL.c_str()); @@ -1272,7 +1210,7 @@ int CVideoDatabase::GetEpisodeId(const CStdString& strFilenameAndPath, int idEpi return -1; } -int CVideoDatabase::GetMusicVideoId(const CStdString& strFilenameAndPath) +int CVideoDatabase::GetMusicVideoId(const std::string& strFilenameAndPath) { try { @@ -1283,7 +1221,7 @@ int CVideoDatabase::GetMusicVideoId(const CStdString& strFilenameAndPath) if (idFile < 0) return -1; - CStdString strSQL=PrepareSQL("select idMVideo from musicvideo where idFile=%i", idFile); + std::string strSQL=PrepareSQL("select idMVideo from musicvideo where idFile=%i", idFile); CLog::Log(LOGDEBUG, "%s (%s), query = %s", __FUNCTION__, CURL::GetRedacted(strFilenameAndPath).c_str(), strSQL.c_str()); m_pDS->query(strSQL.c_str()); @@ -1302,7 +1240,7 @@ int CVideoDatabase::GetMusicVideoId(const CStdString& strFilenameAndPath) } //******************************************************************************************************************************** -int CVideoDatabase::AddMovie(const CStdString& strFilenameAndPath) +int CVideoDatabase::AddMovie(const std::string& strFilenameAndPath) { try { @@ -1316,7 +1254,7 @@ int CVideoDatabase::AddMovie(const CStdString& strFilenameAndPath) if (idFile < 0) return -1; UpdateFileDateAdded(idFile, strFilenameAndPath); - CStdString strSQL=PrepareSQL("insert into movie (idMovie, idFile) values (NULL, %i)", idFile); + std::string strSQL=PrepareSQL("insert into movie (idMovie, idFile) values (NULL, %i)", idFile); m_pDS->exec(strSQL.c_str()); idMovie = (int)m_pDS->lastinsertid(); } @@ -1379,7 +1317,7 @@ int CVideoDatabase::AddTvShow() } //******************************************************************************************************************************** -int CVideoDatabase::AddEpisode(int idShow, const CStdString& strFilenameAndPath) +int CVideoDatabase::AddEpisode(int idShow, const std::string& strFilenameAndPath) { try { @@ -1391,7 +1329,7 @@ int CVideoDatabase::AddEpisode(int idShow, const CStdString& strFilenameAndPath) return -1; UpdateFileDateAdded(idFile, strFilenameAndPath); - CStdString strSQL=PrepareSQL("insert into episode (idEpisode, idFile, idShow) values (NULL, %i, %i)", idFile, idShow); + std::string strSQL=PrepareSQL("insert into episode (idEpisode, idFile, idShow) values (NULL, %i, %i)", idFile, idShow); m_pDS->exec(strSQL.c_str()); return (int)m_pDS->lastinsertid(); } @@ -1402,7 +1340,7 @@ int CVideoDatabase::AddEpisode(int idShow, const CStdString& strFilenameAndPath) return -1; } -int CVideoDatabase::AddMusicVideo(const CStdString& strFilenameAndPath) +int CVideoDatabase::AddMusicVideo(const std::string& strFilenameAndPath) { try { @@ -1416,7 +1354,7 @@ int CVideoDatabase::AddMusicVideo(const CStdString& strFilenameAndPath) if (idFile < 0) return -1; UpdateFileDateAdded(idFile, strFilenameAndPath); - CStdString strSQL=PrepareSQL("insert into musicvideo (idMVideo, idFile) values (NULL, %i)", idFile); + std::string strSQL=PrepareSQL("insert into musicvideo (idMVideo, idFile) values (NULL, %i)", idFile); m_pDS->exec(strSQL.c_str()); idMVideo = (int)m_pDS->lastinsertid(); } @@ -1431,14 +1369,14 @@ int CVideoDatabase::AddMusicVideo(const CStdString& strFilenameAndPath) } //******************************************************************************************************************************** -int CVideoDatabase::AddToTable(const CStdString& table, const CStdString& firstField, const CStdString& secondField, const CStdString& value) +int CVideoDatabase::AddToTable(const std::string& table, const std::string& firstField, const std::string& secondField, const std::string& value) { try { if (NULL == m_pDB.get()) return -1; if (NULL == m_pDS.get()) return -1; - CStdString strSQL = PrepareSQL("select %s from %s where %s like '%s'", firstField.c_str(), table.c_str(), secondField.c_str(), value.c_str()); + std::string strSQL = PrepareSQL("select %s from %s where %s like '%s'", firstField.c_str(), table.c_str(), secondField.c_str(), value.c_str()); m_pDS->query(strSQL.c_str()); if (m_pDS->num_rows() == 0) { @@ -1451,7 +1389,7 @@ int CVideoDatabase::AddToTable(const CStdString& table, const CStdString& firstF } else { - int id = m_pDS->fv(firstField).get_asInt(); + int id = m_pDS->fv(firstField.c_str()).get_asInt(); m_pDS->close(); return id; } @@ -1464,7 +1402,7 @@ int CVideoDatabase::AddToTable(const CStdString& table, const CStdString& firstF return -1; } -int CVideoDatabase::AddSet(const CStdString& strSet) +int CVideoDatabase::AddSet(const std::string& strSet) { if (strSet.empty()) return -1; @@ -1472,55 +1410,39 @@ int CVideoDatabase::AddSet(const CStdString& strSet) return AddToTable("sets", "idSet", "strSet", strSet); } -int CVideoDatabase::AddTag(const std::string& tag) +int CVideoDatabase::AddTag(const std::string& name) { - if (tag.empty()) + if (name.empty()) return -1; - return AddToTable("tag", "idTag", "strTag", tag); -} - -int CVideoDatabase::AddGenre(const CStdString& strGenre) -{ - return AddToTable("genre", "idGenre", "strGenre", strGenre); -} - -int CVideoDatabase::AddStudio(const CStdString& strStudio) -{ - return AddToTable("studio", "idStudio", "strStudio", strStudio); -} - -//******************************************************************************************************************************** -int CVideoDatabase::AddCountry(const CStdString& strCountry) -{ - return AddToTable("country", "idCountry", "strCountry", strCountry); + return AddToTable("tag", "tag_id", "name", name); } -int CVideoDatabase::AddActor(const CStdString& strActor, const CStdString& thumbURLs, const CStdString &thumb) +int CVideoDatabase::AddActor(const std::string& name, const std::string& thumbURLs, const std::string &thumb) { try { if (NULL == m_pDB.get()) return -1; if (NULL == m_pDS.get()) return -1; int idActor = -1; - CStdString strSQL=PrepareSQL("select idActor from actors where strActor like '%s'", strActor.c_str()); + std::string strSQL=PrepareSQL("select actor_id from actor where name like '%s'", name.c_str()); m_pDS->query(strSQL.c_str()); if (m_pDS->num_rows() == 0) { m_pDS->close(); // doesnt exists, add it - strSQL=PrepareSQL("insert into actors (idActor, strActor, strThumb) values( NULL, '%s','%s')", strActor.c_str(),thumbURLs.c_str()); + strSQL=PrepareSQL("insert into actor (actor_id, name, art_urls) values( NULL, '%s','%s')", name.c_str(),thumbURLs.c_str()); m_pDS->exec(strSQL.c_str()); idActor = (int)m_pDS->lastinsertid(); } else { - idActor = m_pDS->fv("idActor").get_asInt(); + idActor = m_pDS->fv(0).get_asInt(); m_pDS->close(); // update the thumb url's if (!thumbURLs.empty()) { - strSQL=PrepareSQL("update actors set strThumb='%s' where idActor=%i",thumbURLs.c_str(),idActor); + strSQL=PrepareSQL("update actor set art_urls='%s' where actor_id=%i",thumbURLs.c_str(),idActor); m_pDS->exec(strSQL.c_str()); } } @@ -1531,141 +1453,113 @@ int CVideoDatabase::AddActor(const CStdString& strActor, const CStdString& thumb } catch (...) { - CLog::Log(LOGERROR, "%s (%s) failed", __FUNCTION__, strActor.c_str() ); + CLog::Log(LOGERROR, "%s (%s) failed", __FUNCTION__, name.c_str() ); } return -1; } -void CVideoDatabase::AddLinkToActor(const char *table, int actorID, const char *field, int secondID, const CStdString &role, int order) +void CVideoDatabase::AddLinkToActor(int mediaId, const char *mediaType, int actorId, const std::string &role, int order) { - try - { - if (NULL == m_pDB.get()) return ; - if (NULL == m_pDS.get()) return ; + std::string sql=PrepareSQL("SELECT 1 FROM actor_link WHERE actor_id=%i AND media_id=%i AND media_type='%s'", actorId, mediaId, mediaType); - CStdString strSQL=PrepareSQL("select * from actorlink%s where idActor=%i and id%s=%i", table, actorID, field, secondID); - m_pDS->query(strSQL.c_str()); - if (m_pDS->num_rows() == 0) - { - // doesnt exists, add it - strSQL=PrepareSQL("insert into actorlink%s (idActor, id%s, strRole, iOrder) values(%i,%i,'%s',%i)", table, field, actorID, secondID, role.c_str(), order); - m_pDS->exec(strSQL.c_str()); - } - m_pDS->close(); - } - catch (...) - { - CLog::Log(LOGERROR, "%s failed", __FUNCTION__); + if (GetSingleValue(sql).empty()) + { // doesnt exists, add it + sql = PrepareSQL("INSERT INTO actor_link (actor_id, media_id, media_type, role, cast_order) VALUES(%i,%i,'%s','%s',%i)", actorId, mediaId, mediaType, role.c_str(), order); + ExecuteQuery(sql); } } -void CVideoDatabase::AddToLinkTable(const char *table, const char *firstField, int firstID, const char *secondField, int secondID, const char *typeField /* = NULL */, const char *type /* = NULL */) +void CVideoDatabase::AddToLinkTable(int mediaId, const std::string& mediaType, const std::string& table, int valueId, const char *foreignKey) { - try - { - if (NULL == m_pDB.get()) return ; - if (NULL == m_pDS.get()) return ; + const char *key = foreignKey ? foreignKey : table.c_str(); + std::string sql = PrepareSQL("SELECT 1 FROM %s_link WHERE %s_id=%i AND media_id=%i AND media_type='%s'", table.c_str(), key, valueId, mediaId, mediaType.c_str()); - CStdString strSQL = PrepareSQL("select * from %s where %s=%i and %s=%i", table, firstField, firstID, secondField, secondID); - if (typeField != NULL && type != NULL) - strSQL += PrepareSQL(" and %s='%s'", typeField, type); - m_pDS->query(strSQL.c_str()); - if (m_pDS->num_rows() == 0) - { - // doesnt exists, add it - if (typeField == NULL || type == NULL) - strSQL = PrepareSQL("insert into %s (%s,%s) values(%i,%i)", table, firstField, secondField, firstID, secondID); - else - strSQL = PrepareSQL("insert into %s (%s,%s,%s) values(%i,%i,'%s')", table, firstField, secondField, typeField, firstID, secondID, type); - m_pDS->exec(strSQL.c_str()); - } - m_pDS->close(); - } - catch (...) - { - CLog::Log(LOGERROR, "%s failed", __FUNCTION__); + if (GetSingleValue(sql).empty()) + { // doesnt exists, add it + sql = PrepareSQL("INSERT INTO %s_link (%s_id,media_id,media_type) VALUES(%i,%i,'%s')", table.c_str(), key, valueId, mediaId, mediaType.c_str()); + ExecuteQuery(sql); } } -void CVideoDatabase::RemoveFromLinkTable(const char *table, const char *firstField, int firstID, const char *secondField, int secondID, const char *typeField /* = NULL */, const char *type /* = NULL */) +void CVideoDatabase::RemoveFromLinkTable(int mediaId, const std::string& mediaType, const std::string& table, int valueId, const char *foreignKey) { - try - { - if (NULL == m_pDB.get()) return ; - if (NULL == m_pDS.get()) return ; + const char *key = foreignKey ? foreignKey : table.c_str(); + std::string sql = PrepareSQL("DELETE FROM %s_link WHERE %s_id=%i AND media_id=%i AND media_type='%s'", table.c_str(), key, valueId, mediaId, mediaType.c_str()); - CStdString strSQL = PrepareSQL("DELETE FROM %s WHERE %s = %i AND %s = %i", table, firstField, firstID, secondField, secondID); - if (typeField != NULL && type != NULL) - strSQL += PrepareSQL(" AND %s='%s'", typeField, type); - m_pDS->exec(strSQL.c_str()); - } - catch (...) - { - CLog::Log(LOGERROR, "%s failed", __FUNCTION__); - } + ExecuteQuery(sql); } -void CVideoDatabase::UpdateLinkTable(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values) +void CVideoDatabase::AddLinksToItem(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values) { - std::string sql = PrepareSQL("delete from %slink%s where id%s=%i", field.c_str(), mediaType.c_str(), mediaType.c_str(), mediaId); - m_pDS->exec(sql); - for (std::vector<std::string>::const_iterator i = values.begin(); i != values.end(); ++i) { if (!i->empty()) { - int idValue = AddToTable(field, "id" + field, "str" + field, *i); + int idValue = AddToTable(field, field + "_id", "name", *i); if (idValue > -1) - AddToLinkTable((field + "link" + mediaType).c_str(), ("id" + field).c_str(), idValue, ("id" + mediaType).c_str(), mediaId); + AddToLinkTable(mediaId, mediaType, field, idValue); } } } -void CVideoDatabase::UpdateActorLinkTable(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values) +void CVideoDatabase::UpdateLinksToItem(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values) { - std::string sql = PrepareSQL("delete from %slink%s where id%s=%i", field.c_str(), mediaType.c_str(), mediaType.c_str(), mediaId); + std::string sql = PrepareSQL("DELETE FROM %s_link WHERE media_id=%i AND media_type='%s'", field.c_str(), mediaId, mediaType.c_str()); m_pDS->exec(sql); + AddLinksToItem(mediaId, mediaType, field, values); +} + +void CVideoDatabase::AddActorLinksToItem(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values) +{ for (std::vector<std::string>::const_iterator i = values.begin(); i != values.end(); ++i) { if (!i->empty()) { int idValue = AddActor(*i, ""); if (idValue > -1) - AddToLinkTable((field + "link" + mediaType).c_str(), ("id" + field).c_str(), idValue, ("id" + mediaType).c_str(), mediaId); + AddToLinkTable(mediaId, mediaType, field, idValue, "actor"); } } } +void CVideoDatabase::UpdateActorLinksToItem(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values) +{ + std::string sql = PrepareSQL("DELETE FROM %s_link WHERE media_id=%i AND media_type='%s'", field.c_str(), mediaId, mediaType.c_str()); + m_pDS->exec(sql); + + AddActorLinksToItem(mediaId, mediaType, field, values); +} + //****Tags**** -void CVideoDatabase::AddTagToItem(int idMovie, int idTag, const std::string &type) +void CVideoDatabase::AddTagToItem(int media_id, int tag_id, const std::string &type) { if (type.empty()) return; - AddToLinkTable("taglinks", "idTag", idTag, "idMedia", idMovie, "media_type", type.c_str()); + AddToLinkTable(media_id, type, "tag", tag_id); } -void CVideoDatabase::RemoveTagFromItem(int idItem, int idTag, const std::string &type) +void CVideoDatabase::RemoveTagFromItem(int media_id, int tag_id, const std::string &type) { if (type.empty()) return; - RemoveFromLinkTable("taglinks", "idTag", idTag, "idMedia", idItem, "media_type", type.c_str()); + RemoveFromLinkTable(media_id, type, "tag", tag_id); } -void CVideoDatabase::RemoveTagsFromItem(int idItem, const std::string &type) +void CVideoDatabase::RemoveTagsFromItem(int media_id, const std::string &type) { if (type.empty()) return; - m_pDS2->exec(PrepareSQL("DELETE FROM taglinks WHERE idMedia=%d AND media_type='%s'", idItem, type.c_str())); + m_pDS2->exec(PrepareSQL("DELETE FROM tag_link WHERE media_id=%d AND media_type='%s'", media_id, type.c_str())); } //****Actors**** -void CVideoDatabase::AddCast(int idMedia, const char *table, const char *field, const std::vector< SActorInfo > &cast) +void CVideoDatabase::AddCast(int mediaId, const char *mediaType, const std::vector< SActorInfo > &cast) { if (cast.empty()) return; @@ -1674,86 +1568,12 @@ void CVideoDatabase::AddCast(int idMedia, const char *table, const char *field, for (CVideoInfoTag::iCast it = cast.begin(); it != cast.end(); ++it) { int idActor = AddActor(it->strName, it->thumbUrl.m_xml, it->thumb); - AddLinkToActor(table, idActor, field, idMedia, it->strRole, it->order >= 0 ? it->order : ++order); + AddLinkToActor(mediaId, mediaType, idActor, it->strRole, it->order >= 0 ? it->order : ++order); } } -void CVideoDatabase::AddArtistToMusicVideo(int idMVideo, int idArtist) -{ - AddToLinkTable("artistlinkmusicvideo", "idArtist", idArtist, "idMVideo", idMVideo); -} - -//****Directors + Writers**** -void CVideoDatabase::AddDirectorToMovie(int idMovie, int idDirector) -{ - AddToLinkTable("directorlinkmovie", "idDirector", idDirector, "idMovie", idMovie); -} - -void CVideoDatabase::AddDirectorToTvShow(int idTvShow, int idDirector) -{ - AddToLinkTable("directorlinktvshow", "idDirector", idDirector, "idShow", idTvShow); -} - -void CVideoDatabase::AddWriterToEpisode(int idEpisode, int idWriter) -{ - AddToLinkTable("writerlinkepisode", "idWriter", idWriter, "idEpisode", idEpisode); -} - -void CVideoDatabase::AddWriterToMovie(int idMovie, int idWriter) -{ - AddToLinkTable("writerlinkmovie", "idWriter", idWriter, "idMovie", idMovie); -} - -void CVideoDatabase::AddDirectorToEpisode(int idEpisode, int idDirector) -{ - AddToLinkTable("directorlinkepisode", "idDirector", idDirector, "idEpisode", idEpisode); -} - -void CVideoDatabase::AddDirectorToMusicVideo(int idMVideo, int idDirector) -{ - AddToLinkTable("directorlinkmusicvideo", "idDirector", idDirector, "idMVideo", idMVideo); -} - -//****Studios**** -void CVideoDatabase::AddStudioToMovie(int idMovie, int idStudio) -{ - AddToLinkTable("studiolinkmovie", "idStudio", idStudio, "idMovie", idMovie); -} - -void CVideoDatabase::AddStudioToTvShow(int idTvShow, int idStudio) -{ - AddToLinkTable("studiolinktvshow", "idStudio", idStudio, "idShow", idTvShow); -} - -void CVideoDatabase::AddStudioToMusicVideo(int idMVideo, int idStudio) -{ - AddToLinkTable("studiolinkmusicvideo", "idStudio", idStudio, "idMVideo", idMVideo); -} - -//****Genres**** -void CVideoDatabase::AddGenreToMovie(int idMovie, int idGenre) -{ - AddToLinkTable("genrelinkmovie", "idGenre", idGenre, "idMovie", idMovie); -} - -void CVideoDatabase::AddGenreToTvShow(int idTvShow, int idGenre) -{ - AddToLinkTable("genrelinktvshow", "idGenre", idGenre, "idShow", idTvShow); -} - -void CVideoDatabase::AddGenreToMusicVideo(int idMVideo, int idGenre) -{ - AddToLinkTable("genrelinkmusicvideo", "idGenre", idGenre, "idMVideo", idMVideo); -} - -//****Country**** -void CVideoDatabase::AddCountryToMovie(int idMovie, int idCountry) -{ - AddToLinkTable("countrylinkmovie", "idCountry", idCountry, "idMovie", idMovie); -} - //******************************************************************************************************************************** -bool CVideoDatabase::LoadVideoInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details) +bool CVideoDatabase::LoadVideoInfo(const std::string& strFilenameAndPath, CVideoInfoTag& details) { if (GetMovieInfo(strFilenameAndPath, details)) return true; @@ -1767,7 +1587,7 @@ bool CVideoDatabase::LoadVideoInfo(const CStdString& strFilenameAndPath, CVideoI return false; } -bool CVideoDatabase::HasMovieInfo(const CStdString& strFilenameAndPath) +bool CVideoDatabase::HasMovieInfo(const std::string& strFilenameAndPath) { try { @@ -1783,7 +1603,7 @@ bool CVideoDatabase::HasMovieInfo(const CStdString& strFilenameAndPath) return false; } -bool CVideoDatabase::HasTvShowInfo(const CStdString& strPath) +bool CVideoDatabase::HasTvShowInfo(const std::string& strPath) { try { @@ -1799,7 +1619,7 @@ bool CVideoDatabase::HasTvShowInfo(const CStdString& strPath) return false; } -bool CVideoDatabase::HasEpisodeInfo(const CStdString& strFilenameAndPath) +bool CVideoDatabase::HasEpisodeInfo(const std::string& strFilenameAndPath) { try { @@ -1815,7 +1635,7 @@ bool CVideoDatabase::HasEpisodeInfo(const CStdString& strFilenameAndPath) return false; } -bool CVideoDatabase::HasMusicVideoInfo(const CStdString& strFilenameAndPath) +bool CVideoDatabase::HasMusicVideoInfo(const std::string& strFilenameAndPath) { try { @@ -1831,7 +1651,7 @@ bool CVideoDatabase::HasMusicVideoInfo(const CStdString& strFilenameAndPath) return false; } -void CVideoDatabase::DeleteDetailsForTvShow(const CStdString& strPath) +void CVideoDatabase::DeleteDetailsForTvShow(const std::string& strPath) { int idTvShow = GetTvShowId(strPath); if (idTvShow >= 0) @@ -1845,17 +1665,17 @@ void CVideoDatabase::DeleteDetailsForTvShow(int idTvShow) if (NULL == m_pDB.get()) return ; if (NULL == m_pDS.get()) return ; - CStdString strSQL; - strSQL=PrepareSQL("delete from genrelinktvshow where idShow=%i", idTvShow); + std::string strSQL; + strSQL=PrepareSQL("DELETE from genre_link WHERE media_id=%i AND media_type='tvshow'", idTvShow); m_pDS->exec(strSQL.c_str()); - strSQL=PrepareSQL("delete from actorlinktvshow where idShow=%i", idTvShow); + strSQL=PrepareSQL("DELETE FROM actor_link WHERE media_id=%i AND media_type='tvshow'", idTvShow); m_pDS->exec(strSQL.c_str()); - strSQL=PrepareSQL("delete from directorlinktvshow where idShow=%i", idTvShow); + strSQL=PrepareSQL("DELETE FROM director_link WHERE media_id=%i AND media_type='tvshow'", idTvShow); m_pDS->exec(strSQL.c_str()); - strSQL=PrepareSQL("delete from studiolinktvshow where idShow=%i", idTvShow); + strSQL=PrepareSQL("DELETE FROM studio_link WHERE media_id=%i AND media_type='tvshow'", idTvShow); m_pDS->exec(strSQL.c_str()); // remove all info other than the id @@ -1877,42 +1697,42 @@ void CVideoDatabase::DeleteDetailsForTvShow(int idTvShow) } //******************************************************************************************************************************** -void CVideoDatabase::GetMoviesByActor(const CStdString& strActor, CFileItemList& items) +void CVideoDatabase::GetMoviesByActor(const std::string& name, CFileItemList& items) { Filter filter; - filter.join = "LEFT JOIN actorlinkmovie ON actorlinkmovie.idMovie=movieview.idMovie " - "LEFT JOIN actors a ON a.idActor=actorlinkmovie.idActor " - "LEFT JOIN directorlinkmovie ON directorlinkmovie.idMovie=movieview.idMovie " - "LEFT JOIN actors d ON d.idActor=directorlinkmovie.idDirector"; - filter.where = PrepareSQL("a.strActor='%s' OR d.strActor='%s'", strActor.c_str(), strActor.c_str()); - filter.group = "movieview.idMovie"; + filter.join = "LEFT JOIN actor_link ON actor_link.media_id=movie_view.idMovie AND actor_link.media_type='movie' " + "LEFT JOIN actor a ON a.actor_id=actor_link.actor_id " + "LEFT JOIN director_link ON director_link.media_id=movie_view.idMovie AND director_link.media_type='movie' " + "LEFT JOIN actor d ON d.actor_id=director_link.actor_id"; + filter.where = PrepareSQL("a.name='%s' OR d.name='%s'", name.c_str(), name.c_str()); + filter.group = "movie_view.idMovie"; GetMoviesByWhere("videodb://movies/titles/", filter, items); } -void CVideoDatabase::GetTvShowsByActor(const CStdString& strActor, CFileItemList& items) +void CVideoDatabase::GetTvShowsByActor(const std::string& name, CFileItemList& items) { Filter filter; - filter.join = "LEFT JOIN actorlinktvshow ON actorlinktvshow.idShow=tvshowview.idShow " - "LEFT JOIN actors a ON a.idActor=actorlinktvshow.idActor " - "LEFT JOIN directorlinktvshow ON directorlinktvshow.idShow=tvshowview.idShow " - "LEFT JOIN actors d ON d.idActor=directorlinktvshow.idDirector"; - filter.where = PrepareSQL("a.strActor='%s' OR d.strActor='%s'", strActor.c_str(), strActor.c_str()); + filter.join = "LEFT JOIN actor_link ON actor_link.media_id=tvshow_view.idShow AND actor_link.media_type='tvshow' " + "LEFT JOIN actor a ON a.actor_id=actor_link.actor_id " + "LEFT JOIN director_link ON director_link.media_id=tvshow_view.idShow AND director_link.media_type='tvshow' " + "LEFT JOIN actor d ON d.actor_id=director_link.actor_id"; + filter.where = PrepareSQL("a.name='%s' OR d.name='%s'", name.c_str(), name.c_str()); GetTvShowsByWhere("videodb://tvshows/titles/", filter, items); } -void CVideoDatabase::GetEpisodesByActor(const CStdString& strActor, CFileItemList& items) +void CVideoDatabase::GetEpisodesByActor(const std::string& name, CFileItemList& items) { Filter filter; - filter.join = "LEFT JOIN actorlinkepisode ON actorlinkepisode.idEpisode=episodeview.idEpisode " - "LEFT JOIN actors a ON a.idActor=actorlinkepisode.idActor " - "LEFT JOIN directorlinkepisode ON directorlinkepisode.idEpisode=episodeview.idEpisode " - "LEFT JOIN actors d ON d.idActor=directorlinkepisode.idDirector"; - filter.where = PrepareSQL("a.strActor='%s' OR d.strActor='%s'", strActor.c_str(), strActor.c_str()); - filter.group = "episodeview.idEpisode"; + filter.join = "LEFT JOIN actor_link ON actor_link.media_id=episode_view.idEpisode AND actor_link.media_type='episode' " + "LEFT JOIN actor a ON a.actor_id=actor_link.actor_id " + "LEFT JOIN director_link ON director_link.media_id=episode_view.idEpisode AND director_link.media_type='episode' " + "LEFT JOIN actor d ON d.actor_id=director_link.actor_id"; + filter.where = PrepareSQL("a.name='%s' OR d.name='%s'", name.c_str(), name.c_str()); + filter.group = "episode_view.idEpisode"; GetEpisodesByWhere("videodb://tvshows/titles/", filter, items); } -void CVideoDatabase::GetMusicVideosByArtist(const CStdString& strArtist, CFileItemList& items) +void CVideoDatabase::GetMusicVideosByArtist(const std::string& strArtist, CFileItemList& items) { try { @@ -1920,11 +1740,11 @@ void CVideoDatabase::GetMusicVideosByArtist(const CStdString& strArtist, CFileIt if (NULL == m_pDB.get()) return ; if (NULL == m_pDS.get()) return ; - CStdString strSQL; + std::string strSQL; if (strArtist.empty()) // TODO: SMARTPLAYLISTS what is this here for??? - strSQL=PrepareSQL("select distinct * from musicvideoview join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo=musicvideoview.idMVideo join actors on actors.idActor=artistlinkmusicvideo.idArtist"); + strSQL=PrepareSQL("select distinct * from musicvideo_view join actor_link on actor_link.media_id=musicvideo_view.idMVideo AND actor_link.media_type='musicvideo' join actor on actor.actor_id=actor_link.actor_id"); else - strSQL=PrepareSQL("select * from musicvideoview join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo=musicvideoview.idMVideo join actors on actors.idActor=artistlinkmusicvideo.idArtist where actors.strActor='%s'", strArtist.c_str()); + strSQL=PrepareSQL("select * from musicvideo_view join actor_link on actor_link.media_id=musicvideo_view.idMVideo AND actor_link.media_type='musicvideo' join actor on actor.actor_id=actor_link.actor_id where actor.name='%s'", strArtist.c_str()); m_pDS->query( strSQL.c_str() ); while (!m_pDS->eof()) @@ -1944,7 +1764,7 @@ void CVideoDatabase::GetMusicVideosByArtist(const CStdString& strArtist, CFileIt } //******************************************************************************************************************************** -bool CVideoDatabase::GetMovieInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details, int idMovie /* = -1 */) +bool CVideoDatabase::GetMovieInfo(const std::string& strFilenameAndPath, CVideoInfoTag& details, int idMovie /* = -1 */) { try { @@ -1953,7 +1773,7 @@ bool CVideoDatabase::GetMovieInfo(const CStdString& strFilenameAndPath, CVideoIn idMovie = GetMovieId(strFilenameAndPath); if (idMovie < 0) return false; - CStdString sql = PrepareSQL("select * from movieview where idMovie=%i", idMovie); + std::string sql = PrepareSQL("select * from movie_view where idMovie=%i", idMovie); if (!m_pDS->query(sql.c_str())) return false; details = GetDetailsForMovie(m_pDS, true); @@ -1967,7 +1787,7 @@ bool CVideoDatabase::GetMovieInfo(const CStdString& strFilenameAndPath, CVideoIn } //******************************************************************************************************************************** -bool CVideoDatabase::GetTvShowInfo(const CStdString& strPath, CVideoInfoTag& details, int idTvShow /* = -1 */, CFileItem *item /* = NULL */) +bool CVideoDatabase::GetTvShowInfo(const std::string& strPath, CVideoInfoTag& details, int idTvShow /* = -1 */, CFileItem *item /* = NULL */) { try { @@ -1975,7 +1795,7 @@ bool CVideoDatabase::GetTvShowInfo(const CStdString& strPath, CVideoInfoTag& det idTvShow = GetTvShowId(strPath); if (idTvShow < 0) return false; - CStdString sql = PrepareSQL("SELECT * FROM tvshowview WHERE idShow=%i GROUP BY idShow", idTvShow); + std::string sql = PrepareSQL("SELECT * FROM tvshow_view WHERE idShow=%i GROUP BY idShow", idTvShow); if (!m_pDS->query(sql.c_str())) return false; details = GetDetailsForTvShow(m_pDS, true, item); @@ -1998,7 +1818,7 @@ bool CVideoDatabase::GetSeasonInfo(int idSeason, CVideoInfoTag& details) if (!m_pDB.get() || !m_pDS.get()) return false; - CStdString sql = PrepareSQL("SELECT idShow FROM seasons WHERE idSeason=%i", idSeason); + std::string sql = PrepareSQL("SELECT idShow FROM seasons WHERE idSeason=%i", idSeason); if (!m_pDS->query(sql.c_str())) return false; @@ -2032,7 +1852,7 @@ bool CVideoDatabase::GetSeasonInfo(int idSeason, CVideoInfoTag& details) return false; } -bool CVideoDatabase::GetEpisodeInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details, int idEpisode /* = -1 */) +bool CVideoDatabase::GetEpisodeInfo(const std::string& strFilenameAndPath, CVideoInfoTag& details, int idEpisode /* = -1 */) { try { @@ -2041,7 +1861,7 @@ bool CVideoDatabase::GetEpisodeInfo(const CStdString& strFilenameAndPath, CVideo idEpisode = GetEpisodeId(strFilenameAndPath); if (idEpisode < 0) return false; - CStdString sql = PrepareSQL("select * from episodeview where idEpisode=%i",idEpisode); + std::string sql = PrepareSQL("select * from episode_view where idEpisode=%i",idEpisode); if (!m_pDS->query(sql.c_str())) return false; details = GetDetailsForEpisode(m_pDS, true); @@ -2054,7 +1874,7 @@ bool CVideoDatabase::GetEpisodeInfo(const CStdString& strFilenameAndPath, CVideo return false; } -bool CVideoDatabase::GetMusicVideoInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details, int idMVideo /* = -1 */) +bool CVideoDatabase::GetMusicVideoInfo(const std::string& strFilenameAndPath, CVideoInfoTag& details, int idMVideo /* = -1 */) { try { @@ -2063,7 +1883,7 @@ bool CVideoDatabase::GetMusicVideoInfo(const CStdString& strFilenameAndPath, CVi idMVideo = GetMusicVideoId(strFilenameAndPath); if (idMVideo < 0) return false; - CStdString sql = PrepareSQL("select * from musicvideoview where idMVideo=%i", idMVideo); + std::string sql = PrepareSQL("select * from musicvideo_view where idMVideo=%i", idMVideo); if (!m_pDS->query(sql.c_str())) return false; details = GetDetailsForMusicVideo(m_pDS, true); @@ -2101,7 +1921,7 @@ bool CVideoDatabase::GetSetInfo(int idSet, CVideoInfoTag& details) return false; } -bool CVideoDatabase::GetFileInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details, int idFile /* = -1 */) +bool CVideoDatabase::GetFileInfo(const std::string& strFilenameAndPath, CVideoInfoTag& details, int idFile /* = -1 */) { try { @@ -2110,7 +1930,7 @@ bool CVideoDatabase::GetFileInfo(const CStdString& strFilenameAndPath, CVideoInf if (idFile < 0) return false; - CStdString sql = PrepareSQL("SELECT * FROM files " + std::string sql = PrepareSQL("SELECT * FROM files " "JOIN path ON path.idPath = files.idPath " "LEFT JOIN bookmark ON bookmark.idFile = files.idFile AND bookmark.type = %i " "WHERE files.idFile = %i", CBookmark::RESUME, idFile); @@ -2119,7 +1939,7 @@ bool CVideoDatabase::GetFileInfo(const CStdString& strFilenameAndPath, CVideoInf details.m_iFileId = m_pDS->fv("files.idFile").get_asInt(); details.m_strPath = m_pDS->fv("path.strPath").get_asString(); - CStdString strFileName = m_pDS->fv("files.strFilename").get_asString(); + std::string strFileName = m_pDS->fv("files.strFilename").get_asString(); ConstructPath(details.m_strFileNameAndPath, details.m_strPath, strFileName); details.m_playCount = max(details.m_playCount, m_pDS->fv("files.playCount").get_asInt()); if (!details.m_lastPlayed.IsValid()) @@ -2145,21 +1965,7 @@ bool CVideoDatabase::GetFileInfo(const CStdString& strFilenameAndPath, CVideoInf return false; } -void CVideoDatabase::AddGenreAndDirectorsAndStudios(const CVideoInfoTag& details, vector<int>& vecDirectors, vector<int>& vecGenres, vector<int>& vecStudios) -{ - // add all directors - for (unsigned int i = 0; i < details.m_director.size(); i++) - vecDirectors.push_back(AddActor(details.m_director[i],"")); - - // add all genres - for (unsigned int i = 0; i < details.m_genre.size(); i++) - vecGenres.push_back(AddGenre(details.m_genre[i])); - // add all studios - for (unsigned int i = 0; i < details.m_studio.size(); i++) - vecStudios.push_back(AddStudio(details.m_studio[i])); -} - -CStdString CVideoDatabase::GetValueString(const CVideoInfoTag &details, int min, int max, const SDbTableOffsets *offsets) const +std::string CVideoDatabase::GetValueString(const CVideoInfoTag &details, int min, int max, const SDbTableOffsets *offsets) const { std::vector<std::string> conditions; for (int i = min + 1; i < max; ++i) @@ -2167,7 +1973,7 @@ CStdString CVideoDatabase::GetValueString(const CVideoInfoTag &details, int min, switch (offsets[i].type) { case VIDEODB_TYPE_STRING: - conditions.push_back(PrepareSQL("c%02d='%s'", i, ((CStdString*)(((char*)&details)+offsets[i].offset))->c_str())); + conditions.push_back(PrepareSQL("c%02d='%s'", i, ((std::string*)(((char*)&details)+offsets[i].offset))->c_str())); break; case VIDEODB_TYPE_INT: conditions.push_back(PrepareSQL("c%02d='%i'", i, *(int*)(((char*)&details)+offsets[i].offset))); @@ -2203,7 +2009,7 @@ CStdString CVideoDatabase::GetValueString(const CVideoInfoTag &details, int min, } //******************************************************************************************************************************** -int CVideoDatabase::SetDetailsForMovie(const CStdString& strFilenameAndPath, const CVideoInfoTag& details, const map<string, string> &artwork, int idMovie /* = -1 */) +int CVideoDatabase::SetDetailsForMovie(const std::string& strFilenameAndPath, const CVideoInfoTag& details, const map<string, string> &artwork, int idMovie /* = -1 */) { try { @@ -2227,25 +2033,13 @@ int CVideoDatabase::SetDetailsForMovie(const CStdString& strFilenameAndPath, con } } - vector<int> vecDirectors; - vector<int> vecGenres; - vector<int> vecStudios; - AddGenreAndDirectorsAndStudios(details,vecDirectors,vecGenres,vecStudios); - - for (unsigned int i = 0; i < vecGenres.size(); ++i) - AddGenreToMovie(idMovie, vecGenres[i]); - - for (unsigned int i = 0; i < vecDirectors.size(); ++i) - AddDirectorToMovie(idMovie, vecDirectors[i]); - - for (unsigned int i = 0; i < vecStudios.size(); ++i) - AddStudioToMovie(idMovie, vecStudios[i]); - - // add writers... - for (unsigned int i = 0; i < details.m_writingCredits.size(); i++) - AddWriterToMovie(idMovie, AddActor(details.m_writingCredits[i],"")); - - AddCast(idMovie, "movie", "movie", details.m_cast); + AddCast(idMovie, "movie", details.m_cast); + AddLinksToItem(idMovie, MediaTypeMovie, "genre", details.m_genre); + AddLinksToItem(idMovie, MediaTypeMovie, "studio", details.m_studio); + AddLinksToItem(idMovie, MediaTypeMovie, "country", details.m_country); + AddLinksToItem(idMovie, MediaTypeMovie, "tag", details.m_tags); + AddActorLinksToItem(idMovie, MediaTypeMovie, "director", details.m_director); + AddActorLinksToItem(idMovie, MediaTypeMovie, "writer", details.m_writingCredits); // add set... int idSet = -1; @@ -2258,17 +2052,6 @@ int CVideoDatabase::SetDetailsForMovie(const CStdString& strFilenameAndPath, con SetArtForItem(idSet, MediaTypeVideoCollection, artwork); } - // add tags... - for (unsigned int i = 0; i < details.m_tags.size(); i++) - { - int idTag = AddTag(details.m_tags[i]); - AddTagToItem(idMovie, idTag, MediaTypeMovie); - } - - // add countries... - for (unsigned int i = 0; i < details.m_country.size(); i++) - AddCountryToMovie(idMovie, AddCountry(details.m_country[i])); - if (details.HasStreamDetails()) SetStreamDetailsForFileId(details.m_streamDetails, GetFileId(strFilenameAndPath)); @@ -2276,7 +2059,7 @@ int CVideoDatabase::SetDetailsForMovie(const CStdString& strFilenameAndPath, con if (!details.m_strIMDBNumber.empty() && details.m_iYear) { // query DB for any movies matching imdbid and year - CStdString strSQL = PrepareSQL("select files.playCount, files.lastPlayed from movie,files where files.idFile=movie.idFile and movie.c%02d='%s' and movie.c%02d=%i and movie.idMovie!=%i and files.playCount > 0", VIDEODB_ID_IDENT, details.m_strIMDBNumber.c_str(), VIDEODB_ID_YEAR, details.m_iYear, idMovie); + std::string strSQL = PrepareSQL("select files.playCount, files.lastPlayed from movie,files where files.idFile=movie.idFile and movie.c%02d='%s' and movie.c%02d=%i and movie.idMovie!=%i and files.playCount > 0", VIDEODB_ID_IDENT, details.m_strIMDBNumber.c_str(), VIDEODB_ID_YEAR, details.m_iYear, idMovie); m_pDS->query(strSQL.c_str()); if (!m_pDS->eof()) @@ -2297,7 +2080,7 @@ int CVideoDatabase::SetDetailsForMovie(const CStdString& strFilenameAndPath, con } // update our movie table (we know it was added already above) // and insert the new row - CStdString sql = "update movie set " + GetValueString(details, VIDEODB_ID_MIN, VIDEODB_ID_MAX, DbMovieOffsets); + std::string sql = "update movie set " + GetValueString(details, VIDEODB_ID_MIN, VIDEODB_ID_MAX, DbMovieOffsets); if (idSet > 0) sql += PrepareSQL(", idSet = %i", idSet); else @@ -2329,23 +2112,19 @@ int CVideoDatabase::UpdateDetailsForMovie(int idMovie, const CVideoInfoTag& deta // process the link table updates if (updatedDetails.find("genre") != updatedDetails.end()) - UpdateLinkTable(idMovie, "movie", "genre", details.m_genre); + UpdateLinksToItem(idMovie, MediaTypeMovie, "genre", details.m_genre); if (updatedDetails.find("studio") != updatedDetails.end()) - UpdateLinkTable(idMovie, "movie", "studio", details.m_studio); + UpdateLinksToItem(idMovie, MediaTypeMovie, "studio", details.m_studio); if (updatedDetails.find("country") != updatedDetails.end()) - UpdateLinkTable(idMovie, "movie", "country", details.m_country); + UpdateLinksToItem(idMovie, MediaTypeMovie, "country", details.m_country); + if (updatedDetails.find("tag") != updatedDetails.end()) + UpdateLinksToItem(idMovie, MediaTypeMovie, "tag", details.m_tags); if (updatedDetails.find("director") != updatedDetails.end()) - UpdateActorLinkTable(idMovie, "movie", "director", details.m_director); + UpdateActorLinksToItem(idMovie, MediaTypeMovie, "director", details.m_director); if (updatedDetails.find("writer") != updatedDetails.end()) - UpdateActorLinkTable(idMovie, "movie", "writer", details.m_writingCredits); - if (updatedDetails.find("tag") != updatedDetails.end()) - { - RemoveTagsFromItem(idMovie, "movie"); - for (unsigned int i = 0; i < details.m_tags.size(); i++) - AddTagToItem(idMovie, AddTag(details.m_tags[i]), "movie"); - } + UpdateActorLinksToItem(idMovie, MediaTypeMovie, "writer", details.m_writingCredits); if (updatedDetails.find("art.altered") != updatedDetails.end()) - SetArtForItem(idMovie, "movie", artwork); + SetArtForItem(idMovie, MediaTypeMovie, artwork); // track if the set was updated int idSet = 0; @@ -2406,7 +2185,7 @@ int CVideoDatabase::SetDetailsForMovieSet(const CVideoInfoTag& details, const st SetArtForItem(idSet, MediaTypeVideoCollection, artwork); // and insert the new row - CStdString sql = PrepareSQL("UPDATE sets SET strSet='%s' WHERE idSet=%i", details.m_strTitle.c_str(), idSet); + std::string sql = PrepareSQL("UPDATE sets SET strSet='%s' WHERE idSet=%i", details.m_strTitle.c_str(), idSet); m_pDS->exec(sql.c_str()); CommitTransaction(); @@ -2476,29 +2255,11 @@ bool CVideoDatabase::UpdateDetailsForTvShow(int idTvShow, const CVideoInfoTag &d DeleteDetailsForTvShow(idTvShow); - vector<int> vecDirectors; - vector<int> vecGenres; - vector<int> vecStudios; - AddGenreAndDirectorsAndStudios(details,vecDirectors,vecGenres,vecStudios); - - AddCast(idTvShow, "tvshow", "show", details.m_cast); - - unsigned int i; - for (i = 0; i < vecGenres.size(); ++i) - AddGenreToTvShow(idTvShow, vecGenres[i]); - - for (i = 0; i < vecDirectors.size(); ++i) - AddDirectorToTvShow(idTvShow, vecDirectors[i]); - - for (i = 0; i < vecStudios.size(); ++i) - AddStudioToTvShow(idTvShow, vecStudios[i]); - - // add tags... - for (unsigned int i = 0; i < details.m_tags.size(); i++) - { - int idTag = AddTag(details.m_tags[i]); - AddTagToItem(idTvShow, idTag, MediaTypeTvShow); - } + AddCast(idTvShow, "tvshow", details.m_cast); + AddLinksToItem(idTvShow, MediaTypeTvShow, "genre", details.m_genre); + AddLinksToItem(idTvShow, MediaTypeTvShow, "studio", details.m_studio); + AddLinksToItem(idTvShow, MediaTypeTvShow, "tag", details.m_tags); + AddActorLinksToItem(idTvShow, MediaTypeTvShow, "director", details.m_director); // add "all seasons" - the rest are added in SetDetailsForEpisode AddSeason(idTvShow, -1); @@ -2544,7 +2305,7 @@ int CVideoDatabase::SetDetailsForSeason(const CVideoInfoTag& details, const std: SetArtForItem(idSeason, MediaTypeSeason, artwork); // and insert the new row - CStdString sql = PrepareSQL("UPDATE seasons SET season=%i WHERE idSeason=%i", details.m_iSeason, idSeason); + std::string sql = PrepareSQL("UPDATE seasons SET season=%i WHERE idSeason=%i", details.m_iSeason, idSeason); m_pDS->exec(sql.c_str()); CommitTransaction(); @@ -2558,7 +2319,7 @@ int CVideoDatabase::SetDetailsForSeason(const CVideoInfoTag& details, const std: return -1; } -int CVideoDatabase::SetDetailsForEpisode(const CStdString& strFilenameAndPath, const CVideoInfoTag& details, const map<string, string> &artwork, int idShow, int idEpisode) +int CVideoDatabase::SetDetailsForEpisode(const std::string& strFilenameAndPath, const CVideoInfoTag& details, const map<string, string> &artwork, int idShow, int idEpisode) { try { @@ -2581,21 +2342,9 @@ int CVideoDatabase::SetDetailsForEpisode(const CStdString& strFilenameAndPath, c } } - vector<int> vecDirectors; - vector<int> vecGenres; - vector<int> vecStudios; - AddGenreAndDirectorsAndStudios(details,vecDirectors,vecGenres,vecStudios); - - AddCast(idEpisode, "episode", "episode", details.m_cast); - - // add writers... - for (unsigned int i = 0; i < details.m_writingCredits.size(); i++) - AddWriterToEpisode(idEpisode, AddActor(details.m_writingCredits[i],"")); - - for (unsigned int i = 0; i < vecDirectors.size(); ++i) - { - AddDirectorToEpisode(idEpisode, vecDirectors[i]); - } + AddCast(idEpisode, "episode", details.m_cast); + AddActorLinksToItem(idEpisode, MediaTypeEpisode, "director", details.m_director); + AddActorLinksToItem(idEpisode, MediaTypeEpisode, "writer", details.m_writingCredits); if (details.HasStreamDetails()) { @@ -2612,7 +2361,7 @@ int CVideoDatabase::SetDetailsForEpisode(const CStdString& strFilenameAndPath, c if (details.m_iEpisode != -1 && details.m_iSeason != -1) { // query DB for any episodes matching idShow, Season and Episode - CStdString strSQL = PrepareSQL("select files.playCount, files.lastPlayed from episode, files where files.idFile=episode.idFile and episode.c%02d=%i and episode.c%02d=%i AND episode.idShow=%i and episode.idEpisode!=%i and files.playCount > 0",VIDEODB_ID_EPISODE_SEASON, details.m_iSeason, VIDEODB_ID_EPISODE_EPISODE, details.m_iEpisode, idShow, idEpisode); + std::string strSQL = PrepareSQL("select files.playCount, files.lastPlayed from episode, files where files.idFile=episode.idFile and episode.c%02d=%i and episode.c%02d=%i AND episode.idShow=%i and episode.idEpisode!=%i and files.playCount > 0",VIDEODB_ID_EPISODE_SEASON, details.m_iSeason, VIDEODB_ID_EPISODE_EPISODE, details.m_iEpisode, idShow, idEpisode); m_pDS->query(strSQL.c_str()); if (!m_pDS->eof()) @@ -2632,7 +2381,7 @@ int CVideoDatabase::SetDetailsForEpisode(const CStdString& strFilenameAndPath, c m_pDS->close(); } // and insert the new row - CStdString sql = "update episode set " + GetValueString(details, VIDEODB_ID_EPISODE_MIN, VIDEODB_ID_EPISODE_MAX, DbEpisodeOffsets); + std::string sql = "update episode set " + GetValueString(details, VIDEODB_ID_EPISODE_MIN, VIDEODB_ID_EPISODE_MAX, DbEpisodeOffsets); sql += PrepareSQL(" where idEpisode=%i", idEpisode); m_pDS->exec(sql.c_str()); CommitTransaction(); @@ -2649,8 +2398,8 @@ int CVideoDatabase::SetDetailsForEpisode(const CStdString& strFilenameAndPath, c int CVideoDatabase::GetSeasonId(int showID, int season) { - CStdString sql = PrepareSQL("idShow=%i AND season=%i", showID, season); - CStdString id = GetSingleValue("seasons", "idSeason", sql); + std::string sql = PrepareSQL("idShow=%i AND season=%i", showID, season); + std::string id = GetSingleValue("seasons", "idSeason", sql); if (id.empty()) return -1; return strtol(id.c_str(), NULL, 10); @@ -2667,7 +2416,7 @@ int CVideoDatabase::AddSeason(int showID, int season) return seasonId; } -int CVideoDatabase::SetDetailsForMusicVideo(const CStdString& strFilenameAndPath, const CVideoInfoTag& details, const map<string, string> &artwork, int idMVideo /* = -1 */) +int CVideoDatabase::SetDetailsForMusicVideo(const std::string& strFilenameAndPath, const CVideoInfoTag& details, const map<string, string> &artwork, int idMVideo /* = -1 */) { try { @@ -2691,45 +2440,11 @@ int CVideoDatabase::SetDetailsForMusicVideo(const CStdString& strFilenameAndPath } } - vector<int> vecDirectors; - vector<int> vecGenres; - vector<int> vecStudios; - AddGenreAndDirectorsAndStudios(details,vecDirectors,vecGenres,vecStudios); - - // add artists... - if (!details.m_artist.empty()) - { - for (unsigned int i = 0; i < details.m_artist.size(); i++) - { - CStdString artist = details.m_artist[i]; - StringUtils::Trim(artist); - int idArtist = AddActor(artist,""); - AddArtistToMusicVideo(idMVideo, idArtist); - } - } - - unsigned int i; - for (i = 0; i < vecGenres.size(); ++i) - { - AddGenreToMusicVideo(idMVideo, vecGenres[i]); - } - - for (i = 0; i < vecDirectors.size(); ++i) - { - AddDirectorToMusicVideo(idMVideo, vecDirectors[i]); - } - - for (i = 0; i < vecStudios.size(); ++i) - { - AddStudioToMusicVideo(idMVideo, vecStudios[i]); - } - - // add tags... - for (unsigned int i = 0; i < details.m_tags.size(); i++) - { - int idTag = AddTag(details.m_tags[i]); - AddTagToItem(idMVideo, idTag, MediaTypeMusicVideo); - } + AddActorLinksToItem(idMVideo, MediaTypeMusicVideo, "actor", details.m_artist); + AddActorLinksToItem(idMVideo, MediaTypeMusicVideo, "director", details.m_director); + AddLinksToItem(idMVideo, MediaTypeMusicVideo, "genre", details.m_genre); + AddLinksToItem(idMVideo, MediaTypeMusicVideo, "studio", details.m_studio); + AddLinksToItem(idMVideo, MediaTypeMusicVideo, "tag", details.m_tags); if (details.HasStreamDetails()) SetStreamDetailsForFileId(details.m_streamDetails, GetFileId(strFilenameAndPath)); @@ -2738,7 +2453,7 @@ int CVideoDatabase::SetDetailsForMusicVideo(const CStdString& strFilenameAndPath // update our movie table (we know it was added already above) // and insert the new row - CStdString sql = "update musicvideo set " + GetValueString(details, VIDEODB_ID_MUSICVIDEO_MIN, VIDEODB_ID_MUSICVIDEO_MAX, DbMusicVideoOffsets); + std::string sql = "update musicvideo set " + GetValueString(details, VIDEODB_ID_MUSICVIDEO_MIN, VIDEODB_ID_MUSICVIDEO_MAX, DbMusicVideoOffsets); sql += PrepareSQL(" where idMVideo=%i", idMVideo); m_pDS->exec(sql.c_str()); CommitTransaction(); @@ -2753,7 +2468,7 @@ int CVideoDatabase::SetDetailsForMusicVideo(const CStdString& strFilenameAndPath return -1; } -void CVideoDatabase::SetStreamDetailsForFile(const CStreamDetails& details, const CStdString &strFileNameAndPath) +void CVideoDatabase::SetStreamDetailsForFile(const CStreamDetails& details, const std::string &strFileNameAndPath) { // AddFile checks to make sure the file isn't already in the DB first int idFile = AddFile(strFileNameAndPath); @@ -2809,7 +2524,7 @@ void CVideoDatabase::SetStreamDetailsForFileId(const CStreamDetails& details, in tables.push_back(make_pair("musicvideo", VIDEODB_ID_MUSICVIDEO_RUNTIME)); for (vector< pair<string, int> >::iterator i = tables.begin(); i != tables.end(); ++i) { - CStdString sql = PrepareSQL("update %s set c%02d=%d where idFile=%d and c%02d=''", + std::string sql = PrepareSQL("update %s set c%02d=%d where idFile=%d and c%02d=''", i->first.c_str(), i->second, details.GetVideoDuration(), idFile, i->second); m_pDS->exec(sql); } @@ -2825,7 +2540,7 @@ void CVideoDatabase::SetStreamDetailsForFileId(const CStreamDetails& details, in } //******************************************************************************************************************************** -void CVideoDatabase::GetFilePathById(int idMovie, CStdString &filePath, VIDEODB_CONTENT_TYPE iType) +void CVideoDatabase::GetFilePathById(int idMovie, std::string &filePath, VIDEODB_CONTENT_TYPE iType) { try { @@ -2834,7 +2549,7 @@ void CVideoDatabase::GetFilePathById(int idMovie, CStdString &filePath, VIDEODB_ if (idMovie < 0) return ; - CStdString strSQL; + std::string strSQL; if (iType == VIDEODB_CONTENT_MOVIES) strSQL=PrepareSQL("select path.strPath,files.strFileName from path, files, movie where path.idPath=files.idPath and files.idFile=movie.idFile and movie.idMovie=%i order by strFilename", idMovie ); if (iType == VIDEODB_CONTENT_EPISODES) @@ -2849,7 +2564,7 @@ void CVideoDatabase::GetFilePathById(int idMovie, CStdString &filePath, VIDEODB_ { if (iType != VIDEODB_CONTENT_TVSHOWS) { - CStdString fileName = m_pDS->fv("files.strFilename").get_asString(); + std::string fileName = m_pDS->fv("files.strFilename").get_asString(); ConstructPath(filePath,m_pDS->fv("path.strPath").get_asString(),fileName); } else @@ -2864,7 +2579,7 @@ void CVideoDatabase::GetFilePathById(int idMovie, CStdString &filePath, VIDEODB_ } //******************************************************************************************************************************** -void CVideoDatabase::GetBookMarksForFile(const CStdString& strFilenameAndPath, VECBOOKMARKS& bookmarks, CBookmark::EType type /*= CBookmark::STANDARD*/, bool bAppend, long partNumber) +void CVideoDatabase::GetBookMarksForFile(const std::string& strFilenameAndPath, VECBOOKMARKS& bookmarks, CBookmark::EType type /*= CBookmark::STANDARD*/, bool bAppend, long partNumber) { try { @@ -2888,7 +2603,7 @@ void CVideoDatabase::GetBookMarksForFile(const CStdString& strFilenameAndPath, V if (NULL == m_pDB.get()) return ; if (NULL == m_pDS.get()) return ; - CStdString strSQL=PrepareSQL("select * from bookmark where idFile=%i and type=%i order by timeInSeconds", idFile, (int)type); + std::string strSQL=PrepareSQL("select * from bookmark where idFile=%i and type=%i order by timeInSeconds", idFile, (int)type); m_pDS->query( strSQL.c_str() ); while (!m_pDS->eof()) { @@ -2902,7 +2617,7 @@ void CVideoDatabase::GetBookMarksForFile(const CStdString& strFilenameAndPath, V bookmark.type = type; if (type == CBookmark::EPISODE) { - CStdString strSQL2=PrepareSQL("select c%02d, c%02d from episode where c%02d=%i order by c%02d, c%02d", VIDEODB_ID_EPISODE_EPISODE, VIDEODB_ID_EPISODE_SEASON, VIDEODB_ID_EPISODE_BOOKMARK, m_pDS->fv("idBookmark").get_asInt(), VIDEODB_ID_EPISODE_SORTSEASON, VIDEODB_ID_EPISODE_SORTEPISODE); + std::string strSQL2=PrepareSQL("select c%02d, c%02d from episode where c%02d=%i order by c%02d, c%02d", VIDEODB_ID_EPISODE_EPISODE, VIDEODB_ID_EPISODE_SEASON, VIDEODB_ID_EPISODE_BOOKMARK, m_pDS->fv("idBookmark").get_asInt(), VIDEODB_ID_EPISODE_SORTSEASON, VIDEODB_ID_EPISODE_SORTEPISODE); m_pDS2->query(strSQL2.c_str()); bookmark.episodeNumber = m_pDS2->fv(0).get_asInt(); bookmark.seasonNumber = m_pDS2->fv(1).get_asInt(); @@ -2921,7 +2636,7 @@ void CVideoDatabase::GetBookMarksForFile(const CStdString& strFilenameAndPath, V } } -bool CVideoDatabase::GetResumeBookMark(const CStdString& strFilenameAndPath, CBookmark &bookmark) +bool CVideoDatabase::GetResumeBookMark(const std::string& strFilenameAndPath, CBookmark &bookmark) { VECBOOKMARKS bookmarks; GetBookMarksForFile(strFilenameAndPath, bookmarks, CBookmark::RESUME); @@ -2933,7 +2648,7 @@ bool CVideoDatabase::GetResumeBookMark(const CStdString& strFilenameAndPath, CBo return false; } -void CVideoDatabase::DeleteResumeBookMark(const CStdString &strFilenameAndPath) +void CVideoDatabase::DeleteResumeBookMark(const std::string &strFilenameAndPath) { if (!m_pDB.get() || !m_pDS.get()) return; @@ -2944,7 +2659,7 @@ void CVideoDatabase::DeleteResumeBookMark(const CStdString &strFilenameAndPath) try { - CStdString sql = PrepareSQL("delete from bookmark where idFile=%i and type=%i", fileID, CBookmark::RESUME); + std::string sql = PrepareSQL("delete from bookmark where idFile=%i and type=%i", fileID, CBookmark::RESUME); m_pDS->exec(sql.c_str()); } catch(...) @@ -2953,11 +2668,11 @@ void CVideoDatabase::DeleteResumeBookMark(const CStdString &strFilenameAndPath) } } -void CVideoDatabase::GetEpisodesByFile(const CStdString& strFilenameAndPath, vector<CVideoInfoTag>& episodes) +void CVideoDatabase::GetEpisodesByFile(const std::string& strFilenameAndPath, vector<CVideoInfoTag>& episodes) { try { - CStdString strSQL = PrepareSQL("select * from episodeview where idFile=%i order by c%02d, c%02d asc", GetFileId(strFilenameAndPath), VIDEODB_ID_EPISODE_SORTSEASON, VIDEODB_ID_EPISODE_SORTEPISODE); + std::string strSQL = PrepareSQL("select * from episode_view where idFile=%i order by c%02d, c%02d asc", GetFileId(strFilenameAndPath), VIDEODB_ID_EPISODE_SORTSEASON, VIDEODB_ID_EPISODE_SORTEPISODE); m_pDS->query(strSQL.c_str()); while (!m_pDS->eof()) { @@ -2973,7 +2688,7 @@ void CVideoDatabase::GetEpisodesByFile(const CStdString& strFilenameAndPath, vec } //******************************************************************************************************************************** -void CVideoDatabase::AddBookMarkToFile(const CStdString& strFilenameAndPath, const CBookmark &bookmark, CBookmark::EType type /*= CBookmark::STANDARD*/) +void CVideoDatabase::AddBookMarkToFile(const std::string& strFilenameAndPath, const CBookmark &bookmark, CBookmark::EType type /*= CBookmark::STANDARD*/) { try { @@ -2983,7 +2698,7 @@ void CVideoDatabase::AddBookMarkToFile(const CStdString& strFilenameAndPath, con if (NULL == m_pDB.get()) return ; if (NULL == m_pDS.get()) return ; - CStdString strSQL; + std::string strSQL; int idBookmark=-1; if (type == CBookmark::RESUME) // get the same resume mark bookmark each time type { @@ -3019,7 +2734,7 @@ void CVideoDatabase::AddBookMarkToFile(const CStdString& strFilenameAndPath, con } } -void CVideoDatabase::ClearBookMarkOfFile(const CStdString& strFilenameAndPath, CBookmark& bookmark, CBookmark::EType type /*= CBookmark::STANDARD*/) +void CVideoDatabase::ClearBookMarkOfFile(const std::string& strFilenameAndPath, CBookmark& bookmark, CBookmark::EType type /*= CBookmark::STANDARD*/) { try { @@ -3032,7 +2747,7 @@ void CVideoDatabase::ClearBookMarkOfFile(const CStdString& strFilenameAndPath, C /* should be no problem since we never add bookmarks that are closer than that */ double mintime = bookmark.timeInSeconds - 0.5f; double maxtime = bookmark.timeInSeconds + 0.5f; - CStdString strSQL = PrepareSQL("select idBookmark from bookmark where idFile=%i and type=%i and playerState like '%s' and player like '%s' and (timeInSeconds between %f and %f)", idFile, type, bookmark.playerState.c_str(), bookmark.player.c_str(), mintime, maxtime); + std::string strSQL = PrepareSQL("select idBookmark from bookmark where idFile=%i and type=%i and playerState like '%s' and player like '%s' and (timeInSeconds between %f and %f)", idFile, type, bookmark.playerState.c_str(), bookmark.player.c_str(), mintime, maxtime); m_pDS->query( strSQL.c_str() ); if (m_pDS->num_rows() != 0) @@ -3056,7 +2771,7 @@ void CVideoDatabase::ClearBookMarkOfFile(const CStdString& strFilenameAndPath, C } //******************************************************************************************************************************** -void CVideoDatabase::ClearBookMarksOfFile(const CStdString& strFilenameAndPath, CBookmark::EType type /*= CBookmark::STANDARD*/) +void CVideoDatabase::ClearBookMarksOfFile(const std::string& strFilenameAndPath, CBookmark::EType type /*= CBookmark::STANDARD*/) { int idFile = GetFileId(strFilenameAndPath); if (idFile >= 0) @@ -3073,7 +2788,7 @@ void CVideoDatabase::ClearBookMarksOfFile(int idFile, CBookmark::EType type /*= if (NULL == m_pDB.get()) return ; if (NULL == m_pDS.get()) return ; - CStdString strSQL=PrepareSQL("delete from bookmark where idFile=%i and type=%i", idFile, (int)type); + std::string strSQL=PrepareSQL("delete from bookmark where idFile=%i and type=%i", idFile, (int)type); m_pDS->exec(strSQL.c_str()); if (type == CBookmark::EPISODE) { @@ -3092,7 +2807,7 @@ bool CVideoDatabase::GetBookMarkForEpisode(const CVideoInfoTag& tag, CBookmark& { try { - CStdString strSQL = PrepareSQL("select bookmark.* from bookmark join episode on episode.c%02d=bookmark.idBookmark where episode.idEpisode=%i", VIDEODB_ID_EPISODE_BOOKMARK, tag.m_iDbId); + std::string strSQL = PrepareSQL("select bookmark.* from bookmark join episode on episode.c%02d=bookmark.idBookmark where episode.idEpisode=%i", VIDEODB_ID_EPISODE_BOOKMARK, tag.m_iDbId); m_pDS->query( strSQL.c_str() ); if (!m_pDS->eof()) { @@ -3124,7 +2839,7 @@ void CVideoDatabase::AddBookMarkForEpisode(const CVideoInfoTag& tag, const CBook { int idFile = GetFileId(tag.m_strFileNameAndPath); // delete the current episode for the selected episode number - CStdString strSQL = PrepareSQL("delete from bookmark where idBookmark in (select c%02d from episode where c%02d=%i and c%02d=%i and idFile=%i)", VIDEODB_ID_EPISODE_BOOKMARK, VIDEODB_ID_EPISODE_SEASON, tag.m_iSeason, VIDEODB_ID_EPISODE_EPISODE, tag.m_iEpisode, idFile); + std::string strSQL = PrepareSQL("delete from bookmark where idBookmark in (select c%02d from episode where c%02d=%i and c%02d=%i and idFile=%i)", VIDEODB_ID_EPISODE_BOOKMARK, VIDEODB_ID_EPISODE_SEASON, tag.m_iSeason, VIDEODB_ID_EPISODE_EPISODE, tag.m_iEpisode, idFile); m_pDS->exec(strSQL.c_str()); AddBookMarkToFile(tag.m_strFileNameAndPath, bookmark, CBookmark::EPISODE); @@ -3142,7 +2857,7 @@ void CVideoDatabase::DeleteBookMarkForEpisode(const CVideoInfoTag& tag) { try { - CStdString strSQL = PrepareSQL("delete from bookmark where idBookmark in (select c%02d from episode where idEpisode=%i)", VIDEODB_ID_EPISODE_BOOKMARK, tag.m_iDbId); + std::string strSQL = PrepareSQL("delete from bookmark where idBookmark in (select c%02d from episode where idEpisode=%i)", VIDEODB_ID_EPISODE_BOOKMARK, tag.m_iDbId); m_pDS->exec(strSQL.c_str()); strSQL = PrepareSQL("update episode set c%02d=-1 where idEpisode=%i", VIDEODB_ID_EPISODE_BOOKMARK, tag.m_iDbId); m_pDS->exec(strSQL.c_str()); @@ -3154,7 +2869,7 @@ void CVideoDatabase::DeleteBookMarkForEpisode(const CVideoInfoTag& tag) } //******************************************************************************************************************************** -void CVideoDatabase::DeleteMovie(const CStdString& strFilenameAndPath, bool bKeepId /* = false */) +void CVideoDatabase::DeleteMovie(const std::string& strFilenameAndPath, bool bKeepId /* = false */) { int idMovie = GetMovieId(strFilenameAndPath); if (idMovie > -1) @@ -3173,25 +2888,6 @@ void CVideoDatabase::DeleteMovie(int idMovie, bool bKeepId /* = false */) BeginTransaction(); - CStdString strSQL; - strSQL=PrepareSQL("delete from genrelinkmovie where idMovie=%i", idMovie); - m_pDS->exec(strSQL.c_str()); - - strSQL=PrepareSQL("delete from actorlinkmovie where idMovie=%i", idMovie); - m_pDS->exec(strSQL.c_str()); - - strSQL=PrepareSQL("delete from directorlinkmovie where idMovie=%i", idMovie); - m_pDS->exec(strSQL.c_str()); - - strSQL=PrepareSQL("delete from studiolinkmovie where idMovie=%i", idMovie); - m_pDS->exec(strSQL.c_str()); - - strSQL=PrepareSQL("delete from countrylinkmovie where idMovie=%i", idMovie); - m_pDS->exec(strSQL.c_str()); - - strSQL=PrepareSQL("delete from writerlinkmovie where idMovie=%i", idMovie); - m_pDS->exec(strSQL.c_str()); - // keep the movie table entry, linking to tv shows, and bookmarks // so we can update the data in place // the ancilliary tables are still purged @@ -3202,11 +2898,11 @@ void CVideoDatabase::DeleteMovie(int idMovie, bool bKeepId /* = false */) if (!path.empty()) InvalidatePathHash(path); - strSQL=PrepareSQL("delete from movie where idMovie=%i", idMovie); + std::string strSQL = PrepareSQL("delete from movie where idMovie=%i", idMovie); m_pDS->exec(strSQL.c_str()); } - //TODO: move this below CommitTransaction() once UPnP doesn't rely on this anymore + // TODO: move this below CommitTransaction() once UPnP doesn't rely on this anymore if (!bKeepId) AnnounceRemove(MediaTypeMovie, idMovie); @@ -3220,7 +2916,7 @@ void CVideoDatabase::DeleteMovie(int idMovie, bool bKeepId /* = false */) } } -void CVideoDatabase::DeleteTvShow(const CStdString& strPath) +void CVideoDatabase::DeleteTvShow(const std::string& strPath) { int idTvShow = GetTvShowId(strPath); if (idTvShow >= 0) @@ -3239,7 +2935,10 @@ void CVideoDatabase::DeleteTvShow(int idTvShow, bool bKeepId /* = false */) BeginTransaction(); - CStdString strSQL=PrepareSQL("SELECT episode.idEpisode FROM episode WHERE episode.idShow=%i",idTvShow); + set<int> paths; + GetPathsForTvShow(idTvShow, paths); + + std::string strSQL=PrepareSQL("SELECT episode.idEpisode FROM episode WHERE episode.idShow=%i",idTvShow); m_pDS2->query(strSQL.c_str()); while (!m_pDS2->eof()) { @@ -3258,15 +2957,6 @@ void CVideoDatabase::DeleteTvShow(int idTvShow, bool bKeepId /* = false */) strSQL=PrepareSQL("delete from tvshow where idShow=%i", idTvShow); m_pDS->exec(strSQL.c_str()); - strSQL=PrepareSQL("delete from tvshowlinkpath where idShow=%i", idTvShow); - m_pDS->exec(strSQL.c_str()); - - strSQL=PrepareSQL("delete from movielinktvshow where idShow=%i", idTvShow); - m_pDS->exec(strSQL.c_str()); - - // TODO: why do we invalidate the path hash here?? - set<int> paths; - GetPathsForTvShow(idTvShow, paths); for (set<int>::const_iterator i = paths.begin(); i != paths.end(); ++i) { std::string path = GetSingleValue(PrepareSQL("SELECT strPath FROM path WHERE idPath=%i", *i)); @@ -3303,8 +2993,8 @@ void CVideoDatabase::DeleteSeason(int idSeason, bool bKeepId /* = false */) BeginTransaction(); - CStdString strSQL = PrepareSQL("SELECT episode.idEpisode FROM episode " - "JOIN seasons ON seasons.idSeason = %d AND episode.idShow = seasons.idShow AND episode.c%02d = seasons.season ", + std::string strSQL = PrepareSQL("SELECT episode.idEpisode FROM episode " + "JOIN seasons ON seasons.idSeason = %d AND episode.idShow = seasons.idShow AND episode.c%02d = seasons.season ", idSeason, VIDEODB_ID_EPISODE_SEASON); m_pDS2->query(strSQL.c_str()); while (!m_pDS2->eof()) @@ -3324,7 +3014,7 @@ void CVideoDatabase::DeleteSeason(int idSeason, bool bKeepId /* = false */) } } -void CVideoDatabase::DeleteEpisode(const CStdString& strFilenameAndPath, bool bKeepId /* = false */) +void CVideoDatabase::DeleteEpisode(const std::string& strFilenameAndPath, bool bKeepId /* = false */) { int idEpisode = GetEpisodeId(strFilenameAndPath); if (idEpisode > -1) @@ -3345,21 +3035,16 @@ void CVideoDatabase::DeleteEpisode(int idEpisode, bool bKeepId /* = false */) if (!bKeepId) AnnounceRemove(MediaTypeEpisode, idEpisode); - CStdString strSQL; - strSQL=PrepareSQL("delete from actorlinkepisode where idEpisode=%i", idEpisode); - m_pDS->exec(strSQL.c_str()); - - strSQL=PrepareSQL("delete from directorlinkepisode where idEpisode=%i", idEpisode); - m_pDS->exec(strSQL.c_str()); - - strSQL=PrepareSQL("delete from writerlinkepisode where idEpisode=%i", idEpisode); - m_pDS->exec(strSQL.c_str()); - // keep episode table entry and bookmarks so we can update the data in place // the ancilliary tables are still purged if (!bKeepId) { - strSQL=PrepareSQL("delete from episode where idEpisode=%i", idEpisode); + int idFile = GetDbId(PrepareSQL("SELECT idFile FROM episode WHERE idEpisode=%i", idEpisode)); + std::string path = GetSingleValue(PrepareSQL("SELECT strPath FROM path JOIN files ON files.idPath=path.idPath WHERE files.idFile=%i", idFile)); + if (!path.empty()) + InvalidatePathHash(path); + + std::string strSQL = PrepareSQL("delete from episode where idEpisode=%i", idEpisode); m_pDS->exec(strSQL.c_str()); } @@ -3370,7 +3055,7 @@ void CVideoDatabase::DeleteEpisode(int idEpisode, bool bKeepId /* = false */) } } -void CVideoDatabase::DeleteMusicVideo(const CStdString& strFilenameAndPath, bool bKeepId /* = false */) +void CVideoDatabase::DeleteMusicVideo(const std::string& strFilenameAndPath, bool bKeepId /* = false */) { int idMVideo = GetMusicVideoId(strFilenameAndPath); if (idMVideo > -1) @@ -3389,19 +3074,6 @@ void CVideoDatabase::DeleteMusicVideo(int idMVideo, bool bKeepId /* = false */) BeginTransaction(); - CStdString strSQL; - strSQL=PrepareSQL("delete from genrelinkmusicvideo where idMVideo=%i", idMVideo); - m_pDS->exec(strSQL.c_str()); - - strSQL=PrepareSQL("delete from artistlinkmusicvideo where idMVideo=%i", idMVideo); - m_pDS->exec(strSQL.c_str()); - - strSQL=PrepareSQL("delete from directorlinkmusicvideo where idMVideo=%i", idMVideo); - m_pDS->exec(strSQL.c_str()); - - strSQL=PrepareSQL("delete from studiolinkmusicvideo where idMVideo=%i", idMVideo); - m_pDS->exec(strSQL.c_str()); - // keep the music video table entry and bookmarks so we can update data in place // the ancilliary tables are still purged if (!bKeepId) @@ -3411,7 +3083,7 @@ void CVideoDatabase::DeleteMusicVideo(int idMVideo, bool bKeepId /* = false */) if (!path.empty()) InvalidatePathHash(path); - strSQL=PrepareSQL("delete from musicvideo where idMVideo=%i", idMVideo); + std::string strSQL = PrepareSQL("delete from musicvideo where idMVideo=%i", idMVideo); m_pDS->exec(strSQL.c_str()); } @@ -3453,7 +3125,7 @@ void CVideoDatabase::DeleteSet(int idSet) if (NULL == m_pDB.get()) return ; if (NULL == m_pDS.get()) return ; - CStdString strSQL; + std::string strSQL; strSQL=PrepareSQL("delete from sets where idSet = %i", idSet); m_pDS->exec(strSQL.c_str()); strSQL=PrepareSQL("update movie set idSet = null where idSet = %i", idSet); @@ -3495,8 +3167,7 @@ void CVideoDatabase::DeleteTag(int idTag, VIDEODB_CONTENT_TYPE mediaType) else return; - CStdString strSQL; - strSQL = PrepareSQL("DELETE FROM taglinks WHERE idTag = %i AND media_type = '%s'", idTag, type.c_str()); + std::string strSQL = PrepareSQL("DELETE FROM tag_link WHERE tag_id = %i AND media_type = '%s'", idTag, type.c_str()); m_pDS->exec(strSQL.c_str()); } catch (...) @@ -3517,7 +3188,7 @@ void CVideoDatabase::GetDetailsFromDB(const dbiplus::sql_record* const record, i switch (offsets[i].type) { case VIDEODB_TYPE_STRING: - *(CStdString*)(((char*)&details)+offsets[i].offset) = record->at(i+idxOffset).get_asString(); + *(std::string*)(((char*)&details)+offsets[i].offset) = record->at(i+idxOffset).get_asString(); break; case VIDEODB_TYPE_INT: case VIDEODB_TYPE_COUNT: @@ -3530,8 +3201,12 @@ void CVideoDatabase::GetDetailsFromDB(const dbiplus::sql_record* const record, i *(float*)(((char*)&details)+offsets[i].offset) = record->at(i+idxOffset).get_asFloat(); break; case VIDEODB_TYPE_STRINGARRAY: - *(std::vector<std::string>*)(((char*)&details)+offsets[i].offset) = StringUtils::Split(record->at(i+idxOffset).get_asString(), g_advancedSettings.m_videoItemSeparator); + { + std::string value = record->at(i+idxOffset).get_asString(); + if (!value.empty()) + *(std::vector<std::string>*)(((char*)&details)+offsets[i].offset) = StringUtils::Split(value, g_advancedSettings.m_videoItemSeparator); break; + } case VIDEODB_TYPE_DATE: ((CDateTime*)(((char*)&details)+offsets[i].offset))->SetFromDBDate(record->at(i+idxOffset).get_asString()); break; @@ -3603,8 +3278,8 @@ bool CVideoDatabase::GetStreamDetails(CVideoInfoTag& tag) const auto_ptr<Dataset> pDS(m_pDB->CreateDataset()); try { - CStdString strSQL = PrepareSQL("SELECT * FROM streamdetails WHERE idFile = %i", tag.m_iFileId); - pDS->query(strSQL); + std::string strSQL = PrepareSQL("SELECT * FROM streamdetails WHERE idFile = %i", tag.m_iFileId); + pDS->query(strSQL.c_str()); while (!pDS->eof()) { @@ -3694,7 +3369,7 @@ bool CVideoDatabase::GetResumePoint(CVideoInfoTag& tag) } else { - CStdString strSQL=PrepareSQL("select timeInSeconds, totalTimeInSeconds from bookmark where idFile=%i and type=%i order by timeInSeconds", tag.m_iFileId, CBookmark::RESUME); + std::string strSQL=PrepareSQL("select timeInSeconds, totalTimeInSeconds from bookmark where idFile=%i and type=%i order by timeInSeconds", tag.m_iFileId, CBookmark::RESUME); m_pDS2->query( strSQL.c_str() ); if (!m_pDS2->eof()) { @@ -3739,7 +3414,7 @@ CVideoInfoTag CVideoDatabase::GetDetailsForMovie(const dbiplus::sql_record* cons details.m_strSet = record->at(VIDEODB_DETAILS_MOVIE_SET_NAME).get_asString(); details.m_iFileId = record->at(VIDEODB_DETAILS_FILEID).get_asInt(); details.m_strPath = record->at(VIDEODB_DETAILS_MOVIE_PATH).get_asString(); - CStdString strFileName = record->at(VIDEODB_DETAILS_MOVIE_FILE).get_asString(); + std::string strFileName = record->at(VIDEODB_DETAILS_MOVIE_FILE).get_asString(); ConstructPath(details.m_strFileNameAndPath,details.m_strPath,strFileName); details.m_playCount = record->at(VIDEODB_DETAILS_MOVIE_PLAYCOUNT).get_asInt(); details.m_lastPlayed.SetFromDBDateTime(record->at(VIDEODB_DETAILS_MOVIE_LASTPLAYED).get_asString()); @@ -3752,26 +3427,18 @@ CVideoInfoTag CVideoDatabase::GetDetailsForMovie(const dbiplus::sql_record* cons if (getDetails) { - GetCast("movie", "idMovie", details.m_iDbId, details.m_cast); + GetCast(details.m_iDbId, "movie", details.m_cast); + GetTags(details.m_iDbId, MediaTypeMovie, details.m_tags); castTime += XbmcThreads::SystemClockMillis() - time; time = XbmcThreads::SystemClockMillis(); details.m_strPictureURL.Parse(); - // get tags - CStdString strSQL = PrepareSQL("SELECT tag.strTag FROM tag, taglinks WHERE taglinks.idMedia = %i AND taglinks.media_type = 'movie' AND taglinks.idTag = tag.idTag ORDER BY tag.idTag", idMovie); - m_pDS2->query(strSQL.c_str()); - while (!m_pDS2->eof()) - { - details.m_tags.push_back(m_pDS2->fv("tag.strTag").get_asString()); - m_pDS2->next(); - } - // create tvshowlink string vector<int> links; GetLinksToTvShow(idMovie,links); for (unsigned int i=0;i<links.size();++i) { - CStdString strSQL = PrepareSQL("select c%02d from tvshow where idShow=%i", + std::string strSQL = PrepareSQL("select c%02d from tvshow where idShow=%i", VIDEODB_ID_TV_TITLE,links[i]); m_pDS2->query(strSQL.c_str()); if (!m_pDS2->eof()) @@ -3818,16 +3485,8 @@ CVideoInfoTag CVideoDatabase::GetDetailsForTvShow(const dbiplus::sql_record* con if (getDetails) { - GetCast("tvshow", "idShow", details.m_iDbId, details.m_cast); - - // get tags - CStdString strSQL = PrepareSQL("SELECT tag.strTag FROM tag, taglinks WHERE taglinks.idMedia = %i AND taglinks.media_type = 'tvshow' AND taglinks.idTag = tag.idTag ORDER BY tag.idTag", idTvShow); - m_pDS2->query(strSQL.c_str()); - while (!m_pDS2->eof()) - { - details.m_tags.push_back(m_pDS2->fv("tag.strTag").get_asString()); - m_pDS2->next(); - } + GetCast(details.m_iDbId, "tvshow", details.m_cast); + GetTags(details.m_iDbId, MediaTypeTvShow, details.m_tags); castTime += XbmcThreads::SystemClockMillis() - time; time = XbmcThreads::SystemClockMillis(); details.m_strPictureURL.Parse(); @@ -3867,7 +3526,7 @@ CVideoInfoTag CVideoDatabase::GetDetailsForEpisode(const dbiplus::sql_record* co details.m_type = MediaTypeEpisode; details.m_iFileId = record->at(VIDEODB_DETAILS_FILEID).get_asInt(); details.m_strPath = record->at(VIDEODB_DETAILS_EPISODE_PATH).get_asString(); - CStdString strFileName = record->at(VIDEODB_DETAILS_EPISODE_FILE).get_asString(); + std::string strFileName = record->at(VIDEODB_DETAILS_EPISODE_FILE).get_asString(); ConstructPath(details.m_strFileNameAndPath,details.m_strPath,strFileName); details.m_playCount = record->at(VIDEODB_DETAILS_EPISODE_PLAYCOUNT).get_asInt(); details.m_lastPlayed.SetFromDBDateTime(record->at(VIDEODB_DETAILS_EPISODE_LASTPLAYED).get_asString()); @@ -3887,12 +3546,12 @@ CVideoInfoTag CVideoDatabase::GetDetailsForEpisode(const dbiplus::sql_record* co if (getDetails) { - GetCast("episode", "idEpisode", details.m_iDbId, details.m_cast); - GetCast("tvshow", "idShow", details.m_iIdShow, details.m_cast); + GetCast(details.m_iDbId, "episode", details.m_cast); + GetCast(details.m_iIdShow, "tvshow", details.m_cast); castTime += XbmcThreads::SystemClockMillis() - time; time = XbmcThreads::SystemClockMillis(); details.m_strPictureURL.Parse(); - CStdString strSQL = PrepareSQL("select * from bookmark join episode on episode.c%02d=bookmark.idBookmark where episode.idEpisode=%i and bookmark.type=%i", VIDEODB_ID_EPISODE_BOOKMARK,details.m_iDbId,CBookmark::EPISODE); + std::string strSQL = PrepareSQL("select * from bookmark join episode on episode.c%02d=bookmark.idBookmark where episode.idEpisode=%i and bookmark.type=%i", VIDEODB_ID_EPISODE_BOOKMARK,details.m_iDbId,CBookmark::EPISODE); m_pDS2->query(strSQL.c_str()); if (!m_pDS2->eof()) details.m_fEpBookmark = m_pDS2->fv("bookmark.timeInSeconds").get_asFloat(); @@ -3922,7 +3581,7 @@ CVideoInfoTag CVideoDatabase::GetDetailsForMusicVideo(const dbiplus::sql_record* details.m_iFileId = record->at(VIDEODB_DETAILS_FILEID).get_asInt(); details.m_strPath = record->at(VIDEODB_DETAILS_MUSICVIDEO_PATH).get_asString(); - CStdString strFileName = record->at(VIDEODB_DETAILS_MUSICVIDEO_FILE).get_asString(); + std::string strFileName = record->at(VIDEODB_DETAILS_MUSICVIDEO_FILE).get_asString(); ConstructPath(details.m_strFileNameAndPath,details.m_strPath,strFileName); details.m_playCount = record->at(VIDEODB_DETAILS_MUSICVIDEO_PLAYCOUNT).get_asInt(); details.m_lastPlayed.SetFromDBDateTime(record->at(VIDEODB_DETAILS_MUSICVIDEO_LASTPLAYED).get_asString()); @@ -3935,15 +3594,7 @@ CVideoInfoTag CVideoDatabase::GetDetailsForMusicVideo(const dbiplus::sql_record* if (getDetails) { - // get tags - CStdString strSQL = PrepareSQL("SELECT tag.strTag FROM tag, taglinks WHERE taglinks.idMedia = %i AND taglinks.media_type = 'musicvideo' AND taglinks.idTag = tag.idTag ORDER BY tag.idTag", idMVideo); - m_pDS2->query(strSQL.c_str()); - while (!m_pDS2->eof()) - { - details.m_tags.push_back(m_pDS2->fv("tag.strTag").get_asString()); - m_pDS2->next(); - } - m_pDS2->close(); + GetTags(details.m_iDbId, MediaTypeMusicVideo, details.m_tags); details.m_strPictureURL.Parse(); @@ -3953,26 +3604,26 @@ CVideoInfoTag CVideoDatabase::GetDetailsForMusicVideo(const dbiplus::sql_record* return details; } -void CVideoDatabase::GetCast(const CStdString &table, const CStdString &table_id, int type_id, vector<SActorInfo> &cast) +void CVideoDatabase::GetCast(int media_id, const std::string &media_type, vector<SActorInfo> &cast) { try { if (!m_pDB.get()) return; if (!m_pDS2.get()) return; - CStdString sql = PrepareSQL("SELECT actors.strActor," - " actorlink%s.strRole," - " actorlink%s.iOrder," - " actors.strThumb," - " art.url " - "FROM actorlink%s" - " JOIN actors ON" - " actorlink%s.idActor=actors.idActor" - " LEFT JOIN art ON" - " art.media_id=actors.idActor AND art.media_type='actor' AND art.type='thumb' " - "WHERE actorlink%s.%s=%i " - "ORDER BY actorlink%s.iOrder",table.c_str(), table.c_str(), table.c_str(), table.c_str(), table.c_str(), table_id.c_str(), type_id, table.c_str()); - m_pDS2->query(sql.c_str()); + std::string sql = PrepareSQL("SELECT actor.name," + " actor_link.role," + " actor_link.cast_order," + " actor.art_urls," + " art.url " + "FROM actor_link" + " JOIN actor ON" + " actor_link.actor_id=actor.actor_id" + " LEFT JOIN art ON" + " art.media_id=actor.actor_id AND art.media_type='actor' AND art.type='thumb' " + "WHERE actor_link.media_id=%i AND actor_link.media_type='%s'" + "ORDER BY actor_link.cast_order", media_id, media_type.c_str()); + m_pDS2->query(sql); while (!m_pDS2->eof()) { SActorInfo info; @@ -4000,13 +3651,35 @@ void CVideoDatabase::GetCast(const CStdString &table, const CStdString &table_id } catch (...) { - CLog::Log(LOGERROR, "%s(%s,%s,%i) failed", __FUNCTION__, table.c_str(), table_id.c_str(), type_id); + CLog::Log(LOGERROR, "%s(%i,%s) failed", __FUNCTION__, media_id, media_type.c_str()); + } +} + +void CVideoDatabase::GetTags(int media_id, const std::string &media_type, std::vector<std::string> &tags) +{ + try + { + if (!m_pDB.get()) return; + if (!m_pDS2.get()) return; + + std::string sql = PrepareSQL("SELECT tag.name FROM tag, tag_link WHERE tag_link.media_id = %i AND tag_link.media_type = '%s' AND tag_link.tag_id = tag.tag_id ORDER BY tag.tag_id", media_id, media_type.c_str()); + m_pDS2->query(sql); + while (!m_pDS2->eof()) + { + tags.push_back(m_pDS2->fv(0).get_asString()); + m_pDS2->next(); + } + m_pDS2->close(); + } + catch (...) + { + CLog::Log(LOGERROR, "%s(%i,%s) failed", __FUNCTION__, media_id, media_type.c_str()); } } /// \brief GetVideoSettings() obtains any saved video settings for the current file. /// \retval Returns true if the settings exist, false otherwise. -bool CVideoDatabase::GetVideoSettings(const CStdString &strFilenameAndPath, CVideoSettings &settings) +bool CVideoDatabase::GetVideoSettings(const std::string &strFilenameAndPath, CVideoSettings &settings) { try { @@ -4014,16 +3687,16 @@ bool CVideoDatabase::GetVideoSettings(const CStdString &strFilenameAndPath, CVid #ifdef NEW_VIDEODB_METHODS if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strPath, strFileName; + std::string strPath, strFileName; URIUtils::Split(strFilenameAndPath, strPath, strFileName); - CStdString strSQL=PrepareSQL("select * from settings, files, path where settings.idFile=files.idFile and path.idPath=files.idPath and path.strPath='%s' and files.strFileName='%s'", strPath.c_str() , strFileName.c_str()); + std::string strSQL=PrepareSQL("select * from settings, files, path where settings.idFile=files.idFile and path.idPath=files.idPath and path.strPath='%s' and files.strFileName='%s'", strPath.c_str() , strFileName.c_str()); #else int idFile = GetFileId(strFilenameAndPath); if (idFile < 0) return false; if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; // ok, now obtain the settings for this file - CStdString strSQL=PrepareSQL("select * from settings where settings.idFile = '%i'", idFile); + std::string strSQL=PrepareSQL("select * from settings where settings.idFile = '%i'", idFile); #endif m_pDS->query( strSQL.c_str() ); if (m_pDS->num_rows() > 0) @@ -4045,11 +3718,6 @@ bool CVideoDatabase::GetVideoSettings(const CStdString &strFilenameAndPath, CVid settings.m_SubtitleStream = m_pDS->fv("SubtitleStream").get_asInt(); settings.m_ViewMode = m_pDS->fv("ViewMode").get_asInt(); settings.m_ResumeTime = m_pDS->fv("ResumeTime").get_asInt(); - settings.m_Crop = m_pDS->fv("Crop").get_asBool(); - settings.m_CropLeft = m_pDS->fv("CropLeft").get_asInt(); - settings.m_CropRight = m_pDS->fv("CropRight").get_asInt(); - settings.m_CropTop = m_pDS->fv("CropTop").get_asInt(); - settings.m_CropBottom = m_pDS->fv("CropBottom").get_asInt(); settings.m_DeinterlaceMode = (EDEINTERLACEMODE)m_pDS->fv("DeinterlaceMode").get_asInt(); settings.m_InterlaceMethod = (EINTERLACEMETHOD)m_pDS->fv("Deinterlace").get_asInt(); settings.m_VolumeAmplification = m_pDS->fv("VolumeAmplification").get_asFloat(); @@ -4071,7 +3739,7 @@ bool CVideoDatabase::GetVideoSettings(const CStdString &strFilenameAndPath, CVid } /// \brief Sets the settings for a particular video file -void CVideoDatabase::SetVideoSettings(const CStdString& strFilenameAndPath, const CVideoSettings &setting) +void CVideoDatabase::SetVideoSettings(const std::string& strFilenameAndPath, const CVideoSettings &setting) { try { @@ -4080,7 +3748,7 @@ void CVideoDatabase::SetVideoSettings(const CStdString& strFilenameAndPath, cons int idFile = AddFile(strFilenameAndPath); if (idFile < 0) return; - CStdString strSQL = StringUtils::Format("select * from settings where idFile=%i", idFile); + std::string strSQL = PrepareSQL("select * from settings where idFile=%i", idFile); m_pDS->query( strSQL.c_str() ); if (m_pDS->num_rows() > 0) { @@ -4095,8 +3763,8 @@ void CVideoDatabase::SetVideoSettings(const CStdString& strFilenameAndPath, cons setting.m_Brightness, setting.m_Contrast, setting.m_Gamma, setting.m_VolumeAmplification, setting.m_AudioDelay, setting.m_OutputToAllSpeakers,setting.m_Sharpness,setting.m_NoiseReduction,setting.m_CustomNonLinStretch,setting.m_PostProcess,setting.m_ScalingMethod, setting.m_DeinterlaceMode); - CStdString strSQL2; - strSQL2=PrepareSQL("ResumeTime=%i,Crop=%i,CropLeft=%i,CropRight=%i,CropTop=%i,CropBottom=%i,StereoMode=%i,StereoInvert=%i where idFile=%i\n", setting.m_ResumeTime, setting.m_Crop, setting.m_CropLeft, setting.m_CropRight, setting.m_CropTop, setting.m_CropBottom, setting.m_StereoMode, setting.m_StereoInvert, idFile); + std::string strSQL2; + strSQL2=PrepareSQL("ResumeTime=%i,StereoMode=%i,StereoInvert=%i where idFile=%i\n", setting.m_ResumeTime, setting.m_StereoMode, setting.m_StereoInvert, idFile); strSQL += strSQL2; m_pDS->exec(strSQL.c_str()); return ; @@ -4107,14 +3775,14 @@ void CVideoDatabase::SetVideoSettings(const CStdString& strFilenameAndPath, cons strSQL= "INSERT INTO settings (idFile,Deinterlace,ViewMode,ZoomAmount,PixelRatio, VerticalShift, " "AudioStream,SubtitleStream,SubtitleDelay,SubtitlesOn,Brightness," "Contrast,Gamma,VolumeAmplification,AudioDelay,OutputToAllSpeakers," - "ResumeTime,Crop,CropLeft,CropRight,CropTop,CropBottom," + "ResumeTime," "Sharpness,NoiseReduction,NonLinStretch,PostProcess,ScalingMethod,DeinterlaceMode,StereoMode,StereoInvert) " "VALUES "; strSQL += PrepareSQL("(%i,%i,%i,%f,%f,%f,%i,%i,%f,%i,%f,%f,%f,%f,%f,%i,%i,%i,%i,%i,%i,%i,%f,%f,%i,%i,%i,%i,%i,%i)", idFile, setting.m_InterlaceMethod, setting.m_ViewMode, setting.m_CustomZoomAmount, setting.m_CustomPixelRatio, setting.m_CustomVerticalShift, setting.m_AudioStream, setting.m_SubtitleStream, setting.m_SubtitleDelay, setting.m_SubtitleOn, setting.m_Brightness, setting.m_Contrast, setting.m_Gamma, setting.m_VolumeAmplification, setting.m_AudioDelay, setting.m_OutputToAllSpeakers, - setting.m_ResumeTime, setting.m_Crop, setting.m_CropLeft, setting.m_CropRight, setting.m_CropTop, setting.m_CropBottom, + setting.m_ResumeTime, setting.m_Sharpness, setting.m_NoiseReduction, setting.m_CustomNonLinStretch, setting.m_PostProcess, setting.m_ScalingMethod, setting.m_DeinterlaceMode, setting.m_StereoMode, setting.m_StereoInvert); m_pDS->exec(strSQL.c_str()); @@ -4143,7 +3811,7 @@ void CVideoDatabase::SetArtForItem(int mediaId, const MediaType &mediaType, cons if (artType.find('.') != string::npos) return; - CStdString sql = PrepareSQL("SELECT art_id,url FROM art WHERE media_id=%i AND media_type='%s' AND type='%s'", mediaId, mediaType.c_str(), artType.c_str()); + std::string sql = PrepareSQL("SELECT art_id,url FROM art WHERE media_id=%i AND media_type='%s' AND type='%s'", mediaId, mediaType.c_str(), artType.c_str()); m_pDS->query(sql.c_str()); if (!m_pDS->eof()) { // update @@ -4176,7 +3844,7 @@ bool CVideoDatabase::GetArtForItem(int mediaId, const MediaType &mediaType, map< if (NULL == m_pDB.get()) return false; if (NULL == m_pDS2.get()) return false; // using dataset 2 as we're likely called in loops on dataset 1 - CStdString sql = PrepareSQL("SELECT type,url FROM art WHERE media_id=%i AND media_type='%s'", mediaId, mediaType.c_str()); + std::string sql = PrepareSQL("SELECT type,url FROM art WHERE media_id=%i AND media_type='%s'", mediaId, mediaType.c_str()); m_pDS2->query(sql.c_str()); while (!m_pDS2->eof()) { @@ -4221,7 +3889,7 @@ bool CVideoDatabase::GetTvShowSeasonArt(int showId, map<int, map<string, string> if (NULL == m_pDS2.get()) return false; // using dataset 2 as we're likely called in loops on dataset 1 // get all seasons for this show - CStdString sql = PrepareSQL("select idSeason,season from seasons where idShow=%i", showId); + std::string sql = PrepareSQL("select idSeason,season from seasons where idShow=%i", showId); m_pDS2->query(sql.c_str()); vector< pair<int, int> > seasons; @@ -4254,7 +3922,7 @@ bool CVideoDatabase::GetArtTypes(const MediaType &mediaType, std::vector<std::st if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString sql = PrepareSQL("SELECT DISTINCT type FROM art WHERE media_type='%s'", mediaType.c_str()); + std::string sql = PrepareSQL("SELECT DISTINCT type FROM art WHERE media_type='%s'", mediaType.c_str()); int numRows = RunQuery(sql); if (numRows <= 0) return numRows == 0; @@ -4276,7 +3944,7 @@ bool CVideoDatabase::GetArtTypes(const MediaType &mediaType, std::vector<std::st /// \brief GetStackTimes() obtains any saved video times for the stacked file /// \retval Returns true if the stack times exist, false otherwise. -bool CVideoDatabase::GetStackTimes(const CStdString &filePath, vector<int> ×) +bool CVideoDatabase::GetStackTimes(const std::string &filePath, vector<int> ×) { try { @@ -4286,7 +3954,7 @@ bool CVideoDatabase::GetStackTimes(const CStdString &filePath, vector<int> &time if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; // ok, now obtain the settings for this file - CStdString strSQL=PrepareSQL("select times from stacktimes where idFile=%i\n", idFile); + std::string strSQL=PrepareSQL("select times from stacktimes where idFile=%i\n", idFile); m_pDS->query( strSQL.c_str() ); if (m_pDS->num_rows() > 0) { // get the video settings info @@ -4311,7 +3979,7 @@ bool CVideoDatabase::GetStackTimes(const CStdString &filePath, vector<int> &time } /// \brief Sets the stack times for a particular video file -void CVideoDatabase::SetStackTimes(const CStdString& filePath, vector<int> ×) +void CVideoDatabase::SetStackTimes(const std::string& filePath, vector<int> ×) { try { @@ -4325,7 +3993,7 @@ void CVideoDatabase::SetStackTimes(const CStdString& filePath, vector<int> &time m_pDS->exec( PrepareSQL("delete from stacktimes where idFile=%i", idFile) ); // add the items - CStdString timeString = StringUtils::Format("%i", times[0]); + std::string timeString = StringUtils::Format("%i", times[0]); for (unsigned int i = 1; i < times.size(); i++) timeString += StringUtils::Format(",%i", times[i]); @@ -4337,7 +4005,7 @@ void CVideoDatabase::SetStackTimes(const CStdString& filePath, vector<int> &time } } -void CVideoDatabase::RemoveContentForPath(const CStdString& strPath, CGUIDialogProgress *progress /* = NULL */) +void CVideoDatabase::RemoveContentForPath(const std::string& strPath, CGUIDialogProgress *progress /* = NULL */) { if(URIUtils::IsMultiPath(strPath)) { @@ -4379,7 +4047,7 @@ void CVideoDatabase::RemoveContentForPath(const CStdString& strPath, CGUIDialogP DeleteTvShow(i->second); else { - CStdString strSQL = PrepareSQL("select files.strFilename from files join movie on movie.idFile=files.idFile where files.idPath=%i", i->first); + std::string strSQL = PrepareSQL("select files.strFilename from files join movie on movie.idFile=files.idFile where files.idPath=%i", i->first); m_pDS2->query(strSQL.c_str()); if (m_pDS2->eof()) { @@ -4389,8 +4057,8 @@ void CVideoDatabase::RemoveContentForPath(const CStdString& strPath, CGUIDialogP } while (!m_pDS2->eof()) { - CStdString strMoviePath; - CStdString strFileName = m_pDS2->fv("files.strFilename").get_asString(); + std::string strMoviePath; + std::string strFileName = m_pDS2->fv("files.strFilename").get_asString(); ConstructPath(strMoviePath, i->second, strFileName); if (HasMovieInfo(strMoviePath)) DeleteMovie(strMoviePath); @@ -4417,7 +4085,7 @@ void CVideoDatabase::RemoveContentForPath(const CStdString& strPath, CGUIDialogP progress->Close(); } -void CVideoDatabase::SetScraperForPath(const CStdString& filePath, const ScraperPtr& scraper, const VIDEO::SScanSettings& settings) +void CVideoDatabase::SetScraperForPath(const std::string& filePath, const ScraperPtr& scraper, const VIDEO::SScanSettings& settings) { // if we have a multipath, set scraper for all contained paths if(URIUtils::IsMultiPath(filePath)) @@ -4441,7 +4109,7 @@ void CVideoDatabase::SetScraperForPath(const CStdString& filePath, const Scraper return; // Update - CStdString strSQL; + std::string strSQL; if (settings.exclude) { //NB See note in ::GetScraperForPath about strContent=='none' strSQL=PrepareSQL("update path set strContent='', strScraper='', scanRecursive=0, useFolderNames=0, strSettings='', noUpdate=0 , exclude=1 where idPath=%i", idPath); @@ -4452,7 +4120,7 @@ void CVideoDatabase::SetScraperForPath(const CStdString& filePath, const Scraper } else { - CStdString content = TranslateContent(scraper->Content()); + std::string content = TranslateContent(scraper->Content()); strSQL=PrepareSQL("update path set strContent='%s', strScraper='%s', scanRecursive=%i, useFolderNames=%i, strSettings='%s', noUpdate=%i, exclude=0 where idPath=%i", content.c_str(), scraper->ID().c_str(),settings.recurse,settings.parent_name,scraper->GetPathSettings().c_str(),settings.noupdate, idPath); } m_pDS->exec(strSQL.c_str()); @@ -4463,14 +4131,14 @@ void CVideoDatabase::SetScraperForPath(const CStdString& filePath, const Scraper } } -bool CVideoDatabase::ScraperInUse(const CStdString &scraperID) const +bool CVideoDatabase::ScraperInUse(const std::string &scraperID) const { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString sql = PrepareSQL("select count(1) from path where strScraper='%s'", scraperID.c_str()); + std::string sql = PrepareSQL("select count(1) from path where strScraper='%s'", scraperID.c_str()); if (!m_pDS->query(sql.c_str()) || m_pDS->num_rows() == 0) return false; bool found = m_pDS->fv(0).get_asInt() > 0; @@ -4533,7 +4201,7 @@ void CVideoDatabase::UpdateTables(int iVersion) m_pDS->query("SELECT idShow FROM tvshow"); while (!m_pDS->eof()) { - CStdString sql = PrepareSQL("INSERT INTO seasons (idShow,season)" + std::string sql = PrepareSQL("INSERT INTO seasons (idShow,season)" " SELECT DISTINCT" " idShow,c%02d" " FROM" @@ -4562,7 +4230,7 @@ void CVideoDatabase::UpdateTables(int iVersion) while (!m_pDS->eof()) { int idEpisode = m_pDS->fv(0).get_asInt(); - CStdString update = PrepareSQL("UPDATE episode SET idShow=(SELECT idShow FROM tvshowlinkepisode WHERE idEpisode=%d) WHERE idEpisode=%d", idEpisode, idEpisode); + std::string update = PrepareSQL("UPDATE episode SET idShow=(SELECT idShow FROM tvshowlinkepisode WHERE idEpisode=%d) WHERE idEpisode=%d", idEpisode, idEpisode); m_pDS2->exec(update.c_str()); m_pDS->next(); } @@ -4580,7 +4248,7 @@ void CVideoDatabase::UpdateTables(int iVersion) while (!m_pDS->eof()) { int idMovie = m_pDS->fv(0).get_asInt(); - CStdString sql = PrepareSQL("UPDATE movie SET idSet=(SELECT idSet FROM setlinkmovie WHERE idMovie = %d LIMIT 1) WHERE idMovie = %d", idMovie, idMovie); + std::string sql = PrepareSQL("UPDATE movie SET idSet=(SELECT idSet FROM setlinkmovie WHERE idMovie = %d LIMIT 1) WHERE idMovie = %d", idMovie, idMovie); m_pDS2->exec(sql.c_str()); m_pDS->next(); } @@ -4662,7 +4330,7 @@ void CVideoDatabase::UpdateTables(int iVersion) tables.push_back(make_pair("mvideo", VIDEODB_ID_MUSICVIDEO_RUNTIME)); for (vector< pair<string, int> >::iterator i = tables.begin(); i != tables.end(); ++i) { - CStdString sql = PrepareSQL("select id%s,c%02d from %s where c%02d != ''", i->first.c_str(), i->second, (i->first=="mvideo")?"musicvideo":i->first.c_str(), i->second); + std::string sql = PrepareSQL("select id%s,c%02d from %s where c%02d != ''", i->first.c_str(), i->second, (i->first=="mvideo")?"musicvideo":i->first.c_str(), i->second); m_pDS->query(sql.c_str()); vector< pair<int, int> > videos; while (!m_pDS->eof()) @@ -4713,7 +4381,7 @@ void CVideoDatabase::UpdateTables(int iVersion) if (iVersion < 83) { // drop duplicates in tvshow table, and update tvshowlinkpath accordingly - CStdString sql = PrepareSQL("SELECT tvshow.idShow,idPath,c%02d,c%02d,c%02d FROM tvshow JOIN tvshowlinkpath ON tvshow.idShow = tvshowlinkpath.idShow", VIDEODB_ID_TV_TITLE, VIDEODB_ID_TV_PREMIERED, VIDEODB_ID_TV_IDENT); + std::string sql = PrepareSQL("SELECT tvshow.idShow,idPath,c%02d,c%02d,c%02d FROM tvshow JOIN tvshowlinkpath ON tvshow.idShow = tvshowlinkpath.idShow", VIDEODB_ID_TV_TITLE, VIDEODB_ID_TV_PREMIERED, VIDEODB_ID_TV_IDENT); m_pDS->query(sql.c_str()); vector<CShowItem> shows; while (!m_pDS->eof()) @@ -4793,14 +4461,93 @@ void CVideoDatabase::UpdateTables(int iVersion) m_pDS->exec("DELETE from art WHERE media_type='tvshow' AND NOT EXISTS (SELECT 1 FROM tvshow WHERE tvshow.idShow = art.media_id)"); m_pDS->exec("DELETE from art WHERE media_type='season' AND NOT EXISTS (SELECT 1 FROM seasons WHERE seasons.idSeason = art.media_id)"); } + if (iVersion < 91) + { // create actor link table + m_pDS->exec("CREATE TABLE actor_link(actor_id INT, media_id INT, media_type TEXT, role TEXT, cast_order INT)"); + m_pDS->exec("INSERT INTO actor_link(actor_id, media_id, media_type, role, cast_order) SELECT idActor,idMovie,'movie',strRole,iOrder from actorlinkmovie"); + m_pDS->exec("INSERT INTO actor_link(actor_id, media_id, media_type, role, cast_order) SELECT idActor,idShow,'tvshow',strRole,iOrder from actorlinktvshow"); + m_pDS->exec("INSERT INTO actor_link(actor_id, media_id, media_type, role, cast_order) SELECT idActor,idEpisode,'episode',strRole,iOrder from actorlinkepisode"); + m_pDS->exec("DROP TABLE IF EXISTS actorlinkmovie"); + m_pDS->exec("DROP TABLE IF EXISTS actorlinktvshow"); + m_pDS->exec("DROP TABLE IF EXISTS actorlinkepisode"); + m_pDS->exec("CREATE TABLE actor(actor_id INTEGER PRIMARY KEY, name TEXT, art_urls TEXT)"); + m_pDS->exec("INSERT INTO actor(actor_id, name, art_urls) SELECT idActor,strActor,strThumb FROM actors"); + m_pDS->exec("DROP TABLE IF EXISTS actors"); + + // directors + m_pDS->exec("CREATE TABLE director_link(actor_id INTEGER, media_id INTEGER, media_type TEXT)"); + m_pDS->exec("INSERT INTO director_link(actor_id, media_id, media_type) SELECT idDirector,idMovie,'movie' FROM directorlinkmovie"); + m_pDS->exec("INSERT INTO director_link(actor_id, media_id, media_type) SELECT idDirector,idShow,'tvshow' FROM directorlinktvshow"); + m_pDS->exec("INSERT INTO director_link(actor_id, media_id, media_type) SELECT idDirector,idEpisode,'episode' FROM directorlinkepisode"); + m_pDS->exec("INSERT INTO director_link(actor_id, media_id, media_type) SELECT idDirector,idMVideo,'musicvideo' FROM directorlinkmusicvideo"); + m_pDS->exec("DROP TABLE IF EXISTS directorlinkmovie"); + m_pDS->exec("DROP TABLE IF EXISTS directorlinktvshow"); + m_pDS->exec("DROP TABLE IF EXISTS directorlinkepisode"); + m_pDS->exec("DROP TABLE IF EXISTS directorlinkmusicvideo"); + + // writers + m_pDS->exec("CREATE TABLE writer_link(actor_id INTEGER, media_id INTEGER, media_type TEXT)"); + m_pDS->exec("INSERT INTO writer_link(actor_id, media_id, media_type) SELECT idWriter,idMovie,'movie' FROM writerlinkmovie"); + m_pDS->exec("INSERT INTO writer_link(actor_id, media_id, media_type) SELECT idWriter,idEpisode,'episode' FROM writerlinkepisode"); + m_pDS->exec("DROP TABLE IF EXISTS writerlinkmovie"); + m_pDS->exec("DROP TABLE IF EXISTS writerlinkepisode"); + + // music artist + m_pDS->exec("INSERT INTO actor_link(actor_id, media_id, media_type) SELECT idArtist,idMVideo,'musicvideo' FROM artistlinkmusicvideo"); + m_pDS->exec("DROP TABLE IF EXISTS artistlinkmusicvideo"); + + // studios + m_pDS->exec("CREATE TABLE studio_link(studio_id INTEGER, media_id INTEGER, media_type TEXT)"); + m_pDS->exec("INSERT INTO studio_link(studio_id, media_id, media_type) SELECT idStudio,idMovie,'movie' FROM studiolinkmovie"); + m_pDS->exec("INSERT INTO studio_link(studio_id, media_id, media_type) SELECT idStudio,idShow,'tvshow' FROM studiolinktvshow"); + m_pDS->exec("INSERT INTO studio_link(studio_id, media_id, media_type) SELECT idStudio,idMVideo,'musicvideo' FROM studiolinkmusicvideo"); + m_pDS->exec("DROP TABLE IF EXISTS studiolinkmovie"); + m_pDS->exec("DROP TABLE IF EXISTS studiolinktvshow"); + m_pDS->exec("DROP TABLE IF EXISTS studiolinkmusicvideo"); + m_pDS->exec("CREATE TABLE studionew(studio_id INTEGER PRIMARY KEY, name TEXT)"); + m_pDS->exec("INSERT INTO studionew(studio_id, name) SELECT idStudio,strStudio FROM studio"); + m_pDS->exec("DROP TABLE IF EXISTS studio"); + m_pDS->exec("ALTER TABLE studionew RENAME TO studio"); + + // genres + m_pDS->exec("CREATE TABLE genre_link(genre_id INTEGER, media_id INTEGER, media_type TEXT)"); + m_pDS->exec("INSERT INTO genre_link(genre_id, media_id, media_type) SELECT idGenre,idMovie,'movie' FROM genrelinkmovie"); + m_pDS->exec("INSERT INTO genre_link(genre_id, media_id, media_type) SELECT idGenre,idShow,'tvshow' FROM genrelinktvshow"); + m_pDS->exec("INSERT INTO genre_link(genre_id, media_id, media_type) SELECT idGenre,idMVideo,'musicvideo' FROM genrelinkmusicvideo"); + m_pDS->exec("DROP TABLE IF EXISTS genrelinkmovie"); + m_pDS->exec("DROP TABLE IF EXISTS genrelinktvshow"); + m_pDS->exec("DROP TABLE IF EXISTS genrelinkmusicvideo"); + m_pDS->exec("CREATE TABLE genrenew(genre_id INTEGER PRIMARY KEY, name TEXT)"); + m_pDS->exec("INSERT INTO genrenew(genre_id, name) SELECT idGenre,strGenre FROM genre"); + m_pDS->exec("DROP TABLE IF EXISTS genre"); + m_pDS->exec("ALTER TABLE genrenew RENAME TO genre"); + + // country + m_pDS->exec("CREATE TABLE country_link(country_id INTEGER, media_id INTEGER, media_type TEXT)"); + m_pDS->exec("INSERT INTO country_link(country_id, media_id, media_type) SELECT idCountry,idMovie,'movie' FROM countrylinkmovie"); + m_pDS->exec("DROP TABLE IF EXISTS countrylinkmovie"); + m_pDS->exec("CREATE TABLE countrynew(country_id INTEGER PRIMARY KEY, name TEXT)"); + m_pDS->exec("INSERT INTO countrynew(country_id, name) SELECT idCountry,strCountry FROM country"); + m_pDS->exec("DROP TABLE IF EXISTS country"); + m_pDS->exec("ALTER TABLE countrynew RENAME TO country"); + + // tags + m_pDS->exec("CREATE TABLE tag_link(tag_id INTEGER, media_id INTEGER, media_type TEXT)"); + m_pDS->exec("INSERT INTO tag_link(tag_id, media_id, media_type) SELECT idTag,idMedia,media_type FROM taglinks"); + m_pDS->exec("DROP TABLE IF EXISTS taglinks"); + m_pDS->exec("CREATE TABLE tagnew(tag_id INTEGER PRIMARY KEY, name TEXT)"); + m_pDS->exec("INSERT INTO tagnew(tag_id, name) SELECT idTag,strTag FROM tag"); + m_pDS->exec("DROP TABLE IF EXISTS tag"); + m_pDS->exec("ALTER TABLE tagnew RENAME TO tag"); + } } int CVideoDatabase::GetSchemaVersion() const { - return 90; + return 91; } -bool CVideoDatabase::LookupByFolders(const CStdString &path, bool shows) +bool CVideoDatabase::LookupByFolders(const std::string &path, bool shows) { SScanSettings settings; bool foundDirectly = false; @@ -4810,7 +4557,7 @@ bool CVideoDatabase::LookupByFolders(const CStdString &path, bool shows) return settings.parent_name_root; // shows, movies, musicvids } -bool CVideoDatabase::GetPlayCounts(const CStdString &strPath, CFileItemList &items) +bool CVideoDatabase::GetPlayCounts(const std::string &strPath, CFileItemList &items) { if(URIUtils::IsMultiPath(strPath)) { @@ -4841,7 +4588,7 @@ bool CVideoDatabase::GetPlayCounts(const CStdString &strPath, CFileItemList &ite if (NULL == m_pDS.get()) return false; // TODO: also test a single query for the above and below - CStdString sql = PrepareSQL( + std::string sql = PrepareSQL( "SELECT" " files.strFilename, files.playCount," " bookmark.timeInSeconds, bookmark.totalTimeInSeconds " @@ -4856,7 +4603,7 @@ bool CVideoDatabase::GetPlayCounts(const CStdString &strPath, CFileItemList &ite items.SetFastLookup(true); // note: it's possibly quicker the other way around (map on db returned items)? while (!m_pDS->eof()) { - CStdString path; + std::string path; ConstructPath(path, strPath, m_pDS->fv(0).get_asString()); CFileItemPtr item = items.Get(path); if (item) @@ -4892,7 +4639,7 @@ int CVideoDatabase::GetPlayCount(const CFileItem &item) if (NULL == m_pDB.get()) return -1; if (NULL == m_pDS.get()) return -1; - CStdString strSQL = PrepareSQL("select playCount from files WHERE idFile=%i", id); + std::string strSQL = PrepareSQL("select playCount from files WHERE idFile=%i", id); int count = 0; if (m_pDS->query(strSQL.c_str())) { @@ -4916,7 +4663,7 @@ void CVideoDatabase::UpdateFanart(const CFileItem &item, VIDEODB_CONTENT_TYPE ty if (NULL == m_pDS.get()) return; if (!item.HasVideoInfoTag() || item.GetVideoInfoTag()->m_iDbId < 0) return; - CStdString exec; + std::string exec; if (type == VIDEODB_CONTENT_TVSHOWS) exec = PrepareSQL("UPDATE tvshow set c%02d='%s' WHERE idShow=%i", VIDEODB_ID_TV_FANART, item.GetVideoInfoTag()->m_fanart.m_xml.c_str(), item.GetVideoInfoTag()->m_iDbId); else if (type == VIDEODB_CONTENT_MOVIES) @@ -4958,7 +4705,7 @@ void CVideoDatabase::SetPlayCount(const CFileItem &item, int count, const CDateT if (NULL == m_pDB.get()) return ; if (NULL == m_pDS.get()) return ; - CStdString strSQL; + std::string strSQL; if (count) { if (!date.IsValid()) @@ -5004,13 +4751,13 @@ void CVideoDatabase::UpdateLastPlayed(const CFileItem &item) SetPlayCount(item, GetPlayCount(item), CDateTime::GetCurrentDateTime()); } -void CVideoDatabase::UpdateMovieTitle(int idMovie, const CStdString& strNewMovieTitle, VIDEODB_CONTENT_TYPE iType) +void CVideoDatabase::UpdateMovieTitle(int idMovie, const std::string& strNewMovieTitle, VIDEODB_CONTENT_TYPE iType) { try { if (NULL == m_pDB.get()) return ; if (NULL == m_pDS.get()) return ; - CStdString content; + std::string content; if (iType == VIDEODB_CONTENT_MOVIES) { CLog::Log(LOGINFO, "Changing Movie:id:%i New Title:%s", idMovie, strNewMovieTitle.c_str()); @@ -5034,7 +4781,7 @@ void CVideoDatabase::UpdateMovieTitle(int idMovie, const CStdString& strNewMovie else if (iType == VIDEODB_CONTENT_MOVIE_SETS) { CLog::Log(LOGINFO, "Changing Movie set:id:%i New Title:%s", idMovie, strNewMovieTitle.c_str()); - CStdString strSQL = PrepareSQL("UPDATE sets SET strSet='%s' WHERE idSet=%i", strNewMovieTitle.c_str(), idMovie ); + std::string strSQL = PrepareSQL("UPDATE sets SET strSet='%s' WHERE idSet=%i", strNewMovieTitle.c_str(), idMovie ); m_pDS->exec(strSQL.c_str()); } @@ -5046,11 +4793,11 @@ void CVideoDatabase::UpdateMovieTitle(int idMovie, const CStdString& strNewMovie } catch (...) { - CLog::Log(LOGERROR, "%s (int idMovie, const CStdString& strNewMovieTitle) failed on MovieID:%i and Title:%s", __FUNCTION__, idMovie, strNewMovieTitle.c_str()); + CLog::Log(LOGERROR, "%s (int idMovie, const std::string& strNewMovieTitle) failed on MovieID:%i and Title:%s", __FUNCTION__, idMovie, strNewMovieTitle.c_str()); } } -bool CVideoDatabase::UpdateVideoSortTitle(int idDb, const CStdString& strNewSortTitle, VIDEODB_CONTENT_TYPE iType /* = VIDEODB_CONTENT_MOVIES */) +bool CVideoDatabase::UpdateVideoSortTitle(int idDb, const std::string& strNewSortTitle, VIDEODB_CONTENT_TYPE iType /* = VIDEODB_CONTENT_MOVIES */) { try { @@ -5059,7 +4806,7 @@ bool CVideoDatabase::UpdateVideoSortTitle(int idDb, const CStdString& strNewSort if (iType != VIDEODB_CONTENT_MOVIES && iType != VIDEODB_CONTENT_TVSHOWS) return false; - CStdString content = MediaTypeMovie; + std::string content = MediaTypeMovie; if (iType == VIDEODB_CONTENT_TVSHOWS) content = MediaTypeTvShow; @@ -5071,7 +4818,7 @@ bool CVideoDatabase::UpdateVideoSortTitle(int idDb, const CStdString& strNewSort } catch (...) { - CLog::Log(LOGERROR, "%s (int idDb, const CStdString& strNewSortTitle, VIDEODB_CONTENT_TYPE iType) failed on ID: %i and Sort Title: %s", __FUNCTION__, idDb, strNewSortTitle.c_str()); + CLog::Log(LOGERROR, "%s (int idDb, const std::string& strNewSortTitle, VIDEODB_CONTENT_TYPE iType) failed on ID: %i and Sort Title: %s", __FUNCTION__, idDb, strNewSortTitle.c_str()); } return false; @@ -5103,88 +4850,105 @@ void CVideoDatabase::EraseVideoSettings(const std::string &path /* = ""*/) } } -bool CVideoDatabase::GetGenresNav(const CStdString& strBaseDir, CFileItemList& items, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) +bool CVideoDatabase::GetGenresNav(const std::string& strBaseDir, CFileItemList& items, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) { return GetNavCommon(strBaseDir, items, "genre", idContent, filter, countOnly); } -bool CVideoDatabase::GetCountriesNav(const CStdString& strBaseDir, CFileItemList& items, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) +bool CVideoDatabase::GetCountriesNav(const std::string& strBaseDir, CFileItemList& items, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) { return GetNavCommon(strBaseDir, items, "country", idContent, filter, countOnly); } -bool CVideoDatabase::GetStudiosNav(const CStdString& strBaseDir, CFileItemList& items, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) +bool CVideoDatabase::GetStudiosNav(const std::string& strBaseDir, CFileItemList& items, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) { return GetNavCommon(strBaseDir, items, "studio", idContent, filter, countOnly); } -bool CVideoDatabase::GetNavCommon(const CStdString& strBaseDir, CFileItemList& items, const CStdString &type, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) +bool CVideoDatabase::GetNavCommon(const std::string& strBaseDir, CFileItemList& items, const char *type, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL; + std::string strSQL; Filter extFilter = filter; if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) { + std::string view, view_id, media_type, extraField; if (idContent == VIDEODB_CONTENT_MOVIES) { - strSQL = "select %s " + PrepareSQL("from %s ", type.c_str()); - extFilter.fields = PrepareSQL("%s.id%s, %s.str%s, path.strPath, files.playCount", type.c_str(), type.c_str(), type.c_str(), type.c_str()); - extFilter.AppendJoin(PrepareSQL("join %slinkmovie on %s.id%s = %slinkmovie.id%s join movieview on %slinkmovie.idMovie = movieview.idMovie join files on files.idFile = movieview.idFile join path on path.idPath = files.idPath", - type.c_str(), type.c_str(), type.c_str(), type.c_str(), type.c_str(), type.c_str())); + view = MediaTypeMovie; + view_id = "idMovie"; + media_type = MediaTypeMovie; + extraField = "files.playCount"; } else if (idContent == VIDEODB_CONTENT_TVSHOWS) //this will not get tvshows with 0 episodes { - strSQL = "select %s " + PrepareSQL("from %s ", type.c_str()); - extFilter.fields = PrepareSQL("%s.id%s, %s.str%s, path.strPath", type.c_str(), type.c_str(), type.c_str(), type.c_str()); - extFilter.AppendJoin(PrepareSQL("join %slinktvshow on %s.id%s = %slinktvshow.id%s join episodeview on %slinktvshow.idShow = episodeview.idShow join files on files.idFile = episodeview.idFile join path on path.idPath = files.idPath", - type.c_str(), type.c_str(), type.c_str(), type.c_str(), type.c_str(), type.c_str())); + view = MediaTypeEpisode; + view_id = "idShow"; + media_type = MediaTypeTvShow; } else if (idContent == VIDEODB_CONTENT_MUSICVIDEOS) { - strSQL = "select %s " + PrepareSQL("from %s ", type.c_str()); - extFilter.fields = PrepareSQL("%s.id%s, %s.str%s, path.strPath, files.playCount", type.c_str(), type.c_str(), type.c_str(), type.c_str()); - extFilter.AppendJoin(PrepareSQL("join %slinkmusicvideo on %s.id%s = %slinkmusicvideo.id%s join musicvideoview on %slinkmusicvideo.idMVideo = musicvideoview.idMVideo join files on files.idFile = musicvideoview.idFile join path on path.idPath = files.idPath", - type.c_str(), type.c_str(), type.c_str(), type.c_str(), type.c_str(), type.c_str())); + view = MediaTypeMusicVideo; + view_id = "idMVideo"; + media_type = MediaTypeMusicVideo; + extraField = "files.playCount"; } else return false; + + strSQL = "SELECT %s " + PrepareSQL("FROM %s ", type); + extFilter.fields = PrepareSQL("%s.%s_id, %s.name, path.strPath", type, type, type); + extFilter.AppendField(extraField); + extFilter.AppendJoin(PrepareSQL("JOIN %s_link ON %s.%s_id = %s_link.%s_id", type, type, type, type, type)); + extFilter.AppendJoin(PrepareSQL("JOIN %s_view ON %s_link.media_id = %s_view.%s AND %s_link.media_type='%s'", view.c_str(), type, view.c_str(), view_id.c_str(), type, media_type.c_str())); + extFilter.AppendJoin(PrepareSQL("JOIN files ON files.idFile = %s_view.idFile", view.c_str())); + extFilter.AppendJoin("JOIN path ON path.idPath = files.idPath"); } else { + std::string view, view_id, media_type, extraField, extraJoin; if (idContent == VIDEODB_CONTENT_MOVIES) { - strSQL = "select %s " + PrepareSQL("from %s ", type.c_str()); - extFilter.fields = PrepareSQL("%s.id%s, %s.str%s, count(1), count(files.playCount)", type.c_str(), type.c_str(), type.c_str(), type.c_str()); - extFilter.AppendJoin(PrepareSQL("join %slinkmovie on %s.id%s = %slinkmovie.id%s join movieview on %slinkmovie.idMovie = movieview.idMovie join files on files.idFile = movieview.idFile", - type.c_str(), type.c_str(), type.c_str(), type.c_str(), type.c_str(), type.c_str())); - extFilter.AppendGroup(PrepareSQL("%s.id%s", type.c_str(), type.c_str())); + view = MediaTypeMovie; + view_id = "idMovie"; + media_type = MediaTypeMovie; + extraField = "count(1), count(files.playCount)"; + extraJoin = PrepareSQL("JOIN files ON files.idFile = %s_view.idFile", view.c_str()); } else if (idContent == VIDEODB_CONTENT_TVSHOWS) { - strSQL = "select %s " + PrepareSQL("from %s ", type.c_str()); - extFilter.fields = PrepareSQL("distinct %s.id%s, %s.str%s", type.c_str(), type.c_str(), type.c_str(), type.c_str()); - extFilter.AppendJoin(PrepareSQL("join %slinktvshow on %s.id%s = %slinktvshow.id%s join tvshowview on %slinktvshow.idShow = tvshowview.idShow", - type.c_str(), type.c_str(), type.c_str(), type.c_str(), type.c_str(), type.c_str())); + view = MediaTypeTvShow; + view_id = "idShow"; + media_type = MediaTypeTvShow; } else if (idContent == VIDEODB_CONTENT_MUSICVIDEOS) { - strSQL = "select %s " + PrepareSQL("from %s ", type.c_str()); - extFilter.fields = PrepareSQL("%s.id%s, %s.str%s, count(1), count(files.playCount)", type.c_str(), type.c_str(), type.c_str(), type.c_str()); - extFilter.AppendJoin(PrepareSQL("join %slinkmusicvideo on %s.id%s = %slinkmusicvideo.id%s join musicvideoview on %slinkmusicvideo.idMVideo = musicvideoview.idMVideo join files on files.idFile = musicvideoview.idFile", - type.c_str(), type.c_str(), type.c_str(), type.c_str(), type.c_str(), type.c_str())); - extFilter.AppendGroup(PrepareSQL("%s.id%s", type.c_str(), type.c_str())); + view = MediaTypeMusicVideo; + view_id = "idMVideo"; + media_type = MediaTypeMusicVideo; + extraField = "count(1), count(files.playCount)"; + extraJoin = PrepareSQL("JOIN files ON files.idFile = %s_view.idFile", view.c_str()); } else return false; + + strSQL = "SELECT %s " + PrepareSQL("FROM %s ", type); + extFilter.fields = PrepareSQL("%s.%s_id, %s.name", type, type, type); + extFilter.AppendField(extraField); + extFilter.AppendJoin(PrepareSQL("JOIN %s_link ON %s.%s_id = %s_link.%s_id", type, type, type, type, type)); + extFilter.AppendJoin(PrepareSQL("JOIN %s_view ON %s_link.media_id = %s_view.%s AND %s_link.media_type='%s'", + view.c_str(), type, view.c_str(), view_id.c_str(), type, media_type.c_str())); + extFilter.AppendJoin(extraJoin); + extFilter.AppendGroup(PrepareSQL("%s.%s_id", type, type)); } if (countOnly) { - extFilter.fields = PrepareSQL("COUNT(DISTINCT %s.id%s)", type.c_str(), type.c_str()); + extFilter.fields = PrepareSQL("COUNT(DISTINCT %s.%s_id)", type, type); extFilter.group.clear(); extFilter.order.clear(); } @@ -5210,24 +4974,24 @@ bool CVideoDatabase::GetNavCommon(const CStdString& strBaseDir, CFileItemList& i if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) { - map<int, pair<CStdString,int> > mapItems; - map<int, pair<CStdString,int> >::iterator it; + map<int, pair<std::string,int> > mapItems; + map<int, pair<std::string,int> >::iterator it; while (!m_pDS->eof()) { int id = m_pDS->fv(0).get_asInt(); - CStdString str = m_pDS->fv(1).get_asString(); + std::string str = m_pDS->fv(1).get_asString(); // was this already found? it = mapItems.find(id); if (it == mapItems.end()) { // check path - if (g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv(2).get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv(2).get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { if (idContent == VIDEODB_CONTENT_MOVIES || idContent == VIDEODB_CONTENT_MUSICVIDEOS) - mapItems.insert(pair<int, pair<CStdString,int> >(id, pair<CStdString,int>(str,m_pDS->fv(3).get_asInt()))); //fv(3) is file.playCount + mapItems.insert(pair<int, pair<std::string,int> >(id, pair<std::string,int>(str,m_pDS->fv(3).get_asInt()))); //fv(3) is file.playCount else if (idContent == VIDEODB_CONTENT_TVSHOWS) - mapItems.insert(pair<int, pair<CStdString,int> >(id, pair<CStdString,int>(str,0))); + mapItems.insert(pair<int, pair<std::string,int> >(id, pair<std::string,int>(str,0))); } } m_pDS->next(); @@ -5241,7 +5005,7 @@ bool CVideoDatabase::GetNavCommon(const CStdString& strBaseDir, CFileItemList& i pItem->GetVideoInfoTag()->m_type = type; CVideoDbUrl itemUrl = videoUrl; - CStdString path = StringUtils::Format("%i/", it->first); + std::string path = StringUtils::Format("%i/", it->first); itemUrl.AppendPath(path); pItem->SetPath(itemUrl.ToString()); @@ -5264,7 +5028,7 @@ bool CVideoDatabase::GetNavCommon(const CStdString& strBaseDir, CFileItemList& i pItem->GetVideoInfoTag()->m_type = type; CVideoDbUrl itemUrl = videoUrl; - CStdString path = StringUtils::Format("%i/", m_pDS->fv(0).get_asInt()); + std::string path = StringUtils::Format("%i/", m_pDS->fv(0).get_asInt()); itemUrl.AppendPath(path); pItem->SetPath(itemUrl.ToString()); @@ -5289,9 +5053,9 @@ bool CVideoDatabase::GetNavCommon(const CStdString& strBaseDir, CFileItemList& i return false; } -bool CVideoDatabase::GetTagsNav(const CStdString& strBaseDir, CFileItemList& items, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) +bool CVideoDatabase::GetTagsNav(const std::string& strBaseDir, CFileItemList& items, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) { - CStdString mediaType; + std::string mediaType; if (idContent == VIDEODB_CONTENT_MOVIES) mediaType = MediaTypeMovie; else if (idContent == VIDEODB_CONTENT_TVSHOWS) @@ -5306,21 +5070,21 @@ bool CVideoDatabase::GetTagsNav(const CStdString& strBaseDir, CFileItemList& ite if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL = "SELECT %s FROM taglinks "; + std::string strSQL = "SELECT %s FROM tag_link "; Filter extFilter = filter; - extFilter.fields = "tag.idTag, tag.strTag"; - extFilter.AppendJoin("JOIN tag ON tag.idTag = taglinks.idTag"); + extFilter.fields = "tag.tag_id, tag.name"; + extFilter.AppendJoin("JOIN tag ON tag.tag_id = tag_link.tag_id"); if (idContent == (int)VIDEODB_CONTENT_MOVIES) - extFilter.AppendJoin("JOIN movieview ON movieview.idMovie = taglinks.idMedia"); + extFilter.AppendJoin("JOIN movie_view ON movie_view.idMovie = tag_link.media_id"); - extFilter.AppendWhere(PrepareSQL("taglinks.media_type = '%s'", mediaType.c_str())); - extFilter.AppendGroup("taglinks.idTag"); + extFilter.AppendWhere(PrepareSQL("tag_link.media_type = '%s'", mediaType.c_str())); + extFilter.AppendGroup("tag_link.tag_id"); if (countOnly) { - extFilter.fields = "COUNT(DISTINCT taglinks.idTag)"; + extFilter.fields = "COUNT(DISTINCT tag_link.tag_id)"; extFilter.group.clear(); extFilter.order.clear(); } @@ -5355,7 +5119,7 @@ bool CVideoDatabase::GetTagsNav(const CStdString& strBaseDir, CFileItemList& ite pItem->GetVideoInfoTag()->m_type = "tag"; CVideoDbUrl itemUrl = videoUrl; - CStdString path = StringUtils::Format("%i/", idTag); + std::string path = StringUtils::Format("%i/", idTag); itemUrl.AppendPath(path); pItem->SetPath(itemUrl.ToString()); @@ -5378,7 +5142,7 @@ bool CVideoDatabase::GetTagsNav(const CStdString& strBaseDir, CFileItemList& ite return false; } -bool CVideoDatabase::GetSetsNav(const CStdString& strBaseDir, CFileItemList& items, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool ignoreSingleMovieSets /* = false */) +bool CVideoDatabase::GetSetsNav(const std::string& strBaseDir, CFileItemList& items, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool ignoreSingleMovieSets /* = false */) { if (idContent != VIDEODB_CONTENT_MOVIES) return false; @@ -5386,7 +5150,7 @@ bool CVideoDatabase::GetSetsNav(const CStdString& strBaseDir, CFileItemList& ite return GetSetsByWhere(strBaseDir, filter, items, ignoreSingleMovieSets); } -bool CVideoDatabase::GetSetsByWhere(const CStdString& strBaseDir, const Filter &filter, CFileItemList& items, bool ignoreSingleMovieSets /* = false */) +bool CVideoDatabase::GetSetsByWhere(const std::string& strBaseDir, const Filter &filter, CFileItemList& items, bool ignoreSingleMovieSets /* = false */) { try { @@ -5398,7 +5162,7 @@ bool CVideoDatabase::GetSetsByWhere(const CStdString& strBaseDir, const Filter & return false; Filter setFilter = filter; - setFilter.join += " JOIN sets ON movieview.idSet = sets.idSet"; + setFilter.join += " JOIN sets ON movie_view.idSet = sets.idSet"; if (!setFilter.order.empty()) setFilter.order += ","; setFilter.order += "sets.idSet"; @@ -5422,7 +5186,7 @@ bool CVideoDatabase::GetSetsByWhere(const CStdString& strBaseDir, const Filter & return false; } -bool CVideoDatabase::GetMusicVideoAlbumsNav(const CStdString& strBaseDir, CFileItemList& items, int idArtist /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) +bool CVideoDatabase::GetMusicVideoAlbumsNav(const std::string& strBaseDir, CFileItemList& items, int idArtist /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) { try { @@ -5433,21 +5197,21 @@ bool CVideoDatabase::GetMusicVideoAlbumsNav(const CStdString& strBaseDir, CFileI if (!videoUrl.FromString(strBaseDir)) return false; - CStdString strSQL = "select %s from musicvideoview "; + std::string strSQL = "select %s from musicvideo_view "; Filter extFilter = filter; - extFilter.fields = PrepareSQL("musicvideoview.c%02d, musicvideoview.idMVideo, actors.strActor", VIDEODB_ID_MUSICVIDEO_ALBUM); - extFilter.AppendJoin(PrepareSQL("join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo = musicvideoview.idMVideo")); - extFilter.AppendJoin(PrepareSQL("join actors on actors.idActor = artistlinkmusicvideo.idArtist")); + extFilter.fields = PrepareSQL("musicvideo_view.c%02d, musicvideo_view.idMVideo, actor.name", VIDEODB_ID_MUSICVIDEO_ALBUM); + extFilter.AppendJoin(PrepareSQL("JOIN actor_link ON actor_link.media_id=musicvideo_view.idMVideo AND actor_link.media_type='musicvideo'")); + extFilter.AppendJoin(PrepareSQL("JOIN actor ON actor.actor_id = actor_link.actor_id")); if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) { extFilter.fields += ", path.strPath"; - extFilter.AppendJoin("join files on files.idFile = musicvideoview.idFile join path on path.idPath = files.idPath"); + extFilter.AppendJoin("join files on files.idFile = musicvideo_view.idFile join path on path.idPath = files.idPath"); } if (idArtist > -1) videoUrl.AddOption("artistid", idArtist); - extFilter.AppendGroup(PrepareSQL("musicvideoview.c%02d", VIDEODB_ID_MUSICVIDEO_ALBUM)); + extFilter.AppendGroup(PrepareSQL("musicvideo_view.c%02d", VIDEODB_ID_MUSICVIDEO_ALBUM)); if (countOnly) { @@ -5476,18 +5240,18 @@ bool CVideoDatabase::GetMusicVideoAlbumsNav(const CStdString& strBaseDir, CFileI if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) { - map<int, pair<CStdString,CStdString> > mapAlbums; - map<int, pair<CStdString,CStdString> >::iterator it; + map<int, pair<std::string,std::string> > mapAlbums; + map<int, pair<std::string,std::string> >::iterator it; while (!m_pDS->eof()) { int lidMVideo = m_pDS->fv(1).get_asInt(); - CStdString strAlbum = m_pDS->fv(0).get_asString(); + std::string strAlbum = m_pDS->fv(0).get_asString(); it = mapAlbums.find(lidMVideo); // was this genre already found? if (it == mapAlbums.end()) { // check path - if (g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) mapAlbums.insert(make_pair(lidMVideo, make_pair(strAlbum,m_pDS->fv(2).get_asString()))); } m_pDS->next(); @@ -5501,7 +5265,7 @@ bool CVideoDatabase::GetMusicVideoAlbumsNav(const CStdString& strBaseDir, CFileI CFileItemPtr pItem(new CFileItem(it->second.first)); CVideoDbUrl itemUrl = videoUrl; - CStdString path = StringUtils::Format("%i/", it->first); + std::string path = StringUtils::Format("%i/", it->first); itemUrl.AppendPath(path); pItem->SetPath(itemUrl.ToString()); @@ -5524,7 +5288,7 @@ bool CVideoDatabase::GetMusicVideoAlbumsNav(const CStdString& strBaseDir, CFileI CFileItemPtr pItem(new CFileItem(m_pDS->fv(0).get_asString())); CVideoDbUrl itemUrl = videoUrl; - CStdString path = StringUtils::Format("%i/", m_pDS->fv(1).get_asInt()); + std::string path = StringUtils::Format("%i/", m_pDS->fv(1).get_asInt()); itemUrl.AppendPath(path); pItem->SetPath(itemUrl.ToString()); @@ -5551,17 +5315,17 @@ bool CVideoDatabase::GetMusicVideoAlbumsNav(const CStdString& strBaseDir, CFileI return false; } -bool CVideoDatabase::GetWritersNav(const CStdString& strBaseDir, CFileItemList& items, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) +bool CVideoDatabase::GetWritersNav(const std::string& strBaseDir, CFileItemList& items, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) { return GetPeopleNav(strBaseDir, items, "writer", idContent, filter, countOnly); } -bool CVideoDatabase::GetDirectorsNav(const CStdString& strBaseDir, CFileItemList& items, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) +bool CVideoDatabase::GetDirectorsNav(const std::string& strBaseDir, CFileItemList& items, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) { return GetPeopleNav(strBaseDir, items, "director", idContent, filter, countOnly); } -bool CVideoDatabase::GetActorsNav(const CStdString& strBaseDir, CFileItemList& items, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) +bool CVideoDatabase::GetActorsNav(const std::string& strBaseDir, CFileItemList& items, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) { if (GetPeopleNav(strBaseDir, items, (idContent == VIDEODB_CONTENT_MUSICVIDEOS) ? "artist" : "actor", idContent, filter, countOnly)) { // set thumbs - ideally this should be in the normal thumb setting routines @@ -5578,7 +5342,7 @@ bool CVideoDatabase::GetActorsNav(const CStdString& strBaseDir, CFileItemList& i return false; } -bool CVideoDatabase::GetPeopleNav(const CStdString& strBaseDir, CFileItemList& items, const CStdString &type, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) +bool CVideoDatabase::GetPeopleNav(const std::string& strBaseDir, CFileItemList& items, const char *type, int idContent /* = -1 */, const Filter &filter /* = Filter() */, bool countOnly /* = false */) { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; @@ -5595,76 +5359,92 @@ bool CVideoDatabase::GetPeopleNav(const CStdString& strBaseDir, CFileItemList& i // General routine that the other actor/director/writer routines call // get primary genres for movies - CStdString strSQL; + std::string strSQL; Filter extFilter = filter; if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) { + std::string view, view_id, media_type, extraField; if (idContent == VIDEODB_CONTENT_MOVIES) { - strSQL = "select %s from actors "; - extFilter.fields = "actors.idActor, actors.strActor, actors.strThumb, path.strPath, files.playCount"; - extFilter.AppendJoin(PrepareSQL("join %slinkmovie on actors.idActor = %slinkmovie.id%s join movieview on %slinkmovie.idMovie = movieview.idMovie join files on files.idFile = movieview.idFile join path on path.idPath = files.idPath", - type.c_str(), type.c_str(), type.c_str(), type.c_str())); + view = MediaTypeMovie; + view_id = "idMovie"; + media_type = MediaTypeMovie; + extraField = "files.playCount"; } else if (idContent == VIDEODB_CONTENT_TVSHOWS) { - strSQL = "select %s from actors "; - extFilter.fields = "actors.idActor, actors.strActor, actors.strThumb, path.strPath"; - extFilter.AppendJoin(PrepareSQL("join %slinktvshow on actors.idActor = %slinktvshow.id%s join episodeview on %slinktvshow.idShow = episodeview.idShow join files on files.idFile = episodeview.idFile join path on path.idPath = files.idPath", - type.c_str(), type.c_str(), type.c_str(), type.c_str())); + view = MediaTypeEpisode; + view_id = "idShow"; + media_type = MediaTypeTvShow; } else if (idContent == VIDEODB_CONTENT_EPISODES) { - strSQL = "select %s from actors "; - extFilter.fields = "actors.idActor, actors.strActor, actors.strThumb, path.strPath, files.playCount"; - extFilter.AppendJoin(PrepareSQL("join %slinkepisode on actors.idActor = %slinkepisode.id%s join episodeview on %slinkepisode.idEpisode = episodeview.idEpisode join files on files.idFile = episodeview.idFile join path on path.idPath = files.idPath", - type.c_str(), type.c_str(), type.c_str(), type.c_str())); + view = MediaTypeEpisode; + view_id = "idEpisode"; + media_type = MediaTypeEpisode; + extraField = "files.playCount"; } else if (idContent == VIDEODB_CONTENT_MUSICVIDEOS) { - strSQL = "select %s from actors "; - extFilter.fields = "actors.idActor, actors.strActor, actors.strThumb, path.strPath, files.playCount"; - extFilter.AppendJoin(PrepareSQL("join %slinkmusicvideo on actors.idActor = %slinkmusicvideo.id%s join musicvideoview on %slinkmusicvideo.idMVideo = musicvideoview.idMVideo join files on files.idFile = musicvideoview.idFile join path on path.idPath = files.idPath", - type.c_str(), type.c_str(), type.c_str(), type.c_str())); + view = MediaTypeMusicVideo; + view_id = "idMVideo"; + media_type = MediaTypeMusicVideo; + extraField = "files.playCount"; } else return false; + + strSQL = "SELECT %s FROM actor "; + extFilter.fields = "actor.actor_id, actor.name, actor.art_urls, path.strPath"; + extFilter.AppendField(extraField); + extFilter.AppendJoin(PrepareSQL("JOIN %s_link ON actor.actor_id = %s_link.actor_id", type, type)); + extFilter.AppendJoin(PrepareSQL("JOIN %s_view ON %s_link.media_id = %s_view.%s AND %s_link.media_type='%s'", view.c_str(), type, view.c_str(), view_id.c_str(), type, media_type.c_str())); + extFilter.AppendJoin(PrepareSQL("JOIN files ON files.idFile = %s_view.idFile", view.c_str())); + extFilter.AppendJoin("JOIN path ON path.idPath = files.idPath"); } else { + std::string view, view_id, media_type, extraField, extraJoin; if (idContent == VIDEODB_CONTENT_MOVIES) { - strSQL ="select %s from actors "; - extFilter.fields = "actors.idActor, actors.strActor, actors.strThumb, count(1), count(files.playCount)"; - extFilter.AppendJoin(PrepareSQL("join %slinkmovie on actors.idActor = %slinkmovie.id%s join movieview on %slinkmovie.idMovie = movieview.idMovie join files on files.idFile = movieview.idFile", - type.c_str(), type.c_str(), type.c_str(), type.c_str())); - extFilter.AppendGroup("actors.idActor"); + view = MediaTypeMovie; + view_id = "idMovie"; + media_type = MediaTypeMovie; + extraField = "count(1), count(files.playCount)"; + extraJoin = PrepareSQL(" JOIN files ON files.idFile=%s_view.idFile", view.c_str()); } else if (idContent == VIDEODB_CONTENT_TVSHOWS) { - strSQL = "select %s " + PrepareSQL("from actors, %slinktvshow, tvshowview ", type.c_str()); - extFilter.fields = "distinct actors.idActor, actors.strActor, actors.strThumb"; - extFilter.AppendWhere(PrepareSQL("actors.idActor = %slinktvshow.id%s and %slinktvshow.idShow = tvshowview.idShow", - type.c_str(), type.c_str(), type.c_str())); + view = MediaTypeTvShow; + view_id = "idShow"; + media_type = MediaTypeTvShow; } else if (idContent == VIDEODB_CONTENT_EPISODES) { - strSQL = "select %s " + PrepareSQL("from %slinkepisode, actors, episodeview, files ", type.c_str()); - extFilter.fields = "actors.idActor, actors.strActor, actors.strThumb, count(1), count(files.playCount)"; - extFilter.AppendWhere(PrepareSQL("actors.idActor = %slinkepisode.id%s and %slinkepisode.idEpisode = episodeview.idEpisode and files.idFile = episodeview.idFile", - type.c_str(), type.c_str(), type.c_str())); - extFilter.AppendGroup("actors.idActor"); + view = MediaTypeEpisode; + view_id = "idEpisode"; + media_type = MediaTypeEpisode; + extraField = "count(1), count(files.playCount)"; + extraJoin = PrepareSQL("JOIN files ON files.idFile = %s_view.idFile", view.c_str()); } else if (idContent == VIDEODB_CONTENT_MUSICVIDEOS) { - strSQL = "select %s from actors "; - extFilter.fields = "actors.idActor, actors.strActor, actors.strThumb, count(1), count(files.playCount)"; - extFilter.AppendJoin(PrepareSQL("join %slinkmusicvideo on actors.idActor = %slinkmusicvideo.id%s join musicvideoview on %slinkmusicvideo.idMVideo = musicvideoview.idMVideo join files on files.idFile = musicvideoview.idFile", - type.c_str(), type.c_str(), type.c_str(), type.c_str())); - extFilter.AppendGroup("actors.idActor"); + view = MediaTypeMusicVideo; + view_id = "idMVideo"; + media_type = MediaTypeMusicVideo; + extraField = "count(1), count(files.playCount)"; + extraJoin = PrepareSQL("JOIN files ON files.idFile = %s_view.idFile", view.c_str()); } else return false; + + strSQL ="SELECT %s FROM actor "; + extFilter.fields = "actor.actor_id, actor.name, actor.art_urls"; + extFilter.AppendField(extraField); + extFilter.AppendJoin(PrepareSQL("JOIN %s_link on actor.actor_id = %s_link.actor_id", type, type)); + extFilter.AppendJoin(PrepareSQL("JOIN %s_view on %s_link.media_id = %s_view.%s AND %s_link.media_type='%s'", view.c_str(), type, view.c_str(), view_id.c_str(), type, media_type.c_str())); + extFilter.AppendJoin(extraJoin); + extFilter.AppendGroup("actor.actor_id"); } if (countOnly) @@ -5719,7 +5499,7 @@ bool CVideoDatabase::GetPeopleNav(const CStdString& strBaseDir, CFileItemList& i if (it == mapActors.end()) { // check path - if (g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) mapActors.insert(pair<int, CActor>(idActor, actor)); } m_pDS->next(); @@ -5731,7 +5511,7 @@ bool CVideoDatabase::GetPeopleNav(const CStdString& strBaseDir, CFileItemList& i CFileItemPtr pItem(new CFileItem(it->second.name)); CVideoDbUrl itemUrl = videoUrl; - CStdString path = StringUtils::Format("%i/", it->first); + std::string path = StringUtils::Format("%i/", it->first); itemUrl.AppendPath(path); pItem->SetPath(itemUrl.ToString()); @@ -5752,7 +5532,7 @@ bool CVideoDatabase::GetPeopleNav(const CStdString& strBaseDir, CFileItemList& i CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString())); CVideoDbUrl itemUrl = videoUrl; - CStdString path = StringUtils::Format("%i/", m_pDS->fv(0).get_asInt()); + std::string path = StringUtils::Format("%i/", m_pDS->fv(0).get_asInt()); itemUrl.AppendPath(path); pItem->SetPath(itemUrl.ToString()); @@ -5793,54 +5573,54 @@ bool CVideoDatabase::GetPeopleNav(const CStdString& strBaseDir, CFileItemList& i return false; } -bool CVideoDatabase::GetYearsNav(const CStdString& strBaseDir, CFileItemList& items, int idContent /* = -1 */, const Filter &filter /* = Filter() */) +bool CVideoDatabase::GetYearsNav(const std::string& strBaseDir, CFileItemList& items, int idContent /* = -1 */, const Filter &filter /* = Filter() */) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString strSQL; + std::string strSQL; Filter extFilter = filter; if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) { if (idContent == VIDEODB_CONTENT_MOVIES) { - strSQL = PrepareSQL("select movieview.c%02d, path.strPath, files.playCount from movieview ", VIDEODB_ID_YEAR); - extFilter.AppendJoin("join files on files.idFile = movieview.idFile join path on files.idPath = path.idPath"); + strSQL = PrepareSQL("select movie_view.c%02d, path.strPath, files.playCount from movie_view ", VIDEODB_ID_YEAR); + extFilter.AppendJoin("join files on files.idFile = movie_view.idFile join path on files.idPath = path.idPath"); } else if (idContent == VIDEODB_CONTENT_TVSHOWS) { - strSQL = PrepareSQL("select tvshowview.c%02d, path.strPath from tvshowview ", VIDEODB_ID_TV_PREMIERED); - extFilter.AppendJoin("join episodeview on episodeview.idShow = tvshowview.idShow join files on files.idFile = episodeview.idFile join path on files.idPath = path.idPath"); + strSQL = PrepareSQL("select tvshow_view.c%02d, path.strPath from tvshow_view ", VIDEODB_ID_TV_PREMIERED); + extFilter.AppendJoin("join episode_view on episode_view.idShow = tvshow_view.idShow join files on files.idFile = episode_view.idFile join path on files.idPath = path.idPath"); } else if (idContent == VIDEODB_CONTENT_MUSICVIDEOS) { - strSQL = PrepareSQL("select musicvideoview.c%02d, path.strPath, files.playCount from musicvideoview ", VIDEODB_ID_MUSICVIDEO_YEAR); - extFilter.AppendJoin("join files on files.idFile = musicvideoview.idFile join path on files.idPath = path.idPath"); + strSQL = PrepareSQL("select musicvideo_view.c%02d, path.strPath, files.playCount from musicvideo_view ", VIDEODB_ID_MUSICVIDEO_YEAR); + extFilter.AppendJoin("join files on files.idFile = musicvideo_view.idFile join path on files.idPath = path.idPath"); } else return false; } else { - CStdString group; + std::string group; if (idContent == VIDEODB_CONTENT_MOVIES) { - strSQL = PrepareSQL("select movieview.c%02d, count(1), count(files.playCount) from movieview ", VIDEODB_ID_YEAR); - extFilter.AppendJoin("join files on files.idFile = movieview.idFile"); - extFilter.AppendGroup(PrepareSQL("movieview.c%02d", VIDEODB_ID_YEAR)); + strSQL = PrepareSQL("select movie_view.c%02d, count(1), count(files.playCount) from movie_view ", VIDEODB_ID_YEAR); + extFilter.AppendJoin("join files on files.idFile = movie_view.idFile"); + extFilter.AppendGroup(PrepareSQL("movie_view.c%02d", VIDEODB_ID_YEAR)); } else if (idContent == VIDEODB_CONTENT_TVSHOWS) { - strSQL = PrepareSQL("select distinct tvshowview.c%02d from tvshowview", VIDEODB_ID_TV_PREMIERED); - extFilter.AppendGroup(PrepareSQL("tvshowview.c%02d", VIDEODB_ID_TV_PREMIERED)); + strSQL = PrepareSQL("select distinct tvshow_view.c%02d from tvshow_view", VIDEODB_ID_TV_PREMIERED); + extFilter.AppendGroup(PrepareSQL("tvshow_view.c%02d", VIDEODB_ID_TV_PREMIERED)); } else if (idContent == VIDEODB_CONTENT_MUSICVIDEOS) { - strSQL = PrepareSQL("select musicvideoview.c%02d, count(1), count(files.playCount) from musicvideoview ", VIDEODB_ID_MUSICVIDEO_YEAR); - extFilter.AppendJoin("join files on files.idFile = musicvideoview.idFile"); - extFilter.AppendGroup(PrepareSQL("musicvideoview.c%02d", VIDEODB_ID_MUSICVIDEO_YEAR)); + strSQL = PrepareSQL("select musicvideo_view.c%02d, count(1), count(files.playCount) from musicvideo_view ", VIDEODB_ID_MUSICVIDEO_YEAR); + extFilter.AppendJoin("join files on files.idFile = musicvideo_view.idFile"); + extFilter.AppendGroup(PrepareSQL("musicvideo_view.c%02d", VIDEODB_ID_MUSICVIDEO_YEAR)); } else return false; @@ -5856,8 +5636,8 @@ bool CVideoDatabase::GetYearsNav(const CStdString& strBaseDir, CFileItemList& it if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) { - map<int, pair<CStdString,int> > mapYears; - map<int, pair<CStdString,int> >::iterator it; + map<int, pair<std::string,int> > mapYears; + map<int, pair<std::string,int> >::iterator it; while (!m_pDS->eof()) { int lYear = 0; @@ -5873,13 +5653,13 @@ bool CVideoDatabase::GetYearsNav(const CStdString& strBaseDir, CFileItemList& it if (it == mapYears.end()) { // check path - if (g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { - CStdString year = StringUtils::Format("%d", lYear); + std::string year = StringUtils::Format("%d", lYear); if (idContent == VIDEODB_CONTENT_MOVIES || idContent == VIDEODB_CONTENT_MUSICVIDEOS) - mapYears.insert(pair<int, pair<CStdString,int> >(lYear, pair<CStdString,int>(year,m_pDS->fv(2).get_asInt()))); + mapYears.insert(pair<int, pair<std::string,int> >(lYear, pair<std::string,int>(year,m_pDS->fv(2).get_asInt()))); else - mapYears.insert(pair<int, pair<CStdString,int> >(lYear, pair<CStdString,int>(year,0))); + mapYears.insert(pair<int, pair<std::string,int> >(lYear, pair<std::string,int>(year,0))); } } m_pDS->next(); @@ -5893,7 +5673,7 @@ bool CVideoDatabase::GetYearsNav(const CStdString& strBaseDir, CFileItemList& it CFileItemPtr pItem(new CFileItem(it->second.first)); CVideoDbUrl itemUrl = videoUrl; - CStdString path = StringUtils::Format("%i/", it->first); + std::string path = StringUtils::Format("%i/", it->first); itemUrl.AppendPath(path); pItem->SetPath(itemUrl.ToString()); @@ -5908,7 +5688,7 @@ bool CVideoDatabase::GetYearsNav(const CStdString& strBaseDir, CFileItemList& it while (!m_pDS->eof()) { int lYear = 0; - CStdString strLabel; + std::string strLabel; if (idContent == VIDEODB_CONTENT_TVSHOWS) { CDateTime time; @@ -5929,7 +5709,7 @@ bool CVideoDatabase::GetYearsNav(const CStdString& strBaseDir, CFileItemList& it CFileItemPtr pItem(new CFileItem(strLabel)); CVideoDbUrl itemUrl = videoUrl; - CStdString path = StringUtils::Format("%i/", lYear); + std::string path = StringUtils::Format("%i/", lYear); itemUrl.AppendPath(path); pItem->SetPath(itemUrl.ToString()); @@ -5959,7 +5739,7 @@ bool CVideoDatabase::GetYearsNav(const CStdString& strBaseDir, CFileItemList& it return false; } -bool CVideoDatabase::GetSeasonsNav(const CStdString& strBaseDir, CFileItemList& items, int idActor, int idDirector, int idGenre, int idYear, int idShow, bool getLinkedMovies /* = true */) +bool CVideoDatabase::GetSeasonsNav(const std::string& strBaseDir, CFileItemList& items, int idActor, int idDirector, int idGenre, int idYear, int idShow, bool getLinkedMovies /* = true */) { // parse the base path to get additional filters CVideoDbUrl videoUrl; @@ -5984,7 +5764,7 @@ bool CVideoDatabase::GetSeasonsNav(const CStdString& strBaseDir, CFileItemList& if (getLinkedMovies && idShow != -1) { Filter movieFilter; - movieFilter.join = PrepareSQL("join movielinktvshow on movielinktvshow.idMovie=movieview.idMovie"); + movieFilter.join = PrepareSQL("join movielinktvshow on movielinktvshow.idMovie=movie_view.idMovie"); movieFilter.where = PrepareSQL("movielinktvshow.idShow = %i", idShow); CFileItemList movieItems; GetMoviesByWhere("videodb://movies/titles/", movieFilter, movieItems); @@ -5996,7 +5776,7 @@ bool CVideoDatabase::GetSeasonsNav(const CStdString& strBaseDir, CFileItemList& return true; } -bool CVideoDatabase::GetSeasonsByWhere(const CStdString& strBaseDir, const Filter &filter, CFileItemList& items, bool appendFullShowPath /* = true */, const SortDescription &sortDescription /* = SortDescription() */) +bool CVideoDatabase::GetSeasonsByWhere(const std::string& strBaseDir, const Filter &filter, CFileItemList& items, bool appendFullShowPath /* = true */, const SortDescription &sortDescription /* = SortDescription() */) { try { @@ -6008,7 +5788,7 @@ bool CVideoDatabase::GetSeasonsByWhere(const CStdString& strBaseDir, const Filte if (!videoUrl.FromString(strBaseDir)) return false; - CStdString strSQL = "SELECT * FROM seasonview "; + std::string strSQL = "SELECT * FROM season_view "; Filter extFilter = filter; if (!BuildSQL(strBaseDir, strSQL, extFilter, strSQL, videoUrl)) @@ -6032,7 +5812,7 @@ bool CVideoDatabase::GetSeasonsByWhere(const CStdString& strBaseDir, const Filte { mapSeasons.insert(std::make_pair(showId, iSeason)); - CStdString strLabel; + std::string strLabel; if (iSeason == 0) strLabel = g_localizeStrings.Get(20381); else @@ -6040,7 +5820,7 @@ bool CVideoDatabase::GetSeasonsByWhere(const CStdString& strBaseDir, const Filte CFileItemPtr pItem(new CFileItem(strLabel)); CVideoDbUrl itemUrl = videoUrl; - CStdString strDir; + std::string strDir; if (appendFullShowPath) strDir += StringUtils::Format("%d/", showId); strDir += StringUtils::Format("%d/", iSeason); @@ -6091,7 +5871,7 @@ bool CVideoDatabase::GetSeasonsByWhere(const CStdString& strBaseDir, const Filte return false; } -bool CVideoDatabase::GetSortedVideos(const MediaType &mediaType, const CStdString& strBaseDir, const SortDescription &sortDescription, CFileItemList& items, const Filter &filter /* = Filter() */) +bool CVideoDatabase::GetSortedVideos(const MediaType &mediaType, const std::string& strBaseDir, const SortDescription &sortDescription, CFileItemList& items, const Filter &filter /* = Filter() */) { if (NULL == m_pDB.get() || NULL == m_pDS.get()) return false; @@ -6127,7 +5907,7 @@ bool CVideoDatabase::GetSortedVideos(const MediaType &mediaType, const CStdStrin return success; } -bool CVideoDatabase::GetItems(const CStdString &strBaseDir, CFileItemList &items, const Filter &filter /* = Filter() */, const SortDescription &sortDescription /* = SortDescription() */) +bool CVideoDatabase::GetItems(const std::string &strBaseDir, CFileItemList &items, const Filter &filter /* = Filter() */, const SortDescription &sortDescription /* = SortDescription() */) { CVideoDbUrl videoUrl; if (!videoUrl.FromString(strBaseDir)) @@ -6136,19 +5916,19 @@ bool CVideoDatabase::GetItems(const CStdString &strBaseDir, CFileItemList &items return GetItems(strBaseDir, videoUrl.GetType(), videoUrl.GetItemType(), items, filter, sortDescription); } -bool CVideoDatabase::GetItems(const CStdString &strBaseDir, const CStdString &mediaType, const CStdString &itemType, CFileItemList &items, const Filter &filter /* = Filter() */, const SortDescription &sortDescription /* = SortDescription() */) +bool CVideoDatabase::GetItems(const std::string &strBaseDir, const std::string &mediaType, const std::string &itemType, CFileItemList &items, const Filter &filter /* = Filter() */, const SortDescription &sortDescription /* = SortDescription() */) { VIDEODB_CONTENT_TYPE contentType; - if (mediaType.Equals("movies")) + if (StringUtils::EqualsNoCase(mediaType, "movies")) contentType = VIDEODB_CONTENT_MOVIES; - else if (mediaType.Equals("tvshows")) + else if (StringUtils::EqualsNoCase(mediaType, "tvshows")) { - if (itemType.Equals("episodes")) + if (StringUtils::EqualsNoCase(itemType, "episodes")) contentType = VIDEODB_CONTENT_EPISODES; else contentType = VIDEODB_CONTENT_TVSHOWS; } - else if (mediaType.Equals("musicvideos")) + else if (StringUtils::EqualsNoCase(mediaType, "musicvideos")) contentType = VIDEODB_CONTENT_MUSICVIDEOS; else return false; @@ -6156,67 +5936,69 @@ bool CVideoDatabase::GetItems(const CStdString &strBaseDir, const CStdString &me return GetItems(strBaseDir, contentType, itemType, items, filter, sortDescription); } -bool CVideoDatabase::GetItems(const CStdString &strBaseDir, VIDEODB_CONTENT_TYPE mediaType, const CStdString &itemType, CFileItemList &items, const Filter &filter /* = Filter() */, const SortDescription &sortDescription /* = SortDescription() */) +bool CVideoDatabase::GetItems(const std::string &strBaseDir, VIDEODB_CONTENT_TYPE mediaType, const std::string &itemType, CFileItemList &items, const Filter &filter /* = Filter() */, const SortDescription &sortDescription /* = SortDescription() */) { - if (itemType.Equals("movies") && (mediaType == VIDEODB_CONTENT_MOVIES || mediaType == VIDEODB_CONTENT_MOVIE_SETS)) + if (StringUtils::EqualsNoCase(itemType, "movies") && (mediaType == VIDEODB_CONTENT_MOVIES || mediaType == VIDEODB_CONTENT_MOVIE_SETS)) return GetMoviesByWhere(strBaseDir, filter, items, sortDescription); - else if (itemType.Equals("tvshows") && mediaType == VIDEODB_CONTENT_TVSHOWS) + else if (StringUtils::EqualsNoCase(itemType, "tvshows") && mediaType == VIDEODB_CONTENT_TVSHOWS) return GetTvShowsByWhere(strBaseDir, filter, items, sortDescription); - else if (itemType.Equals("musicvideos") && mediaType == VIDEODB_CONTENT_MUSICVIDEOS) + else if (StringUtils::EqualsNoCase(itemType, "musicvideos") && mediaType == VIDEODB_CONTENT_MUSICVIDEOS) return GetMusicVideosByWhere(strBaseDir, filter, items, true, sortDescription); - else if (itemType.Equals("episodes") && mediaType == VIDEODB_CONTENT_EPISODES) + else if (StringUtils::EqualsNoCase(itemType, "episodes") && mediaType == VIDEODB_CONTENT_EPISODES) return GetEpisodesByWhere(strBaseDir, filter, items, true, sortDescription); - else if (itemType.Equals("seasons") && mediaType == VIDEODB_CONTENT_TVSHOWS) + else if (StringUtils::EqualsNoCase(itemType, "seasons") && mediaType == VIDEODB_CONTENT_TVSHOWS) return GetSeasonsNav(strBaseDir, items); - else if (itemType.Equals("genres")) + else if (StringUtils::EqualsNoCase(itemType, "genres")) return GetGenresNav(strBaseDir, items, mediaType, filter); - else if (itemType.Equals("years")) + else if (StringUtils::EqualsNoCase(itemType, "years")) return GetYearsNav(strBaseDir, items, mediaType, filter); - else if (itemType.Equals("actors")) + else if (StringUtils::EqualsNoCase(itemType, "actors")) return GetActorsNav(strBaseDir, items, mediaType, filter); - else if (itemType.Equals("directors")) + else if (StringUtils::EqualsNoCase(itemType, "directors")) return GetDirectorsNav(strBaseDir, items, mediaType, filter); - else if (itemType.Equals("writers")) + else if (StringUtils::EqualsNoCase(itemType, "writers")) return GetWritersNav(strBaseDir, items, mediaType, filter); - else if (itemType.Equals("studios")) + else if (StringUtils::EqualsNoCase(itemType, "studios")) return GetStudiosNav(strBaseDir, items, mediaType, filter); - else if (itemType.Equals("sets")) + else if (StringUtils::EqualsNoCase(itemType, "sets")) return GetSetsNav(strBaseDir, items, mediaType, filter); - else if (itemType.Equals("countries")) + else if (StringUtils::EqualsNoCase(itemType, "countries")) return GetCountriesNav(strBaseDir, items, mediaType, filter); - else if (itemType.Equals("tags")) + else if (StringUtils::EqualsNoCase(itemType, "tags")) return GetTagsNav(strBaseDir, items, mediaType, filter); - else if (itemType.Equals("artists") && mediaType == VIDEODB_CONTENT_MUSICVIDEOS) + else if (StringUtils::EqualsNoCase(itemType, "artists") && mediaType == VIDEODB_CONTENT_MUSICVIDEOS) return GetActorsNav(strBaseDir, items, mediaType, filter); - else if (itemType.Equals("albums") && mediaType == VIDEODB_CONTENT_MUSICVIDEOS) + else if (StringUtils::EqualsNoCase(itemType, "albums") && mediaType == VIDEODB_CONTENT_MUSICVIDEOS) return GetMusicVideoAlbumsNav(strBaseDir, items, -1, filter); return false; } -CStdString CVideoDatabase::GetItemById(const CStdString &itemType, int id) +std::string CVideoDatabase::GetItemById(const std::string &itemType, int id) { - if (itemType.Equals("genres")) + if (StringUtils::EqualsNoCase(itemType, "genres")) return GetGenreById(id); - else if (itemType.Equals("years")) + else if (StringUtils::EqualsNoCase(itemType, "years")) return StringUtils::Format("%d", id); - else if (itemType.Equals("actors") || itemType.Equals("directors") || itemType.Equals("artists")) + else if (StringUtils::EqualsNoCase(itemType, "actors") || + StringUtils::EqualsNoCase(itemType, "directors") || + StringUtils::EqualsNoCase(itemType, "artists")) return GetPersonById(id); - else if (itemType.Equals("studios")) + else if (StringUtils::EqualsNoCase(itemType, "studios")) return GetStudioById(id); - else if (itemType.Equals("sets")) + else if (StringUtils::EqualsNoCase(itemType, "sets")) return GetSetById(id); - else if (itemType.Equals("countries")) + else if (StringUtils::EqualsNoCase(itemType, "countries")) return GetCountryById(id); - else if (itemType.Equals("tags")) + else if (StringUtils::EqualsNoCase(itemType, "tags")) return GetTagById(id); - else if (itemType.Equals("albums")) + else if (StringUtils::EqualsNoCase(itemType, "albums")) return GetMusicVideoAlbumById(id); return ""; } -bool CVideoDatabase::GetMoviesNav(const CStdString& strBaseDir, CFileItemList& items, +bool CVideoDatabase::GetMoviesNav(const std::string& strBaseDir, CFileItemList& items, int idGenre /* = -1 */, int idYear /* = -1 */, int idActor /* = -1 */, int idDirector /* = -1 */, int idStudio /* = -1 */, int idCountry /* = -1 */, int idSet /* = -1 */, int idTag /* = -1 */, const SortDescription &sortDescription /* = SortDescription() */) @@ -6246,7 +6028,7 @@ bool CVideoDatabase::GetMoviesNav(const CStdString& strBaseDir, CFileItemList& i return GetMoviesByWhere(videoUrl.ToString(), filter, items, sortDescription); } -bool CVideoDatabase::GetMoviesByWhere(const CStdString& strBaseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription /* = SortDescription() */) +bool CVideoDatabase::GetMoviesByWhere(const std::string& strBaseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription /* = SortDescription() */) { try { @@ -6265,7 +6047,7 @@ bool CVideoDatabase::GetMoviesByWhere(const CStdString& strBaseDir, const Filter int total = -1; - std::string strSQL = "select %s from movieview "; + std::string strSQL = "select %s from movie_view "; std::string strSQLExtra; if (!CDatabase::BuildSQL(strSQLExtra, extFilter, strSQLExtra)) return false; @@ -6312,7 +6094,7 @@ bool CVideoDatabase::GetMoviesByWhere(const CStdString& strBaseDir, const Filter CFileItemPtr pItem(new CFileItem(movie)); CVideoDbUrl itemUrl = videoUrl; - CStdString path = StringUtils::Format("%i", movie.m_iDbId); + std::string path = StringUtils::Format("%i", movie.m_iDbId); itemUrl.AppendPath(path); pItem->SetPath(itemUrl.ToString()); @@ -6332,7 +6114,7 @@ bool CVideoDatabase::GetMoviesByWhere(const CStdString& strBaseDir, const Filter return false; } -bool CVideoDatabase::GetTvShowsNav(const CStdString& strBaseDir, CFileItemList& items, +bool CVideoDatabase::GetTvShowsNav(const std::string& strBaseDir, CFileItemList& items, int idGenre /* = -1 */, int idYear /* = -1 */, int idActor /* = -1 */, int idDirector /* = -1 */, int idStudio /* = -1 */, int idTag /* = -1 */, const SortDescription &sortDescription /* = SortDescription() */) { @@ -6357,7 +6139,7 @@ bool CVideoDatabase::GetTvShowsNav(const CStdString& strBaseDir, CFileItemList& return GetTvShowsByWhere(videoUrl.ToString(), filter, items, sortDescription); } -bool CVideoDatabase::GetTvShowsByWhere(const CStdString& strBaseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription /* = SortDescription() */) +bool CVideoDatabase::GetTvShowsByWhere(const std::string& strBaseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription /* = SortDescription() */) { try { @@ -6368,7 +6150,7 @@ bool CVideoDatabase::GetTvShowsByWhere(const CStdString& strBaseDir, const Filte int total = -1; - std::string strSQL = "SELECT %s FROM tvshowview "; + std::string strSQL = "SELECT %s FROM tvshow_view "; CVideoDbUrl videoUrl; std::string strSQLExtra; Filter extFilter = filter; @@ -6419,7 +6201,7 @@ bool CVideoDatabase::GetTvShowsByWhere(const CStdString& strBaseDir, const Filte pItem->SetFromVideoInfoTag(movie); CVideoDbUrl itemUrl = videoUrl; - CStdString path = StringUtils::Format("%i/", record->at(0).get_asInt()); + std::string path = StringUtils::Format("%i/", record->at(0).get_asInt()); itemUrl.AppendPath(path); pItem->SetPath(itemUrl.ToString()); @@ -6439,13 +6221,13 @@ bool CVideoDatabase::GetTvShowsByWhere(const CStdString& strBaseDir, const Filte return false; } -bool CVideoDatabase::GetEpisodesNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre, int idYear, int idActor, int idDirector, int idShow, int idSeason, const SortDescription &sortDescription /* = SortDescription() */) +bool CVideoDatabase::GetEpisodesNav(const std::string& strBaseDir, CFileItemList& items, int idGenre, int idYear, int idActor, int idDirector, int idShow, int idSeason, const SortDescription &sortDescription /* = SortDescription() */) { CVideoDbUrl videoUrl; if (!videoUrl.FromString(strBaseDir)) return false; - CStdString strIn; + std::string strIn; if (idShow != -1) { videoUrl.AddOption("tvshowid", idShow); @@ -6471,7 +6253,7 @@ bool CVideoDatabase::GetEpisodesNav(const CStdString& strBaseDir, CFileItemList& if (idSeason == -1 && idShow != -1) { // add any linked movies Filter movieFilter; - movieFilter.join = PrepareSQL("join movielinktvshow on movielinktvshow.idMovie=movieview.idMovie"); + movieFilter.join = PrepareSQL("join movielinktvshow on movielinktvshow.idMovie=movie_view.idMovie"); movieFilter.where = PrepareSQL("movielinktvshow.idShow = %i", idShow); CFileItemList movieItems; GetMoviesByWhere("videodb://movies/titles/", movieFilter, movieItems); @@ -6483,7 +6265,7 @@ bool CVideoDatabase::GetEpisodesNav(const CStdString& strBaseDir, CFileItemList& return ret; } -bool CVideoDatabase::GetEpisodesByWhere(const CStdString& strBaseDir, const Filter &filter, CFileItemList& items, bool appendFullShowPath /* = true */, const SortDescription &sortDescription /* = SortDescription() */) +bool CVideoDatabase::GetEpisodesByWhere(const std::string& strBaseDir, const Filter &filter, CFileItemList& items, bool appendFullShowPath /* = true */, const SortDescription &sortDescription /* = SortDescription() */) { try { @@ -6495,7 +6277,7 @@ bool CVideoDatabase::GetEpisodesByWhere(const CStdString& strBaseDir, const Filt int total = -1; - std::string strSQL = "select %s from episodeview "; + std::string strSQL = "select %s from episode_view "; CVideoDbUrl videoUrl; std::string strSQLExtra; Filter extFilter = filter; @@ -6549,7 +6331,7 @@ bool CVideoDatabase::GetEpisodesByWhere(const CStdString& strBaseDir, const Filt int idEpisode = record->at(0).get_asInt(); CVideoDbUrl itemUrl = videoUrl; - CStdString path; + std::string path; if (appendFullShowPath && videoUrl.GetItemType() != "episodes") path = StringUtils::Format("%i/%i/%i", record->at(VIDEODB_DETAILS_EPISODE_TVSHOW_ID).get_asInt(), movie.m_iSeason, idEpisode); else @@ -6575,7 +6357,7 @@ bool CVideoDatabase::GetEpisodesByWhere(const CStdString& strBaseDir, const Filt return false; } -bool CVideoDatabase::GetMusicVideosNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre, int idYear, int idArtist, int idDirector, int idStudio, int idAlbum, int idTag /* = -1 */, const SortDescription &sortDescription /* = SortDescription() */) +bool CVideoDatabase::GetMusicVideosNav(const std::string& strBaseDir, CFileItemList& items, int idGenre, int idYear, int idArtist, int idDirector, int idStudio, int idAlbum, int idTag /* = -1 */, const SortDescription &sortDescription /* = SortDescription() */) { CVideoDbUrl videoUrl; if (!videoUrl.FromString(strBaseDir)) @@ -6600,7 +6382,7 @@ bool CVideoDatabase::GetMusicVideosNav(const CStdString& strBaseDir, CFileItemLi return GetMusicVideosByWhere(videoUrl.ToString(), filter, items, true, sortDescription); } -bool CVideoDatabase::GetRecentlyAddedMoviesNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit) +bool CVideoDatabase::GetRecentlyAddedMoviesNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit) { Filter filter; filter.order = "dateAdded desc, idMovie desc"; @@ -6608,7 +6390,7 @@ bool CVideoDatabase::GetRecentlyAddedMoviesNav(const CStdString& strBaseDir, CFi return GetMoviesByWhere(strBaseDir, filter, items); } -bool CVideoDatabase::GetRecentlyAddedEpisodesNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit) +bool CVideoDatabase::GetRecentlyAddedEpisodesNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit) { Filter filter; filter.order = "dateAdded desc, idEpisode desc"; @@ -6616,7 +6398,7 @@ bool CVideoDatabase::GetRecentlyAddedEpisodesNav(const CStdString& strBaseDir, C return GetEpisodesByWhere(strBaseDir, filter, items, false); } -bool CVideoDatabase::GetRecentlyAddedMusicVideosNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit) +bool CVideoDatabase::GetRecentlyAddedMusicVideosNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit) { Filter filter; filter.order = "dateAdded desc, idMVideo desc"; @@ -6624,42 +6406,42 @@ bool CVideoDatabase::GetRecentlyAddedMusicVideosNav(const CStdString& strBaseDir return GetMusicVideosByWhere(strBaseDir, filter, items); } -CStdString CVideoDatabase::GetGenreById(int id) +std::string CVideoDatabase::GetGenreById(int id) { - return GetSingleValue("genre", "strGenre", PrepareSQL("idGenre=%i", id)); + return GetSingleValue("genre", "name", PrepareSQL("genre_id=%i", id)); } -CStdString CVideoDatabase::GetCountryById(int id) +std::string CVideoDatabase::GetCountryById(int id) { - return GetSingleValue("country", "strCountry", PrepareSQL("idCountry=%i", id)); + return GetSingleValue("country", "name", PrepareSQL("country_id=%i", id)); } -CStdString CVideoDatabase::GetSetById(int id) +std::string CVideoDatabase::GetSetById(int id) { return GetSingleValue("sets", "strSet", PrepareSQL("idSet=%i", id)); } -CStdString CVideoDatabase::GetTagById(int id) +std::string CVideoDatabase::GetTagById(int id) { - return GetSingleValue("tag", "strTag", PrepareSQL("idTag = %i", id)); + return GetSingleValue("tag", "name", PrepareSQL("tag_id = %i", id)); } -CStdString CVideoDatabase::GetPersonById(int id) +std::string CVideoDatabase::GetPersonById(int id) { - return GetSingleValue("actors", "strActor", PrepareSQL("idActor=%i", id)); + return GetSingleValue("actor", "name", PrepareSQL("actor_id=%i", id)); } -CStdString CVideoDatabase::GetStudioById(int id) +std::string CVideoDatabase::GetStudioById(int id) { - return GetSingleValue("studio", "strStudio", PrepareSQL("idStudio=%i", id)); + return GetSingleValue("studio", "name", PrepareSQL("studio_id=%i", id)); } -CStdString CVideoDatabase::GetTvShowTitleById(int id) +std::string CVideoDatabase::GetTvShowTitleById(int id) { return GetSingleValue("tvshow", PrepareSQL("c%02d", VIDEODB_ID_TV_TITLE), PrepareSQL("idShow=%i", id)); } -CStdString CVideoDatabase::GetMusicVideoAlbumById(int id) +std::string CVideoDatabase::GetMusicVideoAlbumById(int id) { return GetSingleValue("musicvideo", PrepareSQL("c%02d", VIDEODB_ID_MUSICVIDEO_ALBUM), PrepareSQL("idMVideo=%i", id)); } @@ -6671,9 +6453,9 @@ bool CVideoDatabase::HasSets() const if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - m_pDS->query("SELECT movieview.idSet,COUNT(1) AS c FROM movieview " - "JOIN sets ON sets.idSet = movieview.idSet " - "GROUP BY movieview.idSet HAVING c>1"); + m_pDS->query("SELECT movie_view.idSet,COUNT(1) AS c FROM movie_view " + "JOIN sets ON sets.idSet = movie_view.idSet " + "GROUP BY movie_view.idSet HAVING c>1"); bool bResult = (m_pDS->num_rows() > 0); m_pDS->close(); @@ -6694,7 +6476,7 @@ int CVideoDatabase::GetTvShowForEpisode(int idEpisode) if (NULL == m_pDS2.get()) return false; // make sure we use m_pDS2, as this is called in loops using m_pDS - CStdString strSQL=PrepareSQL("select idShow from episode where idEpisode=%i", idEpisode); + std::string strSQL=PrepareSQL("select idShow from episode where idEpisode=%i", idEpisode); m_pDS2->query( strSQL.c_str() ); int result=-1; @@ -6715,7 +6497,7 @@ int CVideoDatabase::GetSeasonForEpisode(int idEpisode) { char column[5]; sprintf(column, "c%0d", VIDEODB_ID_EPISODE_SEASON); - CStdString id = GetSingleValue("episode", column, PrepareSQL("idEpisode=%i", idEpisode)); + std::string id = GetSingleValue("episode", column, PrepareSQL("idEpisode=%i", idEpisode)); if (id.empty()) return -1; return atoi(id.c_str()); @@ -6736,7 +6518,7 @@ bool CVideoDatabase::HasContent(VIDEODB_CONTENT_TYPE type) if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - CStdString sql; + std::string sql; if (type == VIDEODB_CONTENT_MOVIES) sql = "select count(1) from movie"; else if (type == VIDEODB_CONTENT_TVSHOWS) @@ -6757,43 +6539,19 @@ bool CVideoDatabase::HasContent(VIDEODB_CONTENT_TYPE type) return result; } -int CVideoDatabase::GetMusicVideoCount(const CStdString& strWhere) -{ - try - { - if (NULL == m_pDB.get()) return 0; - if (NULL == m_pDS.get()) return 0; - - CStdString strSQL = StringUtils::Format("select count(1) as nummovies from musicvideoview where %s",strWhere.c_str()); - m_pDS->query( strSQL.c_str() ); - - int iResult = 0; - if (!m_pDS->eof()) - iResult = m_pDS->fv("nummovies").get_asInt(); - - m_pDS->close(); - return iResult; - } - catch (...) - { - CLog::Log(LOGERROR, "%s failed", __FUNCTION__); - } - return 0; -} - -ScraperPtr CVideoDatabase::GetScraperForPath( const CStdString& strPath ) +ScraperPtr CVideoDatabase::GetScraperForPath( const std::string& strPath ) { SScanSettings settings; return GetScraperForPath(strPath, settings); } -ScraperPtr CVideoDatabase::GetScraperForPath(const CStdString& strPath, SScanSettings& settings) +ScraperPtr CVideoDatabase::GetScraperForPath(const std::string& strPath, SScanSettings& settings) { bool dummy; return GetScraperForPath(strPath, settings, dummy); } -ScraperPtr CVideoDatabase::GetScraperForPath(const CStdString& strPath, SScanSettings& settings, bool& foundDirectly) +ScraperPtr CVideoDatabase::GetScraperForPath(const std::string& strPath, SScanSettings& settings, bool& foundDirectly) { foundDirectly = false; try @@ -6801,19 +6559,19 @@ ScraperPtr CVideoDatabase::GetScraperForPath(const CStdString& strPath, SScanSet if (strPath.empty() || !m_pDB.get() || !m_pDS.get()) return ScraperPtr(); ScraperPtr scraper; - CStdString strPath2; + std::string strPath2; if (URIUtils::IsMultiPath(strPath)) strPath2 = CMultiPathDirectory::GetFirstPath(strPath); else strPath2 = strPath; - CStdString strPath1 = URIUtils::GetDirectory(strPath2); + std::string strPath1 = URIUtils::GetDirectory(strPath2); int idPath = GetPathId(strPath1); if (idPath > -1) { - CStdString strSQL=PrepareSQL("select path.strContent,path.strScraper,path.scanRecursive,path.useFolderNames,path.strSettings,path.noUpdate,path.exclude from path where path.idPath=%i",idPath); + std::string strSQL=PrepareSQL("select path.strContent,path.strScraper,path.scanRecursive,path.useFolderNames,path.strSettings,path.noUpdate,path.exclude from path where path.idPath=%i",idPath); m_pDS->query( strSQL.c_str() ); } @@ -6831,13 +6589,13 @@ ScraperPtr CVideoDatabase::GetScraperForPath(const CStdString& strPath, SScanSet settings.exclude = false; // try and ascertain scraper for this path - CStdString strcontent = m_pDS->fv("path.strContent").get_asString(); + std::string strcontent = m_pDS->fv("path.strContent").get_asString(); StringUtils::ToLower(strcontent); content = TranslateContent(strcontent); //FIXME paths stored should not have empty strContent //assert(content != CONTENT_NONE); - CStdString scraperID = m_pDS->fv("path.strScraper").get_asString(); + std::string scraperID = m_pDS->fv("path.strScraper").get_asString(); AddonPtr addon; if (!scraperID.empty() && @@ -6858,19 +6616,19 @@ ScraperPtr CVideoDatabase::GetScraperForPath(const CStdString& strPath, SScanSet if (content == CONTENT_NONE) { // this path is not saved in db // we must drill up until a scraper is configured - CStdString strParent; + std::string strParent; while (URIUtils::GetParentPath(strPath1, strParent)) { iFound++; - CStdString strSQL=PrepareSQL("select path.strContent,path.strScraper,path.scanRecursive,path.useFolderNames,path.strSettings,path.noUpdate, path.exclude from path where strPath='%s'",strParent.c_str()); + std::string strSQL=PrepareSQL("select path.strContent,path.strScraper,path.scanRecursive,path.useFolderNames,path.strSettings,path.noUpdate, path.exclude from path where strPath='%s'",strParent.c_str()); m_pDS->query(strSQL.c_str()); CONTENT_TYPE content = CONTENT_NONE; if (!m_pDS->eof()) { - CStdString strcontent = m_pDS->fv("path.strContent").get_asString(); + std::string strcontent = m_pDS->fv("path.strContent").get_asString(); StringUtils::ToLower(strcontent); if (m_pDS->fv("path.exclude").get_asBool()) { @@ -6940,7 +6698,7 @@ ScraperPtr CVideoDatabase::GetScraperForPath(const CStdString& strPath, SScanSet return ScraperPtr(); } -CStdString CVideoDatabase::GetContentForPath(const CStdString& strPath) +std::string CVideoDatabase::GetContentForPath(const std::string& strPath) { SScanSettings settings; bool foundDirectly = false; @@ -6952,7 +6710,7 @@ CStdString CVideoDatabase::GetContentForPath(const CStdString& strPath) // 1. if episodes are in the path then we're in episodes. // 2. if no episodes are found, and content was set directly on this path, then we're in shows. // 3. if no episodes are found, and content was not set directly on this path, we're in seasons (assumes tvshows/seasons/episodes) - CStdString sql = PrepareSQL("select count(1) from episodeview where strPath = '%s' limit 1", strPath.c_str()); + std::string sql = PrepareSQL("select count(1) from episode_view where strPath = '%s' limit 1", strPath.c_str()); m_pDS->query( sql.c_str() ); if (m_pDS->num_rows() && m_pDS->fv(0).get_asInt() > 0) return "episodes"; @@ -6963,9 +6721,9 @@ CStdString CVideoDatabase::GetContentForPath(const CStdString& strPath) return ""; } -void CVideoDatabase::GetMovieGenresByName(const CStdString& strSearch, CFileItemList& items) +void CVideoDatabase::GetMovieGenresByName(const std::string& strSearch, CFileItemList& items) { - CStdString strSQL; + std::string strSQL; try { @@ -6973,23 +6731,23 @@ void CVideoDatabase::GetMovieGenresByName(const CStdString& strSearch, CFileItem if (NULL == m_pDS.get()) return; if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - strSQL=PrepareSQL("select genre.idGenre,genre.strGenre,path.strPath from genre,genrelinkmovie,movie,path,files where genre.idGenre=genrelinkmovie.idGenre and genrelinkmovie.idMovie=movie.idMovie and files.idFile=movie.idFile and path.idPath=files.idPath and genre.strGenre like '%%%s%%'",strSearch.c_str()); + strSQL=PrepareSQL("select genre.genre_id,genre.name,path.strPath from genre,genre_link,movie,path,files where genre.genre_id=genre_link.genre_id and genre_link.media_id=movie.idMovie AND genre_link.media_type='movie' and files.idFile=movie.idFile and path.idPath=files.idPath and genre.name like '%%%s%%'",strSearch.c_str()); else - strSQL=PrepareSQL("select distinct genre.idGenre,genre.strGenre from genre,genrelinkmovie where genrelinkmovie.idGenre=genre.idGenre and strGenre like '%%%s%%'", strSearch.c_str()); + strSQL=PrepareSQL("select distinct genre.genre_id,genre.name from genre,genre_link where genre_link.genre_id=genre.genre_id AND genre_link.media_type='movie' and name like '%%%s%%'", strSearch.c_str()); m_pDS->query( strSQL.c_str() ); while (!m_pDS->eof()) { if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()), + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()), *CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; } - CFileItemPtr pItem(new CFileItem(m_pDS->fv("genre.strGenre").get_asString())); - CStdString strDir = StringUtils::Format("%i/", m_pDS->fv("genre.idGenre").get_asInt()); + CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString())); + std::string strDir = StringUtils::Format("%i/", m_pDS->fv(0).get_asInt()); pItem->SetPath("videodb://movies/genres/"+ strDir); pItem->m_bIsFolder=true; items.Add(pItem); @@ -7003,9 +6761,9 @@ void CVideoDatabase::GetMovieGenresByName(const CStdString& strSearch, CFileItem } } -void CVideoDatabase::GetMovieCountriesByName(const CStdString& strSearch, CFileItemList& items) +void CVideoDatabase::GetMovieCountriesByName(const std::string& strSearch, CFileItemList& items) { - CStdString strSQL; + std::string strSQL; try { @@ -7013,23 +6771,23 @@ void CVideoDatabase::GetMovieCountriesByName(const CStdString& strSearch, CFileI if (NULL == m_pDS.get()) return; if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - strSQL=PrepareSQL("select country.idCountry,country.strCountry,path.strPath from country,countrylinkmovie,movie,path,files where country.idCountry=countrylinkmovie.idCountry and countrylinkmovie.idMovie=movie.idMovie and files.idFile=movie.idFile and path.idPath=files.idPath and country.strCountry like '%%%s%%'",strSearch.c_str()); + strSQL=PrepareSQL("select country.country_id,country.name,path.strPath from country,country_link,movie,path,files where country.country_id=country_link.country_id and country_link.media_id=movie.idMovie AND country_link.media_type='movie' and files.idFile=movie.idFile and path.idPath=files.idPath and country.name like '%%%s%%'",strSearch.c_str()); else - strSQL=PrepareSQL("select distinct country.idCountry,country.strCountry from country,countrylinkmovie where countrylinkmovie.idCountry=country.idCountry and strCountry like '%%%s%%'", strSearch.c_str()); + strSQL=PrepareSQL("select distinct country.country_id,country.name from country,country_link where country_link.country_id=country.country_id AND countrlink.media_type='movie' and name like '%%%s%%'", strSearch.c_str()); m_pDS->query( strSQL.c_str() ); while (!m_pDS->eof()) { if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()), + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()), *CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; } - CFileItemPtr pItem(new CFileItem(m_pDS->fv("country.strCountry").get_asString())); - CStdString strDir = StringUtils::Format("%i/", m_pDS->fv("country.idCountry").get_asInt()); + CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString())); + std::string strDir = StringUtils::Format("%i/", m_pDS->fv(0).get_asInt()); pItem->SetPath("videodb://movies/genres/"+ strDir); pItem->m_bIsFolder=true; items.Add(pItem); @@ -7043,9 +6801,9 @@ void CVideoDatabase::GetMovieCountriesByName(const CStdString& strSearch, CFileI } } -void CVideoDatabase::GetTvShowGenresByName(const CStdString& strSearch, CFileItemList& items) +void CVideoDatabase::GetTvShowGenresByName(const std::string& strSearch, CFileItemList& items) { - CStdString strSQL; + std::string strSQL; try { @@ -7053,22 +6811,22 @@ void CVideoDatabase::GetTvShowGenresByName(const CStdString& strSearch, CFileIte if (NULL == m_pDS.get()) return; if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - strSQL=PrepareSQL("select genre.idGenre,genre.strGenre,path.strPath from genre,genrelinktvshow,tvshow,path,tvshowlinkpath where genre.idGenre=genrelinktvshow.idGenre and genrelinktvshow.idShow=tvshow.idShow and path.idPath=tvshowlinkpath.idPath and tvshowlinkpath.idShow=tvshow.idShow and genre.strGenre like '%%%s%%'",strSearch.c_str()); + strSQL=PrepareSQL("select genre.genre_id,genre.name,path.strPath from genre,genre_link,tvshow,path,tvshowlinkpath where genre.genre_id=genre_link.genre_id and genre_link.media_id=tvshow.idShow AND genre_link.media_type='tvshow' and path.idPath=tvshowlinkpath.idPath and tvshowlinkpath.idShow=tvshow.idShow and genre.name like '%%%s%%'",strSearch.c_str()); else - strSQL=PrepareSQL("select distinct genre.idGenre,genre.strGenre from genre,genrelinktvshow where genrelinktvshow.idGenre=genre.idGenre and strGenre like '%%%s%%'", strSearch.c_str()); + strSQL=PrepareSQL("select distinct genre.genre_id,genre.name from genre,genre_link where genre.genre_id=genre_link.genre_id AND genre_link.media_type='tvshow' and name like '%%%s%%'", strSearch.c_str()); m_pDS->query( strSQL.c_str() ); while (!m_pDS->eof()) { if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; } - CFileItemPtr pItem(new CFileItem(m_pDS->fv("genre.strGenre").get_asString())); - CStdString strDir = StringUtils::Format("%i/", m_pDS->fv("genre.idGenre").get_asInt()); + CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString())); + std::string strDir = StringUtils::Format("%i/", m_pDS->fv(0).get_asInt()); pItem->SetPath("videodb://tvshows/genres/"+ strDir); pItem->m_bIsFolder=true; items.Add(pItem); @@ -7082,9 +6840,9 @@ void CVideoDatabase::GetTvShowGenresByName(const CStdString& strSearch, CFileIte } } -void CVideoDatabase::GetMovieActorsByName(const CStdString& strSearch, CFileItemList& items) +void CVideoDatabase::GetMovieActorsByName(const std::string& strSearch, CFileItemList& items) { - CStdString strSQL; + std::string strSQL; try { @@ -7092,22 +6850,22 @@ void CVideoDatabase::GetMovieActorsByName(const CStdString& strSearch, CFileItem if (NULL == m_pDS.get()) return; if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - strSQL=PrepareSQL("select actors.idActor,actors.strActor,path.strPath from actorlinkmovie,actors,movie,files,path where actors.idActor=actorlinkmovie.idActor and actorlinkmovie.idMovie=movie.idMovie and files.idFile=movie.idFile and files.idPath=path.idPath and actors.strActor like '%%%s%%'",strSearch.c_str()); + strSQL=PrepareSQL("select actor.actor_id,actor.name,path.strPath from actor_link,actor,movie,files,path where actor.actor_id=actor_link.actor_id and actor_link.media_id=movie.idMovie and actor_link.media_type='movie' and files.idFile=movie.idFile and files.idPath=path.idPath and actor.name like '%%%s%%'",strSearch.c_str()); else - strSQL=PrepareSQL("select distinct actors.idActor,actors.strActor from actorlinkmovie,actors,movie where actors.idActor=actorlinkmovie.idActor and actorlinkmovie.idMovie=movie.idMovie and actors.strActor like '%%%s%%'",strSearch.c_str()); + strSQL=PrepareSQL("select distinct actor.actor_id,actor.name from actor_link,actor,movie where actor.actor_id=actor_link.actor_id and actor_link.media_id=movie.idMovie and actor_link.media_type='movie' and actor.name like '%%%s%%'",strSearch.c_str()); m_pDS->query( strSQL.c_str() ); while (!m_pDS->eof()) { if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; } - CFileItemPtr pItem(new CFileItem(m_pDS->fv("actors.strActor").get_asString())); - CStdString strDir = StringUtils::Format("%i/", m_pDS->fv("actors.idActor").get_asInt()); + CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString())); + std::string strDir = StringUtils::Format("%i/", m_pDS->fv(0).get_asInt()); pItem->SetPath("videodb://movies/actors/"+ strDir); pItem->m_bIsFolder=true; items.Add(pItem); @@ -7121,9 +6879,9 @@ void CVideoDatabase::GetMovieActorsByName(const CStdString& strSearch, CFileItem } } -void CVideoDatabase::GetTvShowsActorsByName(const CStdString& strSearch, CFileItemList& items) +void CVideoDatabase::GetTvShowsActorsByName(const std::string& strSearch, CFileItemList& items) { - CStdString strSQL; + std::string strSQL; try { @@ -7131,22 +6889,22 @@ void CVideoDatabase::GetTvShowsActorsByName(const CStdString& strSearch, CFileIt if (NULL == m_pDS.get()) return; if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - strSQL=PrepareSQL("select actors.idActor,actors.strActor,path.strPath from actorlinktvshow,actors,tvshow,path,tvshowlinkpath where actors.idActor=actorlinktvshow.idActor and actorlinktvshow.idShow=tvshow.idShow and tvshowlinkpath.idPath=tvshow.idShow and tvshowlinkpath.idPath=path.idPath and actors.strActor like '%%%s%%'",strSearch.c_str()); + strSQL=PrepareSQL("select actor.actor_id,actor.name,path.strPath from actor_link,actor,tvshow,path,tvshowlinkpath where actor.actor_id=actor_link.actor_id and actor_link.media_id=tvshow.idShow and actor_link.media_type='tvshow' and tvshowlinkpath.idPath=tvshow.idShow and tvshowlinkpath.idPath=path.idPath and actor.name like '%%%s%%'",strSearch.c_str()); else - strSQL=PrepareSQL("select distinct actors.idActor,actors.strActor from actorlinktvshow,actors,tvshow where actors.idActor=actorlinktvshow.idActor and actorlinktvshow.idShow=tvshow.idShow and actors.strActor like '%%%s%%'",strSearch.c_str()); + strSQL=PrepareSQL("select distinct actor.actor_id,actor.name from actor_link,actor,tvshow where actor.actor_id=actor_link.actor_id and actor_link.media_id=tvshow.idShow and actor_link.media_type='tvshow' and actor.name like '%%%s%%'",strSearch.c_str()); m_pDS->query( strSQL.c_str() ); while (!m_pDS->eof()) { if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; } - CFileItemPtr pItem(new CFileItem(m_pDS->fv("actors.strActor").get_asString())); - CStdString strDir = StringUtils::Format("%i/", m_pDS->fv("actors.idActor").get_asInt()); + CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString())); + std::string strDir = StringUtils::Format("%i/", m_pDS->fv(0).get_asInt()); pItem->SetPath("videodb://tvshows/actors/"+ strDir); pItem->m_bIsFolder=true; items.Add(pItem); @@ -7160,35 +6918,35 @@ void CVideoDatabase::GetTvShowsActorsByName(const CStdString& strSearch, CFileIt } } -void CVideoDatabase::GetMusicVideoArtistsByName(const CStdString& strSearch, CFileItemList& items) +void CVideoDatabase::GetMusicVideoArtistsByName(const std::string& strSearch, CFileItemList& items) { - CStdString strSQL; + std::string strSQL; try { if (NULL == m_pDB.get()) return; if (NULL == m_pDS.get()) return; - CStdString strLike; + std::string strLike; if (!strSearch.empty()) - strLike = "and actors.strActor like '%%%s%%'"; + strLike = "and actor.name like '%%%s%%'"; if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - strSQL=PrepareSQL("select actors.idActor,actors.strActor,path.strPath from artistlinkmusicvideo,actors,musicvideo,files,path where actors.idActor=artistlinkmusicvideo.idArtist and artistlinkmusicvideo.idMVideo=musicvideo.idMVideo and files.idFile=musicvideo.idFile and files.idPath=path.idPath "+strLike,strSearch.c_str()); + strSQL=PrepareSQL("select actor.actor_id,actor.name,path.strPath from actor_link,actor,musicvideo,files,path where actor.actor_id=actor_link.actor.id and actor_link.media_id=musicvideo.idMVideo AND actor_link.media_type='musicvideo' and files.idFile=musicvideo.idFile and files.idPath=path.idPath "+strLike,strSearch.c_str()); else - strSQL=PrepareSQL("select distinct actors.idActor,actors.strActor from artistlinkmusicvideo,actors where actors.idActor=artistlinkmusicvideo.idArtist "+strLike,strSearch.c_str()); + strSQL=PrepareSQL("select distinct actor.actor_id,actor.name from actor_link,actor where actor.actor_id=actor_link.actor_id AND actor_link.media_type='musicvideo' "+strLike,strSearch.c_str()); m_pDS->query( strSQL.c_str() ); while (!m_pDS->eof()) { if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; } - CFileItemPtr pItem(new CFileItem(m_pDS->fv("actors.strActor").get_asString())); - CStdString strDir = StringUtils::Format("%i/", m_pDS->fv("actors.idActor").get_asInt()); + CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString())); + std::string strDir = StringUtils::Format("%i/", m_pDS->fv(0).get_asInt()); pItem->SetPath("videodb://musicvideos/artists/"+ strDir); pItem->m_bIsFolder=true; items.Add(pItem); @@ -7202,9 +6960,9 @@ void CVideoDatabase::GetMusicVideoArtistsByName(const CStdString& strSearch, CFi } } -void CVideoDatabase::GetMusicVideoGenresByName(const CStdString& strSearch, CFileItemList& items) +void CVideoDatabase::GetMusicVideoGenresByName(const std::string& strSearch, CFileItemList& items) { - CStdString strSQL; + std::string strSQL; try { @@ -7212,22 +6970,22 @@ void CVideoDatabase::GetMusicVideoGenresByName(const CStdString& strSearch, CFil if (NULL == m_pDS.get()) return; if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - strSQL=PrepareSQL("select genre.idGenre,genre.strGenre,path.strPath from genre,genrelinkmusicvideo,musicvideo,path,files where genre.idGenre=genrelinkmusicvideo.idGenre and genrelinkmusicvideo.idMVideo = musicvideo.idMVideo and files.idFile=musicvideo.idFile and path.idPath=files.idPath and genre.strGenre like '%%%s%%'",strSearch.c_str()); + strSQL=PrepareSQL("select genre.genre_id,genre.name,path.strPath from genre,genre_link,musicvideo,path,files where genre.genre_id=genre_link.genre_id and genre_link.media_id=musicvideo.idMVideo AND genre_link.media_type='musicvideo' and files.idFile=musicvideo.idFile and path.idPath=files.idPath and genre.strGenre like '%%%s%%'",strSearch.c_str()); else - strSQL=PrepareSQL("select distinct genre.idGenre,genre.strGenre from genre,genrelinkmusicvideo where genrelinkmusicvideo.idGenre=genre.idGenre and genre.strGenre like '%%%s%%'", strSearch.c_str()); + strSQL=PrepareSQL("select distinct genre.genre_id,genre.name from genre,genre_link where genre_link.genre_id=genre.genre_id AND genre_link.media_type='musicvideo' and genre.name like '%%%s%%'", strSearch.c_str()); m_pDS->query( strSQL.c_str() ); while (!m_pDS->eof()) { if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; } - CFileItemPtr pItem(new CFileItem(m_pDS->fv("genre.strGenre").get_asString())); - CStdString strDir = StringUtils::Format("%i/", m_pDS->fv("genre.idGenre").get_asInt()); + CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString())); + std::string strDir = StringUtils::Format("%i/", m_pDS->fv(0).get_asInt()); pItem->SetPath("videodb://musicvideos/genres/"+ strDir); pItem->m_bIsFolder=true; items.Add(pItem); @@ -7241,9 +6999,9 @@ void CVideoDatabase::GetMusicVideoGenresByName(const CStdString& strSearch, CFil } } -void CVideoDatabase::GetMusicVideoAlbumsByName(const CStdString& strSearch, CFileItemList& items) +void CVideoDatabase::GetMusicVideoAlbumsByName(const std::string& strSearch, CFileItemList& items) { - CStdString strSQL; + std::string strSQL; try { @@ -7274,14 +7032,14 @@ void CVideoDatabase::GetMusicVideoAlbumsByName(const CStdString& strSearch, CFil } if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv(2).get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv(2).get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; } CFileItemPtr pItem(new CFileItem(m_pDS->fv(0).get_asString())); - CStdString strDir = StringUtils::Format("%i", m_pDS->fv(1).get_asInt()); + std::string strDir = StringUtils::Format("%i", m_pDS->fv(1).get_asInt()); pItem->SetPath("videodb://musicvideos/titles/"+ strDir); pItem->m_bIsFolder=false; items.Add(pItem); @@ -7295,9 +7053,9 @@ void CVideoDatabase::GetMusicVideoAlbumsByName(const CStdString& strSearch, CFil } } -void CVideoDatabase::GetMusicVideosByAlbum(const CStdString& strSearch, CFileItemList& items) +void CVideoDatabase::GetMusicVideosByAlbum(const std::string& strSearch, CFileItemList& items) { - CStdString strSQL; + std::string strSQL; try { @@ -7313,14 +7071,14 @@ void CVideoDatabase::GetMusicVideosByAlbum(const CStdString& strSearch, CFileIte while (!m_pDS->eof()) { if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; } CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString()+" - "+m_pDS->fv(2).get_asString())); - CStdString strDir = StringUtils::Format("3/2/%i",m_pDS->fv("musicvideo.idMVideo").get_asInt()); + std::string strDir = StringUtils::Format("3/2/%i",m_pDS->fv("musicvideo.idMVideo").get_asInt()); pItem->SetPath("videodb://"+ strDir); pItem->m_bIsFolder=false; @@ -7335,7 +7093,7 @@ void CVideoDatabase::GetMusicVideosByAlbum(const CStdString& strSearch, CFileIte } } -bool CVideoDatabase::GetMusicVideosByWhere(const CStdString &baseDir, const Filter &filter, CFileItemList &items, bool checkLocks /*= true*/, const SortDescription &sortDescription /* = SortDescription() */) +bool CVideoDatabase::GetMusicVideosByWhere(const std::string &baseDir, const Filter &filter, CFileItemList &items, bool checkLocks /*= true*/, const SortDescription &sortDescription /* = SortDescription() */) { try { @@ -7347,7 +7105,7 @@ bool CVideoDatabase::GetMusicVideosByWhere(const CStdString &baseDir, const Filt int total = -1; - std::string strSQL = "select %s from musicvideoview "; + std::string strSQL = "select %s from musicvideo_view "; CVideoDbUrl videoUrl; std::string strSQLExtra; Filter extFilter = filter; @@ -7396,7 +7154,7 @@ bool CVideoDatabase::GetMusicVideosByWhere(const CStdString &baseDir, const Filt CFileItemPtr item(new CFileItem(musicvideo)); CVideoDbUrl itemUrl = videoUrl; - CStdString path = StringUtils::Format("%i", record->at(0).get_asInt()); + std::string path = StringUtils::Format("%i", record->at(0).get_asInt()); itemUrl.AppendPath(path); item->SetPath(itemUrl.ToString()); @@ -7416,14 +7174,14 @@ bool CVideoDatabase::GetMusicVideosByWhere(const CStdString &baseDir, const Filt return false; } -unsigned int CVideoDatabase::GetMusicVideoIDs(const CStdString& strWhere, vector<pair<int,int> > &songIDs) +unsigned int CVideoDatabase::GetMusicVideoIDs(const std::string& strWhere, vector<pair<int,int> > &songIDs) { try { if (NULL == m_pDB.get()) return 0; if (NULL == m_pDS.get()) return 0; - CStdString strSQL = "select distinct idMVideo from musicvideoview " + strWhere; + std::string strSQL = "select distinct idMVideo from musicvideo_view " + strWhere; if (!m_pDS->query(strSQL.c_str())) return 0; songIDs.clear(); if (m_pDS->num_rows() == 0) @@ -7447,7 +7205,7 @@ unsigned int CVideoDatabase::GetMusicVideoIDs(const CStdString& strWhere, vector return 0; } -bool CVideoDatabase::GetRandomMusicVideo(CFileItem* item, int& idSong, const CStdString& strWhere) +bool CVideoDatabase::GetRandomMusicVideo(CFileItem* item, int& idSong, const std::string& strWhere) { try { @@ -7456,8 +7214,9 @@ bool CVideoDatabase::GetRandomMusicVideo(CFileItem* item, int& idSong, const CSt if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - // We don't use PrepareSQL here, as the WHERE clause is already formatted. - CStdString strSQL = StringUtils::Format("select * from musicvideoview where %s", strWhere.c_str()); + std::string strSQL = "select * from musicvideo_view"; + if (!strWhere.empty()) + strSQL += " where " + strWhere; strSQL += PrepareSQL(" order by RANDOM() limit 1"); CLog::Log(LOGDEBUG, "%s query = %s", __FUNCTION__, strSQL.c_str()); // run query @@ -7470,7 +7229,7 @@ bool CVideoDatabase::GetRandomMusicVideo(CFileItem* item, int& idSong, const CSt return false; } *item->GetVideoInfoTag() = GetDetailsForMusicVideo(m_pDS); - CStdString path = StringUtils::Format("videodb://musicvideos/titles/%i",item->GetVideoInfoTag()->m_iDbId); + std::string path = StringUtils::Format("videodb://musicvideos/titles/%i",item->GetVideoInfoTag()->m_iDbId); item->SetPath(path); idSong = m_pDS->fv("idMVideo").get_asInt(); item->SetLabel(item->GetVideoInfoTag()->m_strTitle); @@ -7484,27 +7243,27 @@ bool CVideoDatabase::GetRandomMusicVideo(CFileItem* item, int& idSong, const CSt return false; } -int CVideoDatabase::GetMatchingMusicVideo(const CStdString& strArtist, const CStdString& strAlbum, const CStdString& strTitle) +int CVideoDatabase::GetMatchingMusicVideo(const std::string& strArtist, const std::string& strAlbum, const std::string& strTitle) { try { if (NULL == m_pDB.get()) return -1; if (NULL == m_pDS.get()) return -1; - CStdString strSQL; + std::string strSQL; if (strAlbum.empty() && strTitle.empty()) { // we want to return matching artists only if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - strSQL=PrepareSQL("select distinct actors.idActor,path.strPath from artistlinkmusicvideo,actors,musicvideo,files,path where actors.idActor=artistlinkmusicvideo.idArtist and artistlinkmusicvideo.idMVideo=musicvideo.idMVideo and files.idFile=musicvideo.idFile and files.idPath=path.idPath and actors.strActor like '%s'",strArtist.c_str()); + strSQL=PrepareSQL("select distinct actor.actor_id,path.strPath from actor_link,actor,musicvideo,files,path where actor.actor_id=actor_link.actor_id and actor_link.media_id=musicvideo.idMVideo AND actor_link.media_type='musicvideo' and files.idFile=musicvideo.idFile and files.idPath=path.idPath and actor.name like '%s'",strArtist.c_str()); else - strSQL=PrepareSQL("select distinct actors.idActor from artistlinkmusicvideo,actors where actors.idActor=artistlinkmusicvideo.idArtist and actors.strActor like '%s'",strArtist.c_str()); + strSQL=PrepareSQL("select distinct actor.actor_id from actor_link,actor where actor.actor_id=actor_link.actor_id AND actor_link.media_type='musicvideo' and actor.name like '%s'",strArtist.c_str()); } else { // we want to return the matching musicvideo if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - strSQL = PrepareSQL("select musicvideo.idMVideo from musicvideo,files,path,artistlinkmusicvideo,actors where files.idFile=musicvideo.idFile and files.idPath=path.idPath and musicvideo.c%02d like '%s' and musicvideo.c%02d like '%s' and artistlinkmusicvideo.idMVideo=musicvideo.idMVideo and artistlinkmusicvideo.idArtist=actors.idActor and actors.strActor like '%s'",VIDEODB_ID_MUSICVIDEO_ALBUM,strAlbum.c_str(),VIDEODB_ID_MUSICVIDEO_TITLE,strTitle.c_str(),strArtist.c_str()); + strSQL = PrepareSQL("select musicvideo.idMVideo from musicvideo,files,path,actor_link,actor where files.idFile=musicvideo.idFile and files.idPath=path.idPath and musicvideo.c%02d like '%s' and musicvideo.c%02d like '%s' and actor_link.media_id=musicvideo.idMVideo AND actor_link.media_type='musicvideo' and actor_link.actor_id=actor.actor_id and actor.name like '%s'",VIDEODB_ID_MUSICVIDEO_ALBUM,strAlbum.c_str(),VIDEODB_ID_MUSICVIDEO_TITLE,strTitle.c_str(),strArtist.c_str()); else - strSQL = PrepareSQL("select musicvideo.idMVideo from musicvideo join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo=musicvideo.idMVideo join actors on actors.idActor=artistlinkmusicvideo.idArtist where musicvideo.c%02d like '%s' and musicvideo.c%02d like '%s' and actors.strActor like '%s'",VIDEODB_ID_MUSICVIDEO_ALBUM,strAlbum.c_str(),VIDEODB_ID_MUSICVIDEO_TITLE,strTitle.c_str(),strArtist.c_str()); + strSQL = PrepareSQL("select musicvideo.idMVideo from musicvideo join actor_link on actor_link.media_id=musicvideo.idMVideo AND actor_link.media_type='musicvideo' join actor on actor.actor_id=actor_link.actor_id where musicvideo.c%02d like '%s' and musicvideo.c%02d like '%s' and actor.name like '%s'",VIDEODB_ID_MUSICVIDEO_ALBUM,strAlbum.c_str(),VIDEODB_ID_MUSICVIDEO_TITLE,strTitle.c_str(),strArtist.c_str()); } m_pDS->query( strSQL.c_str() ); @@ -7512,7 +7271,7 @@ int CVideoDatabase::GetMatchingMusicVideo(const CStdString& strArtist, const CSt return -1; if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->close(); return -1; @@ -7529,9 +7288,9 @@ int CVideoDatabase::GetMatchingMusicVideo(const CStdString& strArtist, const CSt return -1; } -void CVideoDatabase::GetMoviesByName(const CStdString& strSearch, CFileItemList& items) +void CVideoDatabase::GetMoviesByName(const std::string& strSearch, CFileItemList& items) { - CStdString strSQL; + std::string strSQL; try { @@ -7547,7 +7306,7 @@ void CVideoDatabase::GetMoviesByName(const CStdString& strSearch, CFileItemList& while (!m_pDS->eof()) { if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -7556,7 +7315,7 @@ void CVideoDatabase::GetMoviesByName(const CStdString& strSearch, CFileItemList& int movieId = m_pDS->fv("movie.idMovie").get_asInt(); int setId = m_pDS->fv("movie.idSet").get_asInt(); CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString())); - CStdString path; + std::string path; if (setId <= 0 || !CSettings::Get().GetBool("videolibrary.groupmoviesets")) path = StringUtils::Format("videodb://movies/titles/%i", movieId); else @@ -7574,9 +7333,9 @@ void CVideoDatabase::GetMoviesByName(const CStdString& strSearch, CFileItemList& } } -void CVideoDatabase::GetTvShowsByName(const CStdString& strSearch, CFileItemList& items) +void CVideoDatabase::GetTvShowsByName(const std::string& strSearch, CFileItemList& items) { - CStdString strSQL; + std::string strSQL; try { @@ -7592,14 +7351,14 @@ void CVideoDatabase::GetTvShowsByName(const CStdString& strSearch, CFileItemList while (!m_pDS->eof()) { if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; } CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString())); - CStdString strDir = StringUtils::Format("tvshows/titles/%i/", m_pDS->fv("tvshow.idShow").get_asInt()); + std::string strDir = StringUtils::Format("tvshows/titles/%i/", m_pDS->fv("tvshow.idShow").get_asInt()); pItem->SetPath("videodb://"+ strDir); pItem->m_bIsFolder=true; @@ -7615,9 +7374,9 @@ void CVideoDatabase::GetTvShowsByName(const CStdString& strSearch, CFileItemList } } -void CVideoDatabase::GetEpisodesByName(const CStdString& strSearch, CFileItemList& items) +void CVideoDatabase::GetEpisodesByName(const std::string& strSearch, CFileItemList& items) { - CStdString strSQL; + std::string strSQL; try { @@ -7633,14 +7392,14 @@ void CVideoDatabase::GetEpisodesByName(const CStdString& strSearch, CFileItemLis while (!m_pDS->eof()) { if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; } CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString()+" ("+m_pDS->fv(4).get_asString()+")")); - CStdString path = StringUtils::Format("videodb://tvshows/titles/%i/%i/%i",m_pDS->fv("episode.idShow").get_asInt(),m_pDS->fv(2).get_asInt(),m_pDS->fv(0).get_asInt()); + std::string path = StringUtils::Format("videodb://tvshows/titles/%i/%i/%i",m_pDS->fv("episode.idShow").get_asInt(),m_pDS->fv(2).get_asInt(),m_pDS->fv(0).get_asInt()); pItem->SetPath(path); pItem->m_bIsFolder=false; items.Add(pItem); @@ -7654,13 +7413,13 @@ void CVideoDatabase::GetEpisodesByName(const CStdString& strSearch, CFileItemLis } } -void CVideoDatabase::GetMusicVideosByName(const CStdString& strSearch, CFileItemList& items) +void CVideoDatabase::GetMusicVideosByName(const std::string& strSearch, CFileItemList& items) { // Alternative searching - not quite as fast though due to // retrieving all information // Filter filter(PrepareSQL("c%02d like '%s%%' or c%02d like '%% %s%%'", VIDEODB_ID_MUSICVIDEO_TITLE, strSearch.c_str(), VIDEODB_ID_MUSICVIDEO_TITLE, strSearch.c_str())); // GetMusicVideosByWhere("videodb://musicvideos/titles/", filter, items); - CStdString strSQL; + std::string strSQL; try { @@ -7676,14 +7435,14 @@ void CVideoDatabase::GetMusicVideosByName(const CStdString& strSearch, CFileItem while (!m_pDS->eof()) { if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; } CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString())); - CStdString strDir = StringUtils::Format("3/2/%i",m_pDS->fv("musicvideo.idMVideo").get_asInt()); + std::string strDir = StringUtils::Format("3/2/%i",m_pDS->fv("musicvideo.idMVideo").get_asInt()); pItem->SetPath("videodb://"+ strDir); pItem->m_bIsFolder=false; @@ -7698,7 +7457,7 @@ void CVideoDatabase::GetMusicVideosByName(const CStdString& strSearch, CFileItem } } -void CVideoDatabase::GetEpisodesByPlot(const CStdString& strSearch, CFileItemList& items) +void CVideoDatabase::GetEpisodesByPlot(const std::string& strSearch, CFileItemList& items) { // Alternative searching - not quite as fast though due to // retrieving all information @@ -7707,7 +7466,7 @@ void CVideoDatabase::GetEpisodesByPlot(const CStdString& strSearch, CFileItemLis // filter.where += PrepareSQL("or c%02d like '%s%%' or c%02d like '%% %s%%'", VIDEODB_ID_EPISODE_TITLE, strSearch.c_str(), VIDEODB_ID_EPISODE_TITLE, strSearch.c_str()); // GetEpisodesByWhere("videodb://tvshows/titles/", filter, items); // return; - CStdString strSQL; + std::string strSQL; try { @@ -7723,14 +7482,14 @@ void CVideoDatabase::GetEpisodesByPlot(const CStdString& strSearch, CFileItemLis while (!m_pDS->eof()) { if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; } CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString()+" ("+m_pDS->fv(4).get_asString()+")")); - CStdString path = StringUtils::Format("videodb://tvshows/titles/%i/%i/%i",m_pDS->fv("episode.idShow").get_asInt(),m_pDS->fv(2).get_asInt(),m_pDS->fv(0).get_asInt()); + std::string path = StringUtils::Format("videodb://tvshows/titles/%i/%i/%i",m_pDS->fv("episode.idShow").get_asInt(),m_pDS->fv(2).get_asInt(),m_pDS->fv(0).get_asInt()); pItem->SetPath(path); pItem->m_bIsFolder=false; items.Add(pItem); @@ -7744,9 +7503,9 @@ void CVideoDatabase::GetEpisodesByPlot(const CStdString& strSearch, CFileItemLis } } -void CVideoDatabase::GetMoviesByPlot(const CStdString& strSearch, CFileItemList& items) +void CVideoDatabase::GetMoviesByPlot(const std::string& strSearch, CFileItemList& items) { - CStdString strSQL; + std::string strSQL; try { @@ -7763,14 +7522,14 @@ void CVideoDatabase::GetMoviesByPlot(const CStdString& strSearch, CFileItemList& while (!m_pDS->eof()) { if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv(2).get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv(2).get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; } CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString())); - CStdString path = StringUtils::Format("videodb://movies/titles/%i", m_pDS->fv(0).get_asInt()); + std::string path = StringUtils::Format("videodb://movies/titles/%i", m_pDS->fv(0).get_asInt()); pItem->SetPath(path); pItem->m_bIsFolder=false; @@ -7786,9 +7545,9 @@ void CVideoDatabase::GetMoviesByPlot(const CStdString& strSearch, CFileItemList& } } -void CVideoDatabase::GetMovieDirectorsByName(const CStdString& strSearch, CFileItemList& items) +void CVideoDatabase::GetMovieDirectorsByName(const std::string& strSearch, CFileItemList& items) { - CStdString strSQL; + std::string strSQL; try { @@ -7796,23 +7555,23 @@ void CVideoDatabase::GetMovieDirectorsByName(const CStdString& strSearch, CFileI if (NULL == m_pDS.get()) return; if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - strSQL = PrepareSQL("select distinct directorlinkmovie.idDirector,actors.strActor,path.strPath from movie,files,path,actors,directorlinkmovie where files.idFile=movie.idFile and files.idPath=path.idPath and directorlinkmovie.idMovie=movie.idMovie and directorlinkmovie.idDirector=actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str()); + strSQL = PrepareSQL("select distinct director_link.actor_id,actor.name,path.strPath from movie,files,path,actor,director_link where files.idFile=movie.idFile and files.idPath=path.idPath and director_link.media_id=movie.idMovie AND director_link.media_type='movie' and director_link.actor_id=actor.actor_id and actor.name like '%%%s%%'",strSearch.c_str()); else - strSQL = PrepareSQL("select distinct directorlinkmovie.idDirector,actors.strActor from movie,actors,directorlinkmovie where directorlinkmovie.idMovie=movie.idMovie and directorlinkmovie.idDirector=actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str()); + strSQL = PrepareSQL("select distinct director_link.actor_id,actor.name from movie,actor,director_link where director_link.media_id=movie.idMovie AND director_link.media_type='movie' and director_link.actor_id=actor.actor_id and actor.name like '%%%s%%'",strSearch.c_str()); m_pDS->query( strSQL.c_str() ); while (!m_pDS->eof()) { if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; } - CStdString strDir = StringUtils::Format("%i/", m_pDS->fv("directorlinkmovie.idDirector").get_asInt()); - CFileItemPtr pItem(new CFileItem(m_pDS->fv("actors.strActor").get_asString())); + std::string strDir = StringUtils::Format("%i/", m_pDS->fv(0).get_asInt()); + CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString())); pItem->SetPath("videodb://movies/directors/"+ strDir); pItem->m_bIsFolder=true; @@ -7827,9 +7586,9 @@ void CVideoDatabase::GetMovieDirectorsByName(const CStdString& strSearch, CFileI } } -void CVideoDatabase::GetTvShowsDirectorsByName(const CStdString& strSearch, CFileItemList& items) +void CVideoDatabase::GetTvShowsDirectorsByName(const std::string& strSearch, CFileItemList& items) { - CStdString strSQL; + std::string strSQL; try { @@ -7837,25 +7596,25 @@ void CVideoDatabase::GetTvShowsDirectorsByName(const CStdString& strSearch, CFil if (NULL == m_pDS.get()) return; if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - strSQL = PrepareSQL("select distinct directorlinktvshow.idDirector,actors.strActor,path.strPath from tvshow,path,actors,directorlinktvshow,tvshowlinkpath where tvshowlinkpath.idPath=path.idPath and tvshowlinkpath.idShow=tvshow.idShow and directorlinktvshow.idShow=tvshow.idShow and directorlinktvshow.idDirector=actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str()); + strSQL = PrepareSQL("select distinct director_link.actor_id,actor.name,path.strPath from tvshow,path,actor,director_link,tvshowlinkpath where tvshowlinkpath.idPath=path.idPath and tvshowlinkpath.idShow=tvshow.idShow and director_link.media_id=tvshow.idShow AND director_link.media_type='tvshow' and director_link.actor_id=actor.actor_id and actor.name like '%%%s%%'",strSearch.c_str()); else - strSQL = PrepareSQL("select distinct directorlinktvshow.idDirector,actors.strActor from tvshow,actors,directorlinktvshow where directorlinktvshow.idShow=tvshow.idShow and directorlinktvshow.idDirector=actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str()); + strSQL = PrepareSQL("select distinct director_link.actor_id,actor.name from tvshow,actor,director_link where director_link.media_id=tvshow.idShow AND director_link.media_type='tvshow' and director_link.actor_id=actor.actor_id and actor.name like '%%%s%%'",strSearch.c_str()); m_pDS->query( strSQL.c_str() ); while (!m_pDS->eof()) { if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; } - CStdString strDir = StringUtils::Format("%i/", m_pDS->fv("directorlinktvshow.idDirector").get_asInt()); - CFileItemPtr pItem(new CFileItem(m_pDS->fv("actors.strActor").get_asString())); + std::string strDir = StringUtils::Format("%i/", m_pDS->fv(0).get_asInt()); + CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString())); - pItem->SetPath("videodb://tvshows/studios/"+ strDir); + pItem->SetPath("videodb://tvshows/directors/"+ strDir); pItem->m_bIsFolder=true; items.Add(pItem); m_pDS->next(); @@ -7868,9 +7627,9 @@ void CVideoDatabase::GetTvShowsDirectorsByName(const CStdString& strSearch, CFil } } -void CVideoDatabase::GetMusicVideoDirectorsByName(const CStdString& strSearch, CFileItemList& items) +void CVideoDatabase::GetMusicVideoDirectorsByName(const std::string& strSearch, CFileItemList& items) { - CStdString strSQL; + std::string strSQL; try { @@ -7878,23 +7637,23 @@ void CVideoDatabase::GetMusicVideoDirectorsByName(const CStdString& strSearch, C if (NULL == m_pDS.get()) return; if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - strSQL = PrepareSQL("select distinct directorlinkmusicvideo.idDirector,actors.strActor,path.strPath from musicvideo,files,path,actors,directorlinkmusicvideo where files.idFile=musicvideo.idFile and files.idPath=path.idPath and directorlinkmusicvideo.idMVideo=musicvideo.idMVideo and directorlinkmusicvideo.idDirector=actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str()); + strSQL = PrepareSQL("select distinct director_link.actor_id,actor.name,path.strPath from musicvideo,files,path,actor,director_link where files.idFile=musicvideo.idFile and files.idPath=path.idPath and director_link.media_id=musicvideo.idMVideo AND director_link.media_type='musicvideo' and director_link.actor_id=actor.actor_id and actor.name like '%%%s%%'",strSearch.c_str()); else - strSQL = PrepareSQL("select distinct directorlinkmusicvideo.idDirector,actors.strActor from musicvideo,actors,directorlinkmusicvideo where directorlinkmusicvideo.idMVideo=musicvideo.idMVideo and directorlinkmusicvideo.idDirector=actors.idActor and actors.strActor like '%%%s%%'",strSearch.c_str()); + strSQL = PrepareSQL("select distinct director_link.actor_id,actor.name from musicvideo,actor,director_link where director_link.media_id=musicvideo.idMVideo AND director_link.media_type='musicvideo' and director_link.actor_id=actor.actor_id and actor.name like '%%%s%%'",strSearch.c_str()); m_pDS->query( strSQL.c_str() ); while (!m_pDS->eof()) { if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) + if (!g_passwordManager.IsDatabasePathUnlocked(std::string(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; } - CStdString strDir = StringUtils::Format("%i/", m_pDS->fv("directorlinkmusicvideo.idDirector").get_asInt()); - CFileItemPtr pItem(new CFileItem(m_pDS->fv("actors.strActor").get_asString())); + std::string strDir = StringUtils::Format("%i/", m_pDS->fv(0).get_asInt()); + CFileItemPtr pItem(new CFileItem(m_pDS->fv(1).get_asString())); pItem->SetPath("videodb://musicvideos/albums/"+ strDir); pItem->m_bIsFolder=true; @@ -7924,7 +7683,7 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se BeginTransaction(); // find all the files - CStdString sql = "SELECT files.idFile, files.strFileName, path.strPath FROM files, path WHERE files.idPath = path.idPath"; + std::string sql = "SELECT files.idFile, files.strFileName, path.strPath FROM files, path WHERE files.idPath = path.idPath"; if (paths) { if (paths->empty()) @@ -7934,7 +7693,7 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se return; } - CStdString strPaths; + std::string strPaths; for (std::set<int>::const_iterator it = paths->begin(); it != paths->end(); ++it) strPaths += StringUtils::Format(",%i", *it); sql += PrepareSQL(" AND path.idPath IN (%s)", strPaths.substr(1).c_str()); @@ -7972,7 +7731,7 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se { std::string path = m_pDS->fv("path.strPath").get_asString(); std::string fileName = m_pDS->fv("files.strFileName").get_asString(); - CStdString fullPath; + std::string fullPath; ConstructPath(fullPath, path, fileName); // get the first stacked file @@ -8197,34 +7956,23 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se CLog::Log(LOGDEBUG, "%s: Cleaning genre table", __FUNCTION__); sql = "DELETE FROM genre " - "WHERE NOT EXISTS (SELECT 1 FROM genrelinkmovie WHERE genrelinkmovie.idGenre = genre.idGenre) " - "AND NOT EXISTS (SELECT 1 FROM genrelinktvshow WHERE genrelinktvshow.idGenre = genre.idGenre) " - "AND NOT EXISTS (SELECT 1 FROM genrelinkmusicvideo WHERE genrelinkmusicvideo.idGenre = genre.idGenre)"; + "WHERE NOT EXISTS (SELECT 1 FROM genre_link WHERE genre_link.genre_id = genre.genre_id)"; m_pDS->exec(sql.c_str()); CLog::Log(LOGDEBUG, "%s: Cleaning country table", __FUNCTION__); - sql = "DELETE FROM country WHERE NOT EXISTS (SELECT 1 FROM countrylinkmovie WHERE countrylinkmovie.idCountry = country.idCountry)"; + sql = "DELETE FROM country WHERE NOT EXISTS (SELECT 1 FROM country_link WHERE country_link.country_id = country.country_id)"; m_pDS->exec(sql.c_str()); CLog::Log(LOGDEBUG, "%s: Cleaning actor table of actors, directors and writers", __FUNCTION__); - sql = "DELETE FROM actors " - "WHERE NOT EXISTS (SELECT 1 FROM actorlinkmovie WHERE actorlinkmovie.idActor = actors.idActor) " - "AND NOT EXISTS (SELECT 1 FROM directorlinkmovie WHERE directorlinkmovie.idDirector = actors.idActor) " - "AND NOT EXISTS (SELECT 1 FROM writerlinkmovie WHERE writerlinkmovie.idWriter = actors.idActor) " - "AND NOT EXISTS (SELECT 1 FROM actorlinktvshow WHERE actorlinktvshow.idActor = actors.idActor) " - "AND NOT EXISTS (SELECT 1 FROM actorlinkepisode WHERE actorlinkepisode.idActor = actors.idActor) " - "AND NOT EXISTS (SELECT 1 FROM directorlinktvshow WHERE directorlinktvshow.idDirector = actors.idActor) " - "AND NOT EXISTS (SELECT 1 FROM directorlinkepisode WHERE directorlinkepisode.idDirector = actors.idActor) " - "AND NOT EXISTS (SELECT 1 FROM writerlinkepisode WHERE writerlinkepisode.idWriter = actors.idActor) " - "AND NOT EXISTS (SELECT 1 FROM artistlinkmusicvideo WHERE artistlinkmusicvideo.idArtist = actors.idActor) " - "AND NOT EXISTS (SELECT 1 FROM directorlinkmusicvideo WHERE directorlinkmusicvideo.idDirector = actors.idActor)"; + sql = "DELETE FROM actor " + "WHERE NOT EXISTS (SELECT 1 FROM actor_link WHERE actor_link.actor_id = actor.actor_id) " + "AND NOT EXISTS (SELECT 1 FROM director_link WHERE director_link.actor_id = actor.actor_id) " + "AND NOT EXISTS (SELECT 1 FROM writer_link WHERE writer_link.actor_id = actor.actor_id)"; m_pDS->exec(sql.c_str()); CLog::Log(LOGDEBUG, "%s: Cleaning studio table", __FUNCTION__); sql = "DELETE FROM studio " - "WHERE NOT EXISTS (SELECT 1 FROM studiolinkmovie WHERE studiolinkmovie.idStudio = studio.idStudio) " - "AND NOT EXISTS (SELECT 1 FROM studiolinkmusicvideo WHERE studiolinkmusicvideo.idStudio = studio.idStudio) " - "AND NOT EXISTS (SELECT 1 FROM studiolinktvshow WHERE studiolinktvshow.idStudio = studio.idStudio)"; + "WHERE NOT EXISTS (SELECT 1 FROM studio_link WHERE studio_link.studio_id = studio.studio_id)"; m_pDS->exec(sql.c_str()); CLog::Log(LOGDEBUG, "%s: Cleaning set table", __FUNCTION__); @@ -8380,18 +8128,18 @@ std::vector<int> CVideoDatabase::CleanMediaType(const std::string &mediaType, co return cleanedIDs; } -void CVideoDatabase::DumpToDummyFiles(const CStdString &path) +void CVideoDatabase::DumpToDummyFiles(const std::string &path) { // get all tvshows CFileItemList items; GetTvShowsByWhere("videodb://tvshows/titles/", "", items); - CStdString showPath = URIUtils::AddFileToFolder(path, "shows"); + std::string showPath = URIUtils::AddFileToFolder(path, "shows"); CDirectory::Create(showPath); for (int i = 0; i < items.Size(); i++) { // create a folder in this directory - CStdString showName = CUtil::MakeLegalFileName(items[i]->GetVideoInfoTag()->m_strShowTitle); - CStdString TVFolder = URIUtils::AddFileToFolder(showPath, showName); + std::string showName = CUtil::MakeLegalFileName(items[i]->GetVideoInfoTag()->m_strShowTitle); + std::string TVFolder = URIUtils::AddFileToFolder(showPath, showName); if (CDirectory::Create(TVFolder)) { // right - grab the episodes and dump them as well CFileItemList episodes; @@ -8400,9 +8148,9 @@ void CVideoDatabase::DumpToDummyFiles(const CStdString &path) for (int i = 0; i < episodes.Size(); i++) { CVideoInfoTag *tag = episodes[i]->GetVideoInfoTag(); - CStdString episode = StringUtils::Format("%s.s%02de%02d.avi", showName.c_str(), tag->m_iSeason, tag->m_iEpisode); + std::string episode = StringUtils::Format("%s.s%02de%02d.avi", showName.c_str(), tag->m_iSeason, tag->m_iEpisode); // and make a file - CStdString episodePath = URIUtils::AddFileToFolder(TVFolder, episode); + std::string episodePath = URIUtils::AddFileToFolder(TVFolder, episode); CFile file; if (file.OpenForWrite(episodePath)) file.Close(); @@ -8412,19 +8160,19 @@ void CVideoDatabase::DumpToDummyFiles(const CStdString &path) // get all movies items.Clear(); GetMoviesByWhere("videodb://movies/titles/", "", items); - CStdString moviePath = URIUtils::AddFileToFolder(path, "movies"); + std::string moviePath = URIUtils::AddFileToFolder(path, "movies"); CDirectory::Create(moviePath); for (int i = 0; i < items.Size(); i++) { CVideoInfoTag *tag = items[i]->GetVideoInfoTag(); - CStdString movie = StringUtils::Format("%s.avi", tag->m_strTitle.c_str()); + std::string movie = StringUtils::Format("%s.avi", tag->m_strTitle.c_str()); CFile file; if (file.OpenForWrite(URIUtils::AddFileToFolder(moviePath, movie))) file.Close(); } } -void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = false */, bool images /* = false */, bool actorThumbs /* false */, bool overwrite /*=false*/) +void CVideoDatabase::ExportToXML(const std::string &path, bool singleFiles /* = false */, bool images /* = false */, bool actorThumbs /* false */, bool overwrite /*=false*/) { CGUIDialogProgress *progress=NULL; try @@ -8443,12 +8191,12 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f if (NULL == pDS2.get()) return; // if we're exporting to a single folder, we export thumbs as well - CStdString exportRoot = URIUtils::AddFileToFolder(path, "xbmc_videodb_" + CDateTime::GetCurrentDateTime().GetAsDBDate()); - CStdString xmlFile = URIUtils::AddFileToFolder(exportRoot, "videodb.xml"); - CStdString actorsDir = URIUtils::AddFileToFolder(exportRoot, "actors"); - CStdString moviesDir = URIUtils::AddFileToFolder(exportRoot, "movies"); - CStdString musicvideosDir = URIUtils::AddFileToFolder(exportRoot, "musicvideos"); - CStdString tvshowsDir = URIUtils::AddFileToFolder(exportRoot, "tvshows"); + std::string exportRoot = URIUtils::AddFileToFolder(path, "xbmc_videodb_" + CDateTime::GetCurrentDateTime().GetAsDBDate()); + std::string xmlFile = URIUtils::AddFileToFolder(exportRoot, "videodb.xml"); + std::string actorsDir = URIUtils::AddFileToFolder(exportRoot, "actors"); + std::string moviesDir = URIUtils::AddFileToFolder(exportRoot, "movies"); + std::string musicvideosDir = URIUtils::AddFileToFolder(exportRoot, "musicvideos"); + std::string tvshowsDir = URIUtils::AddFileToFolder(exportRoot, "tvshows"); if (!singleFiles) { images = true; @@ -8464,7 +8212,7 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); // find all movies - CStdString sql = "select * from movieview"; + std::string sql = "select * from movie_view"; m_pDS->query(sql.c_str()); @@ -8539,7 +8287,7 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f } else { - CStdString nfoFile(URIUtils::ReplaceExtension(item.GetTBNFile(), ".nfo")); + std::string nfoFile(URIUtils::ReplaceExtension(item.GetTBNFile(), ".nfo")); if (item.IsOpticalMediaFile()) { @@ -8578,14 +8326,14 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f { if (!singleFiles) { - CStdString strFileName(movie.m_strTitle); + std::string strFileName(movie.m_strTitle); if (movie.m_iYear > 0) strFileName += StringUtils::Format("_%i", movie.m_iYear); item.SetPath(GetSafeFile(moviesDir, strFileName) + ".avi"); } for (map<string, string>::const_iterator i = artwork.begin(); i != artwork.end(); ++i) { - CStdString savedThumb = item.GetLocalArt(i->first, false); + std::string savedThumb = item.GetLocalArt(i->first, false); CTextureCache::Get().Export(i->second, savedThumb, overwrite); } if (actorThumbs) @@ -8597,7 +8345,7 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f m_pDS->close(); // find all musicvideos - sql = "select * from musicvideoview"; + sql = "select * from musicvideo_view"; m_pDS->query(sql.c_str()); @@ -8644,7 +8392,7 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f } else { - CStdString nfoFile(URIUtils::ReplaceExtension(item.GetTBNFile(), ".nfo")); + std::string nfoFile(URIUtils::ReplaceExtension(item.GetTBNFile(), ".nfo")); if (overwrite || !CFile::Exists(nfoFile, false)) { @@ -8675,14 +8423,14 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f { if (!singleFiles) { - CStdString strFileName((CStdString)StringUtils::Join(movie.m_artist, g_advancedSettings.m_videoItemSeparator) + "." + movie.m_strTitle); + std::string strFileName(StringUtils::Join(movie.m_artist, g_advancedSettings.m_videoItemSeparator) + "." + movie.m_strTitle); if (movie.m_iYear > 0) strFileName += StringUtils::Format("_%i", movie.m_iYear); item.SetPath(GetSafeFile(moviesDir, strFileName) + ".avi"); } for (map<string, string>::const_iterator i = artwork.begin(); i != artwork.end(); ++i) { - CStdString savedThumb = item.GetLocalArt(i->first, false); + std::string savedThumb = item.GetLocalArt(i->first, false); CTextureCache::Get().Export(i->second, savedThumb, overwrite); } } @@ -8692,7 +8440,7 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f m_pDS->close(); // repeat for all tvshows - sql = "SELECT * FROM tvshowview"; + sql = "SELECT * FROM tvshow_view"; m_pDS->query(sql.c_str()); total = m_pDS->num_rows(); @@ -8750,7 +8498,7 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f } else { - CStdString nfoFile = URIUtils::AddFileToFolder(tvshow.m_strPath, "tvshow.nfo"); + std::string nfoFile = URIUtils::AddFileToFolder(tvshow.m_strPath, "tvshow.nfo"); if (overwrite || !CFile::Exists(nfoFile, false)) { @@ -8784,7 +8532,7 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f for (map<string, string>::const_iterator i = artwork.begin(); i != artwork.end(); ++i) { - CStdString savedThumb = item.GetLocalArt(i->first, true); + std::string savedThumb = item.GetLocalArt(i->first, true); CTextureCache::Get().Export(i->second, savedThumb, overwrite); } @@ -8803,7 +8551,7 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f seasonThumb = StringUtils::Format("season%02i", i->first); for (map<string, string>::const_iterator j = i->second.begin(); j != i->second.end(); j++) { - CStdString savedThumb(item.GetLocalArt(seasonThumb + "-" + j->first, true)); + std::string savedThumb(item.GetLocalArt(seasonThumb + "-" + j->first, true)); if (!i->second.empty()) CTextureCache::Get().Export(j->second, savedThumb, overwrite); } @@ -8811,9 +8559,9 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f } // now save the episodes from this show - sql = PrepareSQL("select * from episodeview where idShow=%i order by strFileName, idEpisode",tvshow.m_iDbId); + sql = PrepareSQL("select * from episode_view where idShow=%i order by strFileName, idEpisode",tvshow.m_iDbId); pDS->query(sql.c_str()); - CStdString showDir(item.GetPath()); + std::string showDir(item.GetPath()); while (!pDS->eof()) { @@ -8853,7 +8601,7 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f } else { - CStdString nfoFile(URIUtils::ReplaceExtension(item.GetTBNFile(), ".nfo")); + std::string nfoFile(URIUtils::ReplaceExtension(item.GetTBNFile(), ".nfo")); if (overwrite || !CFile::Exists(nfoFile, false)) { @@ -8885,12 +8633,12 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f { if (!singleFiles) { - CStdString epName = StringUtils::Format("s%02ie%02i.avi", episode.m_iSeason, episode.m_iEpisode); + std::string epName = StringUtils::Format("s%02ie%02i.avi", episode.m_iSeason, episode.m_iEpisode); item.SetPath(URIUtils::AddFileToFolder(showDir, epName)); } for (map<string, string>::const_iterator i = artwork.begin(); i != artwork.end(); ++i) { - CStdString savedThumb = item.GetLocalArt(i->first, false); + std::string savedThumb = item.GetLocalArt(i->first, false); CTextureCache::Get().Export(i->second, savedThumb, overwrite); } if (actorThumbs) @@ -8912,11 +8660,11 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f if (!singleFiles) { // now dump path info - set<CStdString> paths; + set<std::string> paths; GetPaths(paths); TiXmlElement xmlPathElement("paths"); TiXmlNode *pPaths = pMain->InsertEndChild(xmlPathElement); - for( set<CStdString>::iterator iter = paths.begin(); iter != paths.end(); ++iter) + for( set<std::string>::iterator iter = paths.begin(); iter != paths.end(); ++iter) { bool foundDirectly = false; SScanSettings settings; @@ -8944,9 +8692,9 @@ void CVideoDatabase::ExportToXML(const CStdString &path, bool singleFiles /* = f progress->Close(); } -void CVideoDatabase::ExportActorThumbs(const CStdString &strDir, const CVideoInfoTag &tag, bool singleFiles, bool overwrite /*=false*/) +void CVideoDatabase::ExportActorThumbs(const std::string &strDir, const CVideoInfoTag &tag, bool singleFiles, bool overwrite /*=false*/) { - CStdString strPath(strDir); + std::string strPath(strDir); if (singleFiles) { strPath = URIUtils::AddFileToFolder(tag.m_strPath, ".actors"); @@ -8963,15 +8711,15 @@ void CVideoDatabase::ExportActorThumbs(const CStdString &strDir, const CVideoInf item.SetLabel(iter->strName); if (!iter->thumb.empty()) { - CStdString thumbFile(GetSafeFile(strPath, iter->strName)); + std::string thumbFile(GetSafeFile(strPath, iter->strName)); CTextureCache::Get().Export(iter->thumb, thumbFile, overwrite); } } } -bool CVideoDatabase::ExportSkipEntry(const CStdString &nfoFile) +bool CVideoDatabase::ExportSkipEntry(const std::string &nfoFile) { - CStdString strParent; + std::string strParent; URIUtils::GetParentPath(nfoFile,strParent); CLog::Log(LOGERROR, "%s: Unable to write to '%s'!", __FUNCTION__, strParent.c_str()); @@ -8985,7 +8733,7 @@ bool CVideoDatabase::ExportSkipEntry(const CStdString &nfoFile) return bSkip; } -void CVideoDatabase::ImportFromXML(const CStdString &path) +void CVideoDatabase::ImportFromXML(const std::string &path) { CGUIDialogProgress *progress=NULL; try @@ -9030,25 +8778,25 @@ void CVideoDatabase::ImportFromXML(const CStdString &path) movie = movie->NextSiblingElement(); } - CStdString actorsDir(URIUtils::AddFileToFolder(path, "actors")); - CStdString moviesDir(URIUtils::AddFileToFolder(path, "movies")); - CStdString musicvideosDir(URIUtils::AddFileToFolder(path, "musicvideos")); - CStdString tvshowsDir(URIUtils::AddFileToFolder(path, "tvshows")); + std::string actorsDir(URIUtils::AddFileToFolder(path, "actors")); + std::string moviesDir(URIUtils::AddFileToFolder(path, "movies")); + std::string musicvideosDir(URIUtils::AddFileToFolder(path, "musicvideos")); + std::string tvshowsDir(URIUtils::AddFileToFolder(path, "tvshows")); CVideoInfoScanner scanner; // add paths first (so we have scraper settings available) TiXmlElement *path = root->FirstChildElement("paths"); path = path->FirstChildElement(); while (path) { - CStdString strPath; + std::string strPath; if (XMLUtils::GetString(path,"url",strPath) && !strPath.empty()) AddPath(strPath); - CStdString content; + std::string content; if (XMLUtils::GetString(path,"content", content) && !content.empty()) { // check the scraper exists, if so store the path AddonPtr addon; - CStdString id; + std::string id; XMLUtils::GetString(path,"scraperpath",id); if (CAddonMgr::Get().GetAddon(id, addon)) { @@ -9072,7 +8820,7 @@ void CVideoDatabase::ImportFromXML(const CStdString &path) info.Load(movie); CFileItem item(info); bool useFolders = info.m_basePath.empty() ? LookupByFolders(item.GetPath()) : false; - CStdString filename = info.m_strTitle; + std::string filename = info.m_strTitle; if (info.m_iYear > 0) filename += StringUtils::Format("_%i", info.m_iYear); CFileItem artItem(item); @@ -9087,7 +8835,7 @@ void CVideoDatabase::ImportFromXML(const CStdString &path) info.Load(movie); CFileItem item(info); bool useFolders = info.m_basePath.empty() ? LookupByFolders(item.GetPath()) : false; - CStdString filename = (CStdString)StringUtils::Join(info.m_artist, g_advancedSettings.m_videoItemSeparator) + "." + info.m_strTitle; + std::string filename = StringUtils::Join(info.m_artist, g_advancedSettings.m_videoItemSeparator) + "." + info.m_strTitle; if (info.m_iYear > 0) filename += StringUtils::Format("_%i", info.m_iYear); CFileItem artItem(item); @@ -9107,7 +8855,7 @@ void CVideoDatabase::ImportFromXML(const CStdString &path) CFileItem showItem(info); bool useFolders = info.m_basePath.empty() ? LookupByFolders(showItem.GetPath(), true) : false; CFileItem artItem(showItem); - CStdString artPath(GetSafeFile(tvshowsDir, info.m_strTitle)); + std::string artPath(GetSafeFile(tvshowsDir, info.m_strTitle)); artItem.SetPath(artPath); scanner.GetArtwork(&artItem, CONTENT_TVSHOWS, useFolders, true, actorsDir); showItem.SetArt(artItem.GetArt()); @@ -9130,7 +8878,7 @@ void CVideoDatabase::ImportFromXML(const CStdString &path) CVideoInfoTag info; info.Load(episode); CFileItem item(info); - CStdString filename = StringUtils::Format("s%02ie%02i.avi", info.m_iSeason, info.m_iEpisode); + std::string filename = StringUtils::Format("s%02ie%02i.avi", info.m_iSeason, info.m_iEpisode); CFileItem artItem(item); artItem.SetPath(GetSafeFile(artPath, filename)); scanner.GetArtwork(&artItem, CONTENT_TVSHOWS, useFolders, true, actorsDir); @@ -9173,7 +8921,7 @@ bool CVideoDatabase::ImportArtFromXML(const TiXmlNode *node, map<string, string> return !artwork.empty(); } -void CVideoDatabase::ConstructPath(CStdString& strDest, const CStdString& strPath, const CStdString& strFileName) +void CVideoDatabase::ConstructPath(std::string& strDest, const std::string& strPath, const std::string& strFileName) { if (URIUtils::IsStack(strFileName) || URIUtils::IsInArchive(strFileName) || URIUtils::IsPlugin(strPath)) @@ -9182,7 +8930,7 @@ void CVideoDatabase::ConstructPath(CStdString& strDest, const CStdString& strPat strDest = URIUtils::AddFileToFolder(strPath, strFileName); } -void CVideoDatabase::SplitPath(const CStdString& strFileNameAndPath, CStdString& strPath, CStdString& strFileName) +void CVideoDatabase::SplitPath(const std::string& strFileNameAndPath, std::string& strPath, std::string& strFileName) { if (URIUtils::IsStack(strFileNameAndPath) || StringUtils::StartsWithNoCase(strFileNameAndPath, "rar://") || StringUtils::StartsWithNoCase(strFileNameAndPath, "zip://")) { @@ -9199,7 +8947,7 @@ void CVideoDatabase::SplitPath(const CStdString& strFileNameAndPath, CStdString& URIUtils::Split(strFileNameAndPath,strPath, strFileName); } -void CVideoDatabase::InvalidatePathHash(const CStdString& strPath) +void CVideoDatabase::InvalidatePathHash(const std::string& strPath) { SScanSettings settings; bool foundDirectly; @@ -9211,7 +8959,7 @@ void CVideoDatabase::InvalidatePathHash(const CStdString& strPath) { if (info->Content() == CONTENT_TVSHOWS || settings.parent_name_root) { - CStdString strParent; + std::string strParent; URIUtils::GetParentPath(strPath,strParent); SetPathHash(strParent,""); } @@ -9310,9 +9058,9 @@ bool CVideoDatabase::SetSingleValue(const std::string &table, const std::string return false; } -CStdString CVideoDatabase::GetSafeFile(const CStdString &dir, const CStdString &name) const +std::string CVideoDatabase::GetSafeFile(const std::string &dir, const std::string &name) const { - CStdString safeThumb(name); + std::string safeThumb(name); StringUtils::Replace(safeThumb, ' ', '_'); return URIUtils::AddFileToFolder(dir, CUtil::MakeLegalFileName(safeThumb)); } @@ -9335,9 +9083,9 @@ void CVideoDatabase::AnnounceUpdate(std::string content, int id) ANNOUNCEMENT::CAnnouncementManager::Get().Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnUpdate", data); } -bool CVideoDatabase::GetItemsForPath(const CStdString &content, const CStdString &strPath, CFileItemList &items) +bool CVideoDatabase::GetItemsForPath(const std::string &content, const std::string &strPath, CFileItemList &items) { - CStdString path(strPath); + std::string path(strPath); if(URIUtils::IsMultiPath(path)) { @@ -9379,6 +9127,27 @@ bool CVideoDatabase::GetItemsForPath(const CStdString &content, const CStdString return items.Size() > 0; } +void CVideoDatabase::AppendIdLinkFilter(const char* field, const char *table, const MediaType& mediaType, const char *view, const char *viewKey, const CUrlOptions::UrlOptions& options, Filter &filter) +{ + CUrlOptions::UrlOptions::const_iterator option = options.find((std::string)field + "id"); + if (option == options.end()) + return; + + filter.AppendJoin(PrepareSQL("JOIN %s_link ON %s_link.media_id=%s_view.%s AND %s_link.media_type='%s'", field, field, view, viewKey, field, mediaType.c_str())); + filter.AppendWhere(PrepareSQL("%s_link.%s_id = %i", field, table, (int)option->second.asInteger())); +} + +void CVideoDatabase::AppendLinkFilter(const char* field, const char *table, const MediaType& mediaType, const char *view, const char *viewKey, const CUrlOptions::UrlOptions& options, Filter &filter) +{ + CUrlOptions::UrlOptions::const_iterator option = options.find(field); + if (option == options.end()) + return; + + filter.AppendJoin(PrepareSQL("JOIN %s_link ON %s_link.media_id=%s_view.%s AND %s_link.media_type='%s'", field, field, view, viewKey, field, mediaType.c_str())); + filter.AppendJoin(PrepareSQL("JOIN %s ON %s.%s_id=%s_link.%s_id", table, table, field, table)); + filter.AppendWhere(PrepareSQL("%s.name like '%s'", table, option->second.asString().c_str())); +} + bool CVideoDatabase::GetFilter(CDbUrl &videoUrl, Filter &filter, SortDescription &sorting) { if (!videoUrl.IsValid()) @@ -9391,206 +9160,73 @@ bool CVideoDatabase::GetFilter(CDbUrl &videoUrl, Filter &filter, SortDescription if (type == "movies") { - option = options.find("genreid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join genrelinkmovie on genrelinkmovie.idMovie = movieview.idMovie")); - filter.AppendWhere(PrepareSQL("genrelinkmovie.idGenre = %i", (int)option->second.asInteger())); - } + AppendIdLinkFilter("genre", "genre", "movie", "movie", "idMovie", options, filter); + AppendLinkFilter("genre", "genre", "movie", "movie", "idMovie", options, filter); - option = options.find("genre"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join genrelinkmovie on genrelinkmovie.idMovie = movieview.idMovie join genre on genre.idGenre = genrelinkmovie.idGenre")); - filter.AppendWhere(PrepareSQL("genre.strGenre like '%s'", option->second.asString().c_str())); - } + AppendIdLinkFilter("country", "country", "movie", "movie", "idMovie", options, filter); + AppendLinkFilter("country", "country", "movie", "movie", "idMovie", options, filter); - option = options.find("countryid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join countrylinkmovie on countrylinkmovie.idMovie = movieview.idMovie")); - filter.AppendWhere(PrepareSQL("countrylinkmovie.idCountry = %i", (int)option->second.asInteger())); - } + AppendIdLinkFilter("studio", "studio", "movie", "movie", "idMovie", options, filter); + AppendLinkFilter("studio", "studio", "movie", "movie", "idMovie", options, filter); - option = options.find("country"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join countrylinkmovie on countrylinkmovie.idMovie = movieview.idMovie join country on country.idCountry = countrylinkmovie.idCountry")); - filter.AppendWhere(PrepareSQL("country.strCountry like '%s'", option->second.asString().c_str())); - } - - option = options.find("studioid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join studiolinkmovie on studiolinkmovie.idMovie = movieview.idMovie")); - filter.AppendWhere(PrepareSQL("studiolinkmovie.idStudio = %i", (int)option->second.asInteger())); - } - - option = options.find("studio"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join studiolinkmovie on studiolinkmovie.idMovie = movieview.idMovie join studio on studio.idStudio = studiolinkmovie.idStudio")); - filter.AppendWhere(PrepareSQL("studio.strStudio like '%s'", option->second.asString().c_str())); - } - - option = options.find("directorid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join directorlinkmovie on directorlinkmovie.idMovie = movieview.idMovie")); - filter.AppendWhere(PrepareSQL("directorlinkmovie.idDirector = %i", (int)option->second.asInteger())); - } - - option = options.find("director"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join directorlinkmovie on directorlinkmovie.idMovie = movieview.idMovie join actors on actors.idActor = directorlinkmovie.idDirector")); - filter.AppendWhere(PrepareSQL("actors.strActor like '%s'", option->second.asString().c_str())); - } + AppendIdLinkFilter("director", "actor", "movie", "movie", "idMovie", options, filter); + AppendLinkFilter("director", "actor", "movie", "movie", "idMovie", options, filter); option = options.find("year"); if (option != options.end()) - filter.AppendWhere(PrepareSQL("movieview.c%02d = '%i'", VIDEODB_ID_YEAR, (int)option->second.asInteger())); + filter.AppendWhere(PrepareSQL("movie_view.c%02d = '%i'", VIDEODB_ID_YEAR, (int)option->second.asInteger())); - option = options.find("actorid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join actorlinkmovie on actorlinkmovie.idMovie = movieview.idMovie")); - filter.AppendWhere(PrepareSQL("actorlinkmovie.idActor = %i", (int)option->second.asInteger())); - } - - option = options.find("actor"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join actorlinkmovie on actorlinkmovie.idMovie = movieview.idMovie join actors on actors.idActor = actorlinkmovie.idActor")); - filter.AppendWhere(PrepareSQL("actors.strActor like '%s'", option->second.asString().c_str())); - } + AppendIdLinkFilter("actor", "actor", "movie", "movie", "idMovie", options, filter); + AppendLinkFilter("actor", "actor", "movie", "movie", "idMovie", options, filter); option = options.find("setid"); if (option != options.end()) - filter.AppendWhere(PrepareSQL("movieview.idSet = %i", (int)option->second.asInteger())); + filter.AppendWhere(PrepareSQL("movie_view.idSet = %i", (int)option->second.asInteger())); option = options.find("set"); if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join setlinkmovie on setlinkmovie.idMovie = movieview.idMovie join sets on sets.idSet = setlinkmovie.idSet")); - filter.AppendWhere(PrepareSQL("sets.strSet like '%s'", option->second.asString().c_str())); - } - - option = options.find("tagid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join taglinks on taglinks.idMedia = movieview.idMovie AND taglinks.media_type = 'movie'")); - filter.AppendWhere(PrepareSQL("taglinks.idTag = %i", (int)option->second.asInteger())); - } + filter.AppendWhere(PrepareSQL("movie_view.strSet LIKE '%s'", option->second.asString().c_str())); - option = options.find("tag"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join taglinks on taglinks.idMedia = movieview.idMovie AND taglinks.media_type = 'movie' join tag on tag.idTag = taglinks.idTag")); - filter.AppendWhere(PrepareSQL("tag.strTag like '%s'", option->second.asString().c_str())); - } + AppendIdLinkFilter("tag", "tag", "movie", "movie", "idMovie", options, filter); + AppendLinkFilter("tag", "tag", "movie", "movie", "idMovie", options, filter); } else if (type == "tvshows") { if (itemType == "tvshows") { - option = options.find("genreid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join genrelinktvshow on genrelinktvshow.idShow = tvshowview.idShow")); - filter.AppendWhere(PrepareSQL("genrelinktvshow.idGenre = %i", (int)option->second.asInteger())); - } - - option = options.find("genre"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join genrelinktvshow on genrelinktvshow.idShow = tvshowview.idShow join genre on genre.idGenre = genrelinktvshow.idGenre")); - filter.AppendWhere(PrepareSQL("genre.strGenre like '%s'", option->second.asString().c_str())); - } + AppendIdLinkFilter("genre", "genre", "tvshow", "tvshow", "idShow", options, filter); + AppendLinkFilter("genre", "genre", "tvshow", "tvshow", "idShow", options, filter); - option = options.find("studioid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join studiolinktvshow on studiolinktvshow.idShow = tvshowview.idShow")); - filter.AppendWhere(PrepareSQL("studiolinktvshow.idStudio = %i", (int)option->second.asInteger())); - } - - option = options.find("studio"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join studiolinktvshow on studiolinktvshow.idShow = tvshowview.idShow join studio on studio.idStudio = studiolinktvshow.idStudio")); - filter.AppendWhere(PrepareSQL("studio.strStudio like '%s'", option->second.asString().c_str())); - } + AppendIdLinkFilter("studio", "studio", "tvshow", "tvshow", "idShow", options, filter); + AppendLinkFilter("studio", "studio", "tvshow", "tvshow", "idShow", options, filter); - option = options.find("directorid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join directorlinktvshow on directorlinktvshow.idShow = tvshowview.idShow")); - filter.AppendWhere(PrepareSQL("directorlinktvshow.idDirector = %i", (int)option->second.asInteger())); - } + AppendIdLinkFilter("director", "actor", "tvshow", "tvshow", "idShow", options, filter); option = options.find("year"); if (option != options.end()) - filter.AppendWhere(PrepareSQL("tvshowview.c%02d like '%%%i%%'", VIDEODB_ID_TV_PREMIERED, (int)option->second.asInteger())); - - option = options.find("actorid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join actorlinktvshow on actorlinktvshow.idShow = tvshowview.idShow")); - filter.AppendWhere(PrepareSQL("actorlinktvshow.idActor = %i", (int)option->second.asInteger())); - } - - option = options.find("actor"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join actorlinktvshow on actorlinktvshow.idShow = tvshowview.idShow join actors on actors.idActor = actorlinktvshow.idActor")); - filter.AppendWhere(PrepareSQL("actors.strActor like '%s'", option->second.asString().c_str())); - } + filter.AppendWhere(PrepareSQL("tvshow_view.c%02d like '%%%i%%'", VIDEODB_ID_TV_PREMIERED, (int)option->second.asInteger())); - option = options.find("tagid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join taglinks on taglinks.idMedia = tvshowview.idShow AND taglinks.media_type = 'tvshow'")); - filter.AppendWhere(PrepareSQL("taglinks.idTag = %i", (int)option->second.asInteger())); - } + AppendIdLinkFilter("actor", "actor", "tvshow", "tvshow", "idShow", options, filter); + AppendLinkFilter("actor", "actor", "tvshow", "tvshow", "idShow", options, filter); - option = options.find("tag"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join taglinks on taglinks.idMedia = tvshowview.idShow AND taglinks.media_type = 'tvshow' join tag on tag.idTag = taglinks.idTag")); - filter.AppendWhere(PrepareSQL("tag.strTag like '%s'", option->second.asString().c_str())); - } + AppendIdLinkFilter("tag", "tag", "tvshow", "tvshow", "idShow", options, filter); + AppendLinkFilter("tag", "tag", "tvshow", "tvshow", "idShow", options, filter); } else if (itemType == "seasons") { option = options.find("tvshowid"); if (option != options.end()) - filter.AppendWhere(PrepareSQL("seasonview.idShow = %i", (int)option->second.asInteger())); + filter.AppendWhere(PrepareSQL("season_view.idShow = %i", (int)option->second.asInteger())); - option = options.find("genreid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join genrelinktvshow on genrelinktvshow.idShow = seasonview.idShow")); - filter.AppendWhere(PrepareSQL("genrelinktvshow.idGenre = %i", (int)option->second.asInteger())); - } + AppendIdLinkFilter("genre", "genre", "tvshow", "season", "idShow", options, filter); + + AppendIdLinkFilter("director", "actor", "tvshow", "season", "idShow", options, filter); - option = options.find("directorid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join directorlinktvshow on directorlinktvshow.idShow = seasonview.idShow")); - filter.AppendWhere(PrepareSQL("directorlinktvshow.idDirector = %i", (int)option->second.asInteger())); - } - option = options.find("year"); if (option != options.end()) - filter.AppendWhere(PrepareSQL("seasonview.premiered like '%%%i%%'", (int)option->second.asInteger())); + filter.AppendWhere(PrepareSQL("season_view.premiered like '%%%i%%'", (int)option->second.asInteger())); - option = options.find("actorid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join actorlinktvshow on actorlinktvshow.idShow = seasonview.idShow")); - filter.AppendWhere(PrepareSQL("actorlinktvshow.idActor = %i", (int)option->second.asInteger())); - } + AppendIdLinkFilter("actor", "actor", "tvshow", "season", "idShow", options, filter); } else if (itemType == "episodes") { @@ -9608,70 +9244,31 @@ bool CVideoDatabase::GetFilter(CDbUrl &videoUrl, Filter &filter, SortDescription { bool condition = false; - option = options.find("genreid"); - if (option != options.end()) - { - condition = true; - filter.AppendJoin(PrepareSQL("join genrelinktvshow on genrelinktvshow.idShow = episodeview.idShow")); - filter.AppendWhere(PrepareSQL("episodeview.idShow = %i and genrelinktvshow.idGenre = %i", idShow, (int)option->second.asInteger())); - } + AppendIdLinkFilter("genre", "genre", "tvshow", "episode", "idShow", options, filter); + AppendLinkFilter("genre", "genre", "tvshow", "episode", "idShow", options, filter); - option = options.find("genre"); - if (option != options.end()) - { - condition = true; - filter.AppendJoin(PrepareSQL("join genrelinktvshow on genrelinktvshow.idShow = episodeview.idShow join genre on genre.idGenre = genrelinktvshow.idGenre")); - filter.AppendWhere(PrepareSQL("episodeview.idShow = %i and genre.strGenre like '%s'", idShow, option->second.asString().c_str())); - } - - option = options.find("directorid"); - if (option != options.end()) - { - condition = true; - filter.AppendJoin(PrepareSQL("join directorlinktvshow on directorlinktvshow.idShow = episodeview.idShow")); - filter.AppendWhere(PrepareSQL("episodeview.idShow = %i and directorlinktvshow.idDirector = %i", idShow, (int)option->second.asInteger())); - } - - option = options.find("director"); - if (option != options.end()) - { - condition = true; - filter.AppendJoin(PrepareSQL("join directorlinktvshow on directorlinktvshow.idShow = episodeview.idShow join actors on actors.idActor = directorlinktvshow.idDirector")); - filter.AppendWhere(PrepareSQL("episodeview.idShow = %i and actors.strActor like '%s'", idShow, option->second.asString().c_str())); - } + AppendIdLinkFilter("director", "actor", "tvshow", "episode", "idShow", options, filter); + AppendLinkFilter("director", "actor", "tvshow", "episode", "idShow", options, filter); option = options.find("year"); if (option != options.end()) { condition = true; - filter.AppendWhere(PrepareSQL("episodeview.idShow = %i and episodeview.premiered like '%%%i%%'", idShow, (int)option->second.asInteger())); - } - - option = options.find("actorid"); - if (option != options.end()) - { - condition = true; - filter.AppendJoin(PrepareSQL("join actorlinktvshow on actorlinktvshow.idShow = episodeview.idShow")); - filter.AppendWhere(PrepareSQL("episodeview.idShow = %i and actorlinktvshow.idActor = %i", idShow, (int)option->second.asInteger())); + filter.AppendWhere(PrepareSQL("episode_view.idShow = %i and episode_view.premiered like '%%%i%%'", idShow, (int)option->second.asInteger())); } - option = options.find("actor"); - if (option != options.end()) - { - condition = true; - filter.AppendJoin(PrepareSQL("join actorlinktvshow on actorlinktvshow.idShow = episodeview.idShow join actors on actors.idActor = actorlinktvshow.idActor")); - filter.AppendWhere(PrepareSQL("episodeview.idShow = %i and actors.strActor = '%s'", idShow, option->second.asString().c_str())); - } + AppendIdLinkFilter("actor", "actor", "tvshow", "episode", "idShow", options, filter); + AppendLinkFilter("actor", "actor", "tvshow", "episode", "idShow", options, filter); if (!condition) - filter.AppendWhere(PrepareSQL("episodeview.idShow = %i", idShow)); + filter.AppendWhere(PrepareSQL("episode_view.idShow = %i", idShow)); if (season > -1) { if (season == 0) // season = 0 indicates a special - we grab all specials here (see below) - filter.AppendWhere(PrepareSQL("episodeview.c%02d = %i", VIDEODB_ID_EPISODE_SEASON, season)); + filter.AppendWhere(PrepareSQL("episode_view.c%02d = %i", VIDEODB_ID_EPISODE_SEASON, season)); else - filter.AppendWhere(PrepareSQL("(episodeview.c%02d = %i or (episodeview.c%02d = 0 and (episodeview.c%02d = 0 or episodeview.c%02d = %i)))", + filter.AppendWhere(PrepareSQL("(episode_view.c%02d = %i or (episode_view.c%02d = 0 and (episode_view.c%02d = 0 or episode_view.c%02d = %i)))", VIDEODB_ID_EPISODE_SEASON, season, VIDEODB_ID_EPISODE_SEASON, VIDEODB_ID_EPISODE_SORTSEASON, VIDEODB_ID_EPISODE_SORTSEASON, season)); } } @@ -9679,78 +9276,34 @@ bool CVideoDatabase::GetFilter(CDbUrl &videoUrl, Filter &filter, SortDescription { option = options.find("year"); if (option != options.end()) - filter.AppendWhere(PrepareSQL("episodeview.premiered like '%%%i%%'", (int)option->second.asInteger())); - - option = options.find("directorid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join directorlinkepisode on directorlinkepisode.idEpisode = episodeview.idEpisode")); - filter.AppendWhere(PrepareSQL("directorlinkepisode.idDirector = %i", (int)option->second.asInteger())); - } + filter.AppendWhere(PrepareSQL("episode_view.premiered like '%%%i%%'", (int)option->second.asInteger())); - option = options.find("director"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join directorlinkepisode on directorlinkepisode.idEpisode = episodeview.idEpisode join actors on actors.idActor = directorlinktvshow.idDirector")); - filter.AppendWhere(PrepareSQL("actors.strActor = %s", option->second.asString().c_str())); - } + AppendIdLinkFilter("director", "actor", "episode", "episode", "idEpisode", options, filter); + AppendLinkFilter("director", "actor", "episode", "episode", "idEpisode", options, filter); } } } else if (type == "musicvideos") { - option = options.find("genreid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join genrelinkmusicvideo on genrelinkmusicvideo.idMVideo = musicvideoview.idMVideo")); - filter.AppendWhere(PrepareSQL("genrelinkmusicvideo.idGenre = %i", (int)option->second.asInteger())); - } + AppendIdLinkFilter("genre", "genre", "musicvideo", "musicvideo", "idMVideo", options, filter); + AppendLinkFilter("genre", "genre", "musicvideo", "musicvideo", "idMVideo", options, filter); - option = options.find("genre"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join genrelinkmusicvideo on genrelinkmusicvideo.idMVideo = musicvideoview.idMVideo join genre on genre.idGenre = genrelinkmusicvideo.idGenre")); - filter.AppendWhere(PrepareSQL("genre.strGenre like '%s'", option->second.asString().c_str())); - } - - option = options.find("studioid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join studiolinkmusicvideo on studiolinkmusicvideo.idMVideo = musicvideoview.idMVideo")); - filter.AppendWhere(PrepareSQL("studiolinkmusicvideo.idStudio = %i", (int)option->second.asInteger())); - } + AppendIdLinkFilter("studio", "studio", "musicvideo", "musicvideo", "idMVideo", options, filter); + AppendLinkFilter("studio", "studio", "musicvideo", "musicvideo", "idMVideo", options, filter); - option = options.find("studio"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join studiolinkmusicvideo on studiolinkmusicvideo.idMVideo = musicvideoview.idMVideo join studio on studio.idStudio = studiolinkmusicvideo.idStudio")); - filter.AppendWhere(PrepareSQL("studio.strStudio like '%s'", option->second.asString().c_str())); - } - - option = options.find("directorid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join directorlinkmusicvideo on directorlinkmusicvideo.idMVideo = musicvideoview.idMVideo")); - filter.AppendWhere(PrepareSQL("directorlinkmusicvideo.idDirector = %i", (int)option->second.asInteger())); - } - - option = options.find("director"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join directorlinkmusicvideo on directorlinkmusicvideo.idMVideo = musicvideoview.idMVideo join actors on actors.idActor = directorlinkmusicvideo.idDirector")); - filter.AppendWhere(PrepareSQL("actors.strActor like '%s'", option->second.asString().c_str())); - } + AppendIdLinkFilter("director", "actor", "musicvideo", "musicvideo", "idMVideo", options, filter); + AppendLinkFilter("director", "actor", "musicvideo", "musicvideo", "idMVideo", options, filter); option = options.find("year"); if (option != options.end()) - filter.AppendWhere(PrepareSQL("musicvideoview.c%02d = '%i'",VIDEODB_ID_MUSICVIDEO_YEAR, (int)option->second.asInteger())); + filter.AppendWhere(PrepareSQL("musicvideo_view.c%02d = '%i'",VIDEODB_ID_MUSICVIDEO_YEAR, (int)option->second.asInteger())); option = options.find("artistid"); if (option != options.end()) { if (itemType != "albums") - filter.AppendJoin(PrepareSQL("join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo = musicvideoview.idMVideo")); - filter.AppendWhere(PrepareSQL("artistlinkmusicvideo.idArtist = %i", (int)option->second.asInteger())); + filter.AppendJoin(PrepareSQL("JOIN actor_link ON actor_link.media_id=musicvideo_view.idMVideo AND actor_link.media_type='musicvideo'")); + filter.AppendWhere(PrepareSQL("actor_link.actor_id = %i", (int)option->second.asInteger())); } option = options.find("artist"); @@ -9758,29 +9311,18 @@ bool CVideoDatabase::GetFilter(CDbUrl &videoUrl, Filter &filter, SortDescription { if (itemType != "albums") { - filter.AppendJoin(PrepareSQL("join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo = musicvideoview.idMVideo")); - filter.AppendJoin(PrepareSQL("join actors on actors.idActor = artistlinkmusicvideo.idArtist")); + filter.AppendJoin(PrepareSQL("JOIN actor_link ON actor_link.media_id=musicvideo_view.idMVideo AND actor_link.media_type='musicvideo'")); + filter.AppendJoin(PrepareSQL("JOIN actor ON actor.actor_id=actor_link.actor_id")); } - filter.AppendWhere(PrepareSQL("actors.strActor like '%s'", option->second.asString().c_str())); + filter.AppendWhere(PrepareSQL("actor.name LIKE '%s'", option->second.asString().c_str())); } option = options.find("albumid"); if (option != options.end()) - filter.AppendWhere(PrepareSQL("musicvideoview.c%02d = (select c%02d from musicvideo where idMVideo = %i)", VIDEODB_ID_MUSICVIDEO_ALBUM, VIDEODB_ID_MUSICVIDEO_ALBUM, (int)option->second.asInteger())); + filter.AppendWhere(PrepareSQL("musicvideo_view.c%02d = (select c%02d from musicvideo where idMVideo = %i)", VIDEODB_ID_MUSICVIDEO_ALBUM, VIDEODB_ID_MUSICVIDEO_ALBUM, (int)option->second.asInteger())); - option = options.find("tagid"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join taglinks on taglinks.idMedia = musicvideoview.idMVideo AND taglinks.media_type = 'musicvideo'")); - filter.AppendWhere(PrepareSQL("taglinks.idTag = %i", (int)option->second.asInteger())); - } - - option = options.find("tag"); - if (option != options.end()) - { - filter.AppendJoin(PrepareSQL("join taglinks on taglinks.idMedia = musicvideoview.idMVideo AND taglinks.media_type = 'musicvideo' join tag on tag.idTag = taglinks.idTag")); - filter.AppendWhere(PrepareSQL("tag.strTag like '%s'", option->second.asString().c_str())); - } + AppendIdLinkFilter("tag", "tag", "musicvideo", "musicvideo", "idMVideo", options, filter); + AppendLinkFilter("tag", "tag", "musicvideo", "musicvideo", "idMVideo", options, filter); } else return false; diff --git a/xbmc/video/VideoDatabase.h b/xbmc/video/VideoDatabase.h index 78259ed8e2..109a8d6110 100644 --- a/xbmc/video/VideoDatabase.h +++ b/xbmc/video/VideoDatabase.h @@ -352,15 +352,15 @@ public: class CActor // used for actor retrieval for non-master users { public: - CStdString name; - CStdString thumb; + std::string name; + std::string thumb; int playcount; }; class CSeason // used for season retrieval for non-master users { public: - CStdString path; + std::string path; std::vector<std::string> genre; int numEpisodes; int numWatched; @@ -370,7 +370,7 @@ public: class CSetInfo { public: - CStdString name; + std::string name; VECMOVIES movies; DatabaseResults results; }; @@ -381,8 +381,8 @@ public: virtual bool Open(); virtual bool CommitTransaction(); - int AddMovie(const CStdString& strFilenameAndPath); - int AddEpisode(int idShow, const CStdString& strFilenameAndPath); + int AddMovie(const std::string& strFilenameAndPath); + int AddEpisode(int idShow, const std::string& strFilenameAndPath); // editing functions /*! \brief Set the playcount of an item @@ -421,45 +421,45 @@ public: \param items CFileItemList to fetch the playcounts for \sa GetPlayCount, SetPlayCount, IncrementPlayCount */ - bool GetPlayCounts(const CStdString &path, CFileItemList &items); - - void UpdateMovieTitle(int idMovie, const CStdString& strNewMovieTitle, VIDEODB_CONTENT_TYPE iType=VIDEODB_CONTENT_MOVIES); - bool UpdateVideoSortTitle(int idDb, const CStdString& strNewSortTitle, VIDEODB_CONTENT_TYPE iType = VIDEODB_CONTENT_MOVIES); - - bool HasMovieInfo(const CStdString& strFilenameAndPath); - bool HasTvShowInfo(const CStdString& strFilenameAndPath); - bool HasEpisodeInfo(const CStdString& strFilenameAndPath); - bool HasMusicVideoInfo(const CStdString& strFilenameAndPath); - - void GetFilePathById(int idMovie, CStdString &filePath, VIDEODB_CONTENT_TYPE iType); - CStdString GetGenreById(int id); - CStdString GetCountryById(int id); - CStdString GetSetById(int id); - CStdString GetTagById(int id); - CStdString GetPersonById(int id); - CStdString GetStudioById(int id); - CStdString GetTvShowTitleById(int id); - CStdString GetMusicVideoAlbumById(int id); + bool GetPlayCounts(const std::string &path, CFileItemList &items); + + void UpdateMovieTitle(int idMovie, const std::string& strNewMovieTitle, VIDEODB_CONTENT_TYPE iType=VIDEODB_CONTENT_MOVIES); + bool UpdateVideoSortTitle(int idDb, const std::string& strNewSortTitle, VIDEODB_CONTENT_TYPE iType = VIDEODB_CONTENT_MOVIES); + + bool HasMovieInfo(const std::string& strFilenameAndPath); + bool HasTvShowInfo(const std::string& strFilenameAndPath); + bool HasEpisodeInfo(const std::string& strFilenameAndPath); + bool HasMusicVideoInfo(const std::string& strFilenameAndPath); + + void GetFilePathById(int idMovie, std::string &filePath, VIDEODB_CONTENT_TYPE iType); + std::string GetGenreById(int id); + std::string GetCountryById(int id); + std::string GetSetById(int id); + std::string GetTagById(int id); + std::string GetPersonById(int id); + std::string GetStudioById(int id); + std::string GetTvShowTitleById(int id); + std::string GetMusicVideoAlbumById(int id); int GetTvShowForEpisode(int idEpisode); int GetSeasonForEpisode(int idEpisode); - bool LoadVideoInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details); - bool GetMovieInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details, int idMovie = -1); - bool GetTvShowInfo(const CStdString& strPath, CVideoInfoTag& details, int idTvShow = -1, CFileItem* item = NULL); + bool LoadVideoInfo(const std::string& strFilenameAndPath, CVideoInfoTag& details); + bool GetMovieInfo(const std::string& strFilenameAndPath, CVideoInfoTag& details, int idMovie = -1); + bool GetTvShowInfo(const std::string& strPath, CVideoInfoTag& details, int idTvShow = -1, CFileItem* item = NULL); bool GetSeasonInfo(int idSeason, CVideoInfoTag& details); - bool GetEpisodeInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details, int idEpisode = -1); - bool GetMusicVideoInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details, int idMVideo=-1); + bool GetEpisodeInfo(const std::string& strFilenameAndPath, CVideoInfoTag& details, int idEpisode = -1); + bool GetMusicVideoInfo(const std::string& strFilenameAndPath, CVideoInfoTag& details, int idMVideo=-1); bool GetSetInfo(int idSet, CVideoInfoTag& details); - bool GetFileInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details, int idFile = -1); + bool GetFileInfo(const std::string& strFilenameAndPath, CVideoInfoTag& details, int idFile = -1); - int GetPathId(const CStdString& strPath); - int GetTvShowId(const CStdString& strPath); - int GetEpisodeId(const CStdString& strFilenameAndPath, int idEpisode=-1, int idSeason=-1); // idEpisode, idSeason are used for multipart episodes as hints + int GetPathId(const std::string& strPath); + int GetTvShowId(const std::string& strPath); + int GetEpisodeId(const std::string& strFilenameAndPath, int idEpisode=-1, int idSeason=-1); // idEpisode, idSeason are used for multipart episodes as hints int GetSeasonId(int idShow, int season); - void GetEpisodesByFile(const CStdString& strFilenameAndPath, std::vector<CVideoInfoTag>& episodes); + void GetEpisodesByFile(const std::string& strFilenameAndPath, std::vector<CVideoInfoTag>& episodes); - int SetDetailsForMovie(const CStdString& strFilenameAndPath, const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idMovie = -1); + int SetDetailsForMovie(const std::string& strFilenameAndPath, const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idMovie = -1); int SetDetailsForMovieSet(const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idSet = -1); /*! \brief add a tvshow to the library, setting metdata detail @@ -475,9 +475,9 @@ public: int SetDetailsForTvShow(const std::vector< std::pair<std::string, std::string> > &paths, const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, const std::map<int, std::map<std::string, std::string> > &seasonArt, int idTvShow = -1); bool UpdateDetailsForTvShow(int idTvShow, const CVideoInfoTag &details, const std::map<std::string, std::string> &artwork, const std::map<int, std::map<std::string, std::string> > &seasonArt); int SetDetailsForSeason(const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idShow, int idSeason = -1); - int SetDetailsForEpisode(const CStdString& strFilenameAndPath, const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idShow, int idEpisode=-1); - int SetDetailsForMusicVideo(const CStdString& strFilenameAndPath, const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idMVideo = -1); - void SetStreamDetailsForFile(const CStreamDetails& details, const CStdString &strFileNameAndPath); + int SetDetailsForEpisode(const std::string& strFilenameAndPath, const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idShow, int idEpisode=-1); + int SetDetailsForMusicVideo(const std::string& strFilenameAndPath, const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idMVideo = -1); + void SetStreamDetailsForFile(const CStreamDetails& details, const std::string &strFileNameAndPath); void SetStreamDetailsForFileId(const CStreamDetails& details, int idFile); bool SetSingleValue(VIDEODB_CONTENT_TYPE type, int dbId, int dbField, const std::string &strValue); @@ -488,25 +488,25 @@ public: int UpdateDetailsForMovie(int idMovie, const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, const std::set<std::string> &updatedDetails); void DeleteMovie(int idMovie, bool bKeepId = false); - void DeleteMovie(const CStdString& strFilenameAndPath, bool bKeepId = false); + void DeleteMovie(const std::string& strFilenameAndPath, bool bKeepId = false); void DeleteTvShow(int idTvShow, bool bKeepId = false); - void DeleteTvShow(const CStdString& strPath); + void DeleteTvShow(const std::string& strPath); void DeleteSeason(int idSeason, bool bKeepId = false); void DeleteEpisode(int idEpisode, bool bKeepId = false); - void DeleteEpisode(const CStdString& strFilenameAndPath, bool bKeepId = false); + void DeleteEpisode(const std::string& strFilenameAndPath, bool bKeepId = false); void DeleteMusicVideo(int idMusicVideo, bool bKeepId = false); - void DeleteMusicVideo(const CStdString& strFilenameAndPath, bool bKeepId = false); + void DeleteMusicVideo(const std::string& strFilenameAndPath, bool bKeepId = false); void DeleteDetailsForTvShow(int idTvShow); - void DeleteDetailsForTvShow(const CStdString& strPath); - void RemoveContentForPath(const CStdString& strPath,CGUIDialogProgress *progress = NULL); + void DeleteDetailsForTvShow(const std::string& strPath); + void RemoveContentForPath(const std::string& strPath,CGUIDialogProgress *progress = NULL); void UpdateFanart(const CFileItem &item, VIDEODB_CONTENT_TYPE type); void DeleteSet(int idSet); void DeleteTag(int idTag, VIDEODB_CONTENT_TYPE mediaType); // per-file video settings - bool GetVideoSettings(const CStdString &strFilenameAndPath, CVideoSettings &settings); - void SetVideoSettings(const CStdString &strFilenameAndPath, const CVideoSettings &settings); - + bool GetVideoSettings(const std::string &strFilenameAndPath, CVideoSettings &settings); + void SetVideoSettings(const std::string &strFilenameAndPath, const CVideoSettings &settings); + /** * Erases settings for all files beginning with the specified path. Defaults * to an empty path, meaning all settings will be erased. @@ -514,15 +514,15 @@ public: */ void EraseVideoSettings(const std::string &path = ""); - bool GetStackTimes(const CStdString &filePath, std::vector<int> ×); - void SetStackTimes(const CStdString &filePath, std::vector<int> ×); + bool GetStackTimes(const std::string &filePath, std::vector<int> ×); + void SetStackTimes(const std::string &filePath, std::vector<int> ×); - void GetBookMarksForFile(const CStdString& strFilenameAndPath, VECBOOKMARKS& bookmarks, CBookmark::EType type = CBookmark::STANDARD, bool bAppend=false, long partNumber=0); - void AddBookMarkToFile(const CStdString& strFilenameAndPath, const CBookmark &bookmark, CBookmark::EType type = CBookmark::STANDARD); - bool GetResumeBookMark(const CStdString& strFilenameAndPath, CBookmark &bookmark); - void DeleteResumeBookMark(const CStdString &strFilenameAndPath); - void ClearBookMarkOfFile(const CStdString& strFilenameAndPath, CBookmark& bookmark, CBookmark::EType type = CBookmark::STANDARD); - void ClearBookMarksOfFile(const CStdString& strFilenameAndPath, CBookmark::EType type = CBookmark::STANDARD); + void GetBookMarksForFile(const std::string& strFilenameAndPath, VECBOOKMARKS& bookmarks, CBookmark::EType type = CBookmark::STANDARD, bool bAppend=false, long partNumber=0); + void AddBookMarkToFile(const std::string& strFilenameAndPath, const CBookmark &bookmark, CBookmark::EType type = CBookmark::STANDARD); + bool GetResumeBookMark(const std::string& strFilenameAndPath, CBookmark &bookmark); + void DeleteResumeBookMark(const std::string &strFilenameAndPath); + void ClearBookMarkOfFile(const std::string& strFilenameAndPath, CBookmark& bookmark, CBookmark::EType type = CBookmark::STANDARD); + void ClearBookMarksOfFile(const std::string& strFilenameAndPath, CBookmark::EType type = CBookmark::STANDARD); void ClearBookMarksOfFile(int idFile, CBookmark::EType type = CBookmark::STANDARD); bool GetBookMarkForEpisode(const CVideoInfoTag& tag, CBookmark& bookmark); void AddBookMarkForEpisode(const CVideoInfoTag& tag, const CBookmark& bookmark); @@ -532,9 +532,9 @@ public: bool GetStreamDetails(CVideoInfoTag& tag) const; // scraper settings - void SetScraperForPath(const CStdString& filePath, const ADDON::ScraperPtr& info, const VIDEO::SScanSettings& settings); - ADDON::ScraperPtr GetScraperForPath(const CStdString& strPath); - ADDON::ScraperPtr GetScraperForPath(const CStdString& strPath, VIDEO::SScanSettings& settings); + void SetScraperForPath(const std::string& filePath, const ADDON::ScraperPtr& info, const VIDEO::SScanSettings& settings); + ADDON::ScraperPtr GetScraperForPath(const std::string& strPath); + ADDON::ScraperPtr GetScraperForPath(const std::string& strPath, VIDEO::SScanSettings& settings); /*! \brief Retrieve the scraper and settings we should use for the specified path If the scraper is not set on this particular path, we'll recursively check parent folders. @@ -544,7 +544,7 @@ public: \return A ScraperPtr containing the scraper information. Returns NULL if a trivial (Content == CONTENT_NONE) scraper or no scraper is found. */ - ADDON::ScraperPtr GetScraperForPath(const CStdString& strPath, VIDEO::SScanSettings& settings, bool& foundDirectly); + ADDON::ScraperPtr GetScraperForPath(const std::string& strPath, VIDEO::SScanSettings& settings, bool& foundDirectly); /*! \brief Retrieve the content type of videos in the given path If content is set on the folder, we return the given content type, except in the case of tvshows, @@ -554,7 +554,7 @@ public: \param strPath path to start searching in. \return A content type string for the current path. */ - CStdString GetContentForPath(const CStdString& strPath); + std::string GetContentForPath(const std::string& strPath); /*! \brief Get videos of the given content type from the given path \param content the content type to fetch. @@ -562,18 +562,18 @@ public: \param items the returned items \return true if items are found, false otherwise. */ - bool GetItemsForPath(const CStdString &content, const CStdString &path, CFileItemList &items); + bool GetItemsForPath(const std::string &content, const std::string &path, CFileItemList &items); /*! \brief Check whether a given scraper is in use. \param scraperID the scraper to check for. \return true if the scraper is in use, false otherwise. */ - bool ScraperInUse(const CStdString &scraperID) const; + bool ScraperInUse(const std::string &scraperID) const; // scanning hashes and paths scanned - bool SetPathHash(const CStdString &path, const CStdString &hash); - bool GetPathHash(const CStdString &path, CStdString &hash); - bool GetPaths(std::set<CStdString> &paths); + bool SetPathHash(const std::string &path, const std::string &hash); + bool GetPathHash(const std::string &path, std::string &hash); + bool GetPaths(std::set<std::string> &paths); bool GetPathsForTvShow(int idShow, std::set<int>& paths); /*! \brief return the paths linked to a tvshow. @@ -588,71 +588,71 @@ public: \param subpaths the returned subpaths \return true if we successfully retrieve subpaths (may be zero), false on error */ - bool GetSubPaths(const CStdString& basepath, std::vector< std::pair<int, std::string> >& subpaths); + bool GetSubPaths(const std::string& basepath, std::vector< std::pair<int, std::string> >& subpaths); bool GetSourcePath(const std::string &path, std::string &sourcePath); bool GetSourcePath(const std::string &path, std::string &sourcePath, VIDEO::SScanSettings& settings); // for music + musicvideo linkups - if no album and title given it will return the artist id, else the id of the matching video - int GetMatchingMusicVideo(const CStdString& strArtist, const CStdString& strAlbum = "", const CStdString& strTitle = ""); + int GetMatchingMusicVideo(const std::string& strArtist, const std::string& strAlbum = "", const std::string& strTitle = ""); // searching functions - void GetMoviesByActor(const CStdString& strActor, CFileItemList& items); - void GetTvShowsByActor(const CStdString& strActor, CFileItemList& items); - void GetEpisodesByActor(const CStdString& strActor, CFileItemList& items); + void GetMoviesByActor(const std::string& strActor, CFileItemList& items); + void GetTvShowsByActor(const std::string& strActor, CFileItemList& items); + void GetEpisodesByActor(const std::string& strActor, CFileItemList& items); - void GetMusicVideosByArtist(const CStdString& strArtist, CFileItemList& items); - void GetMusicVideosByAlbum(const CStdString& strAlbum, CFileItemList& items); + void GetMusicVideosByArtist(const std::string& strArtist, CFileItemList& items); + void GetMusicVideosByAlbum(const std::string& strAlbum, CFileItemList& items); - void GetMovieGenresByName(const CStdString& strSearch, CFileItemList& items); - void GetTvShowGenresByName(const CStdString& strSearch, CFileItemList& items); - void GetMusicVideoGenresByName(const CStdString& strSearch, CFileItemList& items); + void GetMovieGenresByName(const std::string& strSearch, CFileItemList& items); + void GetTvShowGenresByName(const std::string& strSearch, CFileItemList& items); + void GetMusicVideoGenresByName(const std::string& strSearch, CFileItemList& items); - void GetMovieCountriesByName(const CStdString& strSearch, CFileItemList& items); + void GetMovieCountriesByName(const std::string& strSearch, CFileItemList& items); - void GetMusicVideoAlbumsByName(const CStdString& strSearch, CFileItemList& items); + void GetMusicVideoAlbumsByName(const std::string& strSearch, CFileItemList& items); - void GetMovieActorsByName(const CStdString& strSearch, CFileItemList& items); - void GetTvShowsActorsByName(const CStdString& strSearch, CFileItemList& items); - void GetMusicVideoArtistsByName(const CStdString& strSearch, CFileItemList& items); + void GetMovieActorsByName(const std::string& strSearch, CFileItemList& items); + void GetTvShowsActorsByName(const std::string& strSearch, CFileItemList& items); + void GetMusicVideoArtistsByName(const std::string& strSearch, CFileItemList& items); - void GetMovieDirectorsByName(const CStdString& strSearch, CFileItemList& items); - void GetTvShowsDirectorsByName(const CStdString& strSearch, CFileItemList& items); - void GetMusicVideoDirectorsByName(const CStdString& strSearch, CFileItemList& items); + void GetMovieDirectorsByName(const std::string& strSearch, CFileItemList& items); + void GetTvShowsDirectorsByName(const std::string& strSearch, CFileItemList& items); + void GetMusicVideoDirectorsByName(const std::string& strSearch, CFileItemList& items); - void GetMoviesByName(const CStdString& strSearch, CFileItemList& items); - void GetTvShowsByName(const CStdString& strSearch, CFileItemList& items); - void GetEpisodesByName(const CStdString& strSearch, CFileItemList& items); - void GetMusicVideosByName(const CStdString& strSearch, CFileItemList& items); + void GetMoviesByName(const std::string& strSearch, CFileItemList& items); + void GetTvShowsByName(const std::string& strSearch, CFileItemList& items); + void GetEpisodesByName(const std::string& strSearch, CFileItemList& items); + void GetMusicVideosByName(const std::string& strSearch, CFileItemList& items); - void GetEpisodesByPlot(const CStdString& strSearch, CFileItemList& items); - void GetMoviesByPlot(const CStdString& strSearch, CFileItemList& items); + void GetEpisodesByPlot(const std::string& strSearch, CFileItemList& items); + void GetMoviesByPlot(const std::string& strSearch, CFileItemList& items); bool LinkMovieToTvshow(int idMovie, int idShow, bool bRemove); bool IsLinkedToTvshow(int idMovie); bool GetLinksToTvShow(int idMovie, std::vector<int>& ids); // general browsing - bool GetGenresNav(const CStdString& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false); - bool GetCountriesNav(const CStdString& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false); - bool GetStudiosNav(const CStdString& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false); - bool GetYearsNav(const CStdString& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter()); - bool GetActorsNav(const CStdString& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false); - bool GetDirectorsNav(const CStdString& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false); - bool GetWritersNav(const CStdString& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false); - bool GetSetsNav(const CStdString& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool ignoreSingleMovieSets = false); - bool GetTagsNav(const CStdString& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false); - bool GetMusicVideoAlbumsNav(const CStdString& strBaseDir, CFileItemList& items, int idArtist, const Filter &filter = Filter(), bool countOnly = false); - - bool GetMoviesNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idActor=-1, int idDirector=-1, int idStudio=-1, int idCountry=-1, int idSet=-1, int idTag=-1, const SortDescription &sortDescription = SortDescription()); - bool GetTvShowsNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idActor=-1, int idDirector=-1, int idStudio=-1, int idTag=-1, const SortDescription &sortDescription = SortDescription()); - bool GetSeasonsNav(const CStdString& strBaseDir, CFileItemList& items, int idActor=-1, int idDirector=-1, int idGenre=-1, int idYear=-1, int idShow=-1, bool getLinkedMovies = true); - bool GetEpisodesNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idActor=-1, int idDirector=-1, int idShow=-1, int idSeason=-1, const SortDescription &sortDescription = SortDescription()); - bool GetMusicVideosNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idArtist=-1, int idDirector=-1, int idStudio=-1, int idAlbum=-1, int idTag=-1, const SortDescription &sortDescription = SortDescription()); + bool GetGenresNav(const std::string& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false); + bool GetCountriesNav(const std::string& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false); + bool GetStudiosNav(const std::string& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false); + bool GetYearsNav(const std::string& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter()); + bool GetActorsNav(const std::string& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false); + bool GetDirectorsNav(const std::string& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false); + bool GetWritersNav(const std::string& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false); + bool GetSetsNav(const std::string& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool ignoreSingleMovieSets = false); + bool GetTagsNav(const std::string& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false); + bool GetMusicVideoAlbumsNav(const std::string& strBaseDir, CFileItemList& items, int idArtist, const Filter &filter = Filter(), bool countOnly = false); + + bool GetMoviesNav(const std::string& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idActor=-1, int idDirector=-1, int idStudio=-1, int idCountry=-1, int idSet=-1, int idTag=-1, const SortDescription &sortDescription = SortDescription()); + bool GetTvShowsNav(const std::string& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idActor=-1, int idDirector=-1, int idStudio=-1, int idTag=-1, const SortDescription &sortDescription = SortDescription()); + bool GetSeasonsNav(const std::string& strBaseDir, CFileItemList& items, int idActor=-1, int idDirector=-1, int idGenre=-1, int idYear=-1, int idShow=-1, bool getLinkedMovies = true); + bool GetEpisodesNav(const std::string& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idActor=-1, int idDirector=-1, int idShow=-1, int idSeason=-1, const SortDescription &sortDescription = SortDescription()); + bool GetMusicVideosNav(const std::string& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idArtist=-1, int idDirector=-1, int idStudio=-1, int idAlbum=-1, int idTag=-1, const SortDescription &sortDescription = SortDescription()); - bool GetRecentlyAddedMoviesNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit=0); - bool GetRecentlyAddedEpisodesNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit=0); - bool GetRecentlyAddedMusicVideosNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit=0); + bool GetRecentlyAddedMoviesNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit=0); + bool GetRecentlyAddedEpisodesNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit=0); + bool GetRecentlyAddedMusicVideosNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit=0); bool HasContent(); bool HasContent(VIDEODB_CONTENT_TYPE type); @@ -665,7 +665,7 @@ public: \param url - full path of the file to add. \return id of the file, -1 if it could not be added. */ - int AddFile(const CStdString& url); + int AddFile(const std::string& url); /*! \brief Add a file to the database, if necessary Works for both videodb:// items and normal fileitems @@ -681,43 +681,42 @@ public: \param strDateAdded datetime when the path was added to the filesystem/database \return id of the file, -1 if it could not be added. */ - int AddPath(const CStdString& strPath, const CStdString &parentPath = "", const CStdString &strDateAdded = ""); + int AddPath(const std::string& strPath, const std::string &parentPath = "", const std::string &strDateAdded = ""); /*! \brief Updates the dateAdded field in the files table for the file with the given idFile and the given path based on the files modification date \param idFile id of the file in the files table \param strFileNameAndPath path to the file */ - void UpdateFileDateAdded(int idFile, const CStdString& strFileNameAndPath); + void UpdateFileDateAdded(int idFile, const std::string& strFileNameAndPath); - void ExportToXML(const CStdString &path, bool singleFiles = false, bool images=false, bool actorThumbs=false, bool overwrite=false); - bool ExportSkipEntry(const CStdString &nfoFile); - void ExportActorThumbs(const CStdString &path, const CVideoInfoTag& tag, bool singleFiles, bool overwrite=false); - void ImportFromXML(const CStdString &path); - void DumpToDummyFiles(const CStdString &path); + void ExportToXML(const std::string &path, bool singleFiles = false, bool images=false, bool actorThumbs=false, bool overwrite=false); + bool ExportSkipEntry(const std::string &nfoFile); + void ExportActorThumbs(const std::string &path, const CVideoInfoTag& tag, bool singleFiles, bool overwrite=false); + void ImportFromXML(const std::string &path); + void DumpToDummyFiles(const std::string &path); bool ImportArtFromXML(const TiXmlNode *node, std::map<std::string, std::string> &artwork); // smart playlists and main retrieval work in these functions - bool GetMoviesByWhere(const CStdString& strBaseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription = SortDescription()); - bool GetSetsByWhere(const CStdString& strBaseDir, const Filter &filter, CFileItemList& items, bool ignoreSingleMovieSets = false); - bool GetTvShowsByWhere(const CStdString& strBaseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription = SortDescription()); - bool GetSeasonsByWhere(const CStdString& strBaseDir, const Filter &filter, CFileItemList& items, bool appendFullShowPath = true, const SortDescription &sortDescription = SortDescription()); - bool GetEpisodesByWhere(const CStdString& strBaseDir, const Filter &filter, CFileItemList& items, bool appendFullShowPath = true, const SortDescription &sortDescription = SortDescription()); - bool GetMusicVideosByWhere(const CStdString &baseDir, const Filter &filter, CFileItemList& items, bool checkLocks = true, const SortDescription &sortDescription = SortDescription()); + bool GetMoviesByWhere(const std::string& strBaseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription = SortDescription()); + bool GetSetsByWhere(const std::string& strBaseDir, const Filter &filter, CFileItemList& items, bool ignoreSingleMovieSets = false); + bool GetTvShowsByWhere(const std::string& strBaseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription = SortDescription()); + bool GetSeasonsByWhere(const std::string& strBaseDir, const Filter &filter, CFileItemList& items, bool appendFullShowPath = true, const SortDescription &sortDescription = SortDescription()); + bool GetEpisodesByWhere(const std::string& strBaseDir, const Filter &filter, CFileItemList& items, bool appendFullShowPath = true, const SortDescription &sortDescription = SortDescription()); + bool GetMusicVideosByWhere(const std::string &baseDir, const Filter &filter, CFileItemList& items, bool checkLocks = true, const SortDescription &sortDescription = SortDescription()); // retrieve sorted and limited items - bool GetSortedVideos(const MediaType &mediaType, const CStdString& strBaseDir, const SortDescription &sortDescription, CFileItemList& items, const Filter &filter = Filter()); + bool GetSortedVideos(const MediaType &mediaType, const std::string& strBaseDir, const SortDescription &sortDescription, CFileItemList& items, const Filter &filter = Filter()); // retrieve a list of items - bool GetItems(const CStdString &strBaseDir, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription()); - bool GetItems(const CStdString &strBaseDir, const CStdString &mediaType, const CStdString &itemType, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription()); - bool GetItems(const CStdString &strBaseDir, VIDEODB_CONTENT_TYPE mediaType, const CStdString &itemType, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription()); - CStdString GetItemById(const CStdString &itemType, int id); + bool GetItems(const std::string &strBaseDir, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription()); + bool GetItems(const std::string &strBaseDir, const std::string &mediaType, const std::string &itemType, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription()); + bool GetItems(const std::string &strBaseDir, VIDEODB_CONTENT_TYPE mediaType, const std::string &itemType, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription()); + std::string GetItemById(const std::string &itemType, int id); // partymode - int GetMusicVideoCount(const CStdString& strWhere); - unsigned int GetMusicVideoIDs(const CStdString& strWhere, std::vector<std::pair<int,int> > &songIDs); - bool GetRandomMusicVideo(CFileItem* item, int& idSong, const CStdString& strWhere); + unsigned int GetMusicVideoIDs(const std::string& strWhere, std::vector<std::pair<int, int> > &songIDs); + bool GetRandomMusicVideo(CFileItem* item, int& idSong, const std::string& strWhere); static void VideoContentTypeToString(VIDEODB_CONTENT_TYPE type, std::string& out) { @@ -756,14 +755,14 @@ public: virtual bool GetFilter(CDbUrl &videoUrl, Filter &filter, SortDescription &sorting); - int AddSet(const CStdString& strSet); + int AddSet(const std::string& strSet); void ClearMovieSet(int idMovie); void SetMovieSet(int idMovie, int idSet); protected: friend class CEdenVideoArtUpdater; - int GetMovieId(const CStdString& strFilenameAndPath); - int GetMusicVideoId(const CStdString& strFilenameAndPath); + int GetMovieId(const std::string& strFilenameAndPath); + int GetMusicVideoId(const std::string& strFilenameAndPath); /*! \brief Get the id of this fileitem Works for both videodb:// items and normal fileitems @@ -776,16 +775,13 @@ protected: \param url full path to the file \return id of the file, -1 if it is not in the db. */ - int GetFileId(const CStdString& url); + int GetFileId(const std::string& url); - int AddToTable(const CStdString& table, const CStdString& firstField, const CStdString& secondField, const CStdString& value); - int AddGenre(const CStdString& strGenre1); - int AddActor(const CStdString& strActor, const CStdString& thumbURL, const CStdString &thumb = ""); - int AddCountry(const CStdString& strCountry); - int AddStudio(const CStdString& strStudio1); + int AddToTable(const std::string& table, const std::string& firstField, const std::string& secondField, const std::string& value); + int AddActor(const std::string& strActor, const std::string& thumbURL, const std::string &thumb = ""); int AddTvShow(); - int AddMusicVideo(const CStdString& strFilenameAndPath); + int AddMusicVideo(const std::string& strFilenameAndPath); int AddSeason(int showID, int season); /*! \brief Adds a path to the tvshow link table. @@ -804,33 +800,16 @@ protected: int GetMatchingTvShow(const CVideoInfoTag &show); // link functions - these two do all the work - void AddLinkToActor(const char *table, int actorID, const char *secondField, int secondID, const CStdString &role, int order); - void AddToLinkTable(const char *table, const char *firstField, int firstID, const char *secondField, int secondID, const char *typeField = NULL, const char *type = NULL); - void RemoveFromLinkTable(const char *table, const char *firstField, int firstID, const char *secondField, int secondID, const char *typeField = NULL, const char *type = NULL); - void UpdateLinkTable(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values); - void UpdateActorLinkTable(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values); - - void AddCast(int idMedia, const char *table, const char *field, const std::vector<SActorInfo> &cast); - void AddArtistToMusicVideo(int lMVideo, int idArtist); - - void AddDirectorToMovie(int idMovie, int idDirector); - void AddDirectorToTvShow(int idTvShow, int idDirector); - void AddDirectorToEpisode(int idEpisode, int idDirector); - void AddDirectorToMusicVideo(int lMVideo, int idDirector); - void AddWriterToEpisode(int idEpisode, int idWriter); - void AddWriterToMovie(int idMovie, int idWriter); + void AddLinkToActor(int mediaId, const char *mediaType, int actorId, const std::string &role, int order); + void AddToLinkTable(int mediaId, const std::string& mediaType, const std::string& table, int valueId, const char *foreignKey = NULL); + void RemoveFromLinkTable(int mediaId, const std::string& mediaType, const std::string& table, int valueId, const char *foreignKey = NULL); - void AddGenreToMovie(int idMovie, int idGenre); - void AddGenreToTvShow(int idTvShow, int idGenre); - void AddGenreToMusicVideo(int idMVideo, int idGenre); + void AddLinksToItem(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values); + void UpdateLinksToItem(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values); + void AddActorLinksToItem(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values); + void UpdateActorLinksToItem(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values); - void AddStudioToMovie(int idMovie, int idStudio); - void AddStudioToTvShow(int idTvShow, int idStudio); - void AddStudioToMusicVideo(int idMVideo, int idStudio); - - void AddCountryToMovie(int idMovie, int idCountry); - - void AddGenreAndDirectorsAndStudios(const CVideoInfoTag& details, std::vector<int>& vecDirectors, std::vector<int>& vecGenres, std::vector<int>& vecStudios); + void AddCast(int mediaId, const char *mediaType, const std::vector<SActorInfo> &cast); void DeleteStreamDetails(int idFile); CVideoInfoTag GetDetailsByTypeAndId(VIDEODB_CONTENT_TYPE type, int id); @@ -842,18 +821,21 @@ protected: CVideoInfoTag GetDetailsForEpisode(const dbiplus::sql_record* const record, bool getDetails = false); CVideoInfoTag GetDetailsForMusicVideo(std::auto_ptr<dbiplus::Dataset> &pDS, bool getDetails = false); CVideoInfoTag GetDetailsForMusicVideo(const dbiplus::sql_record* const record, bool getDetails = false); - bool GetPeopleNav(const CStdString& strBaseDir, CFileItemList& items, const CStdString& type, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false); - bool GetNavCommon(const CStdString& strBaseDir, CFileItemList& items, const CStdString& type, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false); - void GetCast(const CStdString &table, const CStdString &table_id, int type_id, std::vector<SActorInfo> &cast); + bool GetPeopleNav(const std::string& strBaseDir, CFileItemList& items, const char *type, int idContent = -1, const Filter &filter = Filter(), bool countOnly = false); + bool GetNavCommon(const std::string& strBaseDir, CFileItemList& items, const char *type, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false); + void GetCast(int media_id, const std::string &media_type, std::vector<SActorInfo> &cast); + void GetTags(int media_id, const std::string &media_type, std::vector<std::string> &tags); void GetDetailsFromDB(std::auto_ptr<dbiplus::Dataset> &pDS, int min, int max, const SDbTableOffsets *offsets, CVideoInfoTag &details, int idxOffset = 2); void GetDetailsFromDB(const dbiplus::sql_record* const record, int min, int max, const SDbTableOffsets *offsets, CVideoInfoTag &details, int idxOffset = 2); - CStdString GetValueString(const CVideoInfoTag &details, int min, int max, const SDbTableOffsets *offsets) const; + std::string GetValueString(const CVideoInfoTag &details, int min, int max, const SDbTableOffsets *offsets) const; private: virtual void CreateTables(); virtual void CreateAnalytics(); virtual void UpdateTables(int version); + void CreateLinkIndex(const char *table); + void CreateForeignLinkIndex(const char *table, const char *foreignkey); /*! \brief (Re)Create the generic database views for movies, tvshows, episodes and music videos @@ -872,29 +854,32 @@ private: \param sql the sql query to run \return the number of rows, -1 for an error. */ - int RunQuery(const CStdString &sql); + int RunQuery(const std::string &sql); + + void AppendIdLinkFilter(const char* field, const char *table, const MediaType& mediaType, const char *view, const char *viewKey, const CUrlOptions::UrlOptions& options, Filter &filter); + void AppendLinkFilter(const char* field, const char *table, const MediaType& mediaType, const char *view, const char *viewKey, const CUrlOptions::UrlOptions& options, Filter &filter); /*! \brief Determine whether the path is using lookup using folders \param path the path to check \param shows whether this path is from a tvshow (defaults to false) */ - bool LookupByFolders(const CStdString &path, bool shows = false); + bool LookupByFolders(const std::string &path, bool shows = false); virtual int GetMinSchemaVersion() const { return 60; }; virtual int GetSchemaVersion() const; virtual int GetExportVersion() const { return 1; }; const char *GetBaseDBName() const { return "MyVideos"; }; - void ConstructPath(CStdString& strDest, const CStdString& strPath, const CStdString& strFileName); - void SplitPath(const CStdString& strFileNameAndPath, CStdString& strPath, CStdString& strFileName); - void InvalidatePathHash(const CStdString& strPath); + void ConstructPath(std::string& strDest, const std::string& strPath, const std::string& strFileName); + void SplitPath(const std::string& strFileNameAndPath, std::string& strPath, std::string& strFileName); + void InvalidatePathHash(const std::string& strPath); /*! \brief Get a safe filename from a given string \param dir directory to use for the file \param name movie, show name, or actor to get a safe filename for \return safe filename based on this title */ - CStdString GetSafeFile(const CStdString &dir, const CStdString &name) const; + std::string GetSafeFile(const std::string &dir, const std::string &name) const; std::vector<int> CleanMediaType(const std::string &mediaType, const std::string &cleanableFileIDs, std::map<int, bool> &pathsDeleteDecisions, std::string &deletedFileIDs, bool silent); diff --git a/xbmc/video/VideoDbUrl.cpp b/xbmc/video/VideoDbUrl.cpp index b154b86cbc..cede492abe 100644 --- a/xbmc/video/VideoDbUrl.cpp +++ b/xbmc/video/VideoDbUrl.cpp @@ -40,7 +40,7 @@ bool CVideoDbUrl::parse() if (!m_url.IsProtocol("videodb") || m_url.GetFileName().empty()) return false; - CStdString path = m_url.Get(); + std::string path = m_url.Get(); VIDEODATABASEDIRECTORY::NODE_TYPE dirType = CVideoDatabaseDirectory::GetDirectoryType(path); VIDEODATABASEDIRECTORY::NODE_TYPE childType = CVideoDatabaseDirectory::GetDirectoryChildType(path); diff --git a/xbmc/video/VideoInfoDownloader.cpp b/xbmc/video/VideoInfoDownloader.cpp index f33ac8a0db..b1b507409c 100644 --- a/xbmc/video/VideoInfoDownloader.cpp +++ b/xbmc/video/VideoInfoDownloader.cpp @@ -49,7 +49,7 @@ CVideoInfoDownloader::~CVideoInfoDownloader() } // return value: 0 = we failed, -1 = we failed and reported an error, 1 = success -int CVideoInfoDownloader::InternalFindMovie(const CStdString &strMovie, +int CVideoInfoDownloader::InternalFindMovie(const std::string &strMovie, MOVIELIST& movielist, bool cleanChars /* = true */) { @@ -115,7 +115,7 @@ void CVideoInfoDownloader::Process() m_state = DO_NOTHING; } -int CVideoInfoDownloader::FindMovie(const CStdString &strMovie, +int CVideoInfoDownloader::FindMovie(const std::string &strMovie, MOVIELIST& movieList, CGUIDialogProgress *pProgress /* = NULL */) { diff --git a/xbmc/video/VideoInfoDownloader.h b/xbmc/video/VideoInfoDownloader.h index 22ac229746..2df40a1ddf 100644 --- a/xbmc/video/VideoInfoDownloader.h +++ b/xbmc/video/VideoInfoDownloader.h @@ -26,6 +26,7 @@ #include "Episode.h" #include "XBDateTime.h" #include "filesystem/CurlFile.h" +#include <string> // forward declarations class CXBMCTinyXML; @@ -52,7 +53,7 @@ public: \param pProgress progress bar to update as we go. If NULL we run on thread, if non-NULL we run off thread. \return 1 on success, -1 on a scraper-specific error, 0 on some other error */ - int FindMovie(const CStdString& strMovie, MOVIELIST& movielist, CGUIDialogProgress *pProgress = NULL); + int FindMovie(const std::string& strMovie, MOVIELIST& movielist, CGUIDialogProgress *pProgress = NULL); bool GetDetails(const CScraperUrl& url, CVideoInfoTag &movieDetails, CGUIDialogProgress *pProgress = NULL); bool GetEpisodeDetails(const CScraperUrl& url, CVideoInfoTag &movieDetails, CGUIDialogProgress *pProgress = NULL); bool GetEpisodeList(const CScraperUrl& url, VIDEO::EPISODELIST& details, CGUIDialogProgress *pProgress = NULL); @@ -67,7 +68,7 @@ protected: GET_EPISODE_DETAILS = 4 }; XFILE::CCurlFile* m_http; - CStdString m_strMovie; + std::string m_strMovie; MOVIELIST m_movieList; CVideoInfoTag m_movieDetails; CScraperUrl m_url; @@ -80,6 +81,6 @@ protected: void Process(); void CloseThread(); - int InternalFindMovie(const CStdString& strMovie, MOVIELIST& movielist, bool cleanChars = true); + int InternalFindMovie(const std::string& strMovie, MOVIELIST& movielist, bool cleanChars = true); }; diff --git a/xbmc/video/VideoInfoScanner.cpp b/xbmc/video/VideoInfoScanner.cpp index 6d77da0867..c4310e0d8a 100644 --- a/xbmc/video/VideoInfoScanner.cpp +++ b/xbmc/video/VideoInfoScanner.cpp @@ -129,7 +129,7 @@ namespace VIDEO * reference points to the entry in the set a null reference error * occurs. */ - CStdString directory = *m_pathsToScan.begin(); + std::string directory = *m_pathsToScan.begin(); if (!CDirectory::Exists(directory)) { /* @@ -179,7 +179,7 @@ namespace VIDEO m_handle = NULL; } - void CVideoInfoScanner::Start(const CStdString& strDirectory, bool scanAll) + void CVideoInfoScanner::Start(const std::string& strDirectory, bool scanAll) { m_strStartDir = strDirectory; m_scanAll = scanAll; @@ -253,20 +253,20 @@ namespace VIDEO m_bRunning = false; } - static void OnDirectoryScanned(const CStdString& strDirectory) + static void OnDirectoryScanned(const std::string& strDirectory) { CGUIMessage msg(GUI_MSG_DIRECTORY_SCANNED, 0, 0, 0); msg.SetStringParam(strDirectory); g_windowManager.SendThreadMessage(msg); } - bool CVideoInfoScanner::IsExcluded(const CStdString& strDirectory) const + bool CVideoInfoScanner::IsExcluded(const std::string& strDirectory) const { - CStdString noMediaFile = URIUtils::AddFileToFolder(strDirectory, ".nomedia"); + std::string noMediaFile = URIUtils::AddFileToFolder(strDirectory, ".nomedia"); return CFile::Exists(noMediaFile); } - bool CVideoInfoScanner::DoScan(const CStdString& strDirectory) + bool CVideoInfoScanner::DoScan(const std::string& strDirectory) { if (m_handle) { @@ -278,7 +278,7 @@ namespace VIDEO * the check for file or folder exclusion to prevent an infinite while loop * in Process(). */ - set<CStdString>::iterator it = m_pathsToScan.find(strDirectory); + set<std::string>::iterator it = m_pathsToScan.find(strDirectory); if (it != m_pathsToScan.end()) m_pathsToScan.erase(it); @@ -308,7 +308,7 @@ namespace VIDEO if (content == CONTENT_NONE || ignoreFolder) return true; - CStdString hash, dbHash; + std::string hash, dbHash; if (content == CONTENT_MOVIES ||content == CONTENT_MUSICVIDEOS) { if (m_handle) @@ -317,7 +317,7 @@ namespace VIDEO m_handle->SetTitle(StringUtils::Format(g_localizeStrings.Get(str).c_str(), info->Name().c_str())); } - CStdString fastHash = GetFastHash(strDirectory, regexps); + std::string fastHash = GetFastHash(strDirectory, regexps); if (m_database.GetPathHash(strDirectory, dbHash) && !fastHash.empty() && fastHash == dbHash) { // fast hashes match - no need to process anything hash = fastHash; @@ -531,7 +531,7 @@ namespace VIDEO idTvShow = m_database.GetTvShowId(pItem->GetPath()); else { - CStdString strPath = URIUtils::GetDirectory(pItem->GetPath()); + std::string strPath = URIUtils::GetDirectory(pItem->GetPath()); idTvShow = m_database.GetTvShowId(strPath); } if (idTvShow > -1 && (fetchEpisodes || !pItem->m_bIsFolder)) @@ -724,11 +724,11 @@ namespace VIDEO * Remove this path from the list we're processing in order to avoid hitting * it twice in the main loop. */ - set<CStdString>::iterator it = m_pathsToScan.find(item->GetPath()); + set<std::string>::iterator it = m_pathsToScan.find(item->GetPath()); if (it != m_pathsToScan.end()) m_pathsToScan.erase(it); - CStdString hash, dbHash; + std::string hash, dbHash; hash = GetRecursiveFastHash(item->GetPath(), regexps); if (m_database.GetPathHash(item->GetPath(), dbHash) && !hash.empty() && dbHash == hash) { @@ -805,20 +805,20 @@ namespace VIDEO continue; } - CStdString strPathX, strFileX; + std::string strPathX, strFileX; URIUtils::Split(items[x]->GetPath(), strPathX, strFileX); //CLog::Log(LOGDEBUG,"%i:%s:%s", x, strPathX.c_str(), strFileX.c_str()); const int y = x + 1; - if (strFileX.Equals("VIDEO_TS.IFO")) + if (StringUtils::EqualsNoCase(strFileX, "VIDEO_TS.IFO")) { while (y < items.Size()) { - CStdString strPathY, strFileY; + std::string strPathY, strFileY; URIUtils::Split(items[y]->GetPath(), strPathY, strFileY); //CLog::Log(LOGDEBUG," %i:%s:%s", y, strPathY.c_str(), strFileY.c_str()); - if (strPathY.Equals(strPathX)) + if (StringUtils::EqualsNoCase(strPathY, strPathX)) /* remove everything sorted below the video_ts.ifo file in the same path. understandbly this wont stack correctly if there are other files in the the dvd folder. @@ -838,10 +838,10 @@ namespace VIDEO { if (items[i]->m_bIsFolder) continue; - CStdString strPath = URIUtils::GetDirectory(items[i]->GetPath()); + std::string strPath = URIUtils::GetDirectory(items[i]->GetPath()); URIUtils::RemoveSlashAtEnd(strPath); // want no slash for the test that follows - if (URIUtils::GetFileName(strPath).Equals("sample")) + if (StringUtils::EqualsNoCase(URIUtils::GetFileName(strPath), "sample")) continue; // Discard all exclude files defined by regExExcludes @@ -951,7 +951,7 @@ namespace VIDEO { SETTINGS_TVSHOWLIST expression = g_advancedSettings.m_tvshowEnumRegExps; - CStdString strLabel=item->GetPath(); + std::string strLabel=item->GetPath(); // URLDecode in case an episode is on a http/https/dav/davs:// source and URL-encoded like foo%201x01%20bar.avi strLabel = CURL::Decode(strLabel); @@ -1002,7 +1002,7 @@ namespace VIDEO * only this single episode. If season and episode match with the * actual media file, we set episode.isFolder to true. */ - CStdString strBasePath = item->GetBaseMoviePath(true); + std::string strBasePath = item->GetBaseMoviePath(true); URIUtils::RemoveSlashAtEnd(strBasePath); strBasePath = URIUtils::GetFileName(strBasePath); @@ -1152,7 +1152,7 @@ namespace VIDEO if (pItem->m_bIsFolder) movieDetails.m_strPath = pItem->GetPath(); - CStdString strTitle(movieDetails.m_strTitle); + std::string strTitle(movieDetails.m_strTitle); if (showInfo && content == CONTENT_TVSHOWS) { @@ -1167,7 +1167,7 @@ namespace VIDEO if (content == CONTENT_MOVIES) { // find local trailer first - CStdString strTrailer = pItem->FindTrailer(); + std::string strTrailer = pItem->FindTrailer(); if (!strTrailer.empty()) movieDetails.m_strTrailer = strTrailer; @@ -1362,7 +1362,7 @@ namespace VIDEO pItem->SetArt(art); // parent folder to apply the thumb to and to search for local actor thumbs - CStdString parentDir = GetParentDir(*pItem); + std::string parentDir = GetParentDir(*pItem); if (CSettings::Get().GetBool("videolibrary.actorthumbs")) FetchActorThumbs(movieDetails.m_cast, actorArtPath.empty() ? parentDir : actorArtPath); if (bApplyToDir) @@ -1384,7 +1384,7 @@ namespace VIDEO thumb.find("/") == string::npos && thumb.find("\\") == string::npos) { - CStdString strPath = URIUtils::GetDirectory(pItem->GetPath()); + std::string strPath = URIUtils::GetDirectory(pItem->GetPath()); thumb = URIUtils::AddFileToFolder(strPath, thumb); } } @@ -1603,9 +1603,9 @@ namespace VIDEO return INFO_ADDED; } - CStdString CVideoInfoScanner::GetnfoFile(CFileItem *item, bool bGrabAny) const + std::string CVideoInfoScanner::GetnfoFile(CFileItem *item, bool bGrabAny) const { - CStdString nfoFile; + std::string nfoFile; // Find a matching .nfo file if (!item->m_bIsFolder) { @@ -1613,13 +1613,13 @@ namespace VIDEO { CFileItem item2(*item); CURL url(item->GetPath()); - CStdString strPath = URIUtils::GetDirectory(url.GetHostName()); + std::string strPath = URIUtils::GetDirectory(url.GetHostName()); item2.SetPath(URIUtils::AddFileToFolder(strPath, URIUtils::GetFileName(item->GetPath()))); return GetnfoFile(&item2, bGrabAny); } // grab the folder path - CStdString strPath = URIUtils::GetDirectory(item->GetPath()); + std::string strPath = URIUtils::GetDirectory(item->GetPath()); if (bGrabAny && !item->IsStack()) { // looking up by folder name - movie.nfo takes priority - but not for stacked items (handled below) @@ -1633,14 +1633,14 @@ namespace VIDEO { // first try .nfo file matching first file in stack CStackDirectory dir; - CStdString firstFile = dir.GetFirstStackedFile(item->GetPath()); + std::string firstFile = dir.GetFirstStackedFile(item->GetPath()); CFileItem item2; item2.SetPath(firstFile); nfoFile = GetnfoFile(&item2, bGrabAny); // else try .nfo file matching stacked title if (nfoFile.empty()) { - CStdString stackedTitlePath = dir.GetStackedTitlePath(item->GetPath()); + std::string stackedTitlePath = dir.GetStackedTitlePath(item->GetPath()); item2.SetPath(stackedTitlePath); nfoFile = GetnfoFile(&item2, bGrabAny); } @@ -1683,7 +1683,7 @@ namespace VIDEO // see if there is a unique nfo file in this folder, and if so, use that CFileItemList items; CDirectory dir; - CStdString strPath; + std::string strPath; if (item->m_bIsFolder) strPath = item->GetPath(); else @@ -1743,7 +1743,7 @@ namespace VIDEO return false; // no info found, or cancelled } - void CVideoInfoScanner::ApplyThumbToFolder(const CStdString &folder, const CStdString &imdbThumb) + void CVideoInfoScanner::ApplyThumbToFolder(const std::string &folder, const std::string &imdbThumb) { // copy icon to folder also; if (!imdbThumb.empty()) @@ -1754,7 +1754,7 @@ namespace VIDEO } } - int CVideoInfoScanner::GetPathHash(const CFileItemList &items, CStdString &hash) + int CVideoInfoScanner::GetPathHash(const CFileItemList &items, std::string &hash) { // Create a hash based on the filenames, filesize and filedate. Also count the number of files if (0 == items.Size()) return 0; @@ -1784,7 +1784,7 @@ namespace VIDEO return true; } - CStdString CVideoInfoScanner::GetFastHash(const CStdString &directory, const vector<string> &excludes) const + std::string CVideoInfoScanner::GetFastHash(const std::string &directory, const vector<string> &excludes) const { XBMC::XBMC_MD5 md5state; @@ -1806,7 +1806,7 @@ namespace VIDEO return ""; } - CStdString CVideoInfoScanner::GetRecursiveFastHash(const CStdString &directory, const vector<string> &excludes) const + std::string CVideoInfoScanner::GetRecursiveFastHash(const std::string &directory, const vector<string> &excludes) const { CFileItemList items; items.Add(CFileItemPtr(new CFileItem(directory, true))); @@ -1856,7 +1856,7 @@ namespace VIDEO { for (int i = 0; i < items.Size(); i++) { - CStdString name = URIUtils::GetFileName(items[i]->GetPath()); + std::string name = URIUtils::GetFileName(items[i]->GetPath()); if (reg.RegFind(name) > -1) { int season = atoi(reg.GetMatch(1).c_str()); @@ -1924,10 +1924,10 @@ namespace VIDEO } } - void CVideoInfoScanner::FetchActorThumbs(vector<SActorInfo>& actors, const CStdString& strPath) + void CVideoInfoScanner::FetchActorThumbs(vector<SActorInfo>& actors, const std::string& strPath) { CFileItemList items; - CStdString actorsDir = URIUtils::AddFileToFolder(strPath, ".actors"); + std::string actorsDir = URIUtils::AddFileToFolder(strPath, ".actors"); if (CDirectory::Exists(actorsDir)) CDirectory::GetDirectory(actorsDir, items, ".png|.jpg|.tbn", DIR_FLAG_NO_FILE_DIRS | DIR_FLAG_NO_FILE_INFO); @@ -1935,11 +1935,11 @@ namespace VIDEO { if (i->thumb.empty()) { - CStdString thumbFile = i->strName; + std::string thumbFile = i->strName; StringUtils::Replace(thumbFile, ' ', '_'); for (int j = 0; j < items.Size(); j++) { - CStdString compare = URIUtils::GetFileName(items[j]->GetPath()); + std::string compare = URIUtils::GetFileName(items[j]->GetPath()); URIUtils::RemoveExtension(compare); if (!items[j]->m_bIsFolder && compare == thumbFile) { @@ -1957,7 +1957,7 @@ namespace VIDEO CNfoFile::NFOResult CVideoInfoScanner::CheckForNFOFile(CFileItem* pItem, bool bGrabAny, ScraperPtr& info, CScraperUrl& scrUrl) { - CStdString strNfoFile; + std::string strNfoFile; if (info->Content() == CONTENT_MOVIES || info->Content() == CONTENT_MUSICVIDEOS || (info->Content() == CONTENT_TVSHOWS && !pItem->m_bIsFolder)) strNfoFile = GetnfoFile(pItem, bGrabAny); @@ -1972,7 +1972,7 @@ namespace VIDEO else result = m_nfoReader.Create(strNfoFile,info); - CStdString type; + std::string type; switch(result) { case CNfoFile::COMBINED_NFO: @@ -2028,7 +2028,7 @@ namespace VIDEO return CGUIDialogYesNo::ShowAndGetInput(20448,20449,20450,20022); } - bool CVideoInfoScanner::ProgressCancelled(CGUIDialogProgress* progress, int heading, const CStdString &line1) + bool CVideoInfoScanner::ProgressCancelled(CGUIDialogProgress* progress, int heading, const std::string &line1) { if (progress) { @@ -2041,7 +2041,7 @@ namespace VIDEO return m_bStop; } - int CVideoInfoScanner::FindVideo(const CStdString &videoName, const ScraperPtr &scraper, CScraperUrl &url, CGUIDialogProgress *progress) + int CVideoInfoScanner::FindVideo(const std::string &videoName, const ScraperPtr &scraper, CScraperUrl &url, CGUIDialogProgress *progress) { MOVIELIST movielist; CVideoInfoDownloader imdb(scraper); @@ -2059,16 +2059,16 @@ namespace VIDEO return 0; // didn't find anything } - CStdString CVideoInfoScanner::GetParentDir(const CFileItem &item) const + std::string CVideoInfoScanner::GetParentDir(const CFileItem &item) const { - CStdString strCheck = item.GetPath(); + std::string strCheck = item.GetPath(); if (item.IsStack()) strCheck = CStackDirectory::GetFirstStackedFile(item.GetPath()); - CStdString strDirectory = URIUtils::GetDirectory(strCheck); + std::string strDirectory = URIUtils::GetDirectory(strCheck); if (URIUtils::IsInRAR(strCheck)) { - CStdString strPath=strDirectory; + std::string strPath=strDirectory; URIUtils::GetParentPath(strPath, strDirectory); } if (item.IsStack()) diff --git a/xbmc/video/VideoInfoScanner.h b/xbmc/video/VideoInfoScanner.h index 28bd2bff6f..af63b1e7b3 100644 --- a/xbmc/video/VideoInfoScanner.h +++ b/xbmc/video/VideoInfoScanner.h @@ -58,7 +58,7 @@ namespace VIDEO \param strDirectory path to scan \param scanAll whether to scan everything not already scanned (regardless of whether the user normally doesn't want a folder scanned.) Defaults to false. */ - void Start(const CStdString& strDirectory, bool scanAll = false); + void Start(const std::string& strDirectory, bool scanAll = false); void StartCleanDatabase(); bool IsScanning(); void CleanDatabase(CGUIDialogProgressBarHandle* handle=NULL, const std::set<int>* paths=NULL, bool showProgress=true); @@ -90,7 +90,7 @@ namespace VIDEO */ bool RetrieveVideoInfo(CFileItemList& items, bool bDirNames, CONTENT_TYPE content, bool useLocal = true, CScraperUrl *pURL = NULL, bool fetchEpisodes = true, CGUIDialogProgress* pDlgProgress = NULL); - static void ApplyThumbToFolder(const CStdString &folder, const CStdString &imdbThumb); + static void ApplyThumbToFolder(const std::string &folder, const std::string &imdbThumb); static bool DownloadFailed(CGUIDialogProgress* pDlgProgress); CNfoFile::NFOResult CheckForNFOFile(CFileItem* pItem, bool bGrabAny, ADDON::ScraperPtr& scraper, CScraperUrl& scrUrl); @@ -125,8 +125,8 @@ namespace VIDEO protected: virtual void Process(); - bool DoScan(const CStdString& strDirectory); - bool IsExcluded(const CStdString& strDirectory) const; + bool DoScan(const std::string& strDirectory); + bool IsExcluded(const std::string& strDirectory) const; INFO_RET RetrieveInfoForTvShow(CFileItem *pItem, bool bDirNames, ADDON::ScraperPtr &scraper, bool useLocal, CScraperUrl* pURL, bool fetchEpisodes, CGUIDialogProgress* pDlgProgress); INFO_RET RetrieveInfoForMovie(CFileItem *pItem, bool bDirNames, ADDON::ScraperPtr &scraper, bool useLocal, CScraperUrl* pURL, CGUIDialogProgress* pDlgProgress); @@ -139,7 +139,7 @@ namespace VIDEO \param line1 string to set for the first line \return true if the user has cancelled the scanner, false otherwise */ - bool ProgressCancelled(CGUIDialogProgress* progress, int heading, const CStdString &line1); + bool ProgressCancelled(CGUIDialogProgress* progress, int heading, const std::string &line1); /*! \brief Find a url for the given video using the given scraper \param videoName name of the video to lookup @@ -148,7 +148,7 @@ namespace VIDEO \param progress CGUIDialogProgress bar \return >0 on success, <0 on failure (cancellation), and 0 on no info found */ - int FindVideo(const CStdString &videoName, const ADDON::ScraperPtr &scraper, CScraperUrl &url, CGUIDialogProgress *progress); + int FindVideo(const std::string &videoName, const ADDON::ScraperPtr &scraper, CScraperUrl &url, CGUIDialogProgress *progress); /*! \brief Retrieve detailed information for an item from an online source, optionally supplemented with local data TODO: sort out some better return codes. @@ -181,9 +181,9 @@ namespace VIDEO \param actors - vector of SActorInfo \param strPath - path on filesystem to look for local thumbs */ - void FetchActorThumbs(std::vector<SActorInfo>& actors, const CStdString& strPath); + void FetchActorThumbs(std::vector<SActorInfo>& actors, const std::string& strPath); - static int GetPathHash(const CFileItemList &items, CStdString &hash); + static int GetPathHash(const CFileItemList &items, std::string &hash); /*! \brief Retrieve a "fast" hash of the given directory (if available) Performs a stat() on the directory, and uses modified time to create a "fast" @@ -195,7 +195,7 @@ namespace VIDEO \param excludes string array of exclude expressions \return the md5 hash of the folder" */ - CStdString GetFastHash(const CStdString &directory, const std::vector<std::string> &excludes) const; + std::string GetFastHash(const std::string &directory, const std::vector<std::string> &excludes) const; /*! \brief Retrieve a "fast" hash of the given directory recursively (if available) Performs a stat() on the directory, and uses modified time to create a "fast" @@ -207,7 +207,7 @@ namespace VIDEO \param excludes string array of exclude expressions \return the md5 hash of the folder */ - CStdString GetRecursiveFastHash(const CStdString &directory, const std::vector<std::string> &excludes) const; + std::string GetRecursiveFastHash(const std::string &directory, const std::vector<std::string> &excludes) const; /*! \brief Decide whether a folder listing could use the "fast" hash Fast hashing can be done whenever the folder contains no scannable subfolders, as the @@ -235,13 +235,13 @@ namespace VIDEO bool EnumerateSeriesFolder(CFileItem* item, EPISODELIST& episodeList); bool ProcessItemByVideoInfoTag(const CFileItem *item, EPISODELIST &episodeList); - CStdString GetnfoFile(CFileItem *item, bool bGrabAny=false) const; + std::string GetnfoFile(CFileItem *item, bool bGrabAny=false) const; /*! \brief Retrieve the parent folder of an item, accounting for stacks and files in rars. \param item a media item. \return the folder that contains the item. */ - CStdString GetParentDir(const CFileItem &item) const; + std::string GetParentDir(const CFileItem &item) const; bool m_showDialog; CGUIDialogProgressBarHandle* m_handle; @@ -251,10 +251,10 @@ namespace VIDEO bool m_bCanInterrupt; bool m_bClean; bool m_scanAll; - CStdString m_strStartDir; + std::string m_strStartDir; CVideoDatabase m_database; - std::set<CStdString> m_pathsToScan; - std::set<CStdString> m_pathsToCount; + std::set<std::string> m_pathsToScan; + std::set<std::string> m_pathsToCount; std::set<int> m_pathsToClean; CNfoFile m_nfoReader; }; diff --git a/xbmc/video/VideoInfoTag.cpp b/xbmc/video/VideoInfoTag.cpp index dc408e1b43..ad85cdda4d 100644 --- a/xbmc/video/VideoInfoTag.cpp +++ b/xbmc/video/VideoInfoTag.cpp @@ -94,7 +94,7 @@ void CVideoInfoTag::Reset() m_type.clear(); } -bool CVideoInfoTag::Save(TiXmlNode *node, const CStdString &tag, bool savePathInfo, const TiXmlElement *additionalNode) +bool CVideoInfoTag::Save(TiXmlNode *node, const std::string &tag, bool savePathInfo, const TiXmlElement *additionalNode) { if (!node) return false; @@ -355,7 +355,7 @@ void CVideoInfoTag::Archive(CArchive& ar) ar >> info.strRole; ar >> info.order; ar >> info.thumb; - CStdString strXml; + std::string strXml; ar >> strXml; info.thumbUrl.ParseString(strXml); m_cast.push_back(info); @@ -402,7 +402,7 @@ void CVideoInfoTag::Archive(CArchive& ar) ar >> m_resumePoint.totalTimeInSeconds; ar >> m_iIdShow; - CStdString dateAdded; + std::string dateAdded; ar >> dateAdded; m_dateAdded.SetFromDBDateTime(dateAdded); ar >> m_type; @@ -491,7 +491,7 @@ void CVideoInfoTag::ToSortable(SortItem& sortable, Field field) const case FieldPlot: sortable[FieldPlot] = m_strPlot; break; case FieldTitle: { - // make sure not to overwrite an existing path with an empty one + // make sure not to overwrite an existing title with an empty one std::string title = m_strTitle; if (!title.empty() || sortable.find(FieldTitle) == sortable.end()) sortable[FieldTitle] = title; @@ -550,12 +550,12 @@ void CVideoInfoTag::ToSortable(SortItem& sortable, Field field) const } } -const CStdString CVideoInfoTag::GetCast(bool bIncludeRole /*= false*/) const +const std::string CVideoInfoTag::GetCast(bool bIncludeRole /*= false*/) const { - CStdString strLabel; + std::string strLabel; for (iCast it = m_cast.begin(); it != m_cast.end(); ++it) { - CStdString character; + std::string character; if (it->strRole.empty() || !bIncludeRole) character = StringUtils::Format("%s\n", it->strName.c_str()); else @@ -598,7 +598,7 @@ void CVideoInfoTag::ParseNative(const TiXmlElement* movie, bool prioritise) XMLUtils::GetString(movie, "outline", m_strPlotOutline); XMLUtils::GetString(movie, "plot", m_strPlot); XMLUtils::GetString(movie, "tagline", m_strTagLine); - CStdString runtime; + std::string runtime; if (XMLUtils::GetString(movie, "runtime", runtime) && !runtime.empty()) m_duration = GetDurationFromMinuteString(runtime); XMLUtils::GetString(movie, "mpaa", m_strMPAARating); @@ -617,7 +617,7 @@ void CVideoInfoTag::ParseNative(const TiXmlElement* movie, bool prioritise) XMLUtils::GetString(movie, "basepath", m_basePath); size_t iThumbCount = m_strPictureURL.m_url.size(); - CStdString xmlAdd = m_strPictureURL.m_xml; + std::string xmlAdd = m_strPictureURL.m_xml; const TiXmlElement* thumb = movie->FirstChildElement("thumb"); while (thumb) @@ -625,7 +625,7 @@ void CVideoInfoTag::ParseNative(const TiXmlElement* movie, bool prioritise) m_strPictureURL.ParseElement(thumb); if (prioritise) { - CStdString temp; + std::string temp; temp << *thumb; xmlAdd = temp+xmlAdd; } diff --git a/xbmc/video/VideoInfoTag.h b/xbmc/video/VideoInfoTag.h index 8af9eadbcd..967dabe968 100644 --- a/xbmc/video/VideoInfoTag.h +++ b/xbmc/video/VideoInfoTag.h @@ -19,6 +19,7 @@ * */ +#include <string> #include <vector> #include "XBDateTime.h" #include "utils/ScraperUrl.h" @@ -38,10 +39,10 @@ struct SActorInfo { return order < right.order; } - CStdString strName; - CStdString strRole; + std::string strName; + std::string strRole; CScraperUrl thumbUrl; - CStdString thumb; + std::string thumb; int order; }; @@ -66,15 +67,15 @@ public: \sa ParseNative */ bool Load(const TiXmlElement *element, bool append = false, bool prioritise = false); - bool Save(TiXmlNode *node, const CStdString &tag, bool savePathInfo = true, const TiXmlElement *additionalNode = NULL); + bool Save(TiXmlNode *node, const std::string &tag, bool savePathInfo = true, const TiXmlElement *additionalNode = NULL); virtual void Archive(CArchive& ar); virtual void Serialize(CVariant& value) const; virtual void ToSortable(SortItem& sortable, Field field) const; - const CStdString GetCast(bool bIncludeRole = false) const; + const std::string GetCast(bool bIncludeRole = false) const; bool HasStreamDetails() const; bool IsEmpty() const; - const CStdString& GetPath() const + const std::string& GetPath() const { if (m_strFileNameAndPath.empty()) return m_strPath; @@ -92,40 +93,40 @@ public: */ static unsigned int GetDurationFromMinuteString(const std::string &runtime); - CStdString m_basePath; // the base path of the video, for folder-based lookups + std::string m_basePath; // the base path of the video, for folder-based lookups int m_parentPathID; // the parent path id where the base path of the video lies std::vector<std::string> m_director; std::vector<std::string> m_writingCredits; std::vector<std::string> m_genre; std::vector<std::string> m_country; - CStdString m_strTagLine; - CStdString m_strPlotOutline; - CStdString m_strTrailer; - CStdString m_strPlot; + std::string m_strTagLine; + std::string m_strPlotOutline; + std::string m_strTrailer; + std::string m_strPlot; CScraperUrl m_strPictureURL; - CStdString m_strTitle; - CStdString m_strSortTitle; - CStdString m_strVotes; + std::string m_strTitle; + std::string m_strSortTitle; + std::string m_strVotes; std::vector<std::string> m_artist; std::vector< SActorInfo > m_cast; typedef std::vector< SActorInfo >::const_iterator iCast; - CStdString m_strSet; + std::string m_strSet; int m_iSetId; std::vector<std::string> m_tags; - CStdString m_strFile; - CStdString m_strPath; - CStdString m_strIMDBNumber; - CStdString m_strMPAARating; - CStdString m_strFileNameAndPath; - CStdString m_strOriginalTitle; - CStdString m_strEpisodeGuide; + std::string m_strFile; + std::string m_strPath; + std::string m_strIMDBNumber; + std::string m_strMPAARating; + std::string m_strFileNameAndPath; + std::string m_strOriginalTitle; + std::string m_strEpisodeGuide; CDateTime m_premiered; - CStdString m_strStatus; - CStdString m_strProductionCode; + std::string m_strStatus; + std::string m_strProductionCode; CDateTime m_firstAired; - CStdString m_strShowTitle; + std::string m_strShowTitle; std::vector<std::string> m_studio; - CStdString m_strAlbum; + std::string m_strAlbum; CDateTime m_lastPlayed; std::vector<std::string> m_showLink; int m_playCount; @@ -133,7 +134,7 @@ public: int m_iYear; int m_iSeason; int m_iEpisode; - CStdString m_strUniqueId; + std::string m_strUniqueId; int m_iDbId; int m_iFileId; int m_iSpecialSortSeason; diff --git a/xbmc/video/VideoReferenceClock.cpp b/xbmc/video/VideoReferenceClock.cpp index 06d9ff4f67..9246a35fb5 100644 --- a/xbmc/video/VideoReferenceClock.cpp +++ b/xbmc/video/VideoReferenceClock.cpp @@ -19,7 +19,6 @@ */ #include "system.h" #include <list> -#include "utils/StdString.h" #include "VideoReferenceClock.h" #include "utils/MathUtils.h" #include "utils/log.h" diff --git a/xbmc/video/VideoThumbLoader.cpp b/xbmc/video/VideoThumbLoader.cpp index 07b5459cd5..af977816c3 100644 --- a/xbmc/video/VideoThumbLoader.cpp +++ b/xbmc/video/VideoThumbLoader.cpp @@ -45,7 +45,10 @@ using namespace XFILE; using namespace std; using namespace VIDEO; -CThumbExtractor::CThumbExtractor(const CFileItem& item, const CStdString& listpath, bool thumb, const CStdString& target) +CThumbExtractor::CThumbExtractor(const CFileItem& item, + const std::string& listpath, + bool thumb, + const std::string& target) { m_listpath = listpath; m_target = target; @@ -144,7 +147,7 @@ bool CThumbExtractor::DoWork() } if (info->m_iFileId < 0) - db.SetStreamDetailsForFile(info->m_streamDetails, !info->m_strFileNameAndPath.empty() ? info->m_strFileNameAndPath : m_item.GetPath()); + db.SetStreamDetailsForFile(info->m_streamDetails, !info->m_strFileNameAndPath.empty() ? info->m_strFileNameAndPath : static_cast<const std::string&>(m_item.GetPath())); else db.SetStreamDetailsForFileId(info->m_streamDetails, info->m_iFileId); @@ -182,13 +185,13 @@ void CVideoThumbLoader::OnLoaderFinish() CThumbLoader::OnLoaderFinish(); } -static void SetupRarOptions(CFileItem& item, const CStdString& path) +static void SetupRarOptions(CFileItem& item, const std::string& path) { - CStdString path2(path); + std::string path2(path); if (item.IsVideoDb() && item.HasVideoInfoTag()) path2 = item.GetVideoInfoTag()->m_strFileNameAndPath; CURL url(path2); - CStdString opts = url.GetOptions(); + std::string opts = url.GetOptions(); if (opts.find("flags") != std::string::npos) return; if (opts.size()) @@ -340,14 +343,14 @@ bool CVideoThumbLoader::LoadItemLookup(CFileItem* pItem) if (!pItem->m_bIsFolder && pItem->IsVideo()) { // An auto-generated thumb may have been cached on a different device - check we have it here - CStdString url = pItem->GetArt("thumb"); + std::string url = pItem->GetArt("thumb"); if (StringUtils::StartsWith(url, "image://video@") && !CTextureCache::Get().HasCachedImage(url)) pItem->SetArt("thumb", ""); if (!pItem->HasArt("thumb")) { // create unique thumb for auto generated thumbs - CStdString thumbURL = GetEmbeddedThumbURL(*pItem); + std::string thumbURL = GetEmbeddedThumbURL(*pItem); if (CTextureCache::Get().HasCachedImage(thumbURL)) { CTextureCache::Get().BackgroundCacheImage(thumbURL); @@ -367,7 +370,7 @@ bool CVideoThumbLoader::LoadItemLookup(CFileItem* pItem) CSettings::Get().GetBool("myvideos.extractflags")) { CFileItem item(*pItem); - CStdString path(item.GetPath()); + std::string path(item.GetPath()); if (URIUtils::IsInRAR(item.GetPath())) SetupRarOptions(item,path); @@ -385,7 +388,7 @@ bool CVideoThumbLoader::LoadItemLookup(CFileItem* pItem) !pItem->GetVideoInfoTag()->HasStreamDetails() ) ) { CFileItem item(*pItem); - CStdString path(item.GetPath()); + std::string path(item.GetPath()); if (URIUtils::IsInRAR(item.GetPath())) SetupRarOptions(item,path); CThumbExtractor* extract = new CThumbExtractor(item,path,false); @@ -460,7 +463,7 @@ bool CVideoThumbLoader::FillThumb(CFileItem &item) { if (item.HasArt("thumb")) return true; - CStdString thumb = GetCachedImage(item, "thumb"); + std::string thumb = GetCachedImage(item, "thumb"); if (thumb.empty()) { thumb = GetLocalArt(item, "thumb"); @@ -509,9 +512,9 @@ std::string CVideoThumbLoader::GetLocalArt(const CFileItem &item, const std::str return art; } -CStdString CVideoThumbLoader::GetEmbeddedThumbURL(const CFileItem &item) +std::string CVideoThumbLoader::GetEmbeddedThumbURL(const CFileItem &item) { - CStdString path(item.GetPath()); + std::string path(item.GetPath()); if (item.IsVideoDb() && item.HasVideoInfoTag()) path = item.GetVideoInfoTag()->m_strFileNameAndPath; if (URIUtils::IsStack(path)) diff --git a/xbmc/video/VideoThumbLoader.h b/xbmc/video/VideoThumbLoader.h index 26568beda6..55560dad4e 100644 --- a/xbmc/video/VideoThumbLoader.h +++ b/xbmc/video/VideoThumbLoader.h @@ -38,7 +38,7 @@ class CVideoDatabase; class CThumbExtractor : public CJob { public: - CThumbExtractor(const CFileItem& item, const CStdString& listpath, bool thumb, const CStdString& strTarget=""); + CThumbExtractor(const CFileItem& item, const std::string& listpath, bool thumb, const std::string& strTarget=""); virtual ~CThumbExtractor(); /*! @@ -53,8 +53,8 @@ public: virtual bool operator==(const CJob* job) const; - CStdString m_target; ///< thumbpath - CStdString m_listpath; ///< path used in fileitem list + std::string m_target; ///< thumbpath + std::string m_listpath; ///< path used in fileitem list CFileItem m_item; bool m_thumb; ///< extract thumb? }; @@ -99,7 +99,7 @@ public: \param item a video CFileItem. \return a URL for the embedded thumb. */ - static CStdString GetEmbeddedThumbURL(const CFileItem &item); + static std::string GetEmbeddedThumbURL(const CFileItem &item); /*! \brief helper function to fill the art for a video library item \param item a video CFileItem diff --git a/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp b/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp index 32a9ba4158..aea90e8948 100644 --- a/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp +++ b/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp @@ -184,7 +184,7 @@ void CGUIDialogAudioSubtitleSettings::OnSettingAction(const CSetting *setting) const std::string &settingId = setting->GetId(); if (settingId == SETTING_SUBTITLE_BROWSER) { - CStdString strPath; + std::string strPath; if (URIUtils::IsInRAR(g_application.CurrentFileItem().GetPath()) || URIUtils::IsInZIP(g_application.CurrentFileItem().GetPath())) strPath = CURL(g_application.CurrentFileItem().GetPath()).GetHostName(); else @@ -414,7 +414,7 @@ void CGUIDialogAudioSubtitleSettings::AudioStreamsOptionFiller(const CSetting *s for (int i = 0; i < audioStreamCount; ++i) { std::string strItem; - CStdString strLanguage; + std::string strLanguage; SPlayerAudioStreamInfo info; g_application.m_pPlayer->GetAudioStreamInfo(i, info); @@ -448,8 +448,8 @@ void CGUIDialogAudioSubtitleSettings::SubtitleStreamsOptionFiller(const CSetting SPlayerSubtitleStreamInfo info; g_application.m_pPlayer->GetSubtitleStreamInfo(i, info); - CStdString strItem; - CStdString strLanguage; + std::string strItem; + std::string strLanguage; if (!g_LangCodeExpander.Lookup(strLanguage, info.language)) strLanguage = g_localizeStrings.Get(13205); // Unknown diff --git a/xbmc/video/dialogs/GUIDialogFileStacking.cpp b/xbmc/video/dialogs/GUIDialogFileStacking.cpp index dfa9e3eba8..0207de5812 100644 --- a/xbmc/video/dialogs/GUIDialogFileStacking.cpp +++ b/xbmc/video/dialogs/GUIDialogFileStacking.cpp @@ -94,7 +94,7 @@ void CGUIDialogFileStacking::OnInitWindow() SendMessage(GUI_MSG_LABEL_RESET, GetID(), STACK_LIST); for (int i = 0; i < m_iNumberOfFiles; i++) { - CStdString label = StringUtils::Format(g_localizeStrings.Get(23051).c_str(), i+1); + std::string label = StringUtils::Format(g_localizeStrings.Get(23051).c_str(), i+1); CFileItemPtr item(new CFileItem(label)); m_stackItems->Add(item); } diff --git a/xbmc/video/dialogs/GUIDialogSubtitles.cpp b/xbmc/video/dialogs/GUIDialogSubtitles.cpp index e3939f1dd4..e49d9916e0 100644 --- a/xbmc/video/dialogs/GUIDialogSubtitles.cpp +++ b/xbmc/video/dialogs/GUIDialogSubtitles.cpp @@ -339,7 +339,7 @@ void CGUIDialogSubtitles::Search(const std::string &search/*=""*/) if(StringUtils::EqualsNoCase(preferredLanguage, "original")) { SPlayerAudioStreamInfo info; - CStdString strLanguage; + std::string strLanguage; int currentAudio = g_application.m_pPlayer->GetAudioStream(); g_application.m_pPlayer->GetAudioStreamInfo(currentAudio, info); @@ -446,13 +446,13 @@ void CGUIDialogSubtitles::OnDownloadComplete(const CFileItemList *items, const s SUBTITLE_STORAGEMODE storageMode = (SUBTITLE_STORAGEMODE) CSettings::Get().GetInt("subtitles.storagemode"); // Get (unstacked) path - CStdString strCurrentFile = g_application.CurrentUnstackedItem().GetPath(); + std::string strCurrentFile = g_application.CurrentUnstackedItem().GetPath(); - CStdString strDownloadPath = "special://temp"; - CStdString strDestPath; + std::string strDownloadPath = "special://temp"; + std::string strDestPath; std::vector<std::string> vecFiles; - CStdString strCurrentFilePath; + std::string strCurrentFilePath; if (StringUtils::StartsWith(strCurrentFilePath, "http://")) { strCurrentFile = "TempSubtitle"; @@ -460,7 +460,7 @@ void CGUIDialogSubtitles::OnDownloadComplete(const CFileItemList *items, const s } else { - CStdString subPath = CSpecialProtocol::TranslatePath("special://subtitles"); + std::string subPath = CSpecialProtocol::TranslatePath("special://subtitles"); if (!subPath.empty()) strDownloadPath = subPath; @@ -501,23 +501,23 @@ void CGUIDialogSubtitles::OnDownloadComplete(const CFileItemList *items, const s strDestPath = strDownloadPath; // Extract the language and appropriate extension - CStdString strSubLang; + std::string strSubLang; g_LangCodeExpander.ConvertToTwoCharCode(strSubLang, language); // Iterate over all items to transfer for (unsigned int i = 0; i < vecFiles.size() && i < (unsigned int) items->Size(); i++) { - CStdString strUrl = items->Get(i)->GetPath(); - CStdString strFileName = URIUtils::GetFileName(vecFiles[i]); + std::string strUrl = items->Get(i)->GetPath(); + std::string strFileName = URIUtils::GetFileName(vecFiles[i]); URIUtils::RemoveExtension(strFileName); // construct subtitle path - CStdString strSubExt = URIUtils::GetExtension(strUrl); - CStdString strSubName = StringUtils::Format("%s.%s%s", strFileName.c_str(), strSubLang.c_str(), strSubExt.c_str()); + std::string strSubExt = URIUtils::GetExtension(strUrl); + std::string strSubName = StringUtils::Format("%s.%s%s", strFileName.c_str(), strSubLang.c_str(), strSubExt.c_str()); // Handle URL encoding: - CStdString strDownloadFile = URIUtils::ChangeBasePath(strCurrentFilePath, strSubName, strDownloadPath); - CStdString strDestFile = strDownloadFile; + std::string strDownloadFile = URIUtils::ChangeBasePath(strCurrentFilePath, strSubName, strDownloadPath); + std::string strDestFile = strDownloadFile; if (!CFile::Copy(strUrl, strDownloadFile)) { @@ -529,7 +529,7 @@ void CGUIDialogSubtitles::OnDownloadComplete(const CFileItemList *items, const s if (strDestPath != strDownloadPath) { // Handle URL encoding: - CStdString strTryDestFile = URIUtils::ChangeBasePath(strCurrentFilePath, strSubName, strDestPath); + std::string strTryDestFile = URIUtils::ChangeBasePath(strCurrentFilePath, strSubName, strDestPath); /* Copy the file from temp to our final destination, if that fails fallback to download path * (ie. special://subtitles or use special://temp). Note that after the first item strDownloadPath equals strDestpath @@ -555,12 +555,12 @@ void CGUIDialogSubtitles::OnDownloadComplete(const CFileItemList *items, const s } // for ".sub" subtitles we check if ".idx" counterpart exists and copy that as well - if (strSubExt.Equals(".sub")) + if (StringUtils::EqualsNoCase(strSubExt, ".sub")) { strUrl = URIUtils::ReplaceExtension(strUrl, ".idx"); if(CFile::Exists(strUrl)) { - CStdString strSubNameIdx = StringUtils::Format("%s.%s.idx", strFileName.c_str(), strSubLang.c_str()); + std::string strSubNameIdx = StringUtils::Format("%s.%s.idx", strFileName.c_str(), strSubLang.c_str()); // Handle URL encoding: strDestFile = URIUtils::ChangeBasePath(strCurrentFilePath, strSubNameIdx, strDestPath); CFile::Copy(strUrl, strDestFile); diff --git a/xbmc/video/dialogs/GUIDialogSubtitles.h b/xbmc/video/dialogs/GUIDialogSubtitles.h index dea4a66081..da81a3a138 100644 --- a/xbmc/video/dialogs/GUIDialogSubtitles.h +++ b/xbmc/video/dialogs/GUIDialogSubtitles.h @@ -68,8 +68,8 @@ protected: CFileItemList* m_serviceItems; std::string m_currentService; std::string m_status; - CStdString m_strManualSearch; + std::string m_strManualSearch; bool m_pausedOnRun; bool m_updateSubsList; ///< true if we need to update our subs list - CStdString m_LastAutoDownloaded; ///< Last video file path which automatically downloaded subtitle + std::string m_LastAutoDownloaded; ///< Last video file path which automatically downloaded subtitle }; diff --git a/xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp b/xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp index 1ccabc806e..c77955c737 100644 --- a/xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp @@ -202,7 +202,7 @@ void CGUIDialogVideoBookmarks::OnRefreshList() CBookmark resumemark; // open the d/b and retrieve the bookmarks for the current movie - CStdString path = g_application.CurrentFile(); + std::string path = g_application.CurrentFile(); if (g_application.CurrentFileItem().HasProperty("original_listitem_url") && !URIUtils::IsVideoDb(g_application.CurrentFileItem().GetProperty("original_listitem_url").asString())) path = g_application.CurrentFileItem().GetProperty("original_listitem_url").asString(); @@ -222,7 +222,7 @@ void CGUIDialogVideoBookmarks::OnRefreshList() if (m_bookmarks[i].type == CBookmark::RESUME) m_bookmarks[i].thumbNailImage = "bookmark-resume.png"; - CStdString bookmarkTime; + std::string bookmarkTime; if (m_bookmarks[i].type == CBookmark::EPISODE) bookmarkTime = StringUtils::Format("%s %li %s %li", g_localizeStrings.Get(20373).c_str(), m_bookmarks[i].seasonNumber, g_localizeStrings.Get(20359).c_str(), m_bookmarks[i].episodeNumber); else @@ -293,7 +293,7 @@ void CGUIDialogVideoBookmarks::ClearBookmarks() { CVideoDatabase videoDatabase; videoDatabase.Open(); - CStdString path = g_application.CurrentFile(); + std::string path = g_application.CurrentFile(); if (g_application.CurrentFileItem().HasProperty("original_listitem_url") && !URIUtils::IsVideoDb(g_application.CurrentFileItem().GetProperty("original_listitem_url").asString())) path = g_application.CurrentFileItem().GetProperty("original_listitem_url").asString(); @@ -361,7 +361,7 @@ bool CGUIDialogVideoBookmarks::AddBookmark(CVideoInfoTag* tag) videoDatabase.AddBookMarkForEpisode(*tag, bookmark); else { - CStdString path = g_application.CurrentFile(); + std::string path = g_application.CurrentFile(); if (g_application.CurrentFileItem().HasProperty("original_listitem_url") && !URIUtils::IsVideoDb(g_application.CurrentFileItem().GetProperty("original_listitem_url").asString())) path = g_application.CurrentFileItem().GetProperty("original_listitem_url").asString(); @@ -404,7 +404,7 @@ bool CGUIDialogVideoBookmarks::AddEpisodeBookmark() CContextButtons choices; for (unsigned int i=0; i < episodes.size(); ++i) { - CStdString strButton = StringUtils::Format("%s %i, %s %i", + std::string strButton = StringUtils::Format("%s %i, %s %i", g_localizeStrings.Get(20373).c_str(), episodes[i].m_iSeason, g_localizeStrings.Get(20359).c_str(), episodes[i].m_iEpisode); choices.Add(i, strButton); diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp index 626993695c..d50285b570 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp @@ -163,7 +163,7 @@ bool CGUIDialogVideoInfo::OnMessage(CGUIMessage& message) } else if (iControl == CONTROL_BTN_DIRECTOR) { - CStdString strDirector = StringUtils::Join(m_movieItem->GetVideoInfoTag()->m_director, g_advancedSettings.m_videoItemSeparator); + std::string strDirector = StringUtils::Join(m_movieItem->GetVideoInfoTag()->m_director, g_advancedSettings.m_videoItemSeparator); OnSearch(strDirector); } else if (iControl == CONTROL_LIST) @@ -176,12 +176,12 @@ bool CGUIDialogVideoInfo::OnMessage(CGUIMessage& message) int iItem = msg.GetParam1(); if (iItem < 0 || iItem >= m_castList->Size()) break; - CStdString strItem = m_castList->Get(iItem)->GetLabel(); - CStdString strFind = StringUtils::Format(" %s ",g_localizeStrings.Get(20347).c_str()); + std::string strItem = m_castList->Get(iItem)->GetLabel(); + std::string strFind = StringUtils::Format(" %s ",g_localizeStrings.Get(20347).c_str()); size_t iPos = strItem.find(strFind); if (iPos == std::string::npos) iPos = strItem.size(); - CStdString tmp = strItem.substr(0, iPos); + std::string tmp = strItem.substr(0, iPos); OnSearch(tmp); } } @@ -263,7 +263,7 @@ void CGUIDialogVideoInfo::SetMovie(const CFileItem *item) for (std::vector<std::string>::const_iterator it = artists.begin(); it != artists.end(); ++it) { int idArtist = database.GetArtistByName(*it); - CStdString thumb = database.GetArtForItem(idArtist, MediaTypeArtist, "thumb"); + std::string thumb = database.GetArtForItem(idArtist, MediaTypeArtist, "thumb"); CFileItemPtr item(new CFileItem(*it)); if (!thumb.empty()) item->SetArt("thumb", thumb); @@ -276,7 +276,7 @@ void CGUIDialogVideoInfo::SetMovie(const CFileItem *item) { // movie/show/episode for (CVideoInfoTag::iCast it = m_movieItem->GetVideoInfoTag()->m_cast.begin(); it != m_movieItem->GetVideoInfoTag()->m_cast.end(); ++it) { - CStdString character; + std::string character; if (it->strRole.empty()) character = it->strName; else @@ -286,7 +286,7 @@ void CGUIDialogVideoInfo::SetMovie(const CFileItem *item) item->SetArt("thumb", it->thumb); else if (CSettings::Get().GetBool("videolibrary.actorthumbs")) { // backward compatibility - CStdString thumb = CScraperUrl::GetThumbURL(it->thumbUrl.GetFirstThumb()); + std::string thumb = CScraperUrl::GetThumbURL(it->thumbUrl.GetFirstThumb()); if (!thumb.empty()) { item->SetArt("thumb", thumb); @@ -351,7 +351,7 @@ void CGUIDialogVideoInfo::SetMovie(const CFileItem *item) if (m_movieItem->GetVideoInfoTag()->m_strTrailer.empty() || URIUtils::IsInternetStream(m_movieItem->GetVideoInfoTag()->m_strTrailer)) { - CStdString localTrailer = m_movieItem->FindTrailer(); + std::string localTrailer = m_movieItem->FindTrailer(); if (!localTrailer.empty()) { m_movieItem->GetVideoInfoTag()->m_strTrailer = localTrailer; @@ -375,7 +375,7 @@ void CGUIDialogVideoInfo::SetMovie(const CFileItem *item) void CGUIDialogVideoInfo::Update() { // setup plot text area - CStdString strTmp = m_movieItem->GetVideoInfoTag()->m_strPlot; + std::string strTmp = m_movieItem->GetVideoInfoTag()->m_strPlot; if (!(!m_movieItem->GetVideoInfoTag()->m_strShowTitle.empty() && m_movieItem->GetVideoInfoTag()->m_iSeason == 0)) // dont apply to tvshows if (m_movieItem->GetVideoInfoTag()->m_playCount == 0 && !CSettings::Get().GetBool("videolibrary.showunwatchedplots")) strTmp = g_localizeStrings.Get(20370); @@ -447,7 +447,7 @@ bool CGUIDialogVideoInfo::RefreshAll() const } /// \brief Search the current directory for a string got from the virtual keyboard -void CGUIDialogVideoInfo::OnSearch(CStdString& strSearch) +void CGUIDialogVideoInfo::OnSearch(std::string& strSearch) { CGUIDialogProgress *progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); if (progress) @@ -498,7 +498,7 @@ void CGUIDialogVideoInfo::OnSearch(CStdString& strSearch) /// \brief Make the actual search for the OnSearch function. /// \param strSearch The search string /// \param items Items Found -void CGUIDialogVideoInfo::DoSearch(CStdString& strSearch, CFileItemList& items) +void CGUIDialogVideoInfo::DoSearch(std::string& strSearch, CFileItemList& items) { CVideoDatabase db; if (!db.Open()) @@ -508,7 +508,7 @@ void CGUIDialogVideoInfo::DoSearch(CStdString& strSearch, CFileItemList& items) db.GetMoviesByActor(strSearch, movies); for (int i = 0; i < movies.Size(); ++i) { - CStdString label = movies[i]->GetVideoInfoTag()->m_strTitle; + std::string label = movies[i]->GetVideoInfoTag()->m_strTitle; if (movies[i]->GetVideoInfoTag()->m_iYear > 0) label += StringUtils::Format(" (%i)", movies[i]->GetVideoInfoTag()->m_iYear); movies[i]->SetLabel(label); @@ -518,7 +518,7 @@ void CGUIDialogVideoInfo::DoSearch(CStdString& strSearch, CFileItemList& items) db.GetTvShowsByActor(strSearch, movies); for (int i = 0; i < movies.Size(); ++i) { - CStdString label = movies[i]->GetVideoInfoTag()->m_strShowTitle; + std::string label = movies[i]->GetVideoInfoTag()->m_strShowTitle; if (movies[i]->GetVideoInfoTag()->m_iYear > 0) label += StringUtils::Format(" (%i)", movies[i]->GetVideoInfoTag()->m_iYear); movies[i]->SetLabel(label); @@ -528,7 +528,7 @@ void CGUIDialogVideoInfo::DoSearch(CStdString& strSearch, CFileItemList& items) db.GetEpisodesByActor(strSearch, movies); for (int i = 0; i < movies.Size(); ++i) { - CStdString label = movies[i]->GetVideoInfoTag()->m_strTitle + " (" + movies[i]->GetVideoInfoTag()->m_strShowTitle + ")"; + std::string label = movies[i]->GetVideoInfoTag()->m_strTitle + " (" + movies[i]->GetVideoInfoTag()->m_strShowTitle + ")"; movies[i]->SetLabel(label); } CGUIWindowVideoBase::AppendAndClearSearchItems(movies, "[" + g_localizeStrings.Get(20359) + "] ", items); @@ -536,7 +536,7 @@ void CGUIDialogVideoInfo::DoSearch(CStdString& strSearch, CFileItemList& items) db.GetMusicVideosByArtist(strSearch, movies); for (int i = 0; i < movies.Size(); ++i) { - CStdString label = (CStdString)StringUtils::Join(movies[i]->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator) + " - " + movies[i]->GetVideoInfoTag()->m_strTitle; + std::string label = StringUtils::Join(movies[i]->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator) + " - " + movies[i]->GetVideoInfoTag()->m_strTitle; if (movies[i]->GetVideoInfoTag()->m_iYear > 0) label += StringUtils::Format(" (%i)", movies[i]->GetVideoInfoTag()->m_iYear); movies[i]->SetLabel(label); @@ -585,7 +585,7 @@ void CGUIDialogVideoInfo::Play(bool resume) { if (!m_movieItem->GetVideoInfoTag()->m_strEpisodeGuide.empty()) { - CStdString strPath = StringUtils::Format("videodb://tvshows/titles/%i/",m_movieItem->GetVideoInfoTag()->m_iDbId); + std::string strPath = StringUtils::Format("videodb://tvshows/titles/%i/",m_movieItem->GetVideoInfoTag()->m_iDbId); Close(); g_windowManager.ActivateWindow(WINDOW_VIDEO_NAV,strPath); return; @@ -662,7 +662,7 @@ string CGUIDialogVideoInfo::ChooseArtType(const CFileItem &videoItem, map<string if (dialog->IsButtonPressed()) { // Get the new artwork name - CStdString strArtworkName; + std::string strArtworkName; if (!CGUIKeyboardFactory::ShowAndGetInput(strArtworkName, g_localizeStrings.Get(13516), false)) return ""; @@ -709,7 +709,7 @@ void CGUIDialogVideoInfo::OnGetArt() for (unsigned int i = 0; i < thumbs.size(); ++i) { - CStdString strItemPath = StringUtils::Format("thumb://Remote%i", i); + std::string strItemPath = StringUtils::Format("thumb://Remote%i", i); CFileItemPtr item(new CFileItem(strItemPath, false)); item->SetArt("thumb", thumbs[i]); item->SetIconImage("DefaultPicture.png"); @@ -720,7 +720,7 @@ void CGUIDialogVideoInfo::OnGetArt() items.Add(item); } - CStdString localThumb = CVideoThumbLoader::GetLocalArt(*m_movieItem, type); + std::string localThumb = CVideoThumbLoader::GetLocalArt(*m_movieItem, type); if (!localThumb.empty()) { CFileItemPtr item(new CFileItem("thumb://Local", false)); @@ -738,14 +738,14 @@ void CGUIDialogVideoInfo::OnGetArt() items.Add(item); } - CStdString result; + std::string result; VECSOURCES sources(*CMediaSourceSettings::Get().GetSources("video")); AddItemPathToFileBrowserSources(sources, *m_movieItem); g_mediaManager.GetLocalDrives(sources); if (CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(13511), result) && result != "thumb://Current") // user didn't choose the one they have { - CStdString newThumb; + std::string newThumb; if (StringUtils::StartsWith(result, "thumb://Remote")) { int number = atoi(result.substr(14).c_str()); @@ -804,9 +804,9 @@ void CGUIDialogVideoInfo::OnGetFanart() // Grab the thumbnails from the web for (unsigned int i = 0; i < m_movieItem->GetVideoInfoTag()->m_fanart.GetNumFanarts(); i++) { - CStdString strItemPath = StringUtils::Format("fanart://Remote%i",i); + std::string strItemPath = StringUtils::Format("fanart://Remote%i",i); CFileItemPtr item(new CFileItem(strItemPath, false)); - CStdString thumb = m_movieItem->GetVideoInfoTag()->m_fanart.GetPreviewURL(i); + std::string thumb = m_movieItem->GetVideoInfoTag()->m_fanart.GetPreviewURL(i); item->SetArt("thumb", CTextureUtils::GetWrappedThumbURL(thumb)); item->SetIconImage("DefaultPicture.png"); item->SetLabel(g_localizeStrings.Get(20441)); @@ -817,7 +817,7 @@ void CGUIDialogVideoInfo::OnGetFanart() } CFileItem item(*m_movieItem->GetVideoInfoTag()); - CStdString strLocal = item.GetLocalFanart(); + std::string strLocal = item.GetLocalFanart(); if (!strLocal.empty()) { CFileItemPtr itemLocal(new CFileItem("fanart://Local",false)); @@ -836,15 +836,16 @@ void CGUIDialogVideoInfo::OnGetFanart() items.Add(itemNone); } - CStdString result; + std::string result; VECSOURCES sources(*CMediaSourceSettings::Get().GetSources("video")); AddItemPathToFileBrowserSources(sources, item); g_mediaManager.GetLocalDrives(sources); bool flip=false; - if (!CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(20437), result, &flip, 20445) || result.Equals("fanart://Current")) + if (!CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(20437), result, &flip, 20445) || + StringUtils::EqualsNoCase(result, "fanart://Current")) return; // user cancelled - if (result.Equals("fanart://Local")) + if (StringUtils::EqualsNoCase(result, "fanart://Local")) result = strLocal; if (StringUtils::StartsWith(result, "fanart://Remote")) @@ -860,7 +861,7 @@ void CGUIDialogVideoInfo::OnGetFanart() } result = m_movieItem->GetVideoInfoTag()->m_fanart.GetImageURL(); } - else if (result.Equals("fanart://None") || !CFile::Exists(result)) + else if (StringUtils::EqualsNoCase(result, "fanart://None") || !CFile::Exists(result)) result.clear(); // set the fanart image @@ -903,7 +904,7 @@ void CGUIDialogVideoInfo::PlayTrailer() CApplicationMessenger::Get().PlayFile(item); } -void CGUIDialogVideoInfo::SetLabel(int iControl, const CStdString &strLabel) +void CGUIDialogVideoInfo::SetLabel(int iControl, const std::string &strLabel) { if (strLabel.empty()) { @@ -925,7 +926,7 @@ void CGUIDialogVideoInfo::AddItemPathToFileBrowserSources(VECSOURCES &sources, c if (!item.HasVideoInfoTag()) return; - CStdString itemDir = item.GetVideoInfoTag()->m_basePath; + std::string itemDir = item.GetVideoInfoTag()->m_basePath; //season if (itemDir.empty()) @@ -1229,7 +1230,7 @@ bool CGUIDialogVideoInfo::DeleteVideoItemFromDatabase(const CFileItemPtr &item, return false; } - CStdString path; + std::string path; database.GetFilePathById(item->GetVideoInfoTag()->m_iDbId, path, type); if (!path.empty()) { @@ -1257,9 +1258,9 @@ bool CGUIDialogVideoInfo::DeleteVideoItem(const CFileItemPtr &item, bool unavail g_passwordManager.IsMasterLockUnlocked(true)) && CSettings::Get().GetBool("filelists.allowfiledeletion")) { - CStdString strDeletePath = item->GetVideoInfoTag()->GetPath(); + std::string strDeletePath = item->GetVideoInfoTag()->GetPath(); - if (URIUtils::GetFileName(strDeletePath).Equals("VIDEO_TS.IFO")) + if (StringUtils::EqualsNoCase(URIUtils::GetFileName(strDeletePath), "VIDEO_TS.IFO")) { strDeletePath = URIUtils::GetDirectory(strDeletePath); if (StringUtils::EndsWithNoCase(strDeletePath, "video_ts/")) @@ -1338,8 +1339,8 @@ bool CGUIDialogVideoInfo::GetMoviesForSet(const CFileItem *setItem, CFileItemLis if (!videodb.Open()) return false; - CStdString strHeading = g_localizeStrings.Get(20457); - CStdString baseDir = StringUtils::Format("videodb://movies/sets/%d", setItem->GetVideoInfoTag()->m_iDbId); + std::string strHeading = g_localizeStrings.Get(20457); + std::string baseDir = StringUtils::Format("videodb://movies/sets/%d", setItem->GetVideoInfoTag()->m_iDbId); if (!CDirectory::GetDirectory(baseDir, originalMovies) || originalMovies.Size() <= 0) // keep a copy of the original members of the set return false; @@ -1393,13 +1394,13 @@ bool CGUIDialogVideoInfo::GetSetForMovie(const CFileItem *movieItem, CFileItemPt return false; CFileItemList listItems; - CStdString baseDir = "videodb://movies/sets/"; + std::string baseDir = "videodb://movies/sets/"; if (!CDirectory::GetDirectory(baseDir, listItems)) return false; listItems.Sort(SortByLabel, SortOrderAscending, SortAttributeIgnoreArticle); int currentSetId = 0; - CStdString currentSetLabel; + std::string currentSetLabel; if (movieItem->GetVideoInfoTag()->m_iSetId > currentSetId) { @@ -1410,12 +1411,12 @@ bool CGUIDialogVideoInfo::GetSetForMovie(const CFileItem *movieItem, CFileItemPt if (currentSetId > 0) { // add clear item - CStdString strClear = StringUtils::Format(g_localizeStrings.Get(20467).c_str(), currentSetLabel.c_str()); + std::string strClear = StringUtils::Format(g_localizeStrings.Get(20467).c_str(), currentSetLabel.c_str()); CFileItemPtr clearItem(new CFileItem(strClear)); clearItem->GetVideoInfoTag()->m_iDbId = -1; // -1 will be used to clear set listItems.AddFront(clearItem, 0); // add keep current set item - CStdString strKeep = StringUtils::Format(g_localizeStrings.Get(20469).c_str(), currentSetLabel.c_str()); + std::string strKeep = StringUtils::Format(g_localizeStrings.Get(20469).c_str(), currentSetLabel.c_str()); CFileItemPtr keepItem(new CFileItem(strKeep)); keepItem->GetVideoInfoTag()->m_iDbId = currentSetId; listItems.AddFront(keepItem, 1); @@ -1425,7 +1426,7 @@ bool CGUIDialogVideoInfo::GetSetForMovie(const CFileItem *movieItem, CFileItemPt if (dialog == NULL) return false; - CStdString strHeading = g_localizeStrings.Get(20466); + std::string strHeading = g_localizeStrings.Get(20466); dialog->Reset(); dialog->SetHeading(strHeading); dialog->SetItems(&listItems); @@ -1445,7 +1446,7 @@ bool CGUIDialogVideoInfo::GetSetForMovie(const CFileItem *movieItem, CFileItemPt if (dialog->IsButtonPressed()) { // creating new set - CStdString newSetTitle; + std::string newSetTitle; if (!CGUIKeyboardFactory::ShowAndGetInput(newSetTitle, g_localizeStrings.Get(20468), false)) return false; int idSet = videodb.AddSet(newSetTitle); @@ -1483,7 +1484,7 @@ bool CGUIDialogVideoInfo::SetMovieSet(const CFileItem *movieItem, const CFileIte return true; } -bool CGUIDialogVideoInfo::GetItemsForTag(const CStdString &strHeading, const std::string &type, CFileItemList &items, int idTag /* = -1 */, bool showAll /* = true */) +bool CGUIDialogVideoInfo::GetItemsForTag(const std::string &strHeading, const std::string &type, CFileItemList &items, int idTag /* = -1 */, bool showAll /* = true */) { CVideoDatabase videodb; if (!videodb.Open()) @@ -1522,7 +1523,7 @@ bool CGUIDialogVideoInfo::GetItemsForTag(const CStdString &strHeading, const std if (!showAll) videoUrl.AddOption("tagid", idTag); else - filter.where = videodb.PrepareSQL("%sview.%s NOT IN (SELECT taglinks.idMedia FROM taglinks WHERE taglinks.idTag = %d AND taglinks.media_type = '%s')", type.c_str(), idColumn.c_str(), idTag, type.c_str()); + filter.where = videodb.PrepareSQL("%s_view.%s NOT IN (SELECT tag_link.media_type FROM tag_link WHERE tag_link.tag_id = %d AND tag_link.media_type = '%s')", type.c_str(), idColumn.c_str(), idTag, type.c_str()); } CFileItemList listItems; @@ -1626,7 +1627,7 @@ bool CGUIDialogVideoInfo::ManageVideoItemArtwork(const CFileItemPtr &item, const CFileItemPtr noneitem(new CFileItem("thumb://None", false)); std::string currentThumb; int idArtist = -1; - CStdString artistPath; + std::string artistPath; string artType = "thumb"; if (type == MediaTypeArtist) { @@ -1683,7 +1684,7 @@ bool CGUIDialogVideoInfo::ManageVideoItemArtwork(const CFileItemPtr &item, const else if (type == MediaTypeVideoCollection) { CFileItemList items; - CStdString baseDir = StringUtils::Format("videodb://movies/sets/%d", item->GetVideoInfoTag()->m_iDbId); + std::string baseDir = StringUtils::Format("videodb://movies/sets/%d", item->GetVideoInfoTag()->m_iDbId); if (videodb.GetMoviesNav(baseDir, items)) { for (int i=0; i < items.Size(); i++) @@ -1714,8 +1715,8 @@ bool CGUIDialogVideoInfo::ManageVideoItemArtwork(const CFileItemPtr &item, const if (type == "actor") { - CStdString picturePath; - CStdString strThumb = URIUtils::AddFileToFolder(picturePath, "folder.jpg"); + std::string picturePath; + std::string strThumb = URIUtils::AddFileToFolder(picturePath, "folder.jpg"); if (XFILE::CFile::Exists(strThumb)) { CFileItemPtr pItem(new CFileItem(strThumb,false)); @@ -1733,7 +1734,7 @@ bool CGUIDialogVideoInfo::ManageVideoItemArtwork(const CFileItemPtr &item, const } else { - CStdString strThumb = URIUtils::AddFileToFolder(artistPath, "folder.jpg"); + std::string strThumb = URIUtils::AddFileToFolder(artistPath, "folder.jpg"); if (XFILE::CFile::Exists(strThumb)) { CFileItemPtr pItem(new CFileItem(strThumb, false)); @@ -1749,7 +1750,7 @@ bool CGUIDialogVideoInfo::ManageVideoItemArtwork(const CFileItemPtr &item, const if (!local) items.Add(noneitem); - CStdString result; + std::string result; VECSOURCES sources=*CMediaSourceSettings::Get().GetSources("video"); g_mediaManager.GetLocalDrives(sources); AddItemPathToFileBrowserSources(sources, *item); @@ -1824,7 +1825,7 @@ bool CGUIDialogVideoInfo::UpdateVideoItemSortTitle(const CFileItemPtr &pItem) else if (iType == VIDEODB_CONTENT_TVSHOWS) database.GetTvShowInfo(pItem->GetVideoInfoTag()->m_strFileNameAndPath, detail, iDbId); - CStdString currentTitle; + std::string currentTitle; if (detail.m_strSortTitle.empty()) currentTitle = detail.m_strTitle; else @@ -1921,11 +1922,11 @@ bool CGUIDialogVideoInfo::OnGetFanart(const CFileItemPtr &videoItem) items.Add(itemCurrent); } - vector<CStdString> thumbs; + vector<std::string> thumbs; if (videoItem->GetVideoInfoTag()->m_type == MediaTypeVideoCollection) { CFileItemList movies; - CStdString baseDir = StringUtils::Format("videodb://movies/sets/%d", videoItem->GetVideoInfoTag()->m_iDbId); + std::string baseDir = StringUtils::Format("videodb://movies/sets/%d", videoItem->GetVideoInfoTag()->m_iDbId); if (videodb.GetMoviesNav(baseDir, movies)) { for (int i=0; i < movies.Size(); i++) @@ -1936,9 +1937,9 @@ bool CGUIDialogVideoInfo::OnGetFanart(const CFileItemPtr &videoItem) // Grab the thumbnails from the web for (unsigned int j = 0; j < movies[i]->GetVideoInfoTag()->m_fanart.GetNumFanarts(); j++) { - CStdString strItemPath = StringUtils::Format("fanart://Remote%i",j); + std::string strItemPath = StringUtils::Format("fanart://Remote%i",j); CFileItemPtr item(new CFileItem(strItemPath, false)); - CStdString thumb = movies[i]->GetVideoInfoTag()->m_fanart.GetPreviewURL(j); + std::string thumb = movies[i]->GetVideoInfoTag()->m_fanart.GetPreviewURL(j); item->SetArt("thumb", CTextureUtils::GetWrappedThumbURL(thumb)); item->SetIconImage("DefaultPicture.png"); item->SetLabel(g_localizeStrings.Get(20441)); @@ -1958,7 +1959,7 @@ bool CGUIDialogVideoInfo::OnGetFanart(const CFileItemPtr &videoItem) items.Add(itemNone); } - CStdString result; + std::string result; VECSOURCES sources(*CMediaSourceSettings::Get().GetSources("video")); g_mediaManager.GetLocalDrives(sources); AddItemPathToFileBrowserSources(sources, item); @@ -1972,7 +1973,7 @@ bool CGUIDialogVideoInfo::OnGetFanart(const CFileItemPtr &videoItem) int iFanart = atoi(result.substr(15).c_str()); result = thumbs[iFanart]; } - else if (result.Equals("fanart://None") || !CFile::Exists(result)) + else if (StringUtils::EqualsNoCase(result, "fanart://None") || !CFile::Exists(result)) result.clear(); if (!result.empty() && flip) result = CTextureUtils::GetWrappedImageURL(result, "", "flipped"); diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.h b/xbmc/video/dialogs/GUIDialogVideoInfo.h index 92d3fdaf92..3b6c772d1e 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.h +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.h @@ -57,7 +57,7 @@ public: static bool GetSetForMovie(const CFileItem *movieItem, CFileItemPtr &selectedSet); static bool SetMovieSet(const CFileItem *movieItem, const CFileItem *selectedSet); - static bool GetItemsForTag(const CStdString &strHeading, const std::string &type, CFileItemList &items, int idTag = -1, bool showAll = true); + static bool GetItemsForTag(const std::string &strHeading, const std::string &type, CFileItemList &items, int idTag = -1, bool showAll = true); static bool AddItemsToTag(const CFileItemPtr &tagItem); static bool RemoveItemsFromTag(const CFileItemPtr &tagItem); @@ -67,12 +67,12 @@ public: protected: virtual void OnInitWindow(); void Update(); - void SetLabel(int iControl, const CStdString& strLabel); + void SetLabel(int iControl, const std::string& strLabel); // link cast to movies void ClearCastList(); - void OnSearch(CStdString& strSearch); - void DoSearch(CStdString& strSearch, CFileItemList& items); + void OnSearch(std::string& strSearch); + void DoSearch(std::string& strSearch, CFileItemList& items); void OnSearchItemFound(const CFileItem* pItem); void Play(bool resume = false); void OnGetArt(); diff --git a/xbmc/video/dialogs/GUIDialogVideoSettings.cpp b/xbmc/video/dialogs/GUIDialogVideoSettings.cpp index ca65fdc048..fb7bf7be1e 100644 --- a/xbmc/video/dialogs/GUIDialogVideoSettings.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoSettings.cpp @@ -36,7 +36,6 @@ #include "utils/log.h" #include "video/VideoDatabase.h" -#define SETTING_VIDEO_CROP "video.crop" #define SETTING_VIDEO_VIEW_MODE "video.viewmode" #define SETTING_VIDEO_ZOOM "video.zoom" #define SETTING_VIDEO_PIXEL_RATIO "video.pixelratio" @@ -87,8 +86,6 @@ void CGUIDialogVideoSettings::OnSettingChanged(const CSetting *setting) else if (settingId == SETTING_VIDEO_SCALINGMETHOD) videoSettings.m_ScalingMethod = static_cast<ESCALINGMETHOD>(static_cast<const CSettingInt*>(setting)->GetValue()); #ifdef HAS_VIDEO_PLAYBACK - else if (settingId == SETTING_VIDEO_CROP) - videoSettings.m_Crop = static_cast<const CSettingBool*>(setting)->GetValue(); else if (settingId == SETTING_VIDEO_VIEW_MODE) { videoSettings.m_ViewMode = static_cast<const CSettingInt*>(setting)->GetValue(); @@ -318,9 +315,6 @@ void CGUIDialogVideoSettings::InitializeSettings() AddSpinner(groupVideo, SETTING_VIDEO_SCALINGMETHOD, 16300, 0, static_cast<int>(videoSettings.m_ScalingMethod), entries); #ifdef HAS_VIDEO_PLAYBACK - if (g_renderManager.Supports(RENDERFEATURE_CROP)) - AddToggle(groupVideo, SETTING_VIDEO_CROP, 644, 0, videoSettings.m_Crop); - if (g_renderManager.Supports(RENDERFEATURE_STRETCH) || g_renderManager.Supports(RENDERFEATURE_PIXEL_RATIO)) { entries.clear(); diff --git a/xbmc/video/videosync/VideoSyncCocoa.cpp b/xbmc/video/videosync/VideoSyncCocoa.cpp index 1e28183c5a..f9fe46d871 100644 --- a/xbmc/video/videosync/VideoSyncCocoa.cpp +++ b/xbmc/video/videosync/VideoSyncCocoa.cpp @@ -27,10 +27,7 @@ #include "video/VideoReferenceClock.h" #include "utils/TimeUtils.h" -//ios specifics -#if defined(TARGET_DARWIN_IOS) #include "windowing/WindowingFactory.h" -#endif //osx specifics #if defined(TARGET_DARWIN_OSX) @@ -83,33 +80,34 @@ void CVideoSyncCocoa::VblankHandler(int64_t nowtime, double fps) bool CVideoSyncCocoa::Setup(PUPDATECLOCK func) { CLog::Log(LOGDEBUG, "CVideoSyncCocoa: setting up Cocoa"); + bool setupOk = false; //init the vblank timestamp m_LastVBlankTime = CurrentHostCounter(); UpdateClock = func; + m_abort = false; #if defined(TARGET_DARWIN_IOS) - { - g_Windowing.InitDisplayLink(this); - } + g_Windowing.InitDisplayLink(this); + setupOk = true; #else - if (!Cocoa_CVDisplayLinkCreate((void*)DisplayLinkCallBack, reinterpret_cast<void*>(this))) - { - CLog::Log(LOGDEBUG, "CVideoSyncCocoa: Cocoa_CVDisplayLinkCreate failed"); - return false; - } + setupOk = Cocoa_CVDisplayLinkCreate((void*)DisplayLinkCallBack, reinterpret_cast<void*>(this)); + if (setupOk) + g_Windowing.Register(this); else + CLog::Log(LOGDEBUG, "CVideoSyncCocoa: Cocoa_CVDisplayLinkCreate failed"); #endif - { - GetFps();//UpdateRefreshrate(true); - FIXME?NEEDED? - return true; - } + + if (setupOk) + GetFps(); + + return setupOk; } void CVideoSyncCocoa::Run(volatile bool& stop) { //because cocoa has a vblank callback, we just keep sleeping until we're asked to stop the thread - while(!stop) + while(!stop && !m_abort) { Sleep(1000); } @@ -122,6 +120,7 @@ void CVideoSyncCocoa::Cleanup() g_Windowing.DeinitDisplayLink(); #else Cocoa_CVDisplayLinkRelease(); + g_Windowing.Unregister(this); #endif } @@ -136,6 +135,11 @@ void CVideoSyncCocoa::UpdateFPS(double fps) } } +void CVideoSyncCocoa::OnResetDevice() +{ + m_abort = true; +} + float CVideoSyncCocoa::GetFps() { #if defined(TARGET_DARWIN_IOS) diff --git a/xbmc/video/videosync/VideoSyncCocoa.h b/xbmc/video/videosync/VideoSyncCocoa.h index a7ddc73e56..621d2dacc0 100644 --- a/xbmc/video/videosync/VideoSyncCocoa.h +++ b/xbmc/video/videosync/VideoSyncCocoa.h @@ -21,7 +21,9 @@ #if defined(TARGET_DARWIN) #include "VideoSync.h" -class CVideoSyncCocoa : public CVideoSync +#include "guilib/DispResource.h" + +class CVideoSyncCocoa : public CVideoSync, IDispResource { public: virtual bool Setup(PUPDATECLOCK func); @@ -29,9 +31,11 @@ public: virtual void Cleanup(); virtual float GetFps(); void VblankHandler(int64_t nowtime, double fps); + virtual void OnResetDevice(); private: void UpdateFPS(double fps); int64_t m_LastVBlankTime; //timestamp of the last vblank, used for calculating how many vblanks happened + volatile bool m_abort; }; #endif diff --git a/xbmc/video/videosync/VideoSyncDRM.cpp b/xbmc/video/videosync/VideoSyncDRM.cpp index 1929a3a185..45c1aacb17 100644 --- a/xbmc/video/videosync/VideoSyncDRM.cpp +++ b/xbmc/video/videosync/VideoSyncDRM.cpp @@ -77,7 +77,7 @@ void CVideoSyncDRM::Run(volatile bool& stop) else if (crtc > 1) { vbl.request.type = (drmVBlankSeqType)(vbl.request.type | - (crtc << DRM_VBLANK_HIGH_CRTC_SHIFT) & DRM_VBLANK_HIGH_CRTC_MASK); + ((crtc << DRM_VBLANK_HIGH_CRTC_SHIFT) & DRM_VBLANK_HIGH_CRTC_MASK)); } vbl.request.sequence = 0; ret = drmWaitVBlank(m_fd, &vbl); @@ -98,7 +98,7 @@ void CVideoSyncDRM::Run(volatile bool& stop) else if (crtc > 1) { vbl.request.type = (drmVBlankSeqType)(vbl.request.type | - (crtc << DRM_VBLANK_HIGH_CRTC_SHIFT) & DRM_VBLANK_HIGH_CRTC_MASK); + ((crtc << DRM_VBLANK_HIGH_CRTC_SHIFT) & DRM_VBLANK_HIGH_CRTC_MASK)); } vbl.request.sequence = 1; vbl.request.signal = (unsigned long)&info; @@ -162,7 +162,7 @@ void CVideoSyncDRM::EventHandler(int fd, unsigned int frame, unsigned int sec, else if (crtc > 1) { vbl.request.type = (drmVBlankSeqType)(vbl.request.type | - (crtc << DRM_VBLANK_HIGH_CRTC_SHIFT) & DRM_VBLANK_HIGH_CRTC_MASK); + ((crtc << DRM_VBLANK_HIGH_CRTC_SHIFT) & DRM_VBLANK_HIGH_CRTC_MASK)); } vbl.request.sequence = 1; vbl.request.signal = (unsigned long)data; diff --git a/xbmc/video/windows/GUIWindowFullScreen.cpp b/xbmc/video/windows/GUIWindowFullScreen.cpp index dfbf773fdf..eeeda4420a 100644 --- a/xbmc/video/windows/GUIWindowFullScreen.cpp +++ b/xbmc/video/windows/GUIWindowFullScreen.cpp @@ -261,7 +261,7 @@ bool CGUIWindowFullScreen::OnAction(const CAction &action) else { int autoCloseTime = CSettings::Get().GetBool("pvrplayback.confirmchannelswitch") ? 0 : g_advancedSettings.m_iPVRNumericChannelSwitchTimeout; - CStdString strChannel = StringUtils::Format("%i", action.GetID() - REMOTE_0); + std::string strChannel = StringUtils::Format("%i", action.GetID() - REMOTE_0); if (CGUIDialogNumeric::ShowAndGetNumber(strChannel, g_localizeStrings.Get(19000), autoCloseTime) || autoCloseTime) { int iChannelNumber = atoi(strChannel.c_str()); @@ -281,7 +281,7 @@ bool CGUIWindowFullScreen::OnAction(const CAction &action) { // filesystem provider like slingbox, cmyth, etc int iChannelNumber = -1; - CStdString strChannel = StringUtils::Format("%i", action.GetID() - REMOTE_0); + std::string strChannel = StringUtils::Format("%i", action.GetID() - REMOTE_0); if (CGUIDialogNumeric::ShowAndGetNumber(strChannel, g_localizeStrings.Get(19000))) iChannelNumber = atoi(strChannel.c_str()); @@ -466,7 +466,7 @@ bool CGUIWindowFullScreen::OnMessage(CGUIMessage& message) // Get the currently selected label of the Select button CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControl); OnMessage(msg); - CStdString strLabel = msg.GetLabel(); + std::string strLabel = msg.GetLabel(); CPVRChannelPtr playingChannel; if (g_PVRManager.GetCurrentChannel(playingChannel)) @@ -561,7 +561,7 @@ void CGUIWindowFullScreen::FrameMove() if (m_showCodec) { // show audio codec info - CStdString strAudio, strVideo, strGeneral; + std::string strAudio, strVideo, strGeneral; g_application.m_pPlayer->GetAudioInfo(strAudio); { CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW1); @@ -578,19 +578,19 @@ void CGUIWindowFullScreen::FrameMove() // show general info g_application.m_pPlayer->GetGeneralInfo(strGeneral); { - CStdString strGeneralFPS; + std::string strGeneralFPS; #if defined(TARGET_DARWIN) // We show CPU usage for the entire process, as it's arguably more useful. double dCPU = m_resourceCounter.GetCPUUsage(); - CStdString strCores; + std::string strCores; strCores = StringUtils::Format("cpu:%.0f%%", dCPU); #else - CStdString strCores = g_cpuInfo.GetCoresUsageString(); + std::string strCores = g_cpuInfo.GetCoresUsageString(); #endif int missedvblanks; double refreshrate; double clockspeed; - CStdString strClock; + std::string strClock; if (g_VideoReferenceClock.GetClockInfo(missedvblanks, clockspeed, refreshrate)) strClock = StringUtils::Format("S( refresh:%.3f missed:%i speed:%+.3f%% %s )" @@ -622,9 +622,9 @@ void CGUIWindowFullScreen::FrameMove() { // get the "View Mode" string - CStdString strTitle = g_localizeStrings.Get(629); - CStdString strMode = g_localizeStrings.Get(630 + CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode); - CStdString strInfo = StringUtils::Format("%s : %s", strTitle.c_str(), strMode.c_str()); + std::string strTitle = g_localizeStrings.Get(629); + std::string strMode = g_localizeStrings.Get(630 + CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode); + std::string strInfo = StringUtils::Format("%s : %s", strTitle.c_str(), strMode.c_str()); CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW1); msg.SetLabel(strInfo); OnMessage(msg); @@ -637,7 +637,7 @@ void CGUIWindowFullScreen::FrameMove() float xscale = (float)res.iScreenWidth / (float)res.iWidth; float yscale = (float)res.iScreenHeight / (float)res.iHeight; - CStdString strSizing = StringUtils::Format(g_localizeStrings.Get(245).c_str(), + std::string strSizing = StringUtils::Format(g_localizeStrings.Get(245).c_str(), (int)info.SrcRect.Width(), (int)info.SrcRect.Height(), (int)(info.DestRect.Width() * xscale), @@ -652,7 +652,7 @@ void CGUIWindowFullScreen::FrameMove() } // show resolution information { - CStdString strStatus; + std::string strStatus; if (g_Windowing.IsFullScreen()) strStatus = StringUtils::Format("%s %ix%i@%.2fHz - %s", g_localizeStrings.Get(13287).c_str(), @@ -680,7 +680,7 @@ void CGUIWindowFullScreen::FrameMove() m_timeCodeShow = false; m_timeCodePosition = 0; } - CStdString strDispTime = "00:00:00"; + std::string strDispTime = "00:00:00"; CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW1); diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp index ca9d83930a..4abf94d8a1 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.cpp +++ b/xbmc/video/windows/GUIWindowVideoBase.cpp @@ -97,8 +97,8 @@ using namespace PVR; #define PROPERTY_GROUP_BY "group.by" #define PROPERTY_GROUP_MIXED "group.mixed" -CGUIWindowVideoBase::CGUIWindowVideoBase(int id, const CStdString &xmlFile) - : CGUIMediaWindow(id, xmlFile) +CGUIWindowVideoBase::CGUIWindowVideoBase(int id, const std::string &xmlFile) + : CGUIMediaWindow(id, xmlFile.c_str()) { m_thumbLoader.SetObserver(this); m_stackingAvailable = true; @@ -261,7 +261,7 @@ void CGUIWindowVideoBase::UpdateButtons() g_windowManager.SendMessage(msg); // Add labels to the window selection - CStdString strItem = g_localizeStrings.Get(744); // Files + std::string strItem = g_localizeStrings.Get(744); // Files CGUIMessage msg2(GUI_MSG_LABEL_ADD, GetID(), CONTROL_BTNTYPE); msg2.SetLabel(strItem); g_windowManager.SendMessage(msg2); @@ -422,7 +422,7 @@ bool CGUIWindowVideoBase::ShowIMDB(CFileItem *item, const ScraperPtr &info2, boo // NOTE: This will fail for episodes on multipath shares, as the parent path isn't what is stored in the // database. Possible solutions are to store the paths in the db separately and rely on the show // stacking stuff, or to modify GetTvShowId to do support multipath:// shares - CStdString strParentDirectory; + std::string strParentDirectory; URIUtils::GetParentPath(item->GetPath(), strParentDirectory); if (m_database.GetTvShowId(strParentDirectory) < 0) { @@ -487,7 +487,7 @@ bool CGUIWindowVideoBase::ShowIMDB(CFileItem *item, const ScraperPtr &info2, boo return false; // Get the correct movie title - CStdString movieName = item->GetMovieName(settings.parent_name); + std::string movieName = item->GetMovieName(settings.parent_name); CScraperUrl scrUrl; CVideoInfoScanner scanner; @@ -531,7 +531,7 @@ bool CGUIWindowVideoBase::ShowIMDB(CFileItem *item, const ScraperPtr &info2, boo if (!hasDetails && (scrUrl.m_url.size() == 0 || needsRefresh)) { // 4a. show dialog that we're busy querying www.imdb.com - CStdString strHeading = StringUtils::Format(g_localizeStrings.Get(197).c_str(),info->Name().c_str()); + std::string strHeading = StringUtils::Format(g_localizeStrings.Get(197).c_str(),info->Name().c_str()); pDlgProgress->SetHeading(strHeading); pDlgProgress->SetLine(0, movieName); pDlgProgress->SetLine(1, ""); @@ -619,7 +619,7 @@ bool CGUIWindowVideoBase::ShowIMDB(CFileItem *item, const ScraperPtr &info2, boo item->ClearArt(); CFileItemList list; - CStdString strPath=item->GetPath(); + std::string strPath=item->GetPath(); if (item->IsVideoDb() || fromDB) { vector<string> paths; @@ -808,7 +808,7 @@ void CGUIWindowVideoBase::AddItemToPlayList(const CFileItemPtr &pItem, CFileItem { if (items[i]->m_bIsFolder) { - CStdString strPath = items[i]->GetPath(); + std::string strPath = items[i]->GetPath(); URIUtils::RemoveSlashAtEnd(strPath); if (StringUtils::EndsWithNoCase(strPath, "sample")) // skip sample folders { @@ -886,7 +886,7 @@ void CGUIWindowVideoBase::GetResumeItemOffset(const CFileItem *item, int& starto else { CBookmark bookmark; - CStdString strPath = item->GetPath(); + std::string strPath = item->GetPath(); if ((item->IsVideoDb() || item->IsDVD()) && item->HasVideoInfoTag()) strPath = item->GetVideoInfoTag()->m_strFileNameAndPath; @@ -925,7 +925,7 @@ bool CGUIWindowVideoBase::OnSelect(int iItem) CFileItemPtr item = m_vecItems->Get(iItem); - CStdString path = item->GetPath(); + std::string path = item->GetPath(); if (!item->m_bIsFolder && path != "add" && path != "addons://more/video" && !StringUtils::StartsWith(path, "newsmartplaylist://") && !StringUtils::StartsWith(path, "newplaylist://") && @@ -951,13 +951,13 @@ bool CGUIWindowVideoBase::OnFileAction(int iItem, int action) if (item->IsVideoDb()) { - CStdString itemPath(item->GetPath()); + std::string itemPath(item->GetPath()); itemPath = item->GetVideoInfoTag()->m_strFileNameAndPath; if (URIUtils::IsStack(itemPath) && CFileItem(CStackDirectory::GetFirstStackedFile(itemPath),false).IsDiscImage()) choices.Add(SELECT_ACTION_PLAYPART, 20324); // Play Part } - CStdString resumeString = GetResumeString(*item); + std::string resumeString = GetResumeString(*item); if (!resumeString.empty()) { choices.Add(SELECT_ACTION_RESUME, resumeString); @@ -1015,7 +1015,7 @@ bool CGUIWindowVideoBase::OnInfo(int iItem) ADDON::ScraperPtr scraper; if (!m_vecItems->IsPlugin() && !m_vecItems->IsRSS() && !m_vecItems->IsLiveTV()) { - CStdString strDir; + std::string strDir; if (item->IsVideoDb() && item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strPath.empty()) @@ -1051,9 +1051,9 @@ void CGUIWindowVideoBase::OnRestartItem(int iItem) CGUIMediaWindow::OnClick(iItem); } -CStdString CGUIWindowVideoBase::GetResumeString(const CFileItem &item) +std::string CGUIWindowVideoBase::GetResumeString(const CFileItem &item) { - CStdString resumeString; + std::string resumeString; int startOffset = 0, startPart = 0; GetResumeItemOffset(&item, startOffset, startPart); if (startOffset > 0) @@ -1061,7 +1061,7 @@ CStdString CGUIWindowVideoBase::GetResumeString(const CFileItem &item) resumeString = StringUtils::Format(g_localizeStrings.Get(12022).c_str(), StringUtils::SecondsToTimeString(startOffset/75).c_str()); if (startPart > 0) { - CStdString partString = StringUtils::Format(g_localizeStrings.Get(23051).c_str(), startPart); + std::string partString = StringUtils::Format(g_localizeStrings.Get(23051).c_str(), startPart); resumeString += " (" + partString + ")"; } } @@ -1072,7 +1072,7 @@ bool CGUIWindowVideoBase::ShowResumeMenu(CFileItem &item) { if (!item.m_bIsFolder && !item.IsLiveTV()) { - CStdString resumeString = GetResumeString(item); + std::string resumeString = GetResumeString(item); if (!resumeString.empty()) { // prompt user whether they wish to resume CContextButtons choices; @@ -1097,7 +1097,7 @@ bool CGUIWindowVideoBase::ShowPlaySelection(CFileItemPtr& item) if (CSettings::Get().GetInt("disc.playback") != BD_PLAYBACK_SIMPLE_MENU) return true; - CStdString path; + std::string path; if (item->IsVideoDb()) path = item->GetVideoInfoTag()->m_strFileNameAndPath; else @@ -1105,7 +1105,7 @@ bool CGUIWindowVideoBase::ShowPlaySelection(CFileItemPtr& item) if (item->IsBDFile()) { - CStdString root = URIUtils::GetParentPath(path); + std::string root = URIUtils::GetParentPath(path); URIUtils::RemoveSlashAtEnd(root); if(URIUtils::GetFileName(root) == "BDMV") { @@ -1132,7 +1132,7 @@ bool CGUIWindowVideoBase::ShowPlaySelection(CFileItemPtr& item) return true; } -bool CGUIWindowVideoBase::ShowPlaySelection(CFileItemPtr& item, const CStdString& directory) +bool CGUIWindowVideoBase::ShowPlaySelection(CFileItemPtr& item, const std::string& directory) { CFileItemList items; @@ -1196,7 +1196,7 @@ bool CGUIWindowVideoBase::OnResumeItem(int iItem) return true; } - CStdString resumeString = GetResumeString(*item); + std::string resumeString = GetResumeString(*item); if (!resumeString.empty()) { @@ -1223,7 +1223,7 @@ void CGUIWindowVideoBase::GetContextButtons(int itemNumber, CContextButtons &but { if (!item->IsParentFolder()) { - CStdString path(item->GetPath()); + std::string path(item->GetPath()); if (item->IsVideoDb() && item->HasVideoInfoTag()) path = item->GetVideoInfoTag()->m_strFileNameAndPath; @@ -1302,7 +1302,7 @@ bool CGUIWindowVideoBase::OnPlayStackPart(int iItem) return false; CFileItemPtr stack = m_vecItems->Get(iItem); - CStdString path(stack->GetPath()); + std::string path(stack->GetPath()); if (stack->IsVideoDb()) path = stack->GetVideoInfoTag()->m_strFileNameAndPath; @@ -1321,7 +1321,7 @@ bool CGUIWindowVideoBase::OnPlayStackPart(int iItem) // ISO stack if (CFileItem(CStackDirectory::GetFirstStackedFile(path),false).IsDiscImage()) { - CStdString resumeString = CGUIWindowVideoBase::GetResumeString(*(parts[selectedFile - 1].get())); + std::string resumeString = CGUIWindowVideoBase::GetResumeString(*(parts[selectedFile - 1].get())); stack->m_lStartOffset = 0; if (!resumeString.empty()) { @@ -1364,7 +1364,7 @@ bool CGUIWindowVideoBase::OnContextButton(int itemNumber, CONTEXT_BUTTON button) { case CONTEXT_BUTTON_SET_CONTENT: { - OnAssignContent(item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strPath.empty() ? item->GetVideoInfoTag()->m_strPath : item->GetPath()); + OnAssignContent(item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strPath.empty() ? item->GetVideoInfoTag()->m_strPath : static_cast<const std::string&>(item->GetPath())); return true; } case CONTEXT_BUTTON_PLAY_PART: @@ -1441,7 +1441,7 @@ bool CGUIWindowVideoBase::OnContextButton(int itemNumber, CONTEXT_BUTTON button) ADDON::ScraperPtr info; SScanSettings settings; GetScraperForItem(item.get(), info, settings); - CStdString strPath = item->GetPath(); + std::string strPath = item->GetPath(); if (item->IsVideoDb() && (!item->m_bIsFolder || item->GetVideoInfoTag()->m_strPath.empty())) return false; @@ -1465,7 +1465,7 @@ bool CGUIWindowVideoBase::OnContextButton(int itemNumber, CONTEXT_BUTTON button) return true; case CONTEXT_BUTTON_EDIT_SMART_PLAYLIST: { - CStdString playlist = m_vecItems->Get(itemNumber)->IsSmartPlayList() ? m_vecItems->Get(itemNumber)->GetPath() : m_vecItems->GetPath(); // save path as activatewindow will destroy our items + std::string playlist = m_vecItems->Get(itemNumber)->IsSmartPlayList() ? m_vecItems->Get(itemNumber)->GetPath() : m_vecItems->GetPath(); // save path as activatewindow will destroy our items if (CGUIDialogSmartPlaylistEditor::EditPlaylist(playlist, "video")) Refresh(true); // need to update return true; @@ -1521,21 +1521,21 @@ bool CGUIWindowVideoBase::OnPlayMedia(int iItem) CFileItemPtr tag = g_PVRRecordings->GetByPath(item.GetPath()); if (tag && tag->HasPVRRecordingInfoTag() && !tag->GetPVRRecordingInfoTag()->m_strStreamURL.empty()) { - CStdString stream = tag->GetPVRRecordingInfoTag()->m_strStreamURL; + std::string stream = tag->GetPVRRecordingInfoTag()->m_strStreamURL; /* Isolate the folder from the filename */ size_t found = stream.find_last_of("/"); - if (found == CStdString::npos) + if (found == std::string::npos) found = stream.find_last_of("\\"); - if (found != CStdString::npos) + if (found != std::string::npos) { /* Check here for asterix at the begin of the filename */ if (stream[found+1] == '*') { /* Create a "stack://" url with all files matching the extension */ - CStdString ext = URIUtils::GetExtension(stream); - CStdString dir = stream.substr(0, found).c_str(); + std::string ext = URIUtils::GetExtension(stream); + std::string dir = stream.substr(0, found).c_str(); CFileItemList items; CDirectory::GetDirectory(dir, items); @@ -1552,7 +1552,7 @@ bool CGUIWindowVideoBase::OnPlayMedia(int iItem) { /* If we have a stack change the path of the item to it */ CStackDirectory dir; - CStdString stackPath = dir.ConstructStackPath(items, stack); + std::string stackPath = dir.ConstructStackPath(items, stack); item.SetPath(stackPath); } } @@ -1816,9 +1816,12 @@ void CGUIWindowVideoBase::GetGroupedItems(CFileItemList &items) bool CGUIWindowVideoBase::CheckFilterAdvanced(CFileItemList &items) const { - CStdString content = items.GetContent(); + std::string content = items.GetContent(); if ((items.IsVideoDb() || CanContainFilter(m_strFilterPath)) && - (content.Equals("movies") || content.Equals("tvshows") || content.Equals("episodes") || content.Equals("musicvideos"))) + (StringUtils::EqualsNoCase(content, "movies") || + StringUtils::EqualsNoCase(content, "tvshows") || + StringUtils::EqualsNoCase(content, "episodes") || + StringUtils::EqualsNoCase(content, "musicvideos"))) return true; return false; @@ -1843,7 +1846,7 @@ void CGUIWindowVideoBase::AddToDatabase(int iItem) // prompt for data // enter a new title - CStdString strTitle = pItem->GetLabel(); + std::string strTitle = pItem->GetLabel(); if (!CGUIKeyboardFactory::ShowAndGetInput(strTitle, g_localizeStrings.Get(528), false)) // Enter Title return; @@ -1860,7 +1863,7 @@ void CGUIWindowVideoBase::AddToDatabase(int iItem) pSelect->SetItems(&items); pSelect->EnableButton(true, 531); // New Genre pSelect->DoModal(); - CStdString strGenre; + std::string strGenre; int iSelected = pSelect->GetSelectedLabel(); if (iSelected >= 0) strGenre = items[iSelected]->GetLabel(); @@ -1898,7 +1901,7 @@ void CGUIWindowVideoBase::AddToDatabase(int iItem) /// \brief Search the current directory for a string got from the virtual keyboard void CGUIWindowVideoBase::OnSearch() { - CStdString strSearch; + std::string strSearch; if (!CGUIKeyboardFactory::ShowAndGetInput(strSearch, g_localizeStrings.Get(16017), false)) return ; @@ -1952,8 +1955,8 @@ void CGUIWindowVideoBase::OnSearchItemFound(const CFileItem* pSelItem) { if (pSelItem->m_bIsFolder) { - CStdString strPath = pSelItem->GetPath(); - CStdString strParentPath; + std::string strPath = pSelItem->GetPath(); + std::string strParentPath; URIUtils::GetParentPath(strPath, strParentPath); Update(strParentPath); @@ -1980,7 +1983,7 @@ void CGUIWindowVideoBase::OnSearchItemFound(const CFileItem* pSelItem) } else { - CStdString strPath = URIUtils::GetDirectory(pSelItem->GetPath()); + std::string strPath = URIUtils::GetDirectory(pSelItem->GetPath()); Update(strPath); @@ -2022,11 +2025,11 @@ int CGUIWindowVideoBase::GetScraperForItem(CFileItem *item, ADDON::ScraperPtr &i } bool foundDirectly = false; - info = m_database.GetScraperForPath(item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strPath.empty() ? item->GetVideoInfoTag()->m_strPath : item->GetPath(), settings, foundDirectly); + info = m_database.GetScraperForPath(item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strPath.empty() ? std::string(item->GetVideoInfoTag()->m_strPath) : item->GetPath(), settings, foundDirectly); return foundDirectly ? 1 : 0; } -void CGUIWindowVideoBase::OnScan(const CStdString& strPath, bool scanAll) +void CGUIWindowVideoBase::OnScan(const std::string& strPath, bool scanAll) { g_application.StartVideoScan(strPath, true, scanAll); } @@ -2041,20 +2044,20 @@ std::string CGUIWindowVideoBase::GetStartFolder(const std::string &dir) return CGUIMediaWindow::GetStartFolder(dir); } -void CGUIWindowVideoBase::AppendAndClearSearchItems(CFileItemList &searchItems, const CStdString &prependLabel, CFileItemList &results) +void CGUIWindowVideoBase::AppendAndClearSearchItems(CFileItemList &searchItems, const std::string &prependLabel, CFileItemList &results) { if (!searchItems.Size()) return; searchItems.Sort(SortByLabel, SortOrderAscending, CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); for (int i = 0; i < searchItems.Size(); i++) - searchItems[i]->SetLabel(prependLabel + (CStdString)searchItems[i]->GetLabel()); + searchItems[i]->SetLabel(prependLabel + searchItems[i]->GetLabel()); results.Append(searchItems); searchItems.Clear(); } -bool CGUIWindowVideoBase::OnUnAssignContent(const CStdString &path, int label1, int label2, int label3) +bool CGUIWindowVideoBase::OnUnAssignContent(const std::string &path, int label1, int label2, int label3) { bool bCanceled; CVideoDatabase db; @@ -2082,7 +2085,7 @@ bool CGUIWindowVideoBase::OnUnAssignContent(const CStdString &path, int label1, return false; } -void CGUIWindowVideoBase::OnAssignContent(const CStdString &path) +void CGUIWindowVideoBase::OnAssignContent(const std::string &path) { bool bScan=false; CVideoDatabase db; diff --git a/xbmc/video/windows/GUIWindowVideoBase.h b/xbmc/video/windows/GUIWindowVideoBase.h index 014391006b..170f626ec0 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.h +++ b/xbmc/video/windows/GUIWindowVideoBase.h @@ -39,7 +39,7 @@ enum VideoSelectAction class CGUIWindowVideoBase : public CGUIMediaWindow, public IBackgroundLoaderObserver { public: - CGUIWindowVideoBase(int id, const CStdString &xmlFile); + CGUIWindowVideoBase(int id, const std::string &xmlFile); virtual ~CGUIWindowVideoBase(void); virtual bool OnMessage(CGUIMessage& message); virtual bool OnAction(const CAction &action); @@ -53,7 +53,7 @@ public: /*! \brief Show dialog allowing selection of wanted playback item */ static bool ShowPlaySelection(CFileItemPtr& item); - static bool ShowPlaySelection(CFileItemPtr& item, const CStdString& directory); + static bool ShowPlaySelection(CFileItemPtr& item, const std::string& directory); /*! \brief Show the resume menu for this item (if it has a resume bookmark) @@ -74,23 +74,23 @@ public: \param results the fileitemlist to append the search results to. \sa DoSearch */ - static void AppendAndClearSearchItems(CFileItemList &searchItems, const CStdString &prependLabel, CFileItemList &results); + static void AppendAndClearSearchItems(CFileItemList &searchItems, const std::string &prependLabel, CFileItemList &results); /*! \brief Prompt the user for assigning content to a path. Based on changes, we then call OnUnassignContent, update or refresh scraper information in the database and optionally start a scan \param path the path to assign content for */ - static void OnAssignContent(const CStdString &path); + static void OnAssignContent(const std::string &path); /*! \brief checks the database for a resume position and puts together a string \param item selected item \return string containing the resume position or an empty string if there is no resume position */ - static CStdString GetResumeString(const CFileItem &item); + static std::string GetResumeString(const CFileItem &item); protected: - void OnScan(const CStdString& strPath, bool scanAll = false); + void OnScan(const std::string& strPath, bool scanAll = false); virtual void OnInitWindow(); virtual void UpdateButtons(); virtual bool Update(const std::string &strDirectory, bool updateFilterPath = true); @@ -106,7 +106,7 @@ protected: virtual void OnQueueItem(int iItem); virtual void OnDeleteItem(CFileItemPtr pItem); virtual void OnDeleteItem(int iItem); - virtual void DoSearch(const CStdString& strSearch, CFileItemList& items) {}; + virtual void DoSearch(const std::string& strSearch, CFileItemList& items) {}; virtual std::string GetStartFolder(const std::string &dir); bool OnClick(int iItem); @@ -138,7 +138,7 @@ protected: void OnSearchItemFound(const CFileItem* pSelItem); int GetScraperForItem(CFileItem *item, ADDON::ScraperPtr &info, VIDEO::SScanSettings& settings); - static bool OnUnAssignContent(const CStdString &path, int label1, int label2, int label3); + static bool OnUnAssignContent(const std::string &path, int label1, int label2, int label3); static bool StackingAvailable(const CFileItemList &items); diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp index dc7ae853bd..f70851f6f8 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.cpp +++ b/xbmc/video/windows/GUIWindowVideoNav.cpp @@ -200,66 +200,67 @@ bool CGUIWindowVideoNav::OnMessage(CGUIMessage& message) return CGUIWindowVideoBase::OnMessage(message); } -CStdString CGUIWindowVideoNav::GetQuickpathName(const CStdString& strPath) const +std::string CGUIWindowVideoNav::GetQuickpathName(const std::string& strPath) const { - CStdString path = CLegacyPathTranslation::TranslateVideoDbPath(strPath); - if (path.Equals("videodb://movies/genres/")) + std::string path = CLegacyPathTranslation::TranslateVideoDbPath(strPath); + StringUtils::ToLower(path); + if (path == "videodb://movies/genres/") return "MovieGenres"; - else if (path.Equals("videodb://movies/titles/")) + else if (path == "videodb://movies/titles/") return "MovieTitles"; - else if (path.Equals("videodb://movies/years/")) + else if (path == "videodb://movies/years/") return "MovieYears"; - else if (path.Equals("videodb://movies/actors/")) + else if (path == "videodb://movies/actors/") return "MovieActors"; - else if (path.Equals("videodb://movies/directors/")) + else if (path == "videodb://movies/directors/") return "MovieDirectors"; - else if (path.Equals("videodb://movies/studios/")) + else if (path == "videodb://movies/studios/") return "MovieStudios"; - else if (path.Equals("videodb://movies/sets/")) + else if (path == "videodb://movies/sets/") return "MovieSets"; - else if (path.Equals("videodb://movies/countries/")) + else if (path == "videodb://movies/countries/") return "MovieCountries"; - else if (path.Equals("videodb://movies/tags/")) + else if (path == "videodb://movies/tags/") return "MovieTags"; - else if (path.Equals("videodb://movies/")) + else if (path == "videodb://movies/") return "Movies"; - else if (path.Equals("videodb://tvshows/genres/")) + else if (path == "videodb://tvshows/genres/") return "TvShowGenres"; - else if (path.Equals("videodb://tvshows/titles/")) + else if (path == "videodb://tvshows/titles/") return "TvShowTitles"; - else if (path.Equals("videodb://tvshows/years/")) + else if (path == "videodb://tvshows/years/") return "TvShowYears"; - else if (path.Equals("videodb://tvshows/actors/")) + else if (path == "videodb://tvshows/actors/") return "TvShowActors"; - else if (path.Equals("videodb://tvshows/studios/")) + else if (path == "videodb://tvshows/studios/") return "TvShowStudios"; - else if (path.Equals("videodb://tvshows/tags/")) + else if (path == "videodb://tvshows/tags/") return "TvShowTags"; - else if (path.Equals("videodb://tvshows/")) + else if (path == "videodb://tvshows/") return "TvShows"; - else if (path.Equals("videodb://musicvideos/genres/")) + else if (path == "videodb://musicvideos/genres/") return "MusicVideoGenres"; - else if (path.Equals("videodb://musicvideos/titles/")) + else if (path == "videodb://musicvideos/titles/") return "MusicVideoTitles"; - else if (path.Equals("videodb://musicvideos/years/")) + else if (path == "videodb://musicvideos/years/") return "MusicVideoYears"; - else if (path.Equals("videodb://musicvideos/artists/")) + else if (path == "videodb://musicvideos/artists/") return "MusicVideoArtists"; - else if (path.Equals("videodb://musicvideos/albums/")) + else if (path == "videodb://musicvideos/albums/") return "MusicVideoDirectors"; - else if (path.Equals("videodb://musicvideos/tags/")) + else if (path == "videodb://musicvideos/tags/") return "MusicVideoTags"; - else if (path.Equals("videodb://musicvideos/")) + else if (path == "videodb://musicvideos/") return "MusicVideos"; - else if (path.Equals("videodb://recentlyaddedmovies/")) + else if (path == "videodb://recentlyaddedmovies/") return "RecentlyAddedMovies"; - else if (path.Equals("videodb://recentlyaddedepisodes/")) + else if (path == "videodb://recentlyaddedepisodes/") return "RecentlyAddedEpisodes"; - else if (path.Equals("videodb://recentlyaddedmusicvideos/")) + else if (path == "videodb://recentlyaddedmusicvideos/") return "RecentlyAddedMusicVideos"; - else if (path.Equals("special://videoplaylists/")) + else if (path == "special://videoplaylists/") return "Playlists"; - else if (path.Equals("sources://video/")) + else if (path == "sources://video/") return "Files"; else { @@ -286,12 +287,12 @@ bool CGUIWindowVideoNav::GetDirectory(const std::string &strDirectory, CFileItem VIDEODATABASEDIRECTORY::NODE_TYPE node = dir.GetDirectoryChildType(items.GetPath()); int iFlatten = CSettings::Get().GetInt("videolibrary.flattentvshows"); + int itemsSize = items.GetObjectCount(); + int firstIndex = items.Size() - itemsSize; // perform the flattening logic for tvshows with a single (unwatched) season (+ optional special season) if (node == NODE_TYPE_SEASONS && !items.IsEmpty()) { - int itemsSize = items.GetObjectCount(); - int firstIndex = items.Size() - itemsSize; // check if the last item is the "All seasons" item which should be ignored for flattening if (!items[items.Size() - 1]->HasVideoInfoTag() || items[items.Size() - 1]->GetVideoInfoTag()->m_iSeason < 0) itemsSize -= 1; @@ -357,7 +358,7 @@ bool CGUIWindowVideoNav::GetDirectory(const std::string &strDirectory, CFileItem items.SetProperty("showplot", details.m_strPlot); // the container folder thumb is the parent (i.e. season or show) - if (node == NODE_TYPE_EPISODES || node == NODE_TYPE_RECENTLY_ADDED_EPISODES) + if (itemsSize && (node == NODE_TYPE_EPISODES || node == NODE_TYPE_RECENTLY_ADDED_EPISODES)) { items.SetContent("episodes"); @@ -371,7 +372,7 @@ bool CGUIWindowVideoNav::GetDirectory(const std::string &strDirectory, CFileItem if (seasonParam >= -1) seasonID = m_database.GetSeasonId(details.m_iDbId, seasonParam); else - seasonID = items[items.Size() - items.GetObjectCount()]->GetVideoInfoTag()->m_iIdSeason; + seasonID = items[firstIndex]->GetVideoInfoTag()->m_iIdSeason; CGUIListItem::ArtMap seasonArt; if (seasonID > -1 && m_database.GetArtForItem(seasonID, MediaTypeSeason, seasonArt)) @@ -423,7 +424,7 @@ bool CGUIWindowVideoNav::GetDirectory(const std::string &strDirectory, CFileItem } else if (!items.IsVirtualDirectoryRoot()) { // load info from the database - CStdString label; + std::string label; if (items.GetLabel().empty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::Get().GetSources("video"), &label)) items.SetLabel(label); if (!items.IsSourcesPath()) @@ -456,7 +457,7 @@ void CGUIWindowVideoNav::LoadVideoInfo(CFileItemList &items, CVideoDatabase &dat if (!items.GetContent().empty() && !items.IsPlugin()) return; // don't load for listings that have content set and weren't created from plugins - CStdString content = items.GetContent(); + std::string content = items.GetContent(); // determine content only if it isn't set if (content.empty()) { @@ -561,11 +562,11 @@ void CGUIWindowVideoNav::UpdateButtons() StringUtils::StartsWith(m_vecItems->Get(m_vecItems->Size()-1)->GetPath(), "/-1/")) iItems--; } - CStdString items = StringUtils::Format("%i %s", iItems, g_localizeStrings.Get(127).c_str()); + std::string items = StringUtils::Format("%i %s", iItems, g_localizeStrings.Get(127).c_str()); SET_CONTROL_LABEL(CONTROL_LABELFILES, items); // set the filter label - CStdString strLabel; + std::string strLabel; // "Playlists" if (m_vecItems->IsPath("special://videoplaylists/")) @@ -574,7 +575,7 @@ void CGUIWindowVideoNav::UpdateButtons() else if (m_vecItems->IsPlayList()) { // get playlist name from path - CStdString strDummy; + std::string strDummy; URIUtils::Split(m_vecItems->GetPath(), strDummy, strLabel); } else if (m_vecItems->IsPath("sources://video/")) @@ -612,7 +613,7 @@ bool CGUIWindowVideoNav::GetFilteredItems(const std::string &filter, CFileItemLi /// \brief video databases and return the found \e items /// \param strSearch The search string /// \param items Items Found -void CGUIWindowVideoNav::DoSearch(const CStdString& strSearch, CFileItemList& items) +void CGUIWindowVideoNav::DoSearch(const std::string& strSearch, CFileItemList& items) { CFileItemList tempItems; std::string strGenre = g_localizeStrings.Get(515); // Genre @@ -693,7 +694,7 @@ void CGUIWindowVideoNav::OnInfo(CFileItem* pItem, ADDON::ScraperPtr& scraper) scraper = m_database.GetScraperForPath(pItem->GetVideoInfoTag()->m_strPath); else { - CStdString strPath,strFile; + std::string strPath,strFile; URIUtils::Split(pItem->GetPath(),strPath,strFile); scraper = m_database.GetScraperForPath(strPath); } @@ -719,7 +720,7 @@ void CGUIWindowVideoNav::OnDeleteItem(CFileItemPtr pItem) { CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); pDialog->SetHeading(432); - CStdString strLabel = StringUtils::Format(g_localizeStrings.Get(433).c_str(),pItem->GetLabel().c_str()); + std::string strLabel = StringUtils::Format(g_localizeStrings.Get(433).c_str(),pItem->GetLabel().c_str()); pDialog->SetLine(1, strLabel); pDialog->SetLine(2, "");; pDialog->DoModal(); @@ -740,7 +741,7 @@ void CGUIWindowVideoNav::OnDeleteItem(CFileItemPtr pItem) { CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); pDialog->SetHeading(432); - CStdString strLabel = StringUtils::Format(g_localizeStrings.Get(433).c_str(), pItem->GetLabel().c_str()); + std::string strLabel = StringUtils::Format(g_localizeStrings.Get(433).c_str(), pItem->GetLabel().c_str()); pDialog->SetLine(1, strLabel); pDialog->SetLine(2, ""); pDialog->DoModal(); @@ -921,7 +922,7 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt { // non-video db items, file operations are allowed if ((CSettings::Get().GetBool("filelists.allowfiledeletion") && CUtil::SupportsWriteFileOperations(item->GetPath())) || - (inPlaylists && !URIUtils::GetFileName(item->GetPath()).Equals("PartyMode-Video.xsp") + (inPlaylists && URIUtils::GetFileName(item->GetPath()) != "PartyMode-Video.xsp" && (item->IsPlayList() || item->IsSmartPlayList()))) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); @@ -1001,7 +1002,7 @@ bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) } case CONTEXT_BUTTON_GO_TO_ARTIST: { - CStdString strPath; + std::string strPath; CMusicDatabase database; database.Open(); strPath = StringUtils::Format("musicdb://artists/%i/", @@ -1011,7 +1012,7 @@ bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) } case CONTEXT_BUTTON_GO_TO_ALBUM: { - CStdString strPath; + std::string strPath; CMusicDatabase database; database.Open(); strPath = StringUtils::Format("musicdb://albums/%i/", @@ -1064,7 +1065,7 @@ bool CGUIWindowVideoNav::OnClick(int iItem) } //Get the new title - CStdString strTag; + std::string strTag; if (!CGUIKeyboardFactory::ShowAndGetInput(strTag, g_localizeStrings.Get(20462), false)) return true; @@ -1073,22 +1074,22 @@ bool CGUIWindowVideoNav::OnClick(int iItem) return true; // get the media type and convert from plural to singular (by removing the trailing "s") - CStdString mediaType = item->GetPath().substr(9); + std::string mediaType = item->GetPath().substr(9); mediaType = mediaType.substr(0, mediaType.size() - 1); - CStdString localizedType = CGUIDialogVideoInfo::GetLocalizedVideoType(mediaType); + std::string localizedType = CGUIDialogVideoInfo::GetLocalizedVideoType(mediaType); if (localizedType.empty()) return true; - if (!videodb.GetSingleValue("tag", "tag.idTag", videodb.PrepareSQL("tag.strTag = '%s' AND tag.idTag IN (SELECT taglinks.idTag FROM taglinks WHERE taglinks.media_type = '%s')", strTag.c_str(), mediaType.c_str())).empty()) + if (!videodb.GetSingleValue("tag", "tag.tag_id", videodb.PrepareSQL("tag.name = '%s' AND tag.tag_id IN (SELECT tag_link.tag_id FROM tag_link WHERE tag_link.media_type = '%s')", strTag.c_str(), mediaType.c_str())).empty()) { - CStdString strError = StringUtils::Format(g_localizeStrings.Get(20463).c_str(), strTag.c_str()); + std::string strError = StringUtils::Format(g_localizeStrings.Get(20463).c_str(), strTag.c_str()); CGUIDialogOK::ShowAndGetInput(20462, "", strError, ""); return true; } int idTag = videodb.AddTag(strTag); CFileItemList items; - CStdString strLabel = StringUtils::Format(g_localizeStrings.Get(20464).c_str(), localizedType.c_str()); + std::string strLabel = StringUtils::Format(g_localizeStrings.Get(20464).c_str(), localizedType.c_str()); if (CGUIDialogVideoInfo::GetItemsForTag(strLabel, mediaType, items, idTag)) { for (int index = 0; index < items.Size(); index++) diff --git a/xbmc/video/windows/GUIWindowVideoNav.h b/xbmc/video/windows/GUIWindowVideoNav.h index 75cceb70f8..c91c6a652b 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.h +++ b/xbmc/video/windows/GUIWindowVideoNav.h @@ -58,7 +58,7 @@ protected: // override base class methods virtual bool GetDirectory(const std::string &strDirectory, CFileItemList &items); virtual void UpdateButtons(); - virtual void DoSearch(const CStdString& strSearch, CFileItemList& items); + virtual void DoSearch(const std::string& strSearch, CFileItemList& items); virtual void PlayItem(int iItem); virtual void OnDeleteItem(CFileItemPtr pItem); virtual void GetContextButtons(int itemNumber, CContextButtons &buttons); @@ -66,7 +66,7 @@ protected: virtual bool OnClick(int iItem); virtual std::string GetStartFolder(const std::string &dir); - virtual CStdString GetQuickpathName(const CStdString& strPath) const; + virtual std::string GetQuickpathName(const std::string& strPath) const; VECSOURCES m_shares; }; diff --git a/xbmc/video/windows/GUIWindowVideoPlaylist.cpp b/xbmc/video/windows/GUIWindowVideoPlaylist.cpp index 1ed47dc045..69717a06d4 100644 --- a/xbmc/video/windows/GUIWindowVideoPlaylist.cpp +++ b/xbmc/video/windows/GUIWindowVideoPlaylist.cpp @@ -329,7 +329,7 @@ bool CGUIWindowVideoPlaylist::OnPlayMedia(int iItem) else { CFileItemPtr pItem = m_vecItems->Get(iItem); - CStdString strPath = pItem->GetPath(); + std::string strPath = pItem->GetPath(); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO); // need to update Playlist FileItem's startOffset and resumePoint based on GUIWindowVideoPlaylist FileItem if (pItem->m_lStartOffset == STARTOFFSET_RESUME) @@ -371,14 +371,14 @@ void CGUIWindowVideoPlaylist::RemovePlayListItem(int iItem) /// \brief Save current playlist to playlist folder void CGUIWindowVideoPlaylist::SavePlayList() { - CStdString strNewFileName; + std::string strNewFileName; if (CGUIKeyboardFactory::ShowAndGetInput(strNewFileName, g_localizeStrings.Get(16012), false)) { // need 2 rename it - CStdString strFolder = URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "video"); + std::string strFolder = URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "video"); strNewFileName = CUtil::MakeLegalFileName(strNewFileName); strNewFileName += ".m3u"; - CStdString strPath = URIUtils::AddFileToFolder(strFolder, strNewFileName); + std::string strPath = URIUtils::AddFileToFolder(strFolder, strNewFileName); CPlayListM3U playlist; playlist.Add(*m_vecItems); @@ -499,7 +499,7 @@ bool CGUIWindowVideoPlaylist::OnContextButton(int itemNumber, CONTEXT_BUTTON but return true; case CONTEXT_BUTTON_EDIT_PARTYMODE: { - CStdString playlist = "special://profile/PartyMode-Video.xsp"; + std::string playlist = "special://profile/PartyMode-Video.xsp"; if (CGUIDialogSmartPlaylistEditor::EditPlaylist(playlist)) { // apply new rules diff --git a/xbmc/view/GUIViewControl.cpp b/xbmc/view/GUIViewControl.cpp index 3205fdc657..ed4e603745 100644 --- a/xbmc/view/GUIViewControl.cpp +++ b/xbmc/view/GUIViewControl.cpp @@ -37,8 +37,7 @@ CGUIViewControl::CGUIViewControl(void) } CGUIViewControl::~CGUIViewControl(void) -{ -} +{ } void CGUIViewControl::Reset() { @@ -157,13 +156,16 @@ void CGUIViewControl::UpdateView() int CGUIViewControl::GetSelectedItem(const CGUIControl *control) const { - if (!control || !m_fileItems) return -1; + if (!control || !m_fileItems) + return -1; + CGUIMessage msg(GUI_MSG_ITEM_SELECTED, m_parentWindow, control->GetID()); g_windowManager.SendMessage(msg, m_parentWindow); int iItem = msg.GetParam1(); if (iItem >= m_fileItems->Size()) return -1; + return iItem; } @@ -349,4 +351,3 @@ void CGUIViewControl::UpdateViewVisibility() m_visibleViews.push_back(view); } } - diff --git a/xbmc/view/GUIViewControl.h b/xbmc/view/GUIViewControl.h index 4da81a48bd..e1dfe50974 100644 --- a/xbmc/view/GUIViewControl.h +++ b/xbmc/view/GUIViewControl.h @@ -30,8 +30,8 @@ class CFileItemList; class CGUIViewControl { public: - CGUIViewControl(void); - virtual ~CGUIViewControl(void); + CGUIViewControl(); + virtual ~CGUIViewControl(); void Reset(); void SetParentWindow(int window); @@ -66,12 +66,12 @@ protected: void UpdateViewVisibility(); int GetView(VIEW_TYPE type, int id) const; - std::vector<CGUIControl *> m_allViews; - std::vector<CGUIControl *> m_visibleViews; - typedef std::vector<CGUIControl *>::const_iterator ciViews; + std::vector<CGUIControl*> m_allViews; + std::vector<CGUIControl*> m_visibleViews; + typedef std::vector<CGUIControl*>::const_iterator ciViews; - CFileItemList* m_fileItems; - int m_viewAsControl; - int m_parentWindow; - int m_currentView; + CFileItemList* m_fileItems; + int m_viewAsControl; + int m_parentWindow; + int m_currentView; }; diff --git a/xbmc/view/GUIViewState.cpp b/xbmc/view/GUIViewState.cpp index d2aba54e50..78378dd92e 100644 --- a/xbmc/view/GUIViewState.cpp +++ b/xbmc/view/GUIViewState.cpp @@ -110,64 +110,64 @@ CGUIViewState* CGUIViewState::GetViewState(int windowId, const CFileItemList& it if (url.IsProtocol("androidapp")) return new CGUIViewStateWindowPrograms(items); - if (windowId==WINDOW_MUSIC_NAV) + if (windowId == WINDOW_MUSIC_NAV) return new CGUIViewStateWindowMusicNav(items); - if (windowId==WINDOW_MUSIC_FILES) + if (windowId == WINDOW_MUSIC_FILES) return new CGUIViewStateWindowMusicSongs(items); - if (windowId==WINDOW_MUSIC_PLAYLIST) + if (windowId == WINDOW_MUSIC_PLAYLIST) return new CGUIViewStateWindowMusicPlaylist(items); - if (windowId==WINDOW_MUSIC_PLAYLIST_EDITOR) + if (windowId == WINDOW_MUSIC_PLAYLIST_EDITOR) return new CGUIViewStateWindowMusicSongs(items); - if (windowId==WINDOW_VIDEO_FILES) + if (windowId == WINDOW_VIDEO_FILES) return new CGUIViewStateWindowVideoFiles(items); - if (windowId==WINDOW_VIDEO_NAV) + if (windowId == WINDOW_VIDEO_NAV) return new CGUIViewStateWindowVideoNav(items); - if (windowId==WINDOW_VIDEO_PLAYLIST) + if (windowId == WINDOW_VIDEO_PLAYLIST) return new CGUIViewStateWindowVideoPlaylist(items); - if (windowId==WINDOW_TV_CHANNELS) + if (windowId == WINDOW_TV_CHANNELS) return new CGUIViewStateWindowPVRChannels(windowId, items); - if (windowId==WINDOW_TV_RECORDINGS) + if (windowId == WINDOW_TV_RECORDINGS) return new CGUIViewStateWindowPVRRecordings(windowId, items); - if (windowId==WINDOW_TV_GUIDE) + if (windowId == WINDOW_TV_GUIDE) return new CGUIViewStateWindowPVRGuide(windowId, items); - if (windowId==WINDOW_TV_TIMERS) + if (windowId == WINDOW_TV_TIMERS) return new CGUIViewStateWindowPVRTimers(windowId, items); - if (windowId==WINDOW_TV_SEARCH) + if (windowId == WINDOW_TV_SEARCH) return new CGUIViewStateWindowPVRSearch(windowId, items); - if (windowId==WINDOW_RADIO_CHANNELS) + if (windowId == WINDOW_RADIO_CHANNELS) return new CGUIViewStateWindowPVRChannels(windowId, items); - if (windowId==WINDOW_RADIO_RECORDINGS) + if (windowId == WINDOW_RADIO_RECORDINGS) return new CGUIViewStateWindowPVRRecordings(windowId, items); - if (windowId==WINDOW_RADIO_GUIDE) + if (windowId == WINDOW_RADIO_GUIDE) return new CGUIViewStateWindowPVRGuide(windowId, items); - if (windowId==WINDOW_RADIO_TIMERS) + if (windowId == WINDOW_RADIO_TIMERS) return new CGUIViewStateWindowPVRTimers(windowId, items); - if (windowId==WINDOW_RADIO_SEARCH) + if (windowId == WINDOW_RADIO_SEARCH) return new CGUIViewStateWindowPVRSearch(windowId, items); - if (windowId==WINDOW_PICTURES) + if (windowId == WINDOW_PICTURES) return new CGUIViewStateWindowPictures(items); - if (windowId==WINDOW_PROGRAMS) + if (windowId == WINDOW_PROGRAMS) return new CGUIViewStateWindowPrograms(items); - if (windowId==WINDOW_ADDON_BROWSER) + if (windowId == WINDOW_ADDON_BROWSER) return new CGUIViewStateAddonBrowser(items); // Use as fallback/default @@ -176,46 +176,32 @@ CGUIViewState* CGUIViewState::GetViewState(int windowId, const CFileItemList& it CGUIViewState::CGUIViewState(const CFileItemList& items) : m_items(items) { - m_currentViewAsControl=0; - m_currentSortMethod=0; + m_currentViewAsControl = 0; + m_currentSortMethod = 0; m_playlist = PLAYLIST_NONE; - m_sortOrder = SortOrderAscending; } CGUIViewState::~CGUIViewState() -{ -} - -SortOrder CGUIViewState::GetDisplaySortOrder() const -{ - // we actually treat some sort orders in reverse, so that we can have - // the one sort order variable to save but it can be ascending usually, - // and descending for the views which should be usually descending. - // default sort order for date, size, program count + rating is reversed - SortDescription sorting = GetSortMethod(); - if (sorting.sortBy == SortByDate || sorting.sortBy == SortBySize || sorting.sortBy == SortByPlaycount || - sorting.sortBy == SortByRating || sorting.sortBy == SortByProgramCount || - sorting.sortBy == SortByBitrate || sorting.sortBy == SortByListeners) - { - if (m_sortOrder == SortOrderAscending) - return SortOrderDescending; - if (m_sortOrder == SortOrderDescending) - return SortOrderAscending; - } - - return m_sortOrder; -} +{ } SortOrder CGUIViewState::SetNextSortOrder() { - if (m_sortOrder == SortOrderAscending) + if (GetSortOrder() == SortOrderAscending) SetSortOrder(SortOrderDescending); else SetSortOrder(SortOrderAscending); SaveViewState(); - return m_sortOrder; + return GetSortOrder(); +} + +SortOrder CGUIViewState::GetSortOrder() const +{ + if (m_currentSortMethod >= 0 && m_currentSortMethod < (int)m_sortMethods.size()) + return m_sortMethods[m_currentSortMethod].m_sortDescription.sortOrder; + + return SortOrderAscending; } int CGUIViewState::GetViewAsControl() const @@ -240,9 +226,8 @@ void CGUIViewState::SaveViewAsControl(int viewAsControl) SortDescription CGUIViewState::GetSortMethod() const { SortDescription sorting; - if (m_currentSortMethod>=0 && m_currentSortMethod<(int)m_sortMethods.size()) + if (m_currentSortMethod >= 0 && m_currentSortMethod < (int)m_sortMethods.size()) sorting = m_sortMethods[m_currentSortMethod].m_sortDescription; - sorting.sortOrder = m_sortOrder; return sorting; } @@ -254,7 +239,7 @@ bool CGUIViewState::HasMultipleSortMethods() const int CGUIViewState::GetSortMethodLabel() const { - if (m_currentSortMethod>=0 && m_currentSortMethod<(int)m_sortMethods.size()) + if (m_currentSortMethod >= 0 && m_currentSortMethod < (int)m_sortMethods.size()) return m_sortMethods[m_currentSortMethod].m_buttonLabel; return 551; // default sort method label 'Name' @@ -262,9 +247,9 @@ int CGUIViewState::GetSortMethodLabel() const void CGUIViewState::GetSortMethodLabelMasks(LABEL_MASKS& masks) const { - if (m_currentSortMethod>=0 && m_currentSortMethod<(int)m_sortMethods.size()) + if (m_currentSortMethod >= 0 && m_currentSortMethod < (int)m_sortMethods.size()) { - masks=m_sortMethods[m_currentSortMethod].m_labelMasks; + masks = m_sortMethods[m_currentSortMethod].m_labelMasks; return; } @@ -275,19 +260,32 @@ void CGUIViewState::GetSortMethodLabelMasks(LABEL_MASKS& masks) const return; } -void CGUIViewState::AddSortMethod(SortBy sortBy, int buttonLabel, const LABEL_MASKS &labelMasks, SortAttribute sortAttributes /* = SortAttributeNone */) +void CGUIViewState::AddSortMethod(SortBy sortBy, int buttonLabel, const LABEL_MASKS &labelMasks, SortAttribute sortAttributes /* = SortAttributeNone */, SortOrder sortOrder /* = SortOrderNone */) { - AddSortMethod(sortBy, sortAttributes, buttonLabel, labelMasks); + AddSortMethod(sortBy, sortAttributes, buttonLabel, labelMasks, sortOrder); } -void CGUIViewState::AddSortMethod(SortBy sortBy, SortAttribute sortAttributes, int buttonLabel, const LABEL_MASKS &labelMasks) +void CGUIViewState::AddSortMethod(SortBy sortBy, SortAttribute sortAttributes, int buttonLabel, const LABEL_MASKS &labelMasks, SortOrder sortOrder /* = SortOrderNone */) { for (size_t i = 0; i < m_sortMethods.size(); ++i) if (m_sortMethods[i].m_sortDescription.sortBy == sortBy) return; - SORT_METHOD_DETAILS sort; + // handle unspecified sort order + if (sortBy != SortByNone && sortOrder == SortOrderNone) + { + // the following sort methods are sorted in descending order by default + if (sortBy == SortByDate || sortBy == SortBySize || sortBy == SortByPlaycount || + sortBy == SortByRating || sortBy == SortByProgramCount || + sortBy == SortByBitrate || sortBy == SortByListeners) + sortOrder = SortOrderDescending; + else + sortOrder = SortOrderAscending; + } + + GUIViewSortDetails sort; sort.m_sortDescription.sortBy = sortBy; + sort.m_sortDescription.sortOrder = sortOrder; sort.m_sortDescription.sortAttributes = sortAttributes; sort.m_buttonLabel = buttonLabel; sort.m_labelMasks = labelMasks; @@ -296,7 +294,7 @@ void CGUIViewState::AddSortMethod(SortBy sortBy, SortAttribute sortAttributes, i void CGUIViewState::AddSortMethod(SortDescription sortDescription, int buttonLabel, const LABEL_MASKS &labelMasks) { - AddSortMethod(sortDescription.sortBy, sortDescription.sortAttributes, buttonLabel, labelMasks); + AddSortMethod(sortDescription.sortBy, sortDescription.sortAttributes, buttonLabel, labelMasks, sortDescription.sortOrder); } void CGUIViewState::SetCurrentSortMethod(int method) @@ -309,28 +307,28 @@ void CGUIViewState::SetCurrentSortMethod(int method) if (sortBy < SortByNone || sortBy > SortByRandom) return; // invalid - SetSortMethod(sortBy, sortAttributes); + SetSortMethod(sortBy); SaveViewState(); } -void CGUIViewState::SetSortMethod(SortBy sortBy, SortAttribute sortAttributes /* = SortAttributeNone */) +void CGUIViewState::SetSortMethod(SortBy sortBy, SortOrder sortOrder /* = SortOrderNone */) { for (int i = 0; i < (int)m_sortMethods.size(); ++i) { - if (m_sortMethods[i].m_sortDescription.sortBy == sortBy && - // don't care about SortAttributeIgnoreFolders as it wasn't part of the old sorting comparison - (m_sortMethods[i].m_sortDescription.sortAttributes & ~SortAttributeIgnoreFolders) == (sortAttributes & ~SortAttributeIgnoreFolders)) + if (m_sortMethods[i].m_sortDescription.sortBy == sortBy) { m_currentSortMethod = i; break; } } - SetSortOrder(m_sortOrder); + + if (sortOrder != SortOrderNone) + SetSortOrder(sortOrder); } void CGUIViewState::SetSortMethod(SortDescription sortDescription) { - return SetSortMethod(sortDescription.sortBy, sortDescription.sortAttributes); + return SetSortMethod(sortDescription.sortBy, sortDescription.sortOrder); } SortDescription CGUIViewState::SetNextSortMethod(int direction /* = 1 */) @@ -341,7 +339,6 @@ SortDescription CGUIViewState::SetNextSortMethod(int direction /* = 1 */) m_currentSortMethod = 0; if (m_currentSortMethod < 0) m_currentSortMethod = m_sortMethods.size() ? (int)m_sortMethods.size() - 1 : 0; - SetSortOrder(m_sortOrder); SaveViewState(); @@ -378,7 +375,7 @@ const std::string& CGUIViewState::GetPlaylistDirectory() void CGUIViewState::SetPlaylistDirectory(const std::string& strDirectory) { - m_strPlaylistDirectory=strDirectory; + m_strPlaylistDirectory = strDirectory; URIUtils::RemoveSlashAtEnd(m_strPlaylistDirectory); } @@ -387,10 +384,10 @@ bool CGUIViewState::IsCurrentPlaylistDirectory(const std::string& strDirectory) if (g_playlistPlayer.GetCurrentPlaylist()!=GetPlaylist()) return false; - std::string strDir=strDirectory; + std::string strDir = strDirectory; URIUtils::RemoveSlashAtEnd(strDir); - return (m_strPlaylistDirectory==strDir); + return m_strPlaylistDirectory == strDir; } bool CGUIViewState::AutoPlayNextItem() @@ -470,64 +467,55 @@ void CGUIViewState::AddLiveTVSources() } } -CGUIViewStateGeneral::CGUIViewStateGeneral(const CFileItemList& items) : CGUIViewState(items) +void CGUIViewState::SetSortOrder(SortOrder sortOrder) { - AddSortMethod(SortByLabel, 551, LABEL_MASKS("%F", "%I", "%L", "")); // Filename, size | Foldername, empty - SetSortMethod(SortByLabel); - - SetViewAsControl(DEFAULT_VIEW_LIST); + if (sortOrder == SortOrderNone) + return; - SetSortOrder(SortOrderAscending); -} + if (m_currentSortMethod < 0 || m_currentSortMethod >= (int)m_sortMethods.size()) + return; -void CGUIViewState::SetSortOrder(SortOrder sortOrder) -{ - if (GetSortMethod().sortBy == SortByNone) - m_sortOrder = SortOrderNone; - else if (sortOrder == SortOrderNone) - m_sortOrder = SortOrderAscending; - else - m_sortOrder = sortOrder; + m_sortMethods[m_currentSortMethod].m_sortDescription.sortOrder = sortOrder; } void CGUIViewState::LoadViewState(const std::string &path, int windowID) { // get our view state from the db CViewDatabase db; - if (db.Open()) + if (!db.Open()) + return; + + CViewState state; + if (db.GetViewState(path, windowID, state, CSettings::Get().GetString("lookandfeel.skin")) || + db.GetViewState(path, windowID, state, "")) { - CViewState state; - if (db.GetViewState(path, windowID, state, CSettings::Get().GetString("lookandfeel.skin")) || - db.GetViewState(path, windowID, state, "")) - { - SetViewAsControl(state.m_viewMode); - SetSortMethod(state.m_sortDescription); - SetSortOrder(state.m_sortDescription.sortOrder); - } - db.Close(); + SetViewAsControl(state.m_viewMode); + SetSortMethod(state.m_sortDescription); } } void CGUIViewState::SaveViewToDb(const std::string &path, int windowID, CViewState *viewState) { CViewDatabase db; - if (db.Open()) - { - SortDescription sorting = GetSortMethod(); - CViewState state(m_currentViewAsControl, sorting.sortBy, m_sortOrder, sorting.sortAttributes); - if (viewState) - *viewState = state; - db.SetViewState(path, windowID, state, CSettings::Get().GetString("lookandfeel.skin")); - db.Close(); - if (viewState) - CSettings::Get().Save(); - } + if (!db.Open()) + return; + + SortDescription sorting = GetSortMethod(); + CViewState state(m_currentViewAsControl, sorting.sortBy, sorting.sortOrder, sorting.sortAttributes); + if (viewState != NULL) + *viewState = state; + + db.SetViewState(path, windowID, state, CSettings::Get().GetString("lookandfeel.skin")); + db.Close(); + + if (viewState != NULL) + CSettings::Get().Save(); } void CGUIViewState::AddPlaylistOrder(const CFileItemList &items, LABEL_MASKS label_masks) { SortBy sortBy = SortByPlaylistOrder; - int sortLabel = 559; - SortOrder sortOrder = SortOrderAscending; + int sortLabel = 559; + SortOrder sortOrder = SortOrderAscending; if (items.HasProperty(PROPERTY_SORT_ORDER)) { sortBy = (SortBy)items.GetProperty(PROPERTY_SORT_ORDER).asInteger(); @@ -537,18 +525,25 @@ void CGUIViewState::AddPlaylistOrder(const CFileItemList &items, LABEL_MASKS lab sortOrder = items.GetProperty(PROPERTY_SORT_ASCENDING).asBoolean() ? SortOrderAscending : SortOrderDescending; } } - AddSortMethod(sortBy, sortLabel, label_masks); - SetSortMethod(sortBy); - SetSortOrder(sortOrder); + + AddSortMethod(sortBy, sortLabel, label_masks, SortAttributeNone, sortOrder); + SetSortMethod(sortBy, sortOrder); } +CGUIViewStateGeneral::CGUIViewStateGeneral(const CFileItemList& items) : CGUIViewState(items) +{ + AddSortMethod(SortByLabel, 551, LABEL_MASKS("%F", "%I", "%L", "")); // Filename, size | Foldername, empty + SetSortMethod(SortByLabel); + + SetViewAsControl(DEFAULT_VIEW_LIST); +} CGUIViewStateFromItems::CGUIViewStateFromItems(const CFileItemList &items) : CGUIViewState(items) { - const vector<SORT_METHOD_DETAILS> &details = items.GetSortDetails(); + const vector<GUIViewSortDetails> &details = items.GetSortDetails(); for (unsigned int i = 0; i < details.size(); i++) { - const SORT_METHOD_DETAILS sort = details[i]; + const GUIViewSortDetails sort = details[i]; AddSortMethod(sort.m_sortDescription, sort.m_buttonLabel, sort.m_labelMasks); } // TODO: Should default sort/view mode be specified? @@ -556,7 +551,6 @@ CGUIViewStateFromItems::CGUIViewStateFromItems(const CFileItemList &items) : CGU SetViewAsControl(DEFAULT_VIEW_LIST); - SetSortOrder(SortOrderAscending); if (items.IsPlugin()) { CURL url(items.GetPath()); @@ -570,6 +564,7 @@ CGUIViewStateFromItems::CGUIViewStateFromItems(const CFileItemList &items) : CGU m_playlist = PLAYLIST_VIDEO; } } + LoadViewState(items.GetPath(), g_windowManager.GetActiveWindow()); } @@ -582,7 +577,6 @@ CGUIViewStateLibrary::CGUIViewStateLibrary(const CFileItemList &items) : CGUIVie { AddSortMethod(SortByNone, 551, LABEL_MASKS("%F", "%I", "%L", "")); // Filename, Size | Foldername, empty SetSortMethod(SortByNone); - SetSortOrder(SortOrderNone); SetViewAsControl(DEFAULT_VIEW_LIST); @@ -593,4 +587,3 @@ void CGUIViewStateLibrary::SaveViewState() { SaveViewToDb(m_items.GetPath(), g_windowManager.GetActiveWindow()); } - diff --git a/xbmc/view/GUIViewState.h b/xbmc/view/GUIViewState.h index 9c34bf0f9d..2a6eba6feb 100644 --- a/xbmc/view/GUIViewState.h +++ b/xbmc/view/GUIViewState.h @@ -45,23 +45,26 @@ public: void GetSortMethodLabelMasks(LABEL_MASKS& masks) const; SortOrder SetNextSortOrder(); - SortOrder GetSortOrder() const { return m_sortOrder; }; - SortOrder GetDisplaySortOrder() const; + SortOrder GetSortOrder() const; + virtual bool HideExtensions(); virtual bool HideParentDirItems(); virtual bool DisableAddSourceButtons(); + virtual int GetPlaylist(); const std::string& GetPlaylistDirectory(); void SetPlaylistDirectory(const std::string& strDirectory); bool IsCurrentPlaylistDirectory(const std::string& strDirectory); virtual bool AutoPlayNextItem(); + virtual std::string GetLockType(); virtual std::string GetExtensions(); virtual VECSOURCES& GetSources(); protected: CGUIViewState(const CFileItemList& items); // no direct object creation, use GetViewState() - virtual void SaveViewState()=0; + + virtual void SaveViewState() = 0; virtual void SaveViewToDb(const std::string &path, int windowID, CViewState *viewState = NULL); void LoadViewState(const std::string &path, int windowID); @@ -83,24 +86,22 @@ protected: */ void AddPlaylistOrder(const CFileItemList &items, LABEL_MASKS label_masks); - void AddSortMethod(SortBy sortBy, int buttonLabel, const LABEL_MASKS &labelMasks, SortAttribute sortAttributes = SortAttributeNone); - void AddSortMethod(SortBy sortBy, SortAttribute sortAttributes, int buttonLabel, const LABEL_MASKS &labelMasks); + void AddSortMethod(SortBy sortBy, int buttonLabel, const LABEL_MASKS &labelMasks, SortAttribute sortAttributes = SortAttributeNone, SortOrder sortOrder = SortOrderNone); + void AddSortMethod(SortBy sortBy, SortAttribute sortAttributes, int buttonLabel, const LABEL_MASKS &labelMasks, SortOrder sortOrder = SortOrderNone); void AddSortMethod(SortDescription sortDescription, int buttonLabel, const LABEL_MASKS &labelMasks); - void SetSortMethod(SortBy sortBy, SortAttribute sortAttributes = SortAttributeNone); + void SetSortMethod(SortBy sortBy, SortOrder sortOrder = SortOrderNone); void SetSortMethod(SortDescription sortDescription); void SetSortOrder(SortOrder sortOrder); - const CFileItemList& m_items; - static VECSOURCES m_sources; + const CFileItemList& m_items; int m_currentViewAsControl; int m_playlist; - std::vector<SORT_METHOD_DETAILS> m_sortMethods; + std::vector<GUIViewSortDetails> m_sortMethods; int m_currentSortMethod; - SortOrder m_sortOrder; - + static VECSOURCES m_sources; static std::string m_strPlaylistDirectory; }; @@ -110,7 +111,7 @@ public: CGUIViewStateGeneral(const CFileItemList& items); protected: - virtual void SaveViewState() {}; + virtual void SaveViewState() { } }; class CGUIViewStateFromItems : public CGUIViewState diff --git a/xbmc/view/ViewDatabase.cpp b/xbmc/view/ViewDatabase.cpp index 0d986383e0..d937ecebf1 100644 --- a/xbmc/view/ViewDatabase.cpp +++ b/xbmc/view/ViewDatabase.cpp @@ -30,19 +30,12 @@ #include "dbwrappers/dataset.h" #include "SortFileItem.h" - -//******************************************************************************************************************************** CViewDatabase::CViewDatabase(void) -{ -} +{ } -//******************************************************************************************************************************** CViewDatabase::~CViewDatabase(void) -{ +{ } -} - -//******************************************************************************************************************************** bool CViewDatabase::Open() { return CDatabase::Open(); @@ -52,14 +45,14 @@ void CViewDatabase::CreateTables() { CLog::Log(LOGINFO, "create view table"); m_pDS->exec("CREATE TABLE view (" - "idView integer primary key," - "window integer," - "path text," - "viewMode integer," - "sortMethod integer," - "sortOrder integer," - "sortAttributes integer," - "skin text)\n"); + "idView integer primary key," + "window integer," + "path text," + "viewMode integer," + "sortMethod integer," + "sortOrder integer," + "sortAttributes integer," + "skin text)"); } void CViewDatabase::CreateAnalytics() diff --git a/xbmc/view/ViewDatabase.h b/xbmc/view/ViewDatabase.h index a5f076539f..15291f385f 100644 --- a/xbmc/view/ViewDatabase.h +++ b/xbmc/view/ViewDatabase.h @@ -26,8 +26,8 @@ class CViewState; class CViewDatabase : public CDatabase { public: - CViewDatabase(void); - virtual ~CViewDatabase(void); + CViewDatabase(); + virtual ~CViewDatabase(); virtual bool Open(); bool GetViewState(const std::string &path, int windowID, CViewState &state, const std::string &skin); @@ -38,6 +38,6 @@ protected: virtual void CreateTables(); virtual void CreateAnalytics(); virtual void UpdateTables(int version); - virtual int GetSchemaVersion() const { return 6; }; - const char *GetBaseDBName() const { return "ViewModes"; }; + virtual int GetSchemaVersion() const { return 6; } + const char *GetBaseDBName() const { return "ViewModes"; } }; diff --git a/xbmc/win32/WIN32Util.cpp b/xbmc/win32/WIN32Util.cpp index 9697fc784c..7d5ea8863e 100644 --- a/xbmc/win32/WIN32Util.cpp +++ b/xbmc/win32/WIN32Util.cpp @@ -412,7 +412,7 @@ std::string CWIN32Util::GetSystemPath() std::string CWIN32Util::GetProfilePath() { std::string strProfilePath; - CStdString strHomePath; + std::string strHomePath; CUtil::GetHomePath(strHomePath); @@ -808,7 +808,7 @@ bool CWIN32Util::HasGLDefaultDrivers() { unsigned int a=0,b=0; - CStdString strVendor = g_Windowing.GetRenderVendor(); + std::string strVendor = g_Windowing.GetRenderVendor(); g_Windowing.GetRenderVersion(a, b); if(strVendor.find("Microsoft")!=strVendor.npos && a==1 && b==1) @@ -972,9 +972,9 @@ extern "C" { FILE *fopen_utf8(const char *_Filename, const char *_Mode) { - CStdStringW wfilename, wmode; + std::string modetmp = _Mode; + std::wstring wfilename, wmode(modetmp.begin(), modetmp.end()); g_charsetConverter.utf8ToW(_Filename, wfilename, false); - wmode = _Mode; return _wfopen(wfilename.c_str(), wmode.c_str()); } } diff --git a/xbmc/win32/WMIInterface.cpp b/xbmc/win32/WMIInterface.cpp index 38072bfe7b..0c1c3abcf0 100644 --- a/xbmc/win32/WMIInterface.cpp +++ b/xbmc/win32/WMIInterface.cpp @@ -188,9 +188,9 @@ void CWIN32Wmi::testquery() pclsObj = NULL; } -std::vector<CStdString> CWIN32Wmi::GetWMIStrVector(CStdString& strQuery, CStdStringW& strProperty) +std::vector<std::string> CWIN32Wmi::GetWMIStrVector(std::string& strQuery, std::wstring& strProperty) { - std::vector<CStdString> strResult; + std::vector<std::string> strResult; pEnumerator = NULL; pclsObj = NULL; @@ -236,7 +236,7 @@ std::vector<CStdString> CWIN32Wmi::GetWMIStrVector(CStdString& strQuery, CStdStr return strResult; } -CStdString CWIN32Wmi::GetWMIString(CStdString& strQuery, CStdStringW& strProperty) +std::string CWIN32Wmi::GetWMIString(std::string& strQuery, std::wstring& strProperty) { return GetWMIStrVector(strQuery, strProperty)[0]; } diff --git a/xbmc/win32/WMIInterface.h b/xbmc/win32/WMIInterface.h index c62c4d4aa8..ad16f1141b 100644 --- a/xbmc/win32/WMIInterface.h +++ b/xbmc/win32/WMIInterface.h @@ -23,7 +23,7 @@ #include <Wbemidl.h> #pragma comment(lib, "wbemuuid.lib") #pragma comment(lib, "comsuppw.lib") - +#include <string> class CWIN32Wmi { @@ -35,8 +35,8 @@ public: void Release(); void testquery(); - std::vector<CStdString> GetWMIStrVector(CStdString& strQuery, CStdStringW& strProperty); - CStdString GetWMIString(CStdString& strQuery, CStdStringW& strProperty); + std::vector<std::string> GetWMIStrVector(std::string& strQuery, std::wstring& strProperty); + std::string GetWMIString(std::string& strQuery, std::wstring& strProperty); diff --git a/xbmc/win32/Win32DelayedDllLoad.cpp b/xbmc/win32/Win32DelayedDllLoad.cpp index be3130f9d3..87a6da37a8 100644 --- a/xbmc/win32/Win32DelayedDllLoad.cpp +++ b/xbmc/win32/Win32DelayedDllLoad.cpp @@ -56,49 +56,49 @@ FARPROC WINAPI delayHookNotifyFunc (unsigned dliNotify, PDelayLoadInfo pdli) } if (stricmp(pdli->szDll, "libxslt.dll") == 0) { - CStdString strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/libxslt.dll"); + std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/libxslt.dll"); HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH); return (FARPROC)hMod; } if (stricmp(pdli->szDll, "avcodec-56.dll") == 0) { - CStdString strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/dvdplayer/avcodec-56.dll"); + std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/dvdplayer/avcodec-56.dll"); HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH); return (FARPROC)hMod; } if (stricmp(pdli->szDll, "avfilter-5.dll") == 0) { - CStdString strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/dvdplayer/avfilter-5.dll"); + std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/dvdplayer/avfilter-5.dll"); HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH); return (FARPROC)hMod; } if (stricmp(pdli->szDll, "avformat-56.dll") == 0) { - CStdString strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/dvdplayer/avformat-56.dll"); + std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/dvdplayer/avformat-56.dll"); HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH); return (FARPROC)hMod; } if (stricmp(pdli->szDll, "avutil-54.dll") == 0) { - CStdString strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/dvdplayer/avutil-54.dll"); + std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/dvdplayer/avutil-54.dll"); HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH); return (FARPROC)hMod; } if (stricmp(pdli->szDll, "postproc-53.dll") == 0) { - CStdString strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/dvdplayer/postproc-53.dll"); + std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/dvdplayer/postproc-53.dll"); HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH); return (FARPROC)hMod; } if (stricmp(pdli->szDll, "swresample-1.dll") == 0) { - CStdString strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/dvdplayer/swresample-1.dll"); + std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/dvdplayer/swresample-1.dll"); HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH); return (FARPROC)hMod; } if (stricmp(pdli->szDll, "swscale-3.dll") == 0) { - CStdString strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/dvdplayer/swscale-3.dll"); + std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/dvdplayer/swscale-3.dll"); HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH); return (FARPROC)hMod; } @@ -123,4 +123,4 @@ FARPROC WINAPI delayHookFailureFunc (unsigned dliNotify, PDelayLoadInfo pdli) // assign hook functions PfnDliHook __pfnDliNotifyHook2 = delayHookNotifyFunc; -PfnDliHook __pfnDliFailureHook2 = delayHookFailureFunc;
\ No newline at end of file +PfnDliHook __pfnDliFailureHook2 = delayHookFailureFunc; diff --git a/xbmc/win32/XBMC_PC.rc.in b/xbmc/win32/XBMC_PC.rc.in index 7f215abbaf..b76f15dd04 100644 --- a/xbmc/win32/XBMC_PC.rc.in +++ b/xbmc/win32/XBMC_PC.rc.in @@ -71,12 +71,12 @@ BEGIN BEGIN VALUE "CompanyName", "@COMPANY_NAME@" VALUE "FileDescription", "@APP_NAME@" - VALUE "FileVersion", "@APP_VERSION_MAJOR@.@APP_VERSION_MINOR@-@APP_VERSION_TAG@" + VALUE "FileVersion", "@APP_VERSION@" VALUE "InternalName", "@APP_NAME@.exe" VALUE "LegalCopyright", "Copyright (c) @COMPANY_NAME@. All rights reserved." VALUE "OriginalFilename", "@APP_NAME@.exe" VALUE "ProductName", "@APP_NAME@ for Windows" - VALUE "ProductVersion", "@APP_VERSION_MAJOR@.@APP_VERSION_MINOR@-@APP_VERSION_TAG@" + VALUE "ProductVersion", "@APP_VERSION@" END END BLOCK "VarFileInfo" diff --git a/xbmc/windowing/WinEventsSDL.cpp b/xbmc/windowing/WinEventsSDL.cpp index 13bb2c398b..5c031528d6 100644 --- a/xbmc/windowing/WinEventsSDL.cpp +++ b/xbmc/windowing/WinEventsSDL.cpp @@ -457,19 +457,6 @@ bool CWinEventsSDL::ProcessOSXShortcuts(SDL_Event& event) CApplicationMessenger::Get().Minimize(); return true; - case SDLK_v: // CMD-v to paste clipboard text - if (g_Windowing.IsTextInputEnabled()) - { - const char *szStr = Cocoa_Paste(); - if (szStr) - { - CGUIMessage msg(GUI_MSG_INPUT_TEXT, 0, 0); - msg.SetLabel(szStr); - g_windowManager.SendMessage(msg, g_windowManager.GetFocusedWindow()); - } - } - return true; - default: return false; } diff --git a/xbmc/windowing/WinEventsX11.cpp b/xbmc/windowing/WinEventsX11.cpp index 869fb1d582..41f6e98faf 100644 --- a/xbmc/windowing/WinEventsX11.cpp +++ b/xbmc/windowing/WinEventsX11.cpp @@ -461,8 +461,8 @@ bool CWinEventsX11Imp::MessagePump() case XLookupChars: case XLookupBoth: { - CStdString data(WinEvents->m_keybuf, len); - CStdStringW keys; + std::string data(WinEvents->m_keybuf, len); + std::wstring keys; g_charsetConverter.utf8ToW(data, keys, false); if (keys.length() == 0) diff --git a/xbmc/windowing/WinSystem.h b/xbmc/windowing/WinSystem.h index 59aeb2cebd..67d306702a 100644 --- a/xbmc/windowing/WinSystem.h +++ b/xbmc/windowing/WinSystem.h @@ -60,7 +60,7 @@ public: // windowing interfaces virtual bool InitWindowSystem(); virtual bool DestroyWindowSystem(){ return false; } - virtual bool CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) = 0; + virtual bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) = 0; virtual bool DestroyWindow(){ return false; } virtual bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop) = 0; virtual bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays) = 0; diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp index 83ad7df098..1af749683c 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -142,7 +142,7 @@ bool CWinSystemX11::DestroyWindowSystem() return true; } -bool CWinSystemX11::CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) +bool CWinSystemX11::CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) { if(!SetFullScreen(fullScreen, res, false)) return false; @@ -364,7 +364,7 @@ void CWinSystemX11::UpdateResolutions() std::vector<XOutput> outputs = g_xrandr.GetModes(); for (size_t i=0; i<outputs.size(); i++) { - if (outputs[i].name.Equals(m_userOutput.c_str())) + if (StringUtils::EqualsNoCase(outputs[i].name, m_userOutput)) continue; g_xrandr.TurnOffOutput(outputs[i].name); } @@ -457,7 +457,7 @@ bool CWinSystemX11::HasCalibration(const RESOLUTION_INFO &resInfo) XOutput *out = g_xrandr.GetOutput(m_currentOutput); // keep calibrations done on a not connected output - if (!out->name.Equals(resInfo.strOutput)) + if (!StringUtils::EqualsNoCase(out->name, resInfo.strOutput)) return true; // keep calibrations not updated with resolution data @@ -486,7 +486,7 @@ bool CWinSystemX11::HasCalibration(const RESOLUTION_INFO &resInfo) return false; } -void CWinSystemX11::GetConnectedOutputs(std::vector<CStdString> *outputs) +void CWinSystemX11::GetConnectedOutputs(std::vector<std::string> *outputs) { vector<XOutput> outs; g_xrandr.Query(true); @@ -498,9 +498,9 @@ void CWinSystemX11::GetConnectedOutputs(std::vector<CStdString> *outputs) } } -bool CWinSystemX11::IsCurrentOutput(CStdString output) +bool CWinSystemX11::IsCurrentOutput(std::string output) { - return (output.Equals("Default")) || (m_currentOutput.compare(output) == 0); + return (StringUtils::EqualsNoCase(output, "Default")) || (m_currentOutput.compare(output.c_str()) == 0); } #if defined(HAS_EGL) @@ -899,7 +899,7 @@ void CWinSystemX11::RecreateWindow() for (i = RES_DESKTOP; i < CDisplaySettings::Get().ResolutionInfoSize(); ++i) { res = CDisplaySettings::Get().GetResolutionInfo(i); - if (CDisplaySettings::Get().GetResolutionInfo(i).strId.Equals(mode.id)) + if (StringUtils::EqualsNoCase(CDisplaySettings::Get().GetResolutionInfo(i).strId, mode.id)) { found = true; break; diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h index d15655482d..5ac2482a79 100644 --- a/xbmc/windowing/X11/WinSystemX11.h +++ b/xbmc/windowing/X11/WinSystemX11.h @@ -49,7 +49,7 @@ public: // CWinSystemBase virtual bool InitWindowSystem(); virtual bool DestroyWindowSystem(); - virtual bool CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction); + virtual bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction); virtual bool DestroyWindow(); virtual bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop); virtual bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays); @@ -84,8 +84,8 @@ public: EGLContext GetEGLContext() const { return m_eglContext;} #endif void NotifyXRREvent(); - void GetConnectedOutputs(std::vector<CStdString> *outputs); - bool IsCurrentOutput(CStdString output); + void GetConnectedOutputs(std::vector<std::string> *outputs); + bool IsCurrentOutput(std::string output); void RecreateWindow(); int GetCrtc() { return m_crtc; } diff --git a/xbmc/windowing/X11/WinSystemX11GL.cpp b/xbmc/windowing/X11/WinSystemX11GL.cpp index 3c154cd995..4c3537f168 100644 --- a/xbmc/windowing/X11/WinSystemX11GL.cpp +++ b/xbmc/windowing/X11/WinSystemX11GL.cpp @@ -151,7 +151,7 @@ bool CWinSystemX11GL::IsExtSupported(const char* extension) if(strncmp(extension, "GLX_", 4) != 0) return CRenderSystemGL::IsExtSupported(extension); - CStdString name; + std::string name; name = " "; name += extension; @@ -160,7 +160,7 @@ bool CWinSystemX11GL::IsExtSupported(const char* extension) return m_glxext.find(name) != std::string::npos; } -bool CWinSystemX11GL::CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) +bool CWinSystemX11GL::CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) { if(!CWinSystemX11::CreateNewWindow(name, fullScreen, res, userFunction)) return false; diff --git a/xbmc/windowing/X11/WinSystemX11GL.h b/xbmc/windowing/X11/WinSystemX11GL.h index 2436132b24..dc3ad22f75 100644 --- a/xbmc/windowing/X11/WinSystemX11GL.h +++ b/xbmc/windowing/X11/WinSystemX11GL.h @@ -32,7 +32,7 @@ class CWinSystemX11GL : public CWinSystemX11, public CRenderSystemGL public: CWinSystemX11GL(); virtual ~CWinSystemX11GL(); - virtual bool CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction); + virtual bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction); virtual bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop); virtual bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays); @@ -42,7 +42,7 @@ protected: virtual bool PresentRenderImpl(const CDirtyRegionList& dirty); virtual void SetVSyncImpl(bool enable); - CStdString m_glxext; + std::string m_glxext; int (*m_glXGetVideoSyncSGI)(unsigned int*); int (*m_glXWaitVideoSyncSGI)(int, int, unsigned int*); diff --git a/xbmc/windowing/X11/WinSystemX11GLES.cpp b/xbmc/windowing/X11/WinSystemX11GLES.cpp index 4bbe5b134b..4dc39072e9 100644 --- a/xbmc/windowing/X11/WinSystemX11GLES.cpp +++ b/xbmc/windowing/X11/WinSystemX11GLES.cpp @@ -58,7 +58,7 @@ bool CWinSystemX11GLES::IsExtSupported(const char* extension) if(strncmp(extension, "EGL_", 4) != 0) return CRenderSystemGLES::IsExtSupported(extension); - CStdString name; + std::string name; name = " "; name += extension; @@ -67,7 +67,7 @@ bool CWinSystemX11GLES::IsExtSupported(const char* extension) return m_eglext.find(name) != std::string::npos; } -bool CWinSystemX11GLES::CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) +bool CWinSystemX11GLES::CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) { if(!CWinSystemX11::CreateNewWindow(name, fullScreen, res, userFunction)) return false; diff --git a/xbmc/windowing/X11/WinSystemX11GLES.h b/xbmc/windowing/X11/WinSystemX11GLES.h index 81819e3e2a..1df3e6ad66 100644 --- a/xbmc/windowing/X11/WinSystemX11GLES.h +++ b/xbmc/windowing/X11/WinSystemX11GLES.h @@ -31,7 +31,7 @@ class CWinSystemX11GLES : public CWinSystemX11, public CRenderSystemGLES public: CWinSystemX11GLES(); virtual ~CWinSystemX11GLES(); - virtual bool CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction); + virtual bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction); virtual bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop); virtual bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays); @@ -41,7 +41,7 @@ protected: virtual bool PresentRenderImpl(const CDirtyRegionList& dirty); virtual void SetVSyncImpl(bool enable); - CStdString m_eglext; + std::string m_eglext; }; XBMC_GLOBAL_REF(CWinSystemX11GLES,g_Windowing); diff --git a/xbmc/windowing/X11/XRandR.cpp b/xbmc/windowing/X11/XRandR.cpp index 0a3cdeec8b..458b852335 100644 --- a/xbmc/windowing/X11/XRandR.cpp +++ b/xbmc/windowing/X11/XRandR.cpp @@ -154,7 +154,7 @@ bool CXRandR::Query(bool force, int screennum, bool ignoreoff) return m_outputs.size() > 0; } -bool CXRandR::TurnOffOutput(CStdString name) +bool CXRandR::TurnOffOutput(const std::string& name) { XOutput *output = GetOutput(name); if (!output) @@ -181,7 +181,7 @@ bool CXRandR::TurnOffOutput(CStdString name) return true; } -bool CXRandR::TurnOnOutput(CStdString name) +bool CXRandR::TurnOnOutput(const std::string& name) { XOutput *output = GetOutput(name); if (!output) @@ -346,7 +346,7 @@ bool CXRandR::SetMode(XOutput output, XMode mode) return true; } -XMode CXRandR::GetCurrentMode(CStdString outputName) +XMode CXRandR::GetCurrentMode(const std::string& outputName) { Query(); XMode result; @@ -369,7 +369,7 @@ XMode CXRandR::GetCurrentMode(CStdString outputName) return result; } -XMode CXRandR::GetPreferredMode(CStdString outputName) +XMode CXRandR::GetPreferredMode(const std::string& outputName) { Query(); XMode result; @@ -410,8 +410,8 @@ void CXRandR::LoadCustomModeLinesToAllOutputs(void) } char cmd[255]; - CStdString name; - CStdString strModeLine; + std::string name; + std::string strModeLine; for (TiXmlElement* modeline = pRootElement->FirstChildElement("modeline"); modeline; modeline = modeline->NextSiblingElement("modeline")) { @@ -449,7 +449,7 @@ void CXRandR::SetNumScreens(unsigned int num) m_bInit = false; } -bool CXRandR::IsOutputConnected(CStdString name) +bool CXRandR::IsOutputConnected(const std::string& name) { bool result = false; Query(); @@ -465,7 +465,7 @@ bool CXRandR::IsOutputConnected(CStdString name) return result; } -XOutput* CXRandR::GetOutput(CStdString outputName) +XOutput* CXRandR::GetOutput(const std::string& outputName) { XOutput *result = 0; Query(); diff --git a/xbmc/windowing/X11/XRandR.h b/xbmc/windowing/X11/XRandR.h index 4538bad7a9..94deb29510 100644 --- a/xbmc/windowing/X11/XRandR.h +++ b/xbmc/windowing/X11/XRandR.h @@ -25,7 +25,7 @@ #ifdef HAS_XRANDR -#include "utils/StdString.h" +#include <string> #include <vector> #include <map> @@ -59,8 +59,8 @@ public: return false; return true; } - CStdString id; - CStdString name; + std::string id; + std::string name; float hz; bool isPreferred; bool isCurrent; @@ -77,7 +77,7 @@ public: isConnected=false; w=h=x=y=wmm=hmm=0; } - CStdString name; + std::string name; bool isConnected; int screen; int w; @@ -98,16 +98,16 @@ public: bool Query(bool force=false, bool ignoreoff=true); bool Query(bool force, int screennum, bool ignoreoff=true); std::vector<XOutput> GetModes(void); - XMode GetCurrentMode(CStdString outputName); - XMode GetPreferredMode(CStdString outputName); - XOutput *GetOutput(CStdString outputName); + XMode GetCurrentMode(const std::string& outputName); + XMode GetPreferredMode(const std::string& outputName); + XOutput *GetOutput(const std::string& outputName); bool SetMode(XOutput output, XMode mode); void LoadCustomModeLinesToAllOutputs(void); void SaveState(); void SetNumScreens(unsigned int num); - bool IsOutputConnected(CStdString name); - bool TurnOffOutput(CStdString name); - bool TurnOnOutput(CStdString name); + bool IsOutputConnected(const std::string& name); + bool TurnOffOutput(const std::string& name); + bool TurnOnOutput(const std::string& name); int GetCrtc(int x, int y); //bool Has1080i(); //bool Has1080p(); @@ -117,8 +117,8 @@ public: private: bool m_bInit; std::vector<XOutput> m_outputs; - CStdString m_currentOutput; - CStdString m_currentMode; + std::string m_currentOutput; + std::string m_currentMode; unsigned int m_numScreens; }; diff --git a/xbmc/windowing/egl/EGLNativeType.h b/xbmc/windowing/egl/EGLNativeType.h index 97011f467c..aa5a1c5472 100644 --- a/xbmc/windowing/egl/EGLNativeType.h +++ b/xbmc/windowing/egl/EGLNativeType.h @@ -20,6 +20,9 @@ * */ +#include <string> +#include <vector> + #include "guilib/Resolution.h" #include "EGLQuirks.h" diff --git a/xbmc/windowing/egl/EGLNativeTypeAmlogic.cpp b/xbmc/windowing/egl/EGLNativeTypeAmlogic.cpp index 70648363ac..f2073cb5f9 100644 --- a/xbmc/windowing/egl/EGLNativeTypeAmlogic.cpp +++ b/xbmc/windowing/egl/EGLNativeTypeAmlogic.cpp @@ -22,7 +22,9 @@ #include "guilib/gui3d.h" #include "utils/AMLUtils.h" #include "utils/StringUtils.h" +#include "utils/SysfsUtils.h" +#include <stdio.h> #include <stdlib.h> #include <linux/fb.h> #include <sys/ioctl.h> @@ -49,13 +51,12 @@ CEGLNativeTypeAmlogic::~CEGLNativeTypeAmlogic() bool CEGLNativeTypeAmlogic::CheckCompatibility() { - char name[256] = {0}; + std::string name; std::string modalias = "/sys/class/graphics/" + m_framebuffer_name + "/device/modalias"; - aml_get_sysfs_str(modalias.c_str(), name, 255); - CStdString strName = name; - StringUtils::Trim(strName); - if (strName == "platform:mesonfb") + SysfsUtils::GetString(modalias, name); + StringUtils::Trim(name); + if (name == "platform:mesonfb") return true; return false; } @@ -127,9 +128,9 @@ bool CEGLNativeTypeAmlogic::DestroyNativeWindow() bool CEGLNativeTypeAmlogic::GetNativeResolution(RESOLUTION_INFO *res) const { - char mode[256] = {0}; - aml_get_sysfs_str("/sys/class/display/mode", mode, 255); - return aml_mode_to_resolution(mode, res); + std::string mode; + SysfsUtils::GetString("/sys/class/display/mode", mode); + return aml_mode_to_resolution(mode.c_str(), res); } bool CEGLNativeTypeAmlogic::SetNativeResolution(const RESOLUTION_INFO &res) @@ -180,8 +181,8 @@ bool CEGLNativeTypeAmlogic::SetNativeResolution(const RESOLUTION_INFO &res) bool CEGLNativeTypeAmlogic::ProbeResolutions(std::vector<RESOLUTION_INFO> &resolutions) { - char valstr[256] = {0}; - aml_get_sysfs_str("/sys/class/amhdmitx/amhdmitx0/disp_cap", valstr, 255); + std::string valstr; + SysfsUtils::GetString("/sys/class/amhdmitx/amhdmitx0/disp_cap", valstr); std::vector<std::string> probe_str = StringUtils::Split(valstr, "\n"); resolutions.clear(); @@ -210,15 +211,15 @@ bool CEGLNativeTypeAmlogic::GetPreferredResolution(RESOLUTION_INFO *res) const bool CEGLNativeTypeAmlogic::ShowWindow(bool show) { std::string blank_framebuffer = "/sys/class/graphics/" + m_framebuffer_name + "/blank"; - aml_set_sysfs_int(blank_framebuffer.c_str(), show ? 0 : 1); + SysfsUtils::SetInt(blank_framebuffer.c_str(), show ? 0 : 1); return true; } bool CEGLNativeTypeAmlogic::SetDisplayResolution(const char *resolution) { - CStdString mode = resolution; + std::string mode = resolution; // switch display resolution - aml_set_sysfs_str("/sys/class/display/mode", mode.c_str()); + SysfsUtils::SetString("/sys/class/display/mode", mode.c_str()); SetupVideoScaling(mode.c_str()); return true; @@ -226,67 +227,67 @@ bool CEGLNativeTypeAmlogic::SetDisplayResolution(const char *resolution) void CEGLNativeTypeAmlogic::SetupVideoScaling(const char *mode) { - aml_set_sysfs_int("/sys/class/graphics/fb0/blank", 1); - aml_set_sysfs_int("/sys/class/graphics/fb0/free_scale", 0); - aml_set_sysfs_int("/sys/class/graphics/fb1/free_scale", 0); - aml_set_sysfs_int("/sys/class/ppmgr/ppscaler", 0); + SysfsUtils::SetInt("/sys/class/graphics/fb0/blank", 1); + SysfsUtils::SetInt("/sys/class/graphics/fb0/free_scale", 0); + SysfsUtils::SetInt("/sys/class/graphics/fb1/free_scale", 0); + SysfsUtils::SetInt("/sys/class/ppmgr/ppscaler", 0); if (strstr(mode, "1080")) { - aml_set_sysfs_str("/sys/class/graphics/fb0/request2XScale", "8"); - aml_set_sysfs_str("/sys/class/graphics/fb1/scale_axis", "1280 720 1920 1080"); - aml_set_sysfs_str("/sys/class/graphics/fb1/scale", "0x10001"); + SysfsUtils::SetString("/sys/class/graphics/fb0/request2XScale", "8"); + SysfsUtils::SetString("/sys/class/graphics/fb1/scale_axis", "1280 720 1920 1080"); + SysfsUtils::SetString("/sys/class/graphics/fb1/scale", "0x10001"); } else { - aml_set_sysfs_str("/sys/class/graphics/fb0/request2XScale", "16 1280 720"); + SysfsUtils::SetString("/sys/class/graphics/fb0/request2XScale", "16 1280 720"); } - aml_set_sysfs_int("/sys/class/graphics/fb0/blank", 0); + SysfsUtils::SetInt("/sys/class/graphics/fb0/blank", 0); } void CEGLNativeTypeAmlogic::EnableFreeScale() { // enable OSD free scale using frame buffer size of 720p - aml_set_sysfs_int("/sys/class/graphics/fb0/free_scale", 0); - aml_set_sysfs_int("/sys/class/graphics/fb1/free_scale", 0); - aml_set_sysfs_int("/sys/class/graphics/fb0/scale_width", 1280); - aml_set_sysfs_int("/sys/class/graphics/fb0/scale_height", 720); - aml_set_sysfs_int("/sys/class/graphics/fb1/scale_width", 1280); - aml_set_sysfs_int("/sys/class/graphics/fb1/scale_height", 720); + SysfsUtils::SetInt("/sys/class/graphics/fb0/free_scale", 0); + SysfsUtils::SetInt("/sys/class/graphics/fb1/free_scale", 0); + SysfsUtils::SetInt("/sys/class/graphics/fb0/scale_width", 1280); + SysfsUtils::SetInt("/sys/class/graphics/fb0/scale_height", 720); + SysfsUtils::SetInt("/sys/class/graphics/fb1/scale_width", 1280); + SysfsUtils::SetInt("/sys/class/graphics/fb1/scale_height", 720); // enable video free scale (scaling to 1920x1080 with frame buffer size 1280x720) - aml_set_sysfs_int("/sys/class/ppmgr/ppscaler", 0); - aml_set_sysfs_int("/sys/class/video/disable_video", 1); - aml_set_sysfs_int("/sys/class/ppmgr/ppscaler", 1); - aml_set_sysfs_str("/sys/class/ppmgr/ppscaler_rect", "0 0 1919 1079 0"); - aml_set_sysfs_str("/sys/class/ppmgr/disp", "1280 720"); + SysfsUtils::SetInt("/sys/class/ppmgr/ppscaler", 0); + SysfsUtils::SetInt("/sys/class/video/disable_video", 1); + SysfsUtils::SetInt("/sys/class/ppmgr/ppscaler", 1); + SysfsUtils::SetString("/sys/class/ppmgr/ppscaler_rect", "0 0 1919 1079 0"); + SysfsUtils::SetString("/sys/class/ppmgr/disp", "1280 720"); // - aml_set_sysfs_int("/sys/class/graphics/fb0/scale_width", 1280); - aml_set_sysfs_int("/sys/class/graphics/fb0/scale_height", 720); - aml_set_sysfs_int("/sys/class/graphics/fb1/scale_width", 1280); - aml_set_sysfs_int("/sys/class/graphics/fb1/scale_height", 720); + SysfsUtils::SetInt("/sys/class/graphics/fb0/scale_width", 1280); + SysfsUtils::SetInt("/sys/class/graphics/fb0/scale_height", 720); + SysfsUtils::SetInt("/sys/class/graphics/fb1/scale_width", 1280); + SysfsUtils::SetInt("/sys/class/graphics/fb1/scale_height", 720); // - aml_set_sysfs_int("/sys/class/video/disable_video", 2); - aml_set_sysfs_str("/sys/class/display/axis", "0 0 1279 719 0 0 0 0"); - aml_set_sysfs_str("/sys/class/ppmgr/ppscaler_rect", "0 0 1279 719 1"); + SysfsUtils::SetInt("/sys/class/video/disable_video", 2); + SysfsUtils::SetString("/sys/class/display/axis", "0 0 1279 719 0 0 0 0"); + SysfsUtils::SetString("/sys/class/ppmgr/ppscaler_rect", "0 0 1279 719 1"); // - aml_set_sysfs_int("/sys/class/graphics/fb0/free_scale", 1); - aml_set_sysfs_int("/sys/class/graphics/fb1/free_scale", 1); - aml_set_sysfs_str("/sys/class/graphics/fb0/free_scale_axis", "0 0 1279 719"); + SysfsUtils::SetInt("/sys/class/graphics/fb0/free_scale", 1); + SysfsUtils::SetInt("/sys/class/graphics/fb1/free_scale", 1); + SysfsUtils::SetString("/sys/class/graphics/fb0/free_scale_axis", "0 0 1279 719"); } void CEGLNativeTypeAmlogic::DisableFreeScale() { // turn off frame buffer freescale - aml_set_sysfs_int("/sys/class/graphics/fb0/free_scale", 0); - aml_set_sysfs_int("/sys/class/graphics/fb1/free_scale", 0); - aml_set_sysfs_str("/sys/class/graphics/fb0/free_scale_axis", "0 0 1279 719"); + SysfsUtils::SetInt("/sys/class/graphics/fb0/free_scale", 0); + SysfsUtils::SetInt("/sys/class/graphics/fb1/free_scale", 0); + SysfsUtils::SetString("/sys/class/graphics/fb0/free_scale_axis", "0 0 1279 719"); - aml_set_sysfs_int("/sys/class/ppmgr/ppscaler", 0); - aml_set_sysfs_int("/sys/class/video/disable_video", 0); + SysfsUtils::SetInt("/sys/class/ppmgr/ppscaler", 0); + SysfsUtils::SetInt("/sys/class/video/disable_video", 0); // now default video display to off - aml_set_sysfs_int("/sys/class/video/disable_video", 1); + SysfsUtils::SetInt("/sys/class/video/disable_video", 1); // revert display axis int fd0; @@ -297,9 +298,9 @@ void CEGLNativeTypeAmlogic::DisableFreeScale() struct fb_var_screeninfo vinfo; if (ioctl(fd0, FBIOGET_VSCREENINFO, &vinfo) == 0) { - char daxis_str[255] = {0}; + char daxis_str[256] = {0}; sprintf(daxis_str, "%d %d %d %d 0 0 0 0", 0, 0, vinfo.xres-1, vinfo.yres-1); - aml_set_sysfs_str("/sys/class/display/axis", daxis_str); + SysfsUtils::SetString("/sys/class/display/axis", daxis_str); } close(fd0); } diff --git a/xbmc/windowing/egl/EGLNativeTypeIMX.cpp b/xbmc/windowing/egl/EGLNativeTypeIMX.cpp index 04cadc8132..9893558d35 100644 --- a/xbmc/windowing/egl/EGLNativeTypeIMX.cpp +++ b/xbmc/windowing/egl/EGLNativeTypeIMX.cpp @@ -28,6 +28,7 @@ #include "utils/log.h" #include "utils/RegExp.h" #include "utils/StringUtils.h" +#include "utils/SysfsUtils.h" #include "utils/Environment.h" #include "guilib/gui3d.h" #include "windowing/WindowingFactory.h" @@ -190,7 +191,7 @@ bool CEGLNativeTypeIMX::DestroyNativeWindow() bool CEGLNativeTypeIMX::GetNativeResolution(RESOLUTION_INFO *res) const { std::string mode; - get_sysfs_str("/sys/class/graphics/fb0/mode", mode); + SysfsUtils::GetString("/sys/class/graphics/fb0/mode", mode); return ModeToResolution(mode, res); } @@ -200,14 +201,14 @@ bool CEGLNativeTypeIMX::SetNativeResolution(const RESOLUTION_INFO &res) return false; std::string mode; - get_sysfs_str("/sys/class/graphics/fb0/mode", mode); + SysfsUtils::GetString("/sys/class/graphics/fb0/mode", mode); if (res.strId == mode) return false; DestroyNativeWindow(); DestroyNativeDisplay(); - set_sysfs_str("/sys/class/graphics/fb0/mode", res.strId); + SysfsUtils::SetString("/sys/class/graphics/fb0/mode", res.strId); CreateNativeDisplay(); @@ -225,7 +226,7 @@ bool CEGLNativeTypeIMX::ProbeResolutions(std::vector<RESOLUTION_INFO> &resolutio return false; std::string valstr; - get_sysfs_str("/sys/class/graphics/fb0/modes", valstr); + SysfsUtils::GetString("/sys/class/graphics/fb0/modes", valstr); std::vector<std::string> probe_str; probe_str = StringUtils::Split(valstr, "\n"); @@ -257,41 +258,6 @@ bool CEGLNativeTypeIMX::ShowWindow(bool show) return false; } -int CEGLNativeTypeIMX::get_sysfs_str(std::string path, std::string& valstr) const -{ - int len; - char buf[256] = {0}; - - int fd = open(path.c_str(), O_RDONLY); - if (fd >= 0) - { - while ((len = read(fd, buf, 255)) > 0) - valstr.append(buf, len); - close(fd); - } - else - { - CLog::Log(LOGERROR, "%s: error reading %s",__FUNCTION__, path.c_str()); - valstr = "fail"; - return -1; - } - return 0; -} - -int CEGLNativeTypeIMX::set_sysfs_str(std::string path, std::string val) const -{ - int fd = open(path.c_str(), O_WRONLY); - if (fd >= 0) - { - val += '\n'; - write(fd, val.c_str(), val.size()); - close(fd); - return 0; - } - CLog::Log(LOGERROR, "%s: error writing %s",__FUNCTION__, path.c_str()); - return -1; -} - bool CEGLNativeTypeIMX::ModeToResolution(std::string mode, RESOLUTION_INFO *res) const { if (!res) diff --git a/xbmc/windowing/egl/EGLNativeTypeIMX.h b/xbmc/windowing/egl/EGLNativeTypeIMX.h index d5e57390ca..0298cb53cb 100644 --- a/xbmc/windowing/egl/EGLNativeTypeIMX.h +++ b/xbmc/windowing/egl/EGLNativeTypeIMX.h @@ -50,8 +50,6 @@ public: protected: bool m_readonly; - int get_sysfs_str(std::string path, std::string& valstr) const; - int set_sysfs_str(std::string path, std::string val) const; bool ModeToResolution(std::string mode, RESOLUTION_INFO *res) const; EGLNativeDisplayType m_display; diff --git a/xbmc/windowing/egl/WinSystemEGL.cpp b/xbmc/windowing/egl/WinSystemEGL.cpp index 2bdd4faf41..2edf4db9cb 100644 --- a/xbmc/windowing/egl/WinSystemEGL.cpp +++ b/xbmc/windowing/egl/WinSystemEGL.cpp @@ -261,7 +261,7 @@ bool CWinSystemEGL::DestroyWindowSystem() return true; } -bool CWinSystemEGL::CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) +bool CWinSystemEGL::CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) { RESOLUTION_INFO current_resolution; current_resolution.iWidth = current_resolution.iHeight = 0; diff --git a/xbmc/windowing/egl/WinSystemEGL.h b/xbmc/windowing/egl/WinSystemEGL.h index 654889540c..9d4baf6adb 100644 --- a/xbmc/windowing/egl/WinSystemEGL.h +++ b/xbmc/windowing/egl/WinSystemEGL.h @@ -39,7 +39,7 @@ public: virtual bool InitWindowSystem(); virtual bool DestroyWindowSystem(); - virtual bool CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction); + virtual bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction); virtual bool DestroyWindow(); virtual bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop); virtual bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays); diff --git a/xbmc/windowing/osx/WinSystemIOS.h b/xbmc/windowing/osx/WinSystemIOS.h index c34110a6e6..b221b6ec5a 100644 --- a/xbmc/windowing/osx/WinSystemIOS.h +++ b/xbmc/windowing/osx/WinSystemIOS.h @@ -40,7 +40,7 @@ public: virtual bool InitWindowSystem(); virtual bool DestroyWindowSystem(); - virtual bool CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction); + virtual bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction); virtual bool DestroyWindow(); virtual bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop); virtual bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays); @@ -82,7 +82,7 @@ protected: void *m_glView; // EAGLView opaque void *m_WorkingContext; // shared EAGLContext opaque bool m_bWasFullScreenBeforeMinimize; - CStdString m_eglext; + std::string m_eglext; int m_iVSyncErrors; CCriticalSection m_resourceSection; std::vector<IDispResource*> m_resources; diff --git a/xbmc/windowing/osx/WinSystemIOS.mm b/xbmc/windowing/osx/WinSystemIOS.mm index 5639a9604d..1170d0de84 100644 --- a/xbmc/windowing/osx/WinSystemIOS.mm +++ b/xbmc/windowing/osx/WinSystemIOS.mm @@ -75,7 +75,7 @@ bool CWinSystemIOS::DestroyWindowSystem() return true; } -bool CWinSystemIOS::CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) +bool CWinSystemIOS::CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) { //NSLog(@"%s", __PRETTY_FUNCTION__); @@ -296,7 +296,7 @@ bool CWinSystemIOS::IsExtSupported(const char* extension) if(strncmp(extension, "EGL_", 4) != 0) return CRenderSystemGLES::IsExtSupported(extension); - CStdString name; + std::string name; name = " "; name += extension; diff --git a/xbmc/windowing/osx/WinSystemOSX.h b/xbmc/windowing/osx/WinSystemOSX.h index 04a5df3ef9..d0e6b87ec9 100644 --- a/xbmc/windowing/osx/WinSystemOSX.h +++ b/xbmc/windowing/osx/WinSystemOSX.h @@ -44,7 +44,7 @@ public: // CWinSystemBase virtual bool InitWindowSystem(); virtual bool DestroyWindowSystem(); - virtual bool CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction); + virtual bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction); virtual bool DestroyWindow(); virtual bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop); bool ResizeWindowInternal(int newWidth, int newHeight, int newLeft, int newTop, void *additional); diff --git a/xbmc/windowing/osx/WinSystemOSX.mm b/xbmc/windowing/osx/WinSystemOSX.mm index 59ca25aa1a..fdd756f098 100644 --- a/xbmc/windowing/osx/WinSystemOSX.mm +++ b/xbmc/windowing/osx/WinSystemOSX.mm @@ -678,7 +678,7 @@ bool CWinSystemOSX::DestroyWindowSystem() return true; } -bool CWinSystemOSX::CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) +bool CWinSystemOSX::CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) { m_nWidth = res.iWidth; m_nHeight = res.iHeight; diff --git a/xbmc/windowing/tests/wayland/WestonProcess.cpp b/xbmc/windowing/tests/wayland/WestonProcess.cpp index 6a2a877d03..4aad94cd51 100644 --- a/xbmc/windowing/tests/wayland/WestonProcess.cpp +++ b/xbmc/windowing/tests/wayland/WestonProcess.cpp @@ -30,7 +30,6 @@ #include <sys/wait.h> #include "Util.h" -#include "utils/StdString.h" #include "WestonProcess.h" @@ -88,8 +87,8 @@ FindBinaryFromPATH(const std::string &binary) } } -xt::Process::Process(const CStdString &xbmcTestBase, - const CStdString &tempFileName) : +xt::Process::Process(const westring &xbmcTestBase, + const westring &tempFileName) : m_pid(0) { std::stringstream socketOptionStream; diff --git a/xbmc/windowing/tests/wayland/WestonProcess.h b/xbmc/windowing/tests/wayland/WestonProcess.h index 13026b8b97..6d923cf37c 100644 --- a/xbmc/windowing/tests/wayland/WestonProcess.h +++ b/xbmc/windowing/tests/wayland/WestonProcess.h @@ -24,9 +24,9 @@ #include <boost/noncopyable.hpp> #ifdef UNICODE - typedef CStdStringW CStdString; + typedef std::wstring westring; #else - typedef CStdStringA CStdString; + typedef std::string westring; #endif typedef int32_t pid_t; @@ -40,8 +40,8 @@ class Process : { public: - Process(const CStdString &base, - const CStdString &socket); + Process(const westring &base, + const westring &socket); ~Process(); void WaitForSignal(int signal, int timeout); diff --git a/xbmc/windowing/tests/wayland/WestonTest.cpp b/xbmc/windowing/tests/wayland/WestonTest.cpp index 844b971cc5..d962a58898 100644 --- a/xbmc/windowing/tests/wayland/WestonTest.cpp +++ b/xbmc/windowing/tests/wayland/WestonTest.cpp @@ -40,17 +40,17 @@ class TempFileWrapper : { public: - TempFileWrapper(const CStdString &suffix); + TempFileWrapper(const westring &suffix); ~TempFileWrapper(); - void FetchDirectory(CStdString &directory); - void FetchFilename(CStdString &name); + void FetchDirectory(westring &directory); + void FetchFilename(westring &name); private: XFILE::CFile *m_file; }; -TempFileWrapper::TempFileWrapper(const CStdString &suffix) : +TempFileWrapper::TempFileWrapper(const westring &suffix) : m_file(CXBMCTestUtils::Instance().CreateTempFile(suffix)) { } @@ -60,17 +60,17 @@ TempFileWrapper::~TempFileWrapper() CXBMCTestUtils::Instance().DeleteTempFile(m_file); } -void TempFileWrapper::FetchDirectory(CStdString &directory) +void TempFileWrapper::FetchDirectory(westring &directory) { directory = CXBMCTestUtils::Instance().TempFileDirectory(m_file); /* Strip trailing "/" */ directory.resize(directory.size() - 1); } -void TempFileWrapper::FetchFilename(CStdString &name) +void TempFileWrapper::FetchFilename(westring &name) { - CStdString path(CXBMCTestUtils::Instance().TempFilePath(m_file)); - CStdString directory(CXBMCTestUtils::Instance().TempFileDirectory(m_file)); + westring path(CXBMCTestUtils::Instance().TempFilePath(m_file)); + westring directory(CXBMCTestUtils::Instance().TempFileDirectory(m_file)); name = path.substr(directory.size()); } @@ -82,13 +82,13 @@ public: SavedTempSocket(); - const CStdString & FetchFilename(); - const CStdString & FetchDirectory(); + const westring & FetchFilename(); + const westring & FetchDirectory(); private: - CStdString m_filename; - CStdString m_directory; + westring m_filename; + westring m_directory; }; SavedTempSocket::SavedTempSocket() @@ -98,13 +98,13 @@ SavedTempSocket::SavedTempSocket() wrapper.FetchFilename(m_filename); } -const CStdString & +const westring & SavedTempSocket::FetchFilename() { return m_filename; } -const CStdString & +const westring & SavedTempSocket::FetchDirectory() { return m_directory; @@ -167,7 +167,7 @@ public: Private(); ~Private(); - CStdString m_xbmcTestBase; + westring m_xbmcTestBase; SavedTempSocket m_tempSocketName; TmpEnv m_xdgRuntimeDir; @@ -211,7 +211,7 @@ WestonTest::Pid() return priv->m_process.Pid(); } -const CStdString & +const westring & WestonTest::TempSocketName() { return priv->m_tempSocketName.FetchFilename(); diff --git a/xbmc/windowing/tests/wayland/WestonTest.h b/xbmc/windowing/tests/wayland/WestonTest.h index 8808268dff..5e5548c784 100644 --- a/xbmc/windowing/tests/wayland/WestonTest.h +++ b/xbmc/windowing/tests/wayland/WestonTest.h @@ -24,9 +24,9 @@ #include <gtest/gtest.h> #ifdef UNICODE - typedef CStdStringW CStdString; + typedef std::wstring westring; #else - typedef CStdStringA CStdString; + typedef std::string westring; #endif typedef int32_t pid_t; @@ -39,7 +39,7 @@ public: WestonTest(); ~WestonTest(); pid_t Pid(); - const CStdString & TempSocketName(); + const westring & TempSocketName(); virtual void SetUp(); diff --git a/xbmc/windowing/windows/WinEventsWin32.cpp b/xbmc/windowing/windows/WinEventsWin32.cpp index 76e8e15acb..c023a54b6d 100644 --- a/xbmc/windowing/windows/WinEventsWin32.cpp +++ b/xbmc/windowing/windows/WinEventsWin32.cpp @@ -487,7 +487,7 @@ LRESULT CALLBACK CWinEventsWin32::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, L g_Windowing.NotifyAppFocusChange(g_application.m_AppFocused); if (uMsg == WM_KILLFOCUS) { - CStdString procfile; + std::string procfile; if (CWIN32Util::GetFocussedProcess(procfile)) CLog::Log(LOGDEBUG, __FUNCTION__": Focus switched to process %s", procfile.c_str()); } @@ -770,7 +770,7 @@ LRESULT CALLBACK CWinEventsWin32::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, L // optical medium if (lpdbv -> dbcv_flags & DBTF_MEDIA) { - CStdString strdrive = StringUtils::Format("%c:", CWIN32Util::FirstDriveFromMask(lpdbv ->dbcv_unitmask)); + std::string strdrive = StringUtils::Format("%c:", CWIN32Util::FirstDriveFromMask(lpdbv ->dbcv_unitmask)); if(wParam == DBT_DEVICEARRIVAL) { CLog::Log(LOGDEBUG, __FUNCTION__": Drive %s Media has arrived.", strdrive.c_str()); diff --git a/xbmc/windowing/windows/WinSystemWin32.cpp b/xbmc/windowing/windows/WinSystemWin32.cpp index 55358adfb6..e15311c861 100644 --- a/xbmc/windowing/windows/WinSystemWin32.cpp +++ b/xbmc/windowing/windows/WinSystemWin32.cpp @@ -76,7 +76,7 @@ bool CWinSystemWin32::DestroyWindowSystem() return true; } -bool CWinSystemWin32::CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) +bool CWinSystemWin32::CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) { m_hInstance = ( HINSTANCE )GetModuleHandle( NULL ); diff --git a/xbmc/windowing/windows/WinSystemWin32.h b/xbmc/windowing/windows/WinSystemWin32.h index 245d84c557..7e95b57681 100644 --- a/xbmc/windowing/windows/WinSystemWin32.h +++ b/xbmc/windowing/windows/WinSystemWin32.h @@ -132,7 +132,7 @@ public: // CWinSystemBase virtual bool InitWindowSystem(); virtual bool DestroyWindowSystem(); - virtual bool CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction); + virtual bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction); virtual bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop); virtual bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays); virtual void UpdateResolutions(); diff --git a/xbmc/windowing/windows/WinSystemWin32DX.cpp b/xbmc/windowing/windows/WinSystemWin32DX.cpp index 7f83bfe90d..f73cd5562c 100644 --- a/xbmc/windowing/windows/WinSystemWin32DX.cpp +++ b/xbmc/windowing/windows/WinSystemWin32DX.cpp @@ -42,7 +42,7 @@ bool CWinSystemWin32DX::UseWindowedDX(bool fullScreen) return (CSettings::Get().GetBool("videoscreen.fakefullscreen") || !fullScreen); } -bool CWinSystemWin32DX::CreateNewWindow(CStdString name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) +bool CWinSystemWin32DX::CreateNewWindow(std::string name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) { if(!CWinSystemWin32::CreateNewWindow(name, fullScreen, res, userFunction)) return false; @@ -99,8 +99,8 @@ bool CWinSystemWin32DX::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, boo std::string CWinSystemWin32DX::GetClipboardText(void) { - CStdStringW unicode_text; - CStdStringA utf8_text; + std::wstring unicode_text; + std::string utf8_text; if (OpenClipboard(NULL)) { diff --git a/xbmc/windowing/windows/WinSystemWin32DX.h b/xbmc/windowing/windows/WinSystemWin32DX.h index 5f717afac6..6e9347990a 100644 --- a/xbmc/windowing/windows/WinSystemWin32DX.h +++ b/xbmc/windowing/windows/WinSystemWin32DX.h @@ -39,7 +39,7 @@ public: CWinSystemWin32DX(); ~CWinSystemWin32DX(); - virtual bool CreateNewWindow(CStdString name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction); + virtual bool CreateNewWindow(std::string name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction); virtual bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop); virtual void OnMove(int x, int y); virtual bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays); diff --git a/xbmc/windows/GUIMediaWindow.cpp b/xbmc/windows/GUIMediaWindow.cpp index b1961fd072..b85738261e 100644 --- a/xbmc/windows/GUIMediaWindow.cpp +++ b/xbmc/windows/GUIMediaWindow.cpp @@ -218,7 +218,7 @@ bool CGUIMediaWindow::OnBack(int actionID) { CURL filterUrl(m_strFilterPath); if (actionID == ACTION_NAV_BACK && !m_vecItems->IsVirtualDirectoryRoot() && - (m_vecItems->GetPath() != m_startDirectory || (m_canFilterAdvanced && filterUrl.HasOption("filter")))) + (!URIUtils::PathEquals(m_vecItems->GetPath(), m_startDirectory, true) || (m_canFilterAdvanced && filterUrl.HasOption("filter")))) { GoParentFolder(); return true; @@ -526,14 +526,14 @@ void CGUIMediaWindow::UpdateButtons() if (m_guiState.get()) { // Update sorting controls - if (m_guiState->GetDisplaySortOrder() == SortOrderNone) + if (m_guiState->GetSortOrder() == SortOrderNone) { CONTROL_DISABLE(CONTROL_BTNSORTASC); } else { CONTROL_ENABLE(CONTROL_BTNSORTASC); - SET_CONTROL_SELECTED(GetID(), CONTROL_BTNSORTASC, m_guiState->GetDisplaySortOrder() != SortOrderAscending); + SET_CONTROL_SELECTED(GetID(), CONTROL_BTNSORTASC, m_guiState->GetSortOrder() != SortOrderAscending); } // Update list/thumb control @@ -571,7 +571,7 @@ void CGUIMediaWindow::SortItems(CFileItemList &items) if (guiState.get()) { SortDescription sorting = guiState->GetSortMethod(); - sorting.sortOrder = guiState->GetDisplaySortOrder(); + sorting.sortOrder = guiState->GetSortOrder(); // If the sort method is "sort by playlist" and we have a specific // sort order available we can use the specified sort order to do the sorting // We do this as the new SortBy methods are a superset of the SORT_METHOD methods, thus @@ -588,7 +588,7 @@ void CGUIMediaWindow::SortItems(CFileItemList &items) // if the sort order is descending, we need to switch the original sort order, as we assume // in CGUIViewState::AddPlaylistOrder that SortByPlaylistOrder is ascending. - if (guiState->GetDisplaySortOrder() == SortOrderDescending) + if (guiState->GetSortOrder() == SortOrderDescending) sorting.sortOrder = sorting.sortOrder == SortOrderDescending ? SortOrderAscending : SortOrderDescending; } } @@ -630,7 +630,7 @@ void CGUIMediaWindow::FormatAndSort(CFileItemList &items) viewState->GetSortMethodLabelMasks(labelMasks); FormatItemLabels(items, labelMasks); - items.Sort(viewState->GetSortMethod().sortBy, viewState->GetDisplaySortOrder(), viewState->GetSortMethod().sortAttributes); + items.Sort(viewState->GetSortMethod().sortBy, viewState->GetSortOrder(), viewState->GetSortMethod().sortAttributes); } } @@ -1276,7 +1276,12 @@ void CGUIMediaWindow::SetHistoryForPath(const std::string& strDirectory) strParentPath = url.Get(); } - URIUtils::AddSlashAtEnd(strPath); + // set the original path exactly as it was passed in + if (URIUtils::PathEquals(strPath, strDirectory, true)) + strPath = strDirectory; + else + URIUtils::AddSlashAtEnd(strPath); + m_history.AddPathFront(strPath); m_history.SetSelectedItem(strPath, strParentPath); strPath = strParentPath; @@ -1458,7 +1463,7 @@ void CGUIMediaWindow::OnInitWindow() m_rootDir.SetAllowThreads(false); // the start directory may change during Refresh - bool updateStartDirectory = (m_startDirectory == m_vecItems->GetPath()); + bool updateStartDirectory = URIUtils::PathEquals(m_vecItems->GetPath(), m_startDirectory, true); Refresh(); if (updateStartDirectory) { diff --git a/xbmc/windows/GUIWindowDebugInfo.cpp b/xbmc/windows/GUIWindowDebugInfo.cpp index 47d7cdddcb..a9e1b79350 100644 --- a/xbmc/windows/GUIWindowDebugInfo.cpp +++ b/xbmc/windows/GUIWindowDebugInfo.cpp @@ -96,14 +96,14 @@ void CGUIWindowDebugInfo::Process(unsigned int currentTime, CDirtyRegionList &di if (!m_layout) return; - CStdString info; + std::string info; if (LOG_LEVEL_DEBUG_FREEMEM <= g_advancedSettings.m_logLevel) { MEMORYSTATUSEX stat; stat.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&stat); - CStdString profiling = CGUIControlProfiler::IsRunning() ? " (profiling)" : ""; - CStdString strCores = g_cpuInfo.GetCoresUsageString(); + std::string profiling = CGUIControlProfiler::IsRunning() ? " (profiling)" : ""; + std::string strCores = g_cpuInfo.GetCoresUsageString(); std::string lcAppName = CCompileInfo::GetAppName(); StringUtils::ToLower(lcAppName); #if !defined(TARGET_POSIX) @@ -130,9 +130,9 @@ void CGUIWindowDebugInfo::Process(unsigned int currentTime, CDirtyRegionList &di point = CPoint(pointer->GetXPosition(), pointer->GetYPosition()); if (window) { - CStdString windowName = CButtonTranslator::TranslateWindow(window->GetID()); + std::string windowName = CButtonTranslator::TranslateWindow(window->GetID()); if (!windowName.empty()) - windowName += " (" + CStdString(window->GetProperty("xmlfile").asString()) + ")"; + windowName += " (" + std::string(window->GetProperty("xmlfile").asString()) + ")"; else windowName = window->GetProperty("xmlfile").asString(); info += "Window: " + windowName + " "; diff --git a/xbmc/windows/GUIWindowFileManager.cpp b/xbmc/windows/GUIWindowFileManager.cpp index f137d20f4c..5c483772ac 100644 --- a/xbmc/windows/GUIWindowFileManager.cpp +++ b/xbmc/windows/GUIWindowFileManager.cpp @@ -365,7 +365,7 @@ void CGUIWindowFileManager::ClearFileItems(int iList) void CGUIWindowFileManager::UpdateButtons() { // update our current directory labels - CStdString strDir = CURL(m_Directory[0]->GetPath()).GetWithoutUserDetails(); + std::string strDir = CURL(m_Directory[0]->GetPath()).GetWithoutUserDetails(); if (strDir.empty()) { SET_CONTROL_LABEL(CONTROL_CURRENTDIRLABEL_LEFT,g_localizeStrings.Get(20108)); @@ -408,7 +408,7 @@ void CGUIWindowFileManager::UpdateItemCounts() totalCount++; totalSize += item->m_dwSize; } - CStdString items; + std::string items; if (selectedCount > 0) items = StringUtils::Format("%i/%i %s (%s)", selectedCount, totalCount, g_localizeStrings.Get(127).c_str(), StringUtils::SizeToString(selectedSize).c_str()); else @@ -417,11 +417,11 @@ void CGUIWindowFileManager::UpdateItemCounts() } } -bool CGUIWindowFileManager::Update(int iList, const CStdString &strDirectory) +bool CGUIWindowFileManager::Update(int iList, const std::string &strDirectory) { // get selected item int iItem = GetSelectedItem(iList); - CStdString strSelectedItem = ""; + std::string strSelectedItem = ""; if (iItem >= 0 && iItem < (int)m_vecItems[iList]->Size()) { @@ -433,7 +433,7 @@ bool CGUIWindowFileManager::Update(int iList, const CStdString &strDirectory) } } - CStdString strOldDirectory=m_Directory[iList]->GetPath(); + std::string strOldDirectory=m_Directory[iList]->GetPath(); m_Directory[iList]->SetPath(strDirectory); CFileItemList items; @@ -454,11 +454,11 @@ bool CGUIWindowFileManager::Update(int iList, const CStdString &strDirectory) m_vecItems[iList]->Append(items); m_vecItems[iList]->SetPath(items.GetPath()); - CStdString strParentPath; + std::string strParentPath; URIUtils::GetParentPath(strDirectory, strParentPath); if (strDirectory.empty() && (m_vecItems[iList]->Size() == 0 || CSettings::Get().GetBool("filelists.showaddsourcebuttons"))) { // add 'add source button' - CStdString strLabel = g_localizeStrings.Get(1026); + std::string strLabel = g_localizeStrings.Get(1026); CFileItemPtr pItem(new CFileItem(strLabel)); pItem->SetPath("add"); pItem->SetIconImage("DefaultAddSource.png"); @@ -508,7 +508,7 @@ bool CGUIWindowFileManager::Update(int iList, const CStdString &strDirectory) for (int i = 0; i < m_vecItems[iList]->Size(); ++i) { CFileItemPtr pItem = m_vecItems[iList]->Get(i); - CStdString strHistory; + std::string strHistory; GetDirectoryHistoryString(pItem.get(), strHistory); if (strHistory == strSelectedItem) { @@ -552,7 +552,7 @@ void CGUIWindowFileManager::OnClick(int iList, int iItem) if (pItem->m_bIsFolder) { // save path + drive type because of the possible refresh - CStdString strPath = pItem->GetPath(); + std::string strPath = pItem->GetPath(); int iDriveType = pItem->m_iDriveType; if ( pItem->m_bIsShareOrDrive ) { @@ -593,7 +593,7 @@ void CGUIWindowFileManager::OnStart(CFileItem *pItem) // start playlists from file manager if (pItem->IsPlayList()) { - CStdString strPlayList = pItem->GetPath(); + std::string strPlayList = pItem->GetPath(); auto_ptr<CPlayList> pPlayList (CPlayListFactory::Create(strPlayList)); if (NULL != pPlayList.get()) { @@ -634,7 +634,7 @@ void CGUIWindowFileManager::OnStart(CFileItem *pItem) } } -bool CGUIWindowFileManager::HaveDiscOrConnection( CStdString& strPath, int iDriveType ) +bool CGUIWindowFileManager::HaveDiscOrConnection( std::string& strPath, int iDriveType ) { if ( iDriveType == CMediaSource::SOURCE_TYPE_DVD ) { @@ -720,7 +720,7 @@ void CGUIWindowFileManager::OnDelete(int iList) void CGUIWindowFileManager::OnRename(int iList) { - CStdString strFile; + std::string strFile; for (int i = 0; i < m_vecItems[iList]->Size();++i) { CFileItemPtr pItem = m_vecItems[iList]->Get(i); @@ -750,10 +750,10 @@ void CGUIWindowFileManager::OnSelectAll(int iList) void CGUIWindowFileManager::OnNewFolder(int iList) { - CStdString strNewFolder = ""; + std::string strNewFolder = ""; if (CGUIKeyboardFactory::ShowAndGetInput(strNewFolder, g_localizeStrings.Get(16014), false)) { - CStdString strNewPath = m_Directory[iList]->GetPath(); + std::string strNewPath = m_Directory[iList]->GetPath(); URIUtils::AddSlashAtEnd(strNewPath); strNewPath += strNewFolder; CDirectory::Create(strNewPath); @@ -763,7 +763,7 @@ void CGUIWindowFileManager::OnNewFolder(int iList) for (int i=0; i<m_vecItems[iList]->Size(); ++i) { CFileItemPtr pItem=m_vecItems[iList]->Get(i); - CStdString strPath=pItem->GetPath(); + std::string strPath=pItem->GetPath(); URIUtils::RemoveSlashAtEnd(strPath); if (strPath==strNewPath) { @@ -822,14 +822,14 @@ void CGUIWindowFileManager::GoParentFolder(int iList) g_ZipManager.release(m_Directory[iList]->GetPath()); // release resources } - CStdString strPath(m_strParentPath[iList]), strOldPath(m_Directory[iList]->GetPath()); + std::string strPath(m_strParentPath[iList]), strOldPath(m_Directory[iList]->GetPath()); Update(iList, strPath); } /// \brief Build a directory history string /// \param pItem Item to build the history string from /// \param strHistoryString History string build as return value -void CGUIWindowFileManager::GetDirectoryHistoryString(const CFileItem* pItem, CStdString& strHistoryString) +void CGUIWindowFileManager::GetDirectoryHistoryString(const CFileItem* pItem, std::string& strHistoryString) { if (pItem->m_bIsShareOrDrive) { @@ -842,7 +842,7 @@ void CGUIWindowFileManager::GetDirectoryHistoryString(const CFileItem* pItem, CS // Remove disc label from item label // and use as history string, m_strPath // can change for new discs - CStdString strLabel = pItem->GetLabel(); + std::string strLabel = pItem->GetLabel(); size_t nPosOpen = strLabel.find('('); size_t nPosClose = strLabel.rfind(')'); if (nPosOpen != std::string::npos && @@ -870,7 +870,7 @@ void CGUIWindowFileManager::GetDirectoryHistoryString(const CFileItem* pItem, CS } } -bool CGUIWindowFileManager::GetDirectory(int iList, const CStdString &strDirectory, CFileItemList &items) +bool CGUIWindowFileManager::GetDirectory(int iList, const std::string &strDirectory, CFileItemList &items) { const CURL pathToUrl(strDirectory); return m_rootDir.GetDirectory(pathToUrl, items, false); @@ -1112,7 +1112,7 @@ bool CGUIWindowFileManager::SelectItem(int list, int &item) } // recursively calculates the selected folder size -int64_t CGUIWindowFileManager::CalculateFolderSize(const CStdString &strDirectory, CGUIDialogProgress *pProgress) +int64_t CGUIWindowFileManager::CalculateFolderSize(const std::string &strDirectory, CGUIDialogProgress *pProgress) { const CURL pathToUrl(strDirectory); if (pProgress) @@ -1200,10 +1200,10 @@ void CGUIWindowFileManager::OnInitWindow() } } -void CGUIWindowFileManager::SetInitialPath(const CStdString &path) +void CGUIWindowFileManager::SetInitialPath(const std::string &path) { // check for a passed destination path - CStdString strDestination = path; + std::string strDestination = path; m_rootDir.SetSources(*CMediaSourceSettings::Get().GetSources("files")); if (!strDestination.empty()) { @@ -1219,7 +1219,7 @@ void CGUIWindowFileManager::SetInitialPath(const CStdString &path) if (!strDestination.empty()) { // open root - if (strDestination.Equals("$ROOT")) + if (StringUtils::EqualsNoCase(strDestination, "$ROOT")) { m_Directory[0]->SetPath(""); CLog::Log(LOGINFO, " Success! Opening root listing."); @@ -1236,7 +1236,7 @@ void CGUIWindowFileManager::SetInitialPath(const CStdString &path) if (iIndex > -1) { // set current directory to matching share - CStdString path; + std::string path; if (bIsSourceName && iIndex < (int)shares.size()) path = shares[iIndex].strPath; else diff --git a/xbmc/windows/GUIWindowFileManager.h b/xbmc/windows/GUIWindowFileManager.h index 9d75a64796..05c1901e60 100644 --- a/xbmc/windows/GUIWindowFileManager.h +++ b/xbmc/windows/GUIWindowFileManager.h @@ -43,15 +43,15 @@ public: virtual bool OnBack(int actionID); const CFileItem &CurrentDirectory(int indx) const; - static int64_t CalculateFolderSize(const CStdString &strDirectory, CGUIDialogProgress *pProgress = NULL); + static int64_t CalculateFolderSize(const std::string &strDirectory, CGUIDialogProgress *pProgress = NULL); virtual void OnJobComplete(unsigned int jobID, bool success, CJob *job); protected: virtual void OnInitWindow(); - void SetInitialPath(const CStdString &path); + void SetInitialPath(const std::string &path); void GoParentFolder(int iList); void UpdateControl(int iList, int item); - bool Update(int iList, const CStdString &strDirectory); //??? + bool Update(int iList, const std::string &strDirectory); //??? void OnStart(CFileItem *pItem); bool SelectItem(int iList, int &item); void ClearFileItems(int iList); @@ -68,9 +68,9 @@ protected: void Refresh(); void Refresh(int iList); int GetSelectedItem(int iList); - bool HaveDiscOrConnection( CStdString& strPath, int iDriveType ); - void GetDirectoryHistoryString(const CFileItem* pItem, CStdString& strHistoryString); - bool GetDirectory(int iList, const CStdString &strDirectory, CFileItemList &items); + bool HaveDiscOrConnection( std::string& strPath, int iDriveType ); + void GetDirectoryHistoryString(const CFileItem* pItem, std::string& strHistoryString); + bool GetDirectory(int iList, const std::string &strDirectory, CFileItemList &items); int NumSelected(int iList); int GetFocusedList() const; // functions to check for actions that we can perform @@ -85,14 +85,14 @@ protected: // bool bCheckShareConnectivity; - CStdString strCheckSharePath; + std::string strCheckSharePath; XFILE::CVirtualDirectory m_rootDir; CFileItemList* m_vecItems[2]; typedef std::vector <CFileItem*> ::iterator ivecItems; CFileItem* m_Directory[2]; - CStdString m_strParentPath[2]; + std::string m_strParentPath[2]; CDirectoryHistory m_history[2]; int m_errorHeading, m_errorLine; diff --git a/xbmc/windows/GUIWindowHome.cpp b/xbmc/windows/GUIWindowHome.cpp index 8d504654e7..a82446cbb9 100644 --- a/xbmc/windows/GUIWindowHome.cpp +++ b/xbmc/windows/GUIWindowHome.cpp @@ -29,6 +29,7 @@ #include "utils/Variant.h" #include "guilib/GUIWindowManager.h" #include "Application.h" +#include "utils/StringUtils.h" using namespace ANNOUNCEMENT; @@ -64,8 +65,8 @@ void CGUIWindowHome::OnInitWindow() { // for shared databases (ie mysql) always force an update on return to home // this is a temporary solution until remote announcements can be delivered - if ( g_advancedSettings.m_databaseVideo.type.Equals("mysql") || - g_advancedSettings.m_databaseMusic.type.Equals("mysql") ) + if (StringUtils::EqualsNoCase(g_advancedSettings.m_databaseVideo.type, "mysql") || + StringUtils::EqualsNoCase(g_advancedSettings.m_databaseMusic.type, "mysql") ) m_updateRA = (Audio | Video | Totals); AddRecentlyAddedJobs( m_updateRA ); diff --git a/xbmc/windows/GUIWindowLoginScreen.cpp b/xbmc/windows/GUIWindowLoginScreen.cpp index 3a31965c32..932a0501df 100644 --- a/xbmc/windows/GUIWindowLoginScreen.cpp +++ b/xbmc/windows/GUIWindowLoginScreen.cpp @@ -47,6 +47,7 @@ #include "guilib/LocalizeStrings.h" #include "addons/AddonManager.h" #include "view/ViewState.h" +#include "pvr/PVRManager.h" #define CONTROL_BIG_LIST 52 #define CONTROL_LABEL_HEADER 2 @@ -139,9 +140,10 @@ bool CGUIWindowLoginScreen::OnAction(const CAction &action) // this forces only navigation type actions to be performed. if (action.GetID() == ACTION_BUILT_IN_FUNCTION) { - CStdString actionName = action.GetName(); + std::string actionName = action.GetName(); StringUtils::ToLower(actionName); - if (actionName.find("shutdown") != std::string::npos) + if ((actionName.find("shutdown") != std::string::npos) && + PVR::g_PVRManager.CanSystemPowerdown()) CBuiltins::Execute(action.GetName()); return true; } @@ -159,7 +161,7 @@ void CGUIWindowLoginScreen::FrameMove() if (GetFocusedControlID() == CONTROL_BIG_LIST && g_windowManager.GetTopMostModalDialogID() == WINDOW_INVALID) if (m_viewControl.HasControl(CONTROL_BIG_LIST)) m_iSelectedItem = m_viewControl.GetSelectedItem(); - CStdString strLabel = StringUtils::Format(g_localizeStrings.Get(20114).c_str(), m_iSelectedItem+1, CProfilesManager::Get().GetNumberOfProfiles()); + std::string strLabel = StringUtils::Format(g_localizeStrings.Get(20114).c_str(), m_iSelectedItem+1, CProfilesManager::Get().GetNumberOfProfiles()); SET_CONTROL_LABEL(CONTROL_LABEL_SELECTED_PROFILE,strLabel); CGUIWindow::FrameMove(); } @@ -198,14 +200,14 @@ void CGUIWindowLoginScreen::Update() { const CProfile *profile = CProfilesManager::Get().GetProfile(i); CFileItemPtr item(new CFileItem(profile->getName())); - CStdString strLabel; + std::string strLabel; if (profile->getDate().empty()) strLabel = g_localizeStrings.Get(20113); else strLabel = StringUtils::Format(g_localizeStrings.Get(20112).c_str(), profile->getDate().c_str()); item->SetLabel2(strLabel); item->SetArt("thumb", profile->getThumb()); - if (profile->getThumb().empty() || profile->getThumb().Equals("-")) + if (profile->getThumb().empty() || profile->getThumb() == "-") item->SetArt("thumb", "unknown-user.png"); item->SetLabelPreformated(true); m_vecItems->Add(item); diff --git a/xbmc/windows/GUIWindowLoginScreen.h b/xbmc/windows/GUIWindowLoginScreen.h index 36c96c56e3..e94ec183ab 100644 --- a/xbmc/windows/GUIWindowLoginScreen.h +++ b/xbmc/windows/GUIWindowLoginScreen.h @@ -45,7 +45,7 @@ protected: virtual void OnWindowLoaded(); virtual void OnWindowUnload(); void Update(); - void SetLabel(int iControl, const CStdString& strLabel); + void SetLabel(int iControl, const std::string& strLabel); bool OnPopupMenu(int iItem); CGUIViewControl m_viewControl; diff --git a/xbmc/windows/GUIWindowSystemInfo.cpp b/xbmc/windows/GUIWindowSystemInfo.cpp index 196a1c63e0..9e281b5439 100644 --- a/xbmc/windows/GUIWindowSystemInfo.cpp +++ b/xbmc/windows/GUIWindowSystemInfo.cpp @@ -198,6 +198,6 @@ void CGUIWindowSystemInfo::ResetLabels() void CGUIWindowSystemInfo::SetControlLabel(int id, const char *format, int label, int info) { - CStdString tmpStr = StringUtils::Format(format, g_localizeStrings.Get(label).c_str(), g_infoManager.GetLabel(info).c_str()); + std::string tmpStr = StringUtils::Format(format, g_localizeStrings.Get(label).c_str(), g_infoManager.GetLabel(info).c_str()); SET_CONTROL_LABEL(id, tmpStr); } diff --git a/xbmc/windows/GUIWindowWeather.cpp b/xbmc/windows/GUIWindowWeather.cpp index f1c182d498..fae09432c9 100644 --- a/xbmc/windows/GUIWindowWeather.cpp +++ b/xbmc/windows/GUIWindowWeather.cpp @@ -239,7 +239,7 @@ void CGUIWindowWeather::SetLocation(int loc) { ClearProperties(); g_weatherManager.SetArea(loc); - CStdString strLabel = g_weatherManager.GetLocation(loc); + std::string strLabel = g_weatherManager.GetLocation(loc); size_t iPos = strLabel.rfind(", "); if (iPos != std::string::npos) strLabel = strLabel.substr(0, iPos); @@ -264,12 +264,12 @@ void CGUIWindowWeather::SetProperties() SetProperty("Current.DewPoint", g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_DEWP)); SetProperty("Current.Humidity", g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_HUMI)); // we use the icons code number for fanart as it's the safest way - CStdString fanartcode = URIUtils::GetFileName(g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON)); + std::string fanartcode = URIUtils::GetFileName(g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON)); URIUtils::RemoveExtension(fanartcode); SetProperty("Current.FanartCode", fanartcode); // Future weather - CStdString day; + std::string day; for (int i = 0; i < NUM_DAYS; i++) { day = StringUtils::Format("Day%i.", i); @@ -301,7 +301,7 @@ void CGUIWindowWeather::ClearProperties() SetProperty("Current.FanartCode", ""); // Future weather - CStdString day; + std::string day; for (int i = 0; i < NUM_DAYS; i++) { day = StringUtils::Format("Day%i.", i); |