static bool HavePlatformMPEGDecoders() { return Preferences::GetBool("media.fragmented-mp4.use-blank-decoder") || #ifdef XP_WIN // We have H.264/AAC platform decoders on Windows Vista and up. IsVistaOrLater() || #endif IsAndroidAvailable() || IsFFmpegAvailable() || IsAppleAvailable() || IsGonkMP4DecoderAvailable() || // TODO: Other platforms... false; }
static bool HavePlatformMPEGDecoders() { #ifdef XP_WIN // We always have H.264/AAC platform decoders on Windows. return true; #else return Preferences::GetBool("media.use-blank-decoder") || IsAndroidAvailable() || IsFFmpegAvailable() || IsAppleAvailable() || IsGonkMP4DecoderAvailable() || IsGMPDecoderAvailable() || // TODO: Other platforms... false; #endif }
bool CSettings::LoadSettings(std::string szDir, std::string fileName, bool LoadFromRegistry ) { fileName_ = !szDir.empty() ? szDir + ( (!fileName .empty())? fileName : "Settings.xml") : SettingsFolder + ( !fileName.empty() ? fileName : "Settings.xml"); //std::cout<< fileName_; //MessageBoxA(0,fileName_.c_str(),0,0); if ( !IuCoreUtils::FileExists( fileName_) ) { return true; } SimpleXml xml; xml.LoadFromFile( fileName_ ); mgr_.loadFromXmlNode( xml.getRoot("ImageUploader").GetChild("Settings") ); SimpleXmlNode settingsNode = xml.getRoot( "ImageUploader" ).GetChild( "Settings" ); #if !defined(IU_CLI) && !defined( IU_SHELLEXT) && !defined(IU_SERVERLISTTOOL) std::string temp; if ( !settingsNode["Image"]["Format"].IsNull() ) { // for compatibility with old version configuration file LoadConvertProfile( "Old profile", settingsNode ); } if ( CmdLine.IsOption(_T("afterinstall") )) { if ( CmdLine.IsOption(_T("usenewicon") )) { UseNewIcon = true; } else { UseNewIcon = false; } SaveSettings(); } // Migrating from 1.3.0 to 1.3.1 (added ImageEditor has been addded) if (settingsNode["ImageEditor"].IsNull() ) { if ( Settings.TrayIconSettings.TrayScreenshotAction == TRAY_SCREENSHOT_UPLOAD ) { TrayIconSettings.TrayScreenshotAction = TRAY_SCREENSHOT_OPENINEDITOR; } } LoadConvertProfiles( settingsNode.GetChild("Image").GetChild("Profiles") ); LoadServerProfiles( settingsNode.GetChild("Uploading").GetChild("ServerProfiles") ); #endif LoadAccounts( xml.getRoot( "ImageUploader" ).GetChild( "Settings" ).GetChild( "ServersParams" ) ); #if !defined(IU_CLI) && !defined( IU_SHELLEXT) && !defined(IU_SERVERLISTTOOL) // Fixing profies if ( !imageServer.profileName().IsEmpty() && ServersSettings[WCstringToUtf8(imageServer.serverName())].find(WCstringToUtf8(imageServer.profileName())) == ServersSettings[WCstringToUtf8(imageServer.serverName())].end() ) { imageServer.setProfileName(""); } if ( !fileServer.profileName().IsEmpty() && ServersSettings[WCstringToUtf8(fileServer.serverName())].find(WCstringToUtf8(fileServer.profileName())) == ServersSettings[WCstringToUtf8(fileServer.serverName())].end() ) { fileServer.setProfileName(""); } if ( !contextMenuServer.profileName().IsEmpty() && ServersSettings[WCstringToUtf8(contextMenuServer.serverName())].find(WCstringToUtf8(contextMenuServer.profileName())) == ServersSettings[WCstringToUtf8(contextMenuServer.serverName())].end() ) { contextMenuServer.setProfileName(""); } if ( !quickScreenshotServer.profileName().IsEmpty() && ServersSettings[WCstringToUtf8(quickScreenshotServer.serverName())].find(WCstringToUtf8(quickScreenshotServer.profileName())) == ServersSettings[WCstringToUtf8(quickScreenshotServer.serverName())].end() ) { quickScreenshotServer.setProfileName(""); } if ( !urlShorteningServer.profileName().IsEmpty() && ServersSettings[WCstringToUtf8(urlShorteningServer.serverName())].find(WCstringToUtf8(urlShorteningServer.profileName())) == ServersSettings[WCstringToUtf8(urlShorteningServer.serverName())].end() ) { urlShorteningServer.setProfileName(""); } if ( UploadBufferSize == 65536) { UploadBufferSize = 1024 * 1024; } #endif #if !defined(IU_CLI) && !defined(IU_SERVERLISTTOOL) // Loading some settings from registry if ( LoadFromRegistry ) { CRegistry Reg; Reg.SetRootKey( HKEY_LOCAL_MACHINE ); if ( Reg.SetKey("Software\\Zenden.ws\\Image Uploader", false ) ) { ExplorerContextMenu = Reg.ReadBool("ExplorerContextMenu", false); } else { ExplorerContextMenu = false; } } CRegistry Reg; Reg.SetRootKey( HKEY_CURRENT_USER ); if ( Reg.SetKey("Software\\Zenden.ws\\Image Uploader", false ) ) { ExplorerCascadedMenu = Reg.ReadBool( "ExplorerCascadedMenu", true); ExplorerVideoContextMenu = Reg.ReadBool( "ExplorerVideoContextMenu", true); } CRegistry Reg2; Reg2.SetRootKey(HKEY_CURRENT_USER); if ( Reg2.SetKey("Software\\Zenden.ws\\Image Uploader", false ) ) { AutoStartup = Reg2.ReadBool("AutoStartup", false); } if ( VideoSettings.Engine != VideoEngineDirectshow && VideoSettings.Engine != VideoEngineFFmpeg && VideoSettings.Engine != VideoEngineAuto ){ VideoSettings.Engine = VideoEngineAuto; } if ( !IsFFmpegAvailable() ){ VideoSettings.Engine = VideoEngineDirectshow; } #endif return true; }
CSettings::CSettings() { #if !defined(IU_CLI) && !defined(IU_SERVERLISTTOOL) IsPortable = false; FindDataFolder(); if (!IsDirectory(DataFolder)) { CreateDirectory(DataFolder, 0); } if (!IsDirectory(IuCoreUtils::Utf8ToWstring(SettingsFolder).c_str())) { CreateDirectory(IuCoreUtils::Utf8ToWstring(SettingsFolder).c_str(), 0); } BOOL isElevated = false; IsElevated(&isElevated); if ( isElevated || CmdLine.IsOption(L"afterupdate")) { WinUtils::MakeDirectoryWritable(DataFolder); } #endif #if !defined(IU_CLI) && !defined(IU_SERVERLISTTOOL) CString copyFrom = WinUtils::GetAppFolder() + SETTINGS_FILE_NAME; CString copyTo = DataFolder + SETTINGS_FILE_NAME; if (FileExists(copyFrom) && !FileExists(copyTo)) { MoveFile(copyFrom, copyTo); } // Default values of settings ExplorerCascadedMenu = true; ConnectionSettings.UseProxy = FALSE; ConnectionSettings.ProxyPort = 0; ConnectionSettings.NeedsAuth = false; ConnectionSettings.ProxyType = 0; #endif LastUpdateTime = 0; UploadBufferSize = /*65536*/1024*1024; FileRetryLimit = 3; ActionRetryLimit = 2; #if !defined(IU_SHELLEXT) && !defined(IU_CLI) && !defined(IU_SERVERLISTTOOL) if ( !IsFFmpegAvailable() ){ VideoSettings.Engine = VideoEngineDirectshow; } WatchClipboard = true; ShowTrayIcon = false; ShowTrayIcon_changed = false; *m_Directory = 0; UseTxtTemplate = false; UseDirectLinks = true; CodeLang = 0; ConfirmOnExit = 1; ExplorerContextMenu = false; ExplorerVideoContextMenu = true; ExplorerContextMenu_changed = false; ThumbsPerLine = 4; SendToContextMenu_changed = false; SendToContextMenu = 0; QuickUpload = 1; ParseSubDirs = 1; UseNewIcon = false; RememberImageServer = true; RememberFileServer = true; ShowUploadErrorDialog = true; ImageEditorPath = _T("mspaint.exe \"%1\""); AutoCopyToClipboard = false; AutoShowLog = true; // StringToFont(_T("Tahoma,7,b,204"), &ThumbSettings.ThumbFont); StringToFont(_T("Tahoma,8,,204"), &VideoSettings.Font); /*ThumbSettings.CreateThumbs = true; ThumbSettings.ThumbWidth = 180; ThumbSettings.ThumbHeight = 140; ThumbSettings.DrawFrame = true; ThumbSettings.ThumbAddImageSize = true; ThumbSettings.FrameColor = RGB( 0, 74, 111); ThumbSettings.BackgroundColor = RGB( 255, 255, 255);f ThumbSettings.ThumbColor1 = RGB( 13, 86, 125); ThumbSettings.ThumbColor2 = RGB( 6, 174, 255); ThumbSettings.UseServerThumbs = false; ThumbSettings.ScaleByHeight = false; ThumbSettings.ThumbTextColor = RGB( 255, 255, 255); ThumbSettings.ThumbAlpha = 120; ThumbSettings.Text = _T("%width%x%height% (%size%)"); ThumbSettings.Format = ThumbCreatingParams::tfJPEG; ThumbSettings.FileName = "default"; ThumbSettings.Quality = 85;*/ VideoSettings.Columns = 3; VideoSettings.TileWidth = 200; VideoSettings.GapWidth = 5; VideoSettings.GapHeight = 7; VideoSettings.NumOfFrames = 8; VideoSettings.JPEGQuality = 100; VideoSettings.UseAviInfo = TRUE; VideoSettings.ShowMediaInfo = TRUE; VideoSettings.TextColor = RGB(0, 0, 0); VideoSettings.SnapshotsFolder = IuCoreUtils::Utf8ToWstring(Settings.SettingsFolder).c_str() + CString(_T("Snapshots")); VideoSettings.SnapshotFileTemplate = _T("%f%_%cx%_%cy%_%uid%\\grab_%i%.png"); VideoSettings.Engine = IsFFmpegAvailable() ? VideoEngineAuto : VideoEngineDirectshow; ScreenshotSettings.Format = 1; ScreenshotSettings.Quality = 85; ScreenshotSettings.WindowHidingDelay = 450; ScreenshotSettings.Delay = 1; ScreenshotSettings.brushColor = RGB(255, 0, 0); ScreenshotSettings.ShowForeground = false; ScreenshotSettings.FilenameTemplate = _T("screenshot %y-%m-%d %i"); ScreenshotSettings.CopyToClipboard = false; ScreenshotSettings.RemoveCorners = !WinUtils::IsWindows8orLater(); ScreenshotSettings.AddShadow = false; ScreenshotSettings.RemoveBackground = false; ScreenshotSettings.OpenInEditor = true; ScreenshotSettings.UseOldRegionScreenshotMethod = false; TrayIconSettings.LeftClickCommand = 0; // without action TrayIconSettings.LeftDoubleClickCommand = 12; TrayIconSettings.RightClickCommand = 1; // context menu TrayIconSettings.MiddleClickCommand = 7; // region screenshot TrayIconSettings.DontLaunchCopy = FALSE; TrayIconSettings.ShortenLinks = FALSE; TrayIconSettings.TrayScreenshotAction = TRAY_SCREENSHOT_OPENINEDITOR; ImageEditorSettings.BackgroundColor = Gdiplus::Color(255,255,255); ImageEditorSettings.ForegroundColor = Gdiplus::Color(255,0,0); ImageEditorSettings.PenSize = 12; ImageEditorSettings.RoundingRadius = ImageEditorSettings.PenSize; StringToFont(_T("Arial,12,b,204"), &ImageEditorSettings.Font); ImageReuploaderSettings.PasteHtmlOnCtrlV = true; Hotkeys_changed = false; #endif /* binding settings */ SettingsNode& general = mgr_["General"]; general.n_bind(LastUpdateTime); #if !defined(IU_CLI) && !defined(IU_SERVERLISTTOOL) general.n_bind(Language); general.n_bind(ExplorerContextMenu); /*general.n_bind(ExplorerVideoContextMenu); general.n_bind(ExplorerCascadedMenu);*/ #endif #if !defined(IU_SHELLEXT) && !defined(IU_CLI) && !defined(IU_SERVERLISTTOOL) general.n_bind(ConfirmOnExit); general.n_bind(SendToContextMenu); general.n_bind(ParseSubDirs); general.n_bind(ImageEditorPath); //general.n_bind(AutoStartup); general.n_bind(ShowTrayIcon); general.n_bind(AutoCopyToClipboard); general.n_bind(AutoShowLog); general.n_bind(ImagesFolder); general.n_bind(VideoFolder); general.n_bind(WatchClipboard); general.n_bind(UseNewIcon); general.n_bind(RememberFileServer); general.n_bind(RememberImageServer); #ifndef IU_SERVERLISTTOOL general.n_bind(Hotkeys); #endif SettingsNode& screenshot = mgr_["Screenshot"]; screenshot.nm_bind(ScreenshotSettings, Delay); screenshot.nm_bind(ScreenshotSettings, Format); screenshot.nm_bind(ScreenshotSettings, Quality); screenshot.nm_bind(ScreenshotSettings, ShowForeground); screenshot.nm_bind(ScreenshotSettings, FilenameTemplate); screenshot.nm_bind(ScreenshotSettings, Folder); screenshot.nm_bind(ScreenshotSettings, AddShadow); screenshot.nm_bind(ScreenshotSettings, RemoveBackground); screenshot.nm_bind(ScreenshotSettings, RemoveCorners); screenshot.nm_bind(ScreenshotSettings, CopyToClipboard); screenshot.nm_bind(ScreenshotSettings, brushColor); screenshot.nm_bind(ScreenshotSettings, WindowHidingDelay); screenshot.nm_bind(ScreenshotSettings, OpenInEditor); screenshot.nm_bind(ScreenshotSettings, UseOldRegionScreenshotMethod); SettingsNode& imageEditor = mgr_["ImageEditor"]; imageEditor.nm_bind(ImageEditorSettings, ForegroundColor); imageEditor.nm_bind(ImageEditorSettings, BackgroundColor); imageEditor.nm_bind(ImageEditorSettings, PenSize); imageEditor.nm_bind(ImageEditorSettings, RoundingRadius); imageEditor.nm_bind(ImageEditorSettings, Font); SettingsNode& image = mgr_["Image"]; image["CurrentProfile"].bind(CurrentConvertProfileName); image.nm_bind(UploadProfile, KeepAsIs); /*SettingsNode& thumbnails = mgr_["Thumbnails"]; thumbnails.nm_bind(ThumbSettings, FileName); thumbnails.nm_bind(ThumbSettings, CreateThumbs); thumbnails.nm_bind(ThumbSettings, ThumbWidth); thumbnails.nm_bind(ThumbSettings, ThumbHeight); thumbnails.nm_bind(ThumbSettings, ScaleByHeight); thumbnails.nm_bind(ThumbSettings, FrameColor); thumbnails.nm_bind(ThumbSettings, ThumbColor1); thumbnails.nm_bind(ThumbSettings, ThumbColor2); thumbnails.nm_bind(ThumbSettings, UseServerThumbs); thumbnails.nm_bind(ThumbSettings, ThumbAddImageSize); thumbnails.nm_bind(ThumbSettings, DrawFrame); thumbnails.nm_bind(ThumbSettings, Quality); thumbnails.nm_bind(ThumbSettings, Format); thumbnails.nm_bind(ThumbSettings, Text); thumbnails["Text"]["@Color"].bind(ThumbSettings.ThumbTextColor); thumbnails["Text"]["@Font"].bind(ThumbSettings.ThumbFont); thumbnails["Text"]["@TextOverThumb"].bind(ThumbSettings.TextOverThumb); thumbnails["Text"]["@ThumbAlpha"].bind(ThumbSettings.ThumbAlpha);*/ SettingsNode& video = mgr_["VideoGrabber"]; video.nm_bind(VideoSettings, Columns); video.nm_bind(VideoSettings, TileWidth); video.nm_bind(VideoSettings, GapWidth); video.nm_bind(VideoSettings, GapHeight); video.nm_bind(VideoSettings, NumOfFrames); video.nm_bind(VideoSettings, JPEGQuality); video.nm_bind(VideoSettings, ShowMediaInfo); video.nm_bind(VideoSettings, TextColor); video.nm_bind(VideoSettings, Font); video.nm_bind(VideoSettings, Engine); video.nm_bind(VideoSettings, SnapshotsFolder); video.nm_bind(VideoSettings, SnapshotFileTemplate); SettingsNode& tray = mgr_["TrayIcon"]; tray.nm_bind(TrayIconSettings, LeftDoubleClickCommand); tray.nm_bind(TrayIconSettings, LeftClickCommand); tray.nm_bind(TrayIconSettings, RightClickCommand); tray.nm_bind(TrayIconSettings, MiddleClickCommand); tray.nm_bind(TrayIconSettings, DontLaunchCopy); tray.nm_bind(TrayIconSettings, ShortenLinks); tray.nm_bind(TrayIconSettings, TrayScreenshotAction); SettingsNode& history = mgr_["History"]; history.nm_bind(HistorySettings, EnableDownloading); SettingsNode& imageReuploader = mgr_["ImageReuploader"]; imageReuploader.nm_bind(ImageReuploaderSettings, PasteHtmlOnCtrlV); #endif SettingsNode& upload = mgr_["Uploading"]; #if !defined(IU_CLI) && !defined(IU_SERVERLISTTOOL) upload.n_bind(ServerName); upload.n_bind(FileServerName); // upload.n_bind(UrlShorteningServer); upload.n_bind(QuickUpload); upload.n_bind(QuickServerName); upload.n_bind(CodeLang); upload.n_bind(ThumbsPerLine); upload.n_bind(UseDirectLinks); upload.n_bind(UseTxtTemplate); upload.n_bind(CodeType); upload.n_bind(ShowUploadErrorDialog); imageServer.bind(upload["Server"]); fileServer.bind(upload["FileServer"]); quickScreenshotServer.bind(upload["QuickScreenshotServer"]); contextMenuServer.bind(upload["ContextMenuServer"]); urlShorteningServer.bind(upload["UrlShorteningServer"]); ConvertProfiles["Default"] = ImageConvertingParams(); CurrentConvertProfileName = "Default"; #endif upload.n_bind(UploadBufferSize); upload.n_bind(FileRetryLimit); upload.n_bind(ActionRetryLimit); #if !defined (IU_CLI) && !defined(IU_SHELLEXT) && !defined(IU_SERVERLISTTOOL) SettingsNode& proxy = upload["Proxy"]; proxy["@UseProxy"].bind(ConnectionSettings.UseProxy); proxy["@NeedsAuth"].bind(ConnectionSettings.NeedsAuth); proxy.nm_bind(ConnectionSettings, ServerAddress); proxy.nm_bind(ConnectionSettings, ProxyPort); proxy.nm_bind(ConnectionSettings, ProxyType); proxy.nm_bind(ConnectionSettings, ProxyUser); proxy.nm_bind(ConnectionSettings, ProxyPassword);; #endif }