Пример #1
0
 private string GenerateSettingKey(ConnectionType connectionType, DownloadContentType downloadContentType)
 {
     var res = "";
     switch (connectionType)
     {
         case ConnectionType.Mobile:
             res += "Mobile";
             break;
         case ConnectionType.Wlan:
             res += "Wlan";
             break;
         case ConnectionType.None:
             res += "None";
             break;
     }
     switch (downloadContentType)
     {
         case DownloadContentType.Any:
             res += "Any";
             break;
         case DownloadContentType.Article:
             res += "Article";
             break;
         case DownloadContentType.Feed:
             res += "Feed";
             break;
         case DownloadContentType.Image:
             res += "Image";
             break;
     }
     return res;
 }
Пример #2
0
        private async Task <bool> CanDownloadAsync(DownloadContentType type)
        {
            if (_downloadBlocked)
            {
                _lastResult = false;
            }
            else if (_lastTimeRequested - DateTime.Now > TimeSpan.FromSeconds(10))
            {
                return(_lastResult);
            }
            else
            {
                var conntype = _platformCodeService.GetConnectionType();
                if (conntype == ConnectionType.None)
                {
                    _lastResult = false;
                }
                else if (conntype == ConnectionType.Mobile)
                {
                    if (!(bool)_platformCodeService.GetLocalSetting(AskedAtMobileConnectionKey, false))
                    {
                        _platformCodeService.SetLocalSetting(AskedAtMobileConnectionKey, true);
                        await _dialogService.ShowMessage(
                            "Sie sind über das Mobilfunktnetz online, der Download wurde daher automatisch angehalten. Sie können diese Option in den Einstellungen wieder deaktivieren",
                            "Datenverbindung");
                    }

                    if (
                        !(bool)
                        _platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, DownloadContentType.Any),
                                                             false))
                    {
                        _lastResult = false;
                    }
                    _lastResult = (bool)_platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, type), false);
                }
                else if (conntype == ConnectionType.Wlan)
                {
                    if (
                        !(bool)
                        _platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, DownloadContentType.Any),
                                                             true))
                    {
                        _lastResult = false;
                    }
                    _lastResult = (bool)_platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, type), true);
                }
                else
                {
                    _lastResult = false;
                }
            }
            _lastTimeRequested = DateTime.Now;
            return(_lastResult);
        }
Пример #3
0
        private string getContentType(DownloadContentType arg)
        {
            switch (arg)
            {
            case DownloadContentType.MicrosoftWord:
                return("application/x-msword");

            case DownloadContentType.MicrosoftExcel:
                return("application/x-msexcel");

            case DownloadContentType.PlainText:
                return("text/plain");

            default:
                return("application/octet-stream");
            }
        }
Пример #4
0
        private async Task<bool> CanDownloadAsync(DownloadContentType type)
        {
            if (_downloadBlocked)
                _lastResult = false;
            else if (_lastTimeRequested - DateTime.Now > TimeSpan.FromSeconds(10))
                return _lastResult;
            else
            {
                var conntype = _platformCodeService.GetConnectionType();
                if (conntype == ConnectionType.None)
                    _lastResult = false;
                else if (conntype == ConnectionType.Mobile)
                {
                    if (!(bool) _platformCodeService.GetLocalSetting(AskedAtMobileConnectionKey, false))
                    {
                        _platformCodeService.SetLocalSetting(AskedAtMobileConnectionKey, true);
                        await _dialogService.ShowMessage(
                            "Sie sind über das Mobilfunktnetz online, der Download wurde daher automatisch angehalten. Sie können diese Option in den Einstellungen wieder deaktivieren",
                            "Datenverbindung");
                    }

                    if (
                        !(bool)
                            _platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, DownloadContentType.Any),
                                false))
                        _lastResult = false;
                    _lastResult = (bool) _platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, type), false);
                }
                else if (conntype == ConnectionType.Wlan)
                {
                    if (
                        !(bool)
                            _platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, DownloadContentType.Any),
                                true))
                        _lastResult = false;
                    _lastResult = (bool) _platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, type), true);
                }
                else
                {
                    _lastResult = false;
                }
            }
            _lastTimeRequested = DateTime.Now;
            return _lastResult;
        }
Пример #5
0
        private string GenerateSettingKey(ConnectionType connectionType, DownloadContentType downloadContentType)
        {
            var res = "";

            switch (connectionType)
            {
            case ConnectionType.Mobile:
                res += "Mobile";
                break;

            case ConnectionType.Wlan:
                res += "Wlan";
                break;

            case ConnectionType.None:
                res += "None";
                break;
            }
            switch (downloadContentType)
            {
            case DownloadContentType.Any:
                res += "Any";
                break;

            case DownloadContentType.Article:
                res += "Article";
                break;

            case DownloadContentType.Feed:
                res += "Feed";
                break;

            case DownloadContentType.Image:
                res += "Image";
                break;
            }
            return(res);
        }
Пример #6
0
 public bool GetPermission(ConnectionType conntype, DownloadContentType type, bool fallback)
 {
     return true;
 }
Пример #7
0
        public void SetPermission(ConnectionType conntype, DownloadContentType type, bool val)
        {

        }
Пример #8
0
 public bool GetPermission(ConnectionType conntype, DownloadContentType type, bool fallback)
 {
     return(true);
 }
Пример #9
0
 public void SetPermission(ConnectionType conntype, DownloadContentType type, bool val)
 {
 }
Пример #10
0
 public void SetContentType(DownloadContentType argContentType)
 {
     this.contenttype = getContentType(argContentType);
 }
Пример #11
0
 public bool GetPermission(ConnectionType conntype, DownloadContentType type, bool fallback)
 {
     return((bool)_platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, type), fallback));
 }
Пример #12
0
 public void SetPermission(ConnectionType conntype, DownloadContentType type, bool val)
 {
     _platformCodeService.SetLocalSetting(GenerateSettingKey(conntype, type), val);
     PermissionsChanged?.Invoke(this, EventArgs.Empty);
     _lastTimeRequested = DateTime.MinValue;
 }
Пример #13
0
 public bool GetPermission(ConnectionType conntype, DownloadContentType type, bool fallback)
 {
     return (bool)_platformCodeService.GetLocalSetting(GenerateSettingKey(conntype, type), fallback);
 }
Пример #14
0
 public void SetPermission(ConnectionType conntype, DownloadContentType type, bool val)
 {
     _platformCodeService.SetLocalSetting(GenerateSettingKey(conntype, type), val);
     PermissionsChanged?.Invoke(this, EventArgs.Empty);
     _lastTimeRequested = DateTime.MinValue;
 }