Java Code Examples for org.telegram.tgnet.TLRPC#TL_inputFileLocation

The following examples show how to use org.telegram.tgnet.TLRPC#TL_inputFileLocation . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileLoadOperation.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public FileLoadOperation(TLRPC.FileLocation photoLocation, String extension, int size) {
    if (photoLocation instanceof TLRPC.TL_fileEncryptedLocation) {
        location = new TLRPC.TL_inputEncryptedFileLocation();
        location.id = photoLocation.volume_id;
        location.volume_id = photoLocation.volume_id;
        location.access_hash = photoLocation.secret;
        location.local_id = photoLocation.local_id;
        iv = new byte[32];
        System.arraycopy(photoLocation.iv, 0, iv, 0, iv.length);
        key = photoLocation.key;
        initialDatacenterId = datacenterId = photoLocation.dc_id;
    } else if (photoLocation instanceof TLRPC.TL_fileLocation) {
        location = new TLRPC.TL_inputFileLocation();
        location.volume_id = photoLocation.volume_id;
        location.secret = photoLocation.secret;
        location.local_id = photoLocation.local_id;
        initialDatacenterId = datacenterId = photoLocation.dc_id;
        allowDisordererFileSave = true;
    }
    currentType = ConnectionsManager.FileTypePhoto;
    totalBytesCount = size;
    ext = extension != null ? extension : "jpg";
}
 
Example 2
Source File: FileLoadOperation.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public FileLoadOperation(TLRPC.FileLocation photoLocation, String extension, int size) {
    if (photoLocation instanceof TLRPC.TL_fileEncryptedLocation) {
        location = new TLRPC.TL_inputEncryptedFileLocation();
        location.id = photoLocation.volume_id;
        location.volume_id = photoLocation.volume_id;
        location.access_hash = photoLocation.secret;
        location.local_id = photoLocation.local_id;
        iv = new byte[32];
        System.arraycopy(photoLocation.iv, 0, iv, 0, iv.length);
        key = photoLocation.key;
        initialDatacenterId = datacenterId = photoLocation.dc_id;
    } else if (photoLocation instanceof TLRPC.TL_fileLocation) {
        location = new TLRPC.TL_inputFileLocation();
        location.volume_id = photoLocation.volume_id;
        location.secret = photoLocation.secret;
        location.local_id = photoLocation.local_id;
        initialDatacenterId = datacenterId = photoLocation.dc_id;
        allowDisordererFileSave = true;
    }
    currentType = ConnectionsManager.FileTypePhoto;
    totalBytesCount = size;
    ext = extension != null ? extension : "jpg";
}
 
Example 3
Source File: FileRefController.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private byte[] getFileReference(TLRPC.User user, TLRPC.InputFileLocation location, boolean[] needReplacement, TLRPC.InputFileLocation[] replacement) {
    if (user == null || user.photo == null || !(location instanceof TLRPC.TL_inputFileLocation)) {
        return null;
    }
    byte[] result = getFileReference(user.photo.photo_small, location, needReplacement);
    if (getPeerReferenceReplacement(user, null, false, location, replacement, needReplacement)) {
        return new byte[0];
    }
    if (result == null) {
        result = getFileReference(user.photo.photo_big, location, needReplacement);
        if (getPeerReferenceReplacement(user, null, true, location, replacement, needReplacement)) {
            return new byte[0];
        }
    }
    return result;
}
 
Example 4
Source File: FileRefController.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private byte[] getFileReference(TLRPC.Chat chat, TLRPC.InputFileLocation location, boolean[] needReplacement, TLRPC.InputFileLocation[] replacement) {
    if (chat == null || chat.photo == null || !(location instanceof TLRPC.TL_inputFileLocation)) {
        return null;
    }
    byte[] result = getFileReference(chat.photo.photo_small, location, needReplacement);
    if (getPeerReferenceReplacement(null, chat, false, location, replacement, needReplacement)) {
        return new byte[0];
    }
    if (result == null) {
        result = getFileReference(chat.photo.photo_big, location, needReplacement);
        if (getPeerReferenceReplacement(null, chat, true, location, replacement, needReplacement)) {
            return new byte[0];
        }
    }
    return result;
}
 
