2 * Copyright (C) 2013 Team XBMC
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)
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.
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/>.
22 #include "XBDateTime.h"
23 #include "utils/Job.h"
24 #include "settings/lib/ISettingsHandler.h"
26 class CWakeOnAccess : private IJobCallback, public ISettingsHandler
29 static CWakeOnAccess &Get();
31 bool WakeUpHost (const CURL& fileUrl);
32 bool WakeUpHost (const CStdString& hostName, const std::string& customMessage);
34 void QueueMACDiscoveryForAllRemotes();
36 virtual void OnJobComplete(unsigned int jobID, bool success, CJob *job);
37 virtual void OnSettingsLoaded();
38 virtual void OnSettingsSaved();
40 // struct to keep per host settings
43 WakeUpEntry (bool isAwake = false);
47 CDateTimeSpan timeout;
48 unsigned int wait_online1_sec; // initial wait
49 unsigned int wait_online2_sec; // extended wait
50 unsigned int wait_services_sec;
52 unsigned short ping_port; // where to ping
53 unsigned short ping_mode; // how to ping
60 CStdString GetSettingFile();
64 void SetEnabled(bool enabled);
65 bool IsEnabled() const { return m_enabled; }
67 void QueueMACDiscoveryForHost(const CStdString& host);
68 void SaveMACDiscoveryResult(const CStdString& host, const CStdString& mac);
70 typedef std::vector<WakeUpEntry> EntriesVector;
71 EntriesVector m_entries;
72 CCriticalSection m_entrylist_protect;
73 bool FindOrTouchHostEntry (const CStdString& hostName, WakeUpEntry& server);
74 void TouchHostEntry (const CStdString& hostName);
76 unsigned int m_netinit_sec, m_netsettle_ms; //time to wait for network connection
80 bool WakeUpHost(const WakeUpEntry& server);