예제 #1
0
        private bool CheckForUpdateInternal(bool beta = false)
        {
            try
            {
                Log.O("Checking for " + (beta?"beta ":"") + "updates...");
                string updateUrl = "";

#if APP_RELEASE
                updateUrl = ReleaseData.UpdateBaseUrl + ReleaseData.UpdateConfigFile +
                            "?r=" + DateTime.UtcNow.ToEpochTime().ToString();
                //Because WebClient won't let you disable caching :(
#endif
                Log.O("Downloading update file: " + updateUrl);

                string data = DownloadString(updateUrl);

                var mc = new MapConfig();
                mc.LoadConfig(data);

                string verStr = mc.GetValue(beta?"BetaVersion":"CurrentVersion", string.Empty);
                DownloadUrl      = mc.GetValue(beta ? "BetaDownloadUrl" : "DownloadUrl", string.Empty);
                ReleaseNotesPath = mc.GetValue(beta ? "BetaReleaseNotes" : "ReleaseNotes", string.Empty);

                ReleaseNotes = string.Empty;
                if (ReleaseNotesPath != string.Empty)
                {
                    ReleaseNotes = DownloadString(ReleaseNotesPath);
                }

                Version ver = null;

                if (!Version.TryParse(verStr, out ver))
                {
                    SendUpdateEvent(false);
                    return(false);
                }

                NewVersion = ver;

                bool result = false;
                if (NewVersion > CurrentVersion)
                {
                    result = true;
                }

                UpdateNeeded = result;
                SendUpdateEvent(result);
                return(result);
            }
            catch (Exception e)
            {
                Log.O("Error checking for updates: " + e);
                UpdateNeeded = false;
                SendUpdateEvent(false);
                return(false);
            }
        }
예제 #2
0
        public bool LoadConfig()
        {
            if (!_c.LoadConfig())
            {
                return(false);
            }

            Fields.Debug_WriteLog  = (bool)_c.GetValue(ConfigItems.Debug_WriteLog);
            Fields.Debug_Logpath   = (string)_c.GetValue(ConfigItems.Debug_Logpath);
            Fields.Debug_Timestamp = (bool)_c.GetValue(ConfigItems.Debug_Timestamp);

            Fields.Login_Email    = (string)_c.GetValue(ConfigItems.Login_Email);
            Fields.Login_Password = _c.GetEncryptedString(ConfigItems.Login_Password);

            Fields.Login_AutoLogin = (bool)_c.GetValue(ConfigItems.Login_AutoLogin);

            Fields.Pandora_AudioFormat = (string)_c.GetValue(ConfigItems.Pandora_AudioFormat);
            if (Fields.Pandora_AudioFormat != PAudioFormat.AACPlus &&
                Fields.Pandora_AudioFormat != PAudioFormat.MP3 &&
                Fields.Pandora_AudioFormat != PAudioFormat.MP3_HIFI)
            {
                Fields.Pandora_AudioFormat = PAudioFormat.MP3;
            }
            Fields.Pandora_AutoPlay         = (bool)_c.GetValue(ConfigItems.Pandora_AutoPlay);
            Fields.Pandora_LastStationID    = (string)_c.GetValue(ConfigItems.Pandora_LastStationID);
            Fields.Pandora_StationSortOrder = (string)_c.GetValue(ConfigItems.Pandora_StationSortOrder);

            Fields.Proxy_Address  = ((string)_c.GetValue(ConfigItems.Proxy_Address)).Trim();
            Fields.Proxy_Port     = (int)_c.GetValue(ConfigItems.Proxy_Port);
            Fields.Proxy_User     = (string)_c.GetValue(ConfigItems.Proxy_User);
            Fields.Proxy_Password = _c.GetEncryptedString(ConfigItems.Proxy_Password);

            var     verStr = (string)_c.GetValue(ConfigItems.Elpis_Version);
            Version ver;

            if (Version.TryParse(verStr, out ver))
            {
                Fields.Elpis_Version = ver;
            }

            Fields.Elpis_InstallID             = (string)_c.GetValue(ConfigItems.Elpis_InstallID);
            Fields.Elpis_CheckUpdates          = (bool)_c.GetValue(ConfigItems.Elpis_CheckUpdates);
            Fields.Elpis_CheckBetaUpdates      = (bool)_c.GetValue(ConfigItems.Elpis_CheckBetaUpdates);
            Fields.Elpis_RemoteControlEnabled  = (bool)_c.GetValue(ConfigItems.Elpis_RemoteControlEnabled);
            Fields.Elpis_MinimizeToTray        = (bool)_c.GetValue(ConfigItems.Elpis_MinimizeToTray);
            Fields.Elpis_ShowTrayNotifications = (bool)_c.GetValue(ConfigItems.Elpis_ShowTrayNotifications);
            Fields.Elpis_Volume      = (int)_c.GetValue(ConfigItems.Elpis_Volume);
            Fields.Elpis_PauseOnLock = (bool)_c.GetValue(ConfigItems.Elpis_PauseOnLock);
            Fields.Elpis_MaxHistory  = (int)_c.GetValue(ConfigItems.Elpis_MaxHistory);

            Fields.LastFM_Scrobble   = (bool)_c.GetValue(ConfigItems.LastFM_Scrobble);
            Fields.LastFM_SessionKey = _c.GetEncryptedString(ConfigItems.LastFM_SessionKey);

            var location = (string)_c.GetValue(ConfigItems.Elpis_StartupLocation);

            try
            {
                Fields.Elpis_StartupLocation = Point.Parse(location);
            }
            catch
            {
                Fields.Elpis_StartupLocation = new Point(-1, -1);
            }

            var size = (string)_c.GetValue(ConfigItems.Elpis_StartupSize);

            try
            {
                Fields.Elpis_StartupSize = Size.Parse(size);
            }
            catch
            {
                Fields.Elpis_StartupSize = new Size(0, 0);
            }

            var list = _c.GetValue(ConfigItems.HotKeysList) as Dictionary <int, string>;

            if (list != null)
            {
                foreach (KeyValuePair <int, string> pair in list)
                {
                    Fields.Elpis_HotKeys.Add(pair.Key, new HotkeyConfig(pair.Value, HotkeyConfig.Default));
                }
            }

            Fields.System_OutputDevice = (string)_c.GetValue(ConfigItems.System_OutputDevice);

            Log.O("Config File Contents:");
            Log.O(_c.LastConfig);

            return(true);
        }