Example 5
Source File: FileRefController.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private byte[] getFileReference(TLRPC.User user, TLRPC.InputFileLocation location, boolean[] needReplacement, TLRPC.InputFileLocation[] replacement) {
    if (user == null || user.photo == null || !(location instanceof TLRPC.TL_inputFileLocation)) {
        return null;
    }
    byte[] result = getFileReference(user.photo.photo_small, location, needReplacement);
    if (getPeerReferenceReplacement(user, null, false, location, replacement, needReplacement)) {
        return new byte[0];
    }
    if (result == null) {
        result = getFileReference(user.photo.photo_big, location, needReplacement);
        if (getPeerReferenceReplacement(user, null, true, location, replacement, needReplacement)) {
            return new byte[0];
        }
    }
    return result;
}
 
Example 6
Source File: FileRefController.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private byte[] getFileReference(TLRPC.Chat chat, TLRPC.InputFileLocation location, boolean[] needReplacement, TLRPC.InputFileLocation[] replacement) {
    if (chat == null || chat.photo == null || !(location instanceof TLRPC.TL_inputFileLocation)) {
        return null;
    }
    byte[] result = getFileReference(chat.photo.photo_small, location, needReplacement);
    if (getPeerReferenceReplacement(null, chat, false, location, replacement, needReplacement)) {
        return new byte[0];
    }
    if (result == null) {
        result = getFileReference(chat.photo.photo_big, location, needReplacement);
        if (getPeerReferenceReplacement(null, chat, true, location, replacement, needReplacement)) {
            return new byte[0];
        }
    }
    return result;
}
 
Example 7
Source File: FileRefController.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private byte[] getFileReference(TLRPC.Photo photo, TLRPC.InputFileLocation location, boolean[] needReplacement, TLRPC.InputFileLocation[] replacement) {
    if (photo == null) {
        return null;
    }
    if (location instanceof TLRPC.TL_inputPhotoFileLocation) {
        return photo.id == location.id ? photo.file_reference : null;
    } else if (location instanceof TLRPC.TL_inputFileLocation) {
        for (int a = 0, size = photo.sizes.size(); a < size; a++) {
            TLRPC.PhotoSize photoSize = photo.sizes.get(a);
            byte[] result = getFileReference(photoSize, location, needReplacement);
            if (needReplacement != null && needReplacement[0]) {
                replacement[0] = new TLRPC.TL_inputPhotoFileLocation();
                replacement[0].id = photo.id;
                replacement[0].volume_id = location.volume_id;
                replacement[0].local_id = location.local_id;
                replacement[0].access_hash = photo.access_hash;
                replacement[0].file_reference = photo.file_reference;
                replacement[0].thumb_size = photoSize.type;
                return photo.file_reference;
            }
            if (result != null) {
                return result;
            }
        }
    }
    return null;
}
 
Example 8
Source File: FileRefController.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private byte[] getFileReference(TLRPC.FileLocation fileLocation, TLRPC.InputFileLocation location, boolean[] needReplacement) {
    if (fileLocation == null || !(location instanceof TLRPC.TL_inputFileLocation)) {
        return null;
    }
    if (fileLocation.local_id == location.local_id && fileLocation.volume_id == location.volume_id) {
        if (fileLocation.file_reference == null && needReplacement != null) {
            needReplacement[0] = true;
        }
        return fileLocation.file_reference;
    }
    return null;
}
 
Example 9
Source File: FileRefController.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private byte[] getFileReference(TLRPC.Photo photo, TLRPC.InputFileLocation location, boolean[] needReplacement, TLRPC.InputFileLocation[] replacement) {
    if (photo == null) {
        return null;
    }
    if (location instanceof TLRPC.TL_inputPhotoFileLocation) {
        return photo.id == location.id ? photo.file_reference : null;
    } else if (location instanceof TLRPC.TL_inputFileLocation) {
        for (int a = 0, size = photo.sizes.size(); a < size; a++) {
            TLRPC.PhotoSize photoSize = photo.sizes.get(a);
            byte[] result = getFileReference(photoSize, location, needReplacement);
            if (needReplacement != null && needReplacement[0]) {
                replacement[0] = new TLRPC.TL_inputPhotoFileLocation();
                replacement[0].id = photo.id;
                replacement[0].volume_id = location.volume_id;
                replacement[0].local_id = location.local_id;
                replacement[0].access_hash = photo.access_hash;
                replacement[0].file_reference = photo.file_reference;
                replacement[0].thumb_size = photoSize.type;
                return photo.file_reference;
            }
            if (result != null) {
                return result;
            }
        }
    }
    return null;
}
 
Example 10
Source File: FileRefController.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private byte[] getFileReference(TLRPC.FileLocation fileLocation, TLRPC.InputFileLocation location, boolean[] needReplacement) {
    if (fileLocation == null || !(location instanceof TLRPC.TL_inputFileLocation)) {
        return null;
    }
    if (fileLocation.local_id == location.local_id && fileLocation.volume_id == location.volume_id) {
        if (fileLocation.file_reference == null && needReplacement != null) {
            needReplacement[0] = true;
        }
        return fileLocation.file_reference;
    }
    return null;
}
 
Example 11
Source File: FileLoadOperation.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public FileLoadOperation(ImageLocation imageLocation, Object parent, String extension, int size) {
    parentObject = parent;
    if (imageLocation.isEncrypted()) {
        location = new TLRPC.TL_inputEncryptedFileLocation();
        location.id = imageLocation.location.volume_id;
        location.volume_id = imageLocation.location.volume_id;
        location.local_id = imageLocation.location.local_id;
        location.access_hash = imageLocation.access_hash;
        iv = new byte[32];
        System.arraycopy(imageLocation.iv, 0, iv, 0, iv.length);
        key = imageLocation.key;
    } else if (imageLocation.photoPeer != null) {
        location = new TLRPC.TL_inputPeerPhotoFileLocation();
        location.id = imageLocation.location.volume_id;
        location.volume_id = imageLocation.location.volume_id;
        location.local_id = imageLocation.location.local_id;
        location.big = imageLocation.photoPeerBig;
        location.peer = imageLocation.photoPeer;
    } else if (imageLocation.stickerSet != null) {
        location = new TLRPC.TL_inputStickerSetThumb();
        location.id = imageLocation.location.volume_id;
        location.volume_id = imageLocation.location.volume_id;
        location.local_id = imageLocation.location.local_id;
        location.stickerset = imageLocation.stickerSet;
    } else if (imageLocation.thumbSize != null) {
        if (imageLocation.photoId != 0) {
            location = new TLRPC.TL_inputPhotoFileLocation();
            location.id = imageLocation.photoId;
            location.volume_id = imageLocation.location.volume_id;
            location.local_id = imageLocation.location.local_id;
            location.access_hash = imageLocation.access_hash;
            location.file_reference = imageLocation.file_reference;
            location.thumb_size = imageLocation.thumbSize;
        } else {
            location = new TLRPC.TL_inputDocumentFileLocation();
            location.id = imageLocation.documentId;
            location.volume_id = imageLocation.location.volume_id;
            location.local_id = imageLocation.location.local_id;
            location.access_hash = imageLocation.access_hash;
            location.file_reference = imageLocation.file_reference;
            location.thumb_size = imageLocation.thumbSize;
        }
        if (location.file_reference == null) {
            location.file_reference = new byte[0];
        }
    } else {
        location = new TLRPC.TL_inputFileLocation();
        location.volume_id = imageLocation.location.volume_id;
        location.local_id = imageLocation.location.local_id;
        location.secret = imageLocation.access_hash;
        location.file_reference = imageLocation.file_reference;
        if (location.file_reference == null) {
            location.file_reference = new byte[0];
        }
        allowDisordererFileSave = true;
    }
    ungzip = imageLocation.imageType == FileLoader.IMAGE_TYPE_LOTTIE || imageLocation.imageType == FileLoader.IMAGE_TYPE_SVG;
    initialDatacenterId = datacenterId = imageLocation.dc_id;
    currentType = ConnectionsManager.FileTypePhoto;
    totalBytesCount = size;
    ext = extension != null ? extension : "jpg";
}
 
Example 12
Source File: FileRefController.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private byte[] getFileReference(TLRPC.PhotoSize photoSize, TLRPC.InputFileLocation location, boolean[] needReplacement) {
    if (photoSize == null || !(location instanceof TLRPC.TL_inputFileLocation)) {
        return null;
    }
    return getFileReference(photoSize.location, location, needReplacement);
}
 
Example 13
Source File: FileLoadOperation.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public FileLoadOperation(ImageLocation imageLocation, Object parent, String extension, int size) {
    parentObject = parent;
    if (imageLocation.isEncrypted()) {
        location = new TLRPC.TL_inputEncryptedFileLocation();
        location.id = imageLocation.location.volume_id;
        location.volume_id = imageLocation.location.volume_id;
        location.local_id = imageLocation.location.local_id;
        location.access_hash = imageLocation.access_hash;
        iv = new byte[32];
        System.arraycopy(imageLocation.iv, 0, iv, 0, iv.length);
        key = imageLocation.key;
    } else if (imageLocation.photoPeer != null) {
        location = new TLRPC.TL_inputPeerPhotoFileLocation();
        location.id = imageLocation.location.volume_id;
        location.volume_id = imageLocation.location.volume_id;
        location.local_id = imageLocation.location.local_id;
        location.big = imageLocation.photoPeerBig;
        location.peer = imageLocation.photoPeer;
    } else if (imageLocation.stickerSet != null) {
        location = new TLRPC.TL_inputStickerSetThumb();
        location.id = imageLocation.location.volume_id;
        location.volume_id = imageLocation.location.volume_id;
        location.local_id = imageLocation.location.local_id;
        location.stickerset = imageLocation.stickerSet;
    } else if (imageLocation.thumbSize != null) {
        if (imageLocation.photoId != 0) {
            location = new TLRPC.TL_inputPhotoFileLocation();
            location.id = imageLocation.photoId;
            location.volume_id = imageLocation.location.volume_id;
            location.local_id = imageLocation.location.local_id;
            location.access_hash = imageLocation.access_hash;
            location.file_reference = imageLocation.file_reference;
            location.thumb_size = imageLocation.thumbSize;
        } else {
            location = new TLRPC.TL_inputDocumentFileLocation();
            location.id = imageLocation.documentId;
            location.volume_id = imageLocation.location.volume_id;
            location.local_id = imageLocation.location.local_id;
            location.access_hash = imageLocation.access_hash;
            location.file_reference = imageLocation.file_reference;
            location.thumb_size = imageLocation.thumbSize;
        }
        if (location.file_reference == null) {
            location.file_reference = new byte[0];
        }
    } else {
        location = new TLRPC.TL_inputFileLocation();
        location.volume_id = imageLocation.location.volume_id;
        location.local_id = imageLocation.location.local_id;
        location.secret = imageLocation.access_hash;
        location.file_reference = imageLocation.file_reference;
        if (location.file_reference == null) {
            location.file_reference = new byte[0];
        }
        allowDisordererFileSave = true;
    }
    ungzip = imageLocation.imageType == FileLoader.IMAGE_TYPE_LOTTIE || imageLocation.imageType == FileLoader.IMAGE_TYPE_SVG;
    initialDatacenterId = datacenterId = imageLocation.dc_id;
    currentType = ConnectionsManager.FileTypePhoto;
    totalBytesCount = size;
    ext = extension != null ? extension : "jpg";
}
 
Example 14
Source File: FileRefController.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private byte[] getFileReference(TLRPC.PhotoSize photoSize, TLRPC.InputFileLocation location, boolean[] needReplacement) {
    if (photoSize == null || !(location instanceof TLRPC.TL_inputFileLocation)) {
        return null;
    }
    return getFileReference(photoSize.location, location, needReplacement);
}