diff options
Diffstat (limited to 'xbmc/addons/ScreenSaver.cpp')
| -rw-r--r-- | xbmc/addons/ScreenSaver.cpp | 125 |
1 files changed, 0 insertions, 125 deletions
diff --git a/xbmc/addons/ScreenSaver.cpp b/xbmc/addons/ScreenSaver.cpp deleted file mode 100644 index ef345f5..0000000 --- a/xbmc/addons/ScreenSaver.cpp +++ /dev/null | |||
| @@ -1,125 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2013 Team XBMC | ||
| 3 | * http://xbmc.org | ||
| 4 | * | ||
| 5 | * This Program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 8 | * any later version. | ||
| 9 | * | ||
| 10 | * This Program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with XBMC; see the file COPYING. If not, see | ||
| 17 | * <http://www.gnu.org/licenses/>. | ||
| 18 | * | ||
| 19 | */ | ||
| 20 | #include "ScreenSaver.h" | ||
| 21 | #include "guilib/GraphicContext.h" | ||
| 22 | #include "interfaces/generic/ScriptInvocationManager.h" | ||
| 23 | #include "settings/DisplaySettings.h" | ||
| 24 | #include "utils/AlarmClock.h" | ||
| 25 | #include "windowing/WindowingFactory.h" | ||
| 26 | |||
| 27 | // What sound does a python screensaver make? | ||
| 28 | #define SCRIPT_ALARM "sssssscreensaver" | ||
| 29 | |||
| 30 | #define SCRIPT_TIMEOUT 5 // seconds | ||
| 31 | |||
| 32 | namespace ADDON | ||
| 33 | { | ||
| 34 | |||
| 35 | CScreenSaver::CScreenSaver(const char *addonID) | ||
| 36 | : ADDON::CAddonDll<DllScreenSaver, ScreenSaver, SCR_PROPS>(AddonProps(addonID, ADDON_UNKNOWN, "", "")) | ||
| 37 | { | ||
| 38 | } | ||
| 39 | |||
| 40 | AddonPtr CScreenSaver::Clone() const | ||
| 41 | { | ||
| 42 | // Copy constructor is generated by compiler and calls parent copy constructor | ||
| 43 | return AddonPtr(new CScreenSaver(*this)); | ||
| 44 | } | ||
| 45 | |||
| 46 | bool CScreenSaver::CreateScreenSaver() | ||
| 47 | { | ||
| 48 | if (CScriptInvocationManager::Get().HasLanguageInvoker(LibPath())) | ||
| 49 | { | ||
| 50 | // Don't allow a previously-scheduled alarm to kill our new screensaver | ||
| 51 | g_alarmClock.Stop(SCRIPT_ALARM, true); | ||
| 52 | |||
| 53 | if (!CScriptInvocationManager::Get().Stop(LibPath())) | ||
| 54 | CScriptInvocationManager::Get().ExecuteAsync(LibPath(), Clone()); | ||
| 55 | return true; | ||
| 56 | } | ||
| 57 | // pass it the screen width,height | ||
| 58 | // and the name of the screensaver | ||
| 59 | int iWidth = g_graphicsContext.GetWidth(); | ||
| 60 | int iHeight = g_graphicsContext.GetHeight(); | ||
| 61 | |||
| 62 | m_pInfo = new SCR_PROPS; | ||
| 63 | #ifdef HAS_DX | ||
| 64 | m_pInfo->device = g_Windowing.Get3DDevice(); | ||
| 65 | #else | ||
| 66 | m_pInfo->device = NULL; | ||
| 67 | #endif | ||
| 68 | m_pInfo->x = 0; | ||
| 69 | m_pInfo->y = 0; | ||
| 70 | m_pInfo->width = iWidth; | ||
| 71 | m_pInfo->height = iHeight; | ||
| 72 | m_pInfo->pixelRatio = g_graphicsContext.GetResInfo().fPixelRatio; | ||
| 73 | m_pInfo->name = strdup(Name().c_str()); | ||
| 74 | m_pInfo->presets = strdup(CSpecialProtocol::TranslatePath(Path()).c_str()); | ||
| 75 | m_pInfo->profile = strdup(CSpecialProtocol::TranslatePath(Profile()).c_str()); | ||
| 76 | |||
| 77 | if (CAddonDll<DllScreenSaver, ScreenSaver, SCR_PROPS>::Create() == ADDON_STATUS_OK) | ||
| 78 | return true; | ||
| 79 | |||
| 80 | return false; | ||
| 81 | } | ||
| 82 | |||
| 83 | void CScreenSaver::Start() | ||
| 84 | { | ||
| 85 | // notify screen saver that they should start | ||
| 86 | if (Initialized()) m_pStruct->Start(); | ||
| 87 | } | ||
| 88 | |||
| 89 | void CScreenSaver::Render() | ||
| 90 | { | ||
| 91 | // ask screensaver to render itself | ||
| 92 | if (Initialized()) m_pStruct->Render(); | ||
| 93 | } | ||
| 94 | |||
| 95 | void CScreenSaver::GetInfo(SCR_INFO *info) | ||
| 96 | { | ||
| 97 | // get info from screensaver | ||
| 98 | if (Initialized()) m_pStruct->GetInfo(info); | ||
| 99 | } | ||
| 100 | |||
| 101 | void CScreenSaver::Destroy() | ||
| 102 | { | ||
| 103 | #ifdef HAS_PYTHON | ||
| 104 | if (URIUtils::HasExtension(LibPath(), ".py")) | ||
| 105 | { | ||
| 106 | g_alarmClock.Start(SCRIPT_ALARM, SCRIPT_TIMEOUT, "StopScript(" + LibPath() + ")", true, false); | ||
| 107 | return; | ||
| 108 | } | ||
| 109 | #endif | ||
| 110 | // Release what was allocated in method CScreenSaver::CreateScreenSaver. | ||
| 111 | if (m_pInfo) | ||
| 112 | { | ||
| 113 | free((void *) m_pInfo->name); | ||
| 114 | free((void *) m_pInfo->presets); | ||
| 115 | free((void *) m_pInfo->profile); | ||
| 116 | |||
| 117 | delete m_pInfo; | ||
| 118 | m_pInfo = NULL; | ||
| 119 | } | ||
| 120 | |||
| 121 | CAddonDll<DllScreenSaver, ScreenSaver, SCR_PROPS>::Destroy(); | ||
| 122 | } | ||
| 123 | |||
| 124 | } /*namespace ADDON*/ | ||
| 125 | |||
