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

The following examples show how to use org.telegram.tgnet.TLRPC#TL_upload_getCdnFileHashes . 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 4 votes vote down vote up
private void requestFileOffsets(int offset) {
    if (requestingCdnOffsets) {
        return;
    }
    requestingCdnOffsets = true;
    TLRPC.TL_upload_getCdnFileHashes req = new TLRPC.TL_upload_getCdnFileHashes();
    req.file_token = cdnToken;
    req.offset = offset;
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
        @Override
        public void run(TLObject response, TLRPC.TL_error error) {
            if (error != null) {
                onFail(false, 0);
            } else {
                requestingCdnOffsets = false;
                TLRPC.Vector vector = (TLRPC.Vector) response;
                if (!vector.objects.isEmpty()) {
                    if (cdnHashes == null) {
                        cdnHashes = new SparseArray<>();
                    }
                    for (int a = 0; a < vector.objects.size(); a++) {
                        TLRPC.TL_fileHash hash = (TLRPC.TL_fileHash) vector.objects.get(a);
                        cdnHashes.put(hash.offset, hash);
                    }
                }
                for (int a = 0; a < delayedRequestInfos.size(); a++) {
                    RequestInfo delayedRequestInfo = delayedRequestInfos.get(a);
                    if (notLoadedBytesRanges != null || downloadedBytes == delayedRequestInfo.offset) {
                        delayedRequestInfos.remove(a);
                        if (!processRequestResult(delayedRequestInfo, null)) {
                            if (delayedRequestInfo.response != null) {
                                delayedRequestInfo.response.disableFree = false;
                                delayedRequestInfo.response.freeResources();
                            } else if (delayedRequestInfo.responseWeb != null) {
                                delayedRequestInfo.responseWeb.disableFree = false;
                                delayedRequestInfo.responseWeb.freeResources();
                            } else if (delayedRequestInfo.responseCdn != null) {
                                delayedRequestInfo.responseCdn.disableFree = false;
                                delayedRequestInfo.responseCdn.freeResources();
                            }
                        }
                        break;
                    }
                }
            }
        }
    }, null, null, 0, datacenterId, ConnectionsManager.ConnectionTypeGeneric, true);
}
 
Example 2
Source File: FileLoadOperation.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void requestFileOffsets(int offset) {
    if (requestingCdnOffsets) {
        return;
    }
    requestingCdnOffsets = true;
    TLRPC.TL_upload_getCdnFileHashes req = new TLRPC.TL_upload_getCdnFileHashes();
    req.file_token = cdnToken;
    req.offset = offset;
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
        @Override
        public void run(TLObject response, TLRPC.TL_error error) {
            if (error != null) {
                onFail(false, 0);
            } else {
                requestingCdnOffsets = false;
                TLRPC.Vector vector = (TLRPC.Vector) response;
                if (!vector.objects.isEmpty()) {
                    if (cdnHashes == null) {
                        cdnHashes = new SparseArray<>();
                    }
                    for (int a = 0; a < vector.objects.size(); a++) {
                        TLRPC.TL_fileHash hash = (TLRPC.TL_fileHash) vector.objects.get(a);
                        cdnHashes.put(hash.offset, hash);
                    }
                }
                for (int a = 0; a < delayedRequestInfos.size(); a++) {
                    RequestInfo delayedRequestInfo = delayedRequestInfos.get(a);
                    if (notLoadedBytesRanges != null || downloadedBytes == delayedRequestInfo.offset) {
                        delayedRequestInfos.remove(a);
                        if (!processRequestResult(delayedRequestInfo, null)) {
                            if (delayedRequestInfo.response != null) {
                                delayedRequestInfo.response.disableFree = false;
                                delayedRequestInfo.response.freeResources();
                            } else if (delayedRequestInfo.responseWeb != null) {
                                delayedRequestInfo.responseWeb.disableFree = false;
                                delayedRequestInfo.responseWeb.freeResources();
                            } else if (delayedRequestInfo.responseCdn != null) {
                                delayedRequestInfo.responseCdn.disableFree = false;
                                delayedRequestInfo.responseCdn.freeResources();
                            }
                        }
                        break;
                    }
                }
            }
        }
    }, null, null, 0, datacenterId, ConnectionsManager.ConnectionTypeGeneric, true);
}
 
Example 3
Source File: FileLoadOperation.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private void requestFileOffsets(int offset) {
    if (requestingCdnOffsets) {
        return;
    }
    requestingCdnOffsets = true;
    TLRPC.TL_upload_getCdnFileHashes req = new TLRPC.TL_upload_getCdnFileHashes();
    req.file_token = cdnToken;
    req.offset = offset;
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
        if (error != null) {
            onFail(false, 0);
        } else {
            requestingCdnOffsets = false;
            TLRPC.Vector vector = (TLRPC.Vector) response;
            if (!vector.objects.isEmpty()) {
                if (cdnHashes == null) {
                    cdnHashes = new SparseArray<>();
                }
                for (int a = 0; a < vector.objects.size(); a++) {
                    TLRPC.TL_fileHash hash = (TLRPC.TL_fileHash) vector.objects.get(a);
                    cdnHashes.put(hash.offset, hash);
                }
            }
            for (int a = 0; a < delayedRequestInfos.size(); a++) {
                RequestInfo delayedRequestInfo = delayedRequestInfos.get(a);
                if (notLoadedBytesRanges != null || downloadedBytes == delayedRequestInfo.offset) {
                    delayedRequestInfos.remove(a);
                    if (!processRequestResult(delayedRequestInfo, null)) {
                        if (delayedRequestInfo.response != null) {
                            delayedRequestInfo.response.disableFree = false;
                            delayedRequestInfo.response.freeResources();
                        } else if (delayedRequestInfo.responseWeb != null) {
                            delayedRequestInfo.responseWeb.disableFree = false;
                            delayedRequestInfo.responseWeb.freeResources();
                        } else if (delayedRequestInfo.responseCdn != null) {
                            delayedRequestInfo.responseCdn.disableFree = false;
                            delayedRequestInfo.responseCdn.freeResources();
                        }
                    }
                    break;
                }
            }
        }
    }, null, null, 0, datacenterId, ConnectionsManager.ConnectionTypeGeneric, true);
}
 
Example 4
Source File: FileLoadOperation.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void requestFileOffsets(int offset) {
    if (requestingCdnOffsets) {
        return;
    }
    requestingCdnOffsets = true;
    TLRPC.TL_upload_getCdnFileHashes req = new TLRPC.TL_upload_getCdnFileHashes();
    req.file_token = cdnToken;
    req.offset = offset;
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
        if (error != null) {
            onFail(false, 0);
        } else {
            requestingCdnOffsets = false;
            TLRPC.Vector vector = (TLRPC.Vector) response;
            if (!vector.objects.isEmpty()) {
                if (cdnHashes == null) {
                    cdnHashes = new SparseArray<>();
                }
                for (int a = 0; a < vector.objects.size(); a++) {
                    TLRPC.TL_fileHash hash = (TLRPC.TL_fileHash) vector.objects.get(a);
                    cdnHashes.put(hash.offset, hash);
                }
            }
            for (int a = 0; a < delayedRequestInfos.size(); a++) {
                RequestInfo delayedRequestInfo = delayedRequestInfos.get(a);
                if (notLoadedBytesRanges != null || downloadedBytes == delayedRequestInfo.offset) {
                    delayedRequestInfos.remove(a);
                    if (!processRequestResult(delayedRequestInfo, null)) {
                        if (delayedRequestInfo.response != null) {
                            delayedRequestInfo.response.disableFree = false;
                            delayedRequestInfo.response.freeResources();
                        } else if (delayedRequestInfo.responseWeb != null) {
                            delayedRequestInfo.responseWeb.disableFree = false;
                            delayedRequestInfo.responseWeb.freeResources();
                        } else if (delayedRequestInfo.responseCdn != null) {
                            delayedRequestInfo.responseCdn.disableFree = false;
                            delayedRequestInfo.responseCdn.freeResources();
                        }
                    }
                    break;
                }
            }
        }
    }, null, null, 0, datacenterId, ConnectionsManager.ConnectionTypeGeneric, true);
}