package tdesktop

import (
	
	

	

	
)

//nolint:deadcode,unused,varcheck
const (
	dbiKey               = 0x00
	dbiUser              = 0x01
	dbiDcOptionOldOld    = 0x02
	dbiChatSizeMax       = 0x03
	dbiMutePeer          = 0x04
	dbiSendKey           = 0x05
	dbiAutoStart         = 0x06
	dbiStartMinimized    = 0x07
	dbiSoundNotify       = 0x08
	dbiWorkMode          = 0x09
	dbiSeenTrayTooltip   = 0x0a
	dbiDesktopNotify     = 0x0b
	dbiAutoUpdate        = 0x0c
	dbiLastUpdateCheck   = 0x0d
	dbiWindowPosition    = 0x0e
	dbiConnectionTypeOld = 0x0f
	// 0x10 reserved
	dbiDefaultAttach     = 0x11
	dbiCatsAndDogs       = 0x12
	dbiReplaceEmojis     = 0x13
	dbiAskDownloadPath   = 0x14
	dbiDownloadPathOld   = 0x15
	dbiScale             = 0x16
	dbiEmojiTabOld       = 0x17
	dbiRecentEmojiOldOld = 0x18
	dbiLoggedPhoneNumber = 0x19
	dbiMutedPeers        = 0x1a
	// 0x1b reserved
	dbiNotifyView              = 0x1c
	dbiSendToMenu              = 0x1d
	dbiCompressPastedImage     = 0x1e
	dbiLangOld                 = 0x1f
	dbiLangFileOld             = 0x20
	dbiTileBackground          = 0x21
	dbiAutoLock                = 0x22
	dbiDialogLastPath          = 0x23
	dbiRecentEmojiOld          = 0x24
	dbiEmojiVariantsOld        = 0x25
	dbiRecentStickers          = 0x26
	dbiDcOptionOld             = 0x27
	dbiTryIPv6                 = 0x28
	dbiSongVolume              = 0x29
	dbiWindowsNotificationsOld = 0x30
	dbiIncludeMuted            = 0x31
	dbiMegagroupSizeMax        = 0x32
	dbiDownloadPath            = 0x33
	dbiAutoDownload            = 0x34
	dbiSavedGifsLimit          = 0x35
	dbiShowingSavedGifsOld     = 0x36
	dbiAutoPlay                = 0x37
	dbiAdaptiveForWide         = 0x38
	dbiHiddenPinnedMessages    = 0x39
	dbiRecentEmoji             = 0x3a
	dbiEmojiVariants           = 0x3b
	dbiDialogsMode             = 0x40
	dbiModerateMode            = 0x41
	dbiVideoVolume             = 0x42
	dbiStickersRecentLimit     = 0x43
	dbiNativeNotifications     = 0x44
	dbiNotificationsCount      = 0x45
	dbiNotificationsCorner     = 0x46
	dbiThemeKey                = 0x47
	dbiDialogsWidthRatioOld    = 0x48
	dbiUseExternalVideoPlayer  = 0x49
	dbiDcOptions               = 0x4a
	dbiMtpAuthorization        = 0x4b
	dbiLastSeenWarningSeenOld  = 0x4c
	dbiAuthSessionSettings     = 0x4d
	dbiLangPackKey             = 0x4e
	dbiConnectionType          = 0x4f
	dbiStickersFavedLimit      = 0x50
	dbiSuggestStickersByEmoji  = 0x51

	dbiEncryptedWithSalt = 333
	dbiEncrypted         = 444
)

type qtReader struct {
	buf bin.Buffer
}

func ( *qtReader) () (qtReader, error) {
	,  := .readInt32()
	if  != nil {
		return qtReader{}, errors.Wrap(, "read length")
	}
	 := bin.Buffer{Buf: .buf.Buf}
	if  := .skip(int());  != nil {
		return qtReader{}, io.ErrUnexpectedEOF
	}

	.Buf = .Buf[:]
	return qtReader{buf: }, 
}

func ( *qtReader) () (uint64, error) {
	,  := .buf.Uint64()
	return bits.ReverseBytes64(), 
}

func ( *qtReader) () (uint32, error) {
	,  := .buf.Uint32()
	return bits.ReverseBytes32(), 
}

func ( *qtReader) () (int32, error) {
	,  := .readUint32()
	return int32(), 
}

func ( *qtReader) () (string, error) {
	,  := .readInt32()
	if  != nil {
		return "", 
	}
	 := int()
	switch {
	case  < 0:
		return "", &bin.InvalidLengthError{
			Length: ,
			Where:  "QString",
		}
	case  >= .buf.Len():
		return "", io.ErrUnexpectedEOF
	}
	 := string(.buf.Buf[:])
	.buf.Skip()
	return , nil
}

func ( *qtReader) () ([]byte, error) {
	,  := .readInt32()
	if  != nil {
		return nil, 
	}
	 := int()
	switch {
	case  < 0:
		return nil, &bin.InvalidLengthError{
			Length: ,
			Where:  "QString",
		}
	case  > .buf.Len():
		return nil, io.ErrUnexpectedEOF
	}
	 := append([]byte(nil), .buf.Buf[:]...)
	.buf.Skip()
	return , nil
}

func ( *qtReader) ( []byte,  int) error {
	return .buf.ConsumeN(, )
}

func ( *qtReader) ( int) error {
	if .buf.Len() <  {
		return io.ErrUnexpectedEOF
	}
	.buf.Skip()
	return nil
}