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

The following examples show how to use org.telegram.tgnet.TLRPC#TL_documentAttributeFilename . 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: FileLoader.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public static String getDocumentFileName(TLRPC.Document document)
{
    String fileName = null;
    if (document != null)
    {
        if (document.file_name != null)
        {
            fileName = document.file_name;
        }
        else
        {
            for (int a = 0; a < document.attributes.size(); a++)
            {
                TLRPC.DocumentAttribute documentAttribute = document.attributes.get(a);
                if (documentAttribute instanceof TLRPC.TL_documentAttributeFilename)
                {
                    fileName = documentAttribute.file_name;
                }
            }
        }
    }
    fileName = fixFileName(fileName);
    return fileName != null ? fileName : "";
}
 
Example 2
Source File: FileLoader.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public static String getDocumentFileName(TLRPC.Document document)
{
    String fileName = null;
    if (document != null)
    {
        if (document.file_name != null)
        {
            fileName = document.file_name;
        }
        else
        {
            for (int a = 0; a < document.attributes.size(); a++)
            {
                TLRPC.DocumentAttribute documentAttribute = document.attributes.get(a);
                if (documentAttribute instanceof TLRPC.TL_documentAttributeFilename)
                {
                    fileName = documentAttribute.file_name;
                }
            }
        }
    }
    fileName = fixFileName(fileName);
    return fileName != null ? fileName : "";
}
 
Example 3
Source File: FileLoader.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public static String getDocumentFileName(TLRPC.Document document) {
    String fileName = null;
    if (document != null) {
        if (document.file_name != null) {
            fileName = document.file_name;
        } else {
            for (int a = 0; a < document.attributes.size(); a++) {
                TLRPC.DocumentAttribute documentAttribute = document.attributes.get(a);
                if (documentAttribute instanceof TLRPC.TL_documentAttributeFilename) {
                    fileName = documentAttribute.file_name;
                }
            }
        }
    }
    fileName = fixFileName(fileName);
    return fileName != null ? fileName : "";
}
 
Example 4
Source File: FileLoader.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public static String getDocumentFileName(TLRPC.Document document) {
    String fileName = null;
    if (document != null) {
        if (document.file_name != null) {
            fileName = document.file_name;
        } else {
            for (int a = 0; a < document.attributes.size(); a++) {
                TLRPC.DocumentAttribute documentAttribute = document.attributes.get(a);
                if (documentAttribute instanceof TLRPC.TL_documentAttributeFilename) {
                    fileName = documentAttribute.file_name;
                }
            }
        }
    }
    fileName = fixFileName(fileName);
    return fileName != null ? fileName : "";
}
 
Example 5
Source File: FileStreamLoadOperation.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long open(DataSpec dataSpec) throws IOException {
    uri = dataSpec.uri;
    this.dataSpec = dataSpec;
    currentAccount = Utilities.parseInt(uri.getQueryParameter("account"));
    document = new TLRPC.TL_document();
    document.access_hash = Utilities.parseLong(uri.getQueryParameter("hash"));
    document.id = Utilities.parseLong(uri.getQueryParameter("id"));
    document.size = Utilities.parseInt(uri.getQueryParameter("size"));
    document.dc_id = Utilities.parseInt(uri.getQueryParameter("dc"));
    document.mime_type = uri.getQueryParameter("mime");
    TLRPC.TL_documentAttributeFilename filename = new TLRPC.TL_documentAttributeFilename();
    filename.file_name = uri.getQueryParameter("name");
    document.attributes.add(filename);
    if (document.mime_type.startsWith("video")) {
        document.attributes.add(new TLRPC.TL_documentAttributeVideo());
    } else if (document.mime_type.startsWith("audio")) {
        document.attributes.add(new TLRPC.TL_documentAttributeAudio());
    }
    loadOperation = FileLoader.getInstance(currentAccount).loadStreamFile(this, document, currentOffset = (int) dataSpec.position);
    bytesRemaining = dataSpec.length == C.LENGTH_UNSET ? document.size - dataSpec.position : dataSpec.length;
    if (bytesRemaining < 0) {
        throw new EOFException();
    }
    opened = true;
    if (listener != null) {
        listener.onTransferStart(this, dataSpec, false);
    }
    file = new RandomAccessFile(loadOperation.getCurrentFile(), "r");
    file.seek(currentOffset);
    return bytesRemaining;
}
 
Example 6
Source File: FileStreamLoadOperation.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long open(DataSpec dataSpec) throws IOException {
    uri = dataSpec.uri;
    this.dataSpec = dataSpec;
    currentAccount = Utilities.parseInt(uri.getQueryParameter("account"));
    document = new TLRPC.TL_document();
    document.access_hash = Utilities.parseLong(uri.getQueryParameter("hash"));
    document.id = Utilities.parseLong(uri.getQueryParameter("id"));
    document.size = Utilities.parseInt(uri.getQueryParameter("size"));
    document.dc_id = Utilities.parseInt(uri.getQueryParameter("dc"));
    document.mime_type = uri.getQueryParameter("mime");
    TLRPC.TL_documentAttributeFilename filename = new TLRPC.TL_documentAttributeFilename();
    filename.file_name = uri.getQueryParameter("name");
    document.attributes.add(filename);
    if (document.mime_type.startsWith("video")) {
        document.attributes.add(new TLRPC.TL_documentAttributeVideo());
    } else if (document.mime_type.startsWith("audio")) {
        document.attributes.add(new TLRPC.TL_documentAttributeAudio());
    }
    loadOperation = FileLoader.getInstance(currentAccount).loadStreamFile(this, document, currentOffset = (int) dataSpec.position);
    bytesRemaining = dataSpec.length == C.LENGTH_UNSET ? document.size - dataSpec.position : dataSpec.length;
    if (bytesRemaining < 0) {
        throw new EOFException();
    }
    opened = true;
    if (listener != null) {
        listener.onTransferStart(this, dataSpec, false);
    }
    file = new RandomAccessFile(loadOperation.getCurrentFile(), "r");
    file.seek(currentOffset);
    return bytesRemaining;
}
 
Example 7
Source File: FileStreamLoadOperation.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long open(DataSpec dataSpec) throws IOException {
    uri = dataSpec.uri;
    currentAccount = Utilities.parseInt(uri.getQueryParameter("account"));
    parentObject = FileLoader.getInstance(currentAccount).getParentObject(Utilities.parseInt(uri.getQueryParameter("rid")));
    document = new TLRPC.TL_document();
    document.access_hash = Utilities.parseLong(uri.getQueryParameter("hash"));
    document.id = Utilities.parseLong(uri.getQueryParameter("id"));
    document.size = Utilities.parseInt(uri.getQueryParameter("size"));
    document.dc_id = Utilities.parseInt(uri.getQueryParameter("dc"));
    document.mime_type = uri.getQueryParameter("mime");
    document.file_reference = Utilities.hexToBytes(uri.getQueryParameter("reference"));
    TLRPC.TL_documentAttributeFilename filename = new TLRPC.TL_documentAttributeFilename();
    filename.file_name = uri.getQueryParameter("name");
    document.attributes.add(filename);
    if (document.mime_type.startsWith("video")) {
        document.attributes.add(new TLRPC.TL_documentAttributeVideo());
    } else if (document.mime_type.startsWith("audio")) {
        document.attributes.add(new TLRPC.TL_documentAttributeAudio());
    }
    loadOperation = FileLoader.getInstance(currentAccount).loadStreamFile(this, document, parentObject, currentOffset = (int) dataSpec.position, false);
    bytesRemaining = dataSpec.length == C.LENGTH_UNSET ? document.size - dataSpec.position : dataSpec.length;
    if (bytesRemaining < 0) {
        throw new EOFException();
    }
    opened = true;
    transferStarted(dataSpec);
    if (loadOperation != null) {
        file = new RandomAccessFile(loadOperation.getCurrentFile(), "r");
        file.seek(currentOffset);
    }
    return bytesRemaining;
}
 
Example 8
Source File: FileStreamLoadOperation.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long open(DataSpec dataSpec) throws IOException {
    uri = dataSpec.uri;
    currentAccount = Utilities.parseInt(uri.getQueryParameter("account"));
    parentObject = FileLoader.getInstance(currentAccount).getParentObject(Utilities.parseInt(uri.getQueryParameter("rid")));
    document = new TLRPC.TL_document();
    document.access_hash = Utilities.parseLong(uri.getQueryParameter("hash"));
    document.id = Utilities.parseLong(uri.getQueryParameter("id"));
    document.size = Utilities.parseInt(uri.getQueryParameter("size"));
    document.dc_id = Utilities.parseInt(uri.getQueryParameter("dc"));
    document.mime_type = uri.getQueryParameter("mime");
    document.file_reference = Utilities.hexToBytes(uri.getQueryParameter("reference"));
    TLRPC.TL_documentAttributeFilename filename = new TLRPC.TL_documentAttributeFilename();
    filename.file_name = uri.getQueryParameter("name");
    document.attributes.add(filename);
    if (document.mime_type.startsWith("video")) {
        document.attributes.add(new TLRPC.TL_documentAttributeVideo());
    } else if (document.mime_type.startsWith("audio")) {
        document.attributes.add(new TLRPC.TL_documentAttributeAudio());
    }
    loadOperation = FileLoader.getInstance(currentAccount).loadStreamFile(this, document, parentObject, currentOffset = (int) dataSpec.position, false);
    bytesRemaining = dataSpec.length == C.LENGTH_UNSET ? document.size - dataSpec.position : dataSpec.length;
    if (bytesRemaining < 0) {
        throw new EOFException();
    }
    opened = true;
    transferStarted(dataSpec);
    if (loadOperation != null) {
        file = new RandomAccessFile(loadOperation.getCurrentFile(), "r");
        file.seek(currentOffset);
    }
    return bytesRemaining;
}