示例#1
0
        public bool ShouldDownload(AutoDownloadMode mode, AutoDownloadChat chat, NetworkType networkType)
        {
            bool isWiFi     = networkType is NetworkTypeWiFi;
            bool isCellular = !isWiFi && !(networkType is NetworkTypeNone);

            bool shouldDownload = false;

            switch (chat)
            {
            case AutoDownloadChat.Contact:
                if (isCellular)
                {
                    shouldDownload = (mode & AutoDownloadMode.CellularContacts) != 0;
                }
                else if (isWiFi)
                {
                    shouldDownload = (mode & AutoDownloadMode.WifiContacts) != 0;
                }
                break;

            case AutoDownloadChat.OtherPrivateChat:
                if (isCellular)
                {
                    shouldDownload = (mode & AutoDownloadMode.CellularPrivateChats) != 0;
                }
                else if (isWiFi)
                {
                    shouldDownload = (mode & AutoDownloadMode.WifiPrivateChats) != 0;
                }
                break;

            case AutoDownloadChat.Group:
                if (isCellular)
                {
                    shouldDownload = (mode & AutoDownloadMode.CellularGroups) != 0;
                }
                else if (isWiFi)
                {
                    shouldDownload = (mode & AutoDownloadMode.WifiGroups) != 0;
                }
                break;

            case AutoDownloadChat.Channel:
                if (isCellular)
                {
                    shouldDownload = (mode & AutoDownloadMode.CellularChannels) != 0;
                }
                else if (isWiFi)
                {
                    shouldDownload = (mode & AutoDownloadMode.WifiChannels) != 0;
                }
                break;

            default:
                break;
            }

            return(shouldDownload);
        }
示例#2
0
        public bool ShouldDownloadPhoto(AutoDownloadChat chat, NetworkType networkType = null)
        {
            if (_disabled)
            {
                return(false);
            }

            return(ShouldDownload(_photos, chat, networkType));
        }
示例#3
0
        public bool ShouldDownloadAnimation(AutoDownloadChat chat, NetworkType networkType)
        {
            if (_disabled)
            {
                return(false);
            }

            return(ShouldDownload(_animations, chat, networkType));
        }
示例#4
0
        public bool ShouldDownloadVideoNote(AutoDownloadChat chat, NetworkType networkType)
        {
            if (_disabled)
            {
                return(false);
            }

            return(ShouldDownload(_videoNotes, chat, networkType));
        }
示例#5
0
        public bool ShouldDownloadVoiceMessages(AutoDownloadChat chat, NetworkType networkType = null)
        {
            if (_disabled)
            {
                return(false);
            }

            return(ShouldDownload(VoiceMessages, chat, networkType));
        }
示例#6
0
        public bool ShouldDownloadAudio(AutoDownloadChat chat, NetworkType networkType)
        {
            if (_disabled)
            {
                return(false);
            }

            return(ShouldDownload(_audios, chat, networkType));
        }
示例#7
0
        public bool ShouldDownloadDocument(AutoDownloadChat chat, long size, NetworkType networkType = null)
        {
            if (_disabled)
            {
                return(false);
            }

            if (size > _maximumDocumentSize)
            {
                return(false);
            }

            return(ShouldDownload(_documents, chat, networkType));
        }
示例#8
0
        public bool ShouldDownloadVideo(AutoDownloadChat chat, long size, NetworkType networkType = null)
        {
            if (_disabled)
            {
                return(false);
            }

            if (size > _maximumVideoSize)
            {
                return(false);
            }

            return(ShouldDownload(_videos, chat, networkType));
        }
示例#9
0
        public bool ShouldDownloadDocument(AutoDownloadChat chat, NetworkType networkType, int size)
        {
            if (_disabled)
            {
                return(false);
            }

            if ((size / 1024f) / 1024f > _maximumDocumentSize)
            {
                return(false);
            }

            return(ShouldDownload(_documents, chat, networkType));
        }
示例#10
0
        public bool ShouldDownloadVideo(AutoDownloadChat chat, NetworkType networkType, int size)
        {
            if (_disabled)
            {
                return(false);
            }

            if ((size / 1024f) / 1024f > _maximumVideoSize)
            {
                return(false);
            }

            return(ShouldDownload(_videos, chat, networkType));
        }