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

The following examples show how to use org.telegram.tgnet.TLRPC#TL_encryptedChat . 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: SecretChatHelper.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void sendMessagesReadMessage(TLRPC.EncryptedChat encryptedChat, ArrayList<Long> random_ids, TLRPC.Message resendMessage) {
    if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
        return;
    }
    TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();
    TLRPC.Message message;

    if (resendMessage != null) {
        message = resendMessage;
        reqSend.action = message.action.encryptedAction;
    } else {
        reqSend.action = new TLRPC.TL_decryptedMessageActionReadMessages();
        reqSend.action.random_ids = random_ids;
        message = createServiceSecretMessage(encryptedChat, reqSend.action);
    }
    reqSend.random_id = message.random_id;

    performSendEncryptedRequest(reqSend, message, encryptedChat, null, null, null);
}
 
Example 2
Source File: SecretChatHelper.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void sendAcceptKeyMessage(final TLRPC.EncryptedChat encryptedChat, TLRPC.Message resendMessage) {
    if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
        return;
    }

    TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();
    TLRPC.Message message;

    if (resendMessage != null) {
        message = resendMessage;
        reqSend.action = message.action.encryptedAction;
    } else {
        reqSend.action = new TLRPC.TL_decryptedMessageActionAcceptKey();
        reqSend.action.exchange_id = encryptedChat.exchange_id;
        reqSend.action.key_fingerprint = encryptedChat.future_key_fingerprint;
        reqSend.action.g_b = encryptedChat.g_a_or_b;

        message = createServiceSecretMessage(encryptedChat, reqSend.action);
    }
    reqSend.random_id = message.random_id;

    performSendEncryptedRequest(reqSend, message, encryptedChat, null, null, null);
}
 
Example 3
Source File: SecretChatHelper.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void sendRequestKeyMessage(final TLRPC.EncryptedChat encryptedChat, TLRPC.Message resendMessage) {
    if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
        return;
    }

    TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();
    TLRPC.Message message;

    if (resendMessage != null) {
        message = resendMessage;
        reqSend.action = message.action.encryptedAction;
    } else {
        reqSend.action = new TLRPC.TL_decryptedMessageActionRequestKey();
        reqSend.action.exchange_id = encryptedChat.exchange_id;
        reqSend.action.g_a = encryptedChat.g_a;

        message = createServiceSecretMessage(encryptedChat, reqSend.action);
    }
    reqSend.random_id = message.random_id;

    performSendEncryptedRequest(reqSend, message, encryptedChat, null, null, null);
}
 
Example 4
Source File: VoIPActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void updateKeyView() {
    if (VoIPService.getSharedInstance() == null)
        return;
    IdenticonDrawable img = new IdenticonDrawable();
    img.setColors(new int[]{0x00FFFFFF, 0xFFFFFFFF, 0x99FFFFFF, 0x33FFFFFF});
    TLRPC.EncryptedChat encryptedChat = new TLRPC.TL_encryptedChat();
    try {
        ByteArrayOutputStream buf = new ByteArrayOutputStream();
        buf.write(VoIPService.getSharedInstance().getEncryptionKey());
        buf.write(VoIPService.getSharedInstance().getGA());
        encryptedChat.auth_key = buf.toByteArray();
    } catch (Exception checkedExceptionsAreBad) {
    }
    byte[] sha256 = Utilities.computeSHA256(encryptedChat.auth_key, 0, encryptedChat.auth_key.length);
    String[] emoji = EncryptionKeyEmojifier.emojifyForCall(sha256);
    //keyEmojiText.setText(Emoji.replaceEmoji(TextUtils.join(" ", emoji), keyEmojiText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(32), false));
    emojiWrap.setContentDescription(LocaleController.getString("EncryptionKey", R.string.EncryptionKey) + ", " + TextUtils.join(", ", emoji));
    for (int i = 0; i < 4; i++) {
        Drawable drawable = Emoji.getEmojiDrawable(emoji[i]);
        if (drawable != null) {
            drawable.setBounds(0, 0, AndroidUtilities.dp(22), AndroidUtilities.dp(22));
            keyEmojiViews[i].setImageDrawable(drawable);
        }
    }
}
 
Example 5
Source File: SecretChatHelper.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void sendClearHistoryMessage(TLRPC.EncryptedChat encryptedChat, TLRPC.Message resendMessage) {
    if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
        return;
    }
    TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();
    TLRPC.Message message;

    if (resendMessage != null) {
        message = resendMessage;
        reqSend.action = message.action.encryptedAction;
    } else {
        reqSend.action = new TLRPC.TL_decryptedMessageActionFlushHistory();
        message = createServiceSecretMessage(encryptedChat, reqSend.action);
    }
    reqSend.random_id = message.random_id;

    performSendEncryptedRequest(reqSend, message, encryptedChat, null, null, null);
}
 
Example 6
Source File: SecretChatHelper.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void sendMessagesDeleteMessage(TLRPC.EncryptedChat encryptedChat, ArrayList<Long> random_ids, TLRPC.Message resendMessage) {
    if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
        return;
    }
    TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();
    TLRPC.Message message;

    if (resendMessage != null) {
        message = resendMessage;
        reqSend.action = message.action.encryptedAction;
    } else {
        reqSend.action = new TLRPC.TL_decryptedMessageActionDeleteMessages();
        reqSend.action.random_ids = random_ids;
        message = createServiceSecretMessage(encryptedChat, reqSend.action);
    }
    reqSend.random_id = message.random_id;

    performSendEncryptedRequest(reqSend, message, encryptedChat, null, null, null);
}
 
Example 7
Source File: SecretChatHelper.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void sendAbortKeyMessage(final TLRPC.EncryptedChat encryptedChat, TLRPC.Message resendMessage, long excange_id) {
    if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
        return;
    }

    TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();
    TLRPC.Message message;

    if (resendMessage != null) {
        message = resendMessage;
        reqSend.action = message.action.encryptedAction;
    } else {
        reqSend.action = new TLRPC.TL_decryptedMessageActionAbortKey();
        reqSend.action.exchange_id = excange_id;

        message = createServiceSecretMessage(encryptedChat, reqSend.action);
    }
    reqSend.random_id = message.random_id;

    performSendEncryptedRequest(reqSend, message, encryptedChat, null, null, null);
}
 
Example 8
Source File: SecretChatHelper.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void sendClearHistoryMessage(TLRPC.EncryptedChat encryptedChat, TLRPC.Message resendMessage) {
    if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
        return;
    }
    TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();
    TLRPC.Message message;

    if (resendMessage != null) {
        message = resendMessage;
        reqSend.action = message.action.encryptedAction;
    } else {
        reqSend.action = new TLRPC.TL_decryptedMessageActionFlushHistory();
        message = createServiceSecretMessage(encryptedChat, reqSend.action);
    }
    reqSend.random_id = message.random_id;

    performSendEncryptedRequest(reqSend, message, encryptedChat, null, null, null);
}
 
Example 9
Source File: SecretChatHelper.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void sendNoopMessage(final TLRPC.EncryptedChat encryptedChat, TLRPC.Message resendMessage) {
    if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
        return;
    }

    TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();
    TLRPC.Message message;

    if (resendMessage != null) {
        message = resendMessage;
        reqSend.action = message.action.encryptedAction;
    } else {
        reqSend.action = new TLRPC.TL_decryptedMessageActionNoop();
        message = createServiceSecretMessage(encryptedChat, reqSend.action);
    }
    reqSend.random_id = message.random_id;

    performSendEncryptedRequest(reqSend, message, encryptedChat, null, null, null);
}
 
Example 10
Source File: SecretChatHelper.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void sendNoopMessage(final TLRPC.EncryptedChat encryptedChat, TLRPC.Message resendMessage) {
    if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
        return;
    }

    TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();
    TLRPC.Message message;

    if (resendMessage != null) {
        message = resendMessage;
        reqSend.action = message.action.encryptedAction;
    } else {
        reqSend.action = new TLRPC.TL_decryptedMessageActionNoop();
        message = createServiceSecretMessage(encryptedChat, reqSend.action);
    }
    reqSend.random_id = message.random_id;

    performSendEncryptedRequest(reqSend, message, encryptedChat, null, null, null);
}
 
Example 11
Source File: SecretChatHelper.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void sendCommitKeyMessage(final TLRPC.EncryptedChat encryptedChat, TLRPC.Message resendMessage) {
    if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
        return;
    }

    TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();
    TLRPC.Message message;

    if (resendMessage != null) {
        message = resendMessage;
        reqSend.action = message.action.encryptedAction;
    } else {
        reqSend.action = new TLRPC.TL_decryptedMessageActionCommitKey();
        reqSend.action.exchange_id = encryptedChat.exchange_id;
        reqSend.action.key_fingerprint = encryptedChat.future_key_fingerprint;

        message = createServiceSecretMessage(encryptedChat, reqSend.action);
    }
    reqSend.random_id = message.random_id;

    performSendEncryptedRequest(reqSend, message, encryptedChat, null, null, null);
}
 
Example 12
Source File: SecretChatHelper.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void sendRequestKeyMessage(final TLRPC.EncryptedChat encryptedChat, TLRPC.Message resendMessage) {
    if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
        return;
    }

    TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();
    TLRPC.Message message;

    if (resendMessage != null) {
        message = resendMessage;
        reqSend.action = message.action.encryptedAction;
    } else {
        reqSend.action = new TLRPC.TL_decryptedMessageActionRequestKey();
        reqSend.action.exchange_id = encryptedChat.exchange_id;
        reqSend.action.g_a = encryptedChat.g_a;

        message = createServiceSecretMessage(encryptedChat, reqSend.action);
    }
    reqSend.random_id = message.random_id;

    performSendEncryptedRequest(reqSend, message, encryptedChat, null, null, null);
}
 
Example 13
Source File: VoIPActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void updateKeyView() {
     if(VoIPService.getSharedInstance()==null)
         return;
     IdenticonDrawable img = new IdenticonDrawable();
     img.setColors(new int[]{0x00FFFFFF, 0xFFFFFFFF, 0x99FFFFFF, 0x33FFFFFF});
     TLRPC.EncryptedChat encryptedChat = new TLRPC.TL_encryptedChat();
     try {
         ByteArrayOutputStream buf = new ByteArrayOutputStream();
         buf.write(VoIPService.getSharedInstance().getEncryptionKey());
buf.write(VoIPService.getSharedInstance().getGA());
         encryptedChat.auth_key = buf.toByteArray();
     }catch(Exception checkedExceptionsAreBad){}
     byte[] sha256 = Utilities.computeSHA256(encryptedChat.auth_key, 0, encryptedChat.auth_key.length);
     String[] emoji=EncryptionKeyEmojifier.emojifyForCall(sha256);
     //keyEmojiText.setText(Emoji.replaceEmoji(TextUtils.join(" ", emoji), keyEmojiText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(32), false));
     for(int i=0;i<4;i++) {
         Drawable drawable = Emoji.getEmojiDrawable(emoji[i]);
         if (drawable != null) {
             drawable.setBounds(0, 0, AndroidUtilities.dp(22), AndroidUtilities.dp(22));
             keyEmojiViews[i].setImageDrawable(drawable);
         }
     }
 }
 
Example 14
Source File: SecretChatHelper.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void sendNotifyLayerMessage(final TLRPC.EncryptedChat encryptedChat, TLRPC.Message resendMessage) {
    if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
        return;
    }
    if (sendingNotifyLayer.contains(encryptedChat.id)) {
        return;
    }
    sendingNotifyLayer.add(encryptedChat.id);
    TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();
    TLRPC.Message message;

    if (resendMessage != null) {
        message = resendMessage;
        reqSend.action = message.action.encryptedAction;
    } else {
        reqSend.action = new TLRPC.TL_decryptedMessageActionNotifyLayer();
        reqSend.action.layer = CURRENT_SECRET_CHAT_LAYER;
        message = createServiceSecretMessage(encryptedChat, reqSend.action);
    }
    reqSend.random_id = message.random_id;

    performSendEncryptedRequest(reqSend, message, encryptedChat, null, null, null);
}
 
Example 15
Source File: VoIPActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void updateKeyView() {
    if (VoIPService.getSharedInstance() == null)
        return;
    IdenticonDrawable img = new IdenticonDrawable();
    img.setColors(new int[]{0x00FFFFFF, 0xFFFFFFFF, 0x99FFFFFF, 0x33FFFFFF});
    TLRPC.EncryptedChat encryptedChat = new TLRPC.TL_encryptedChat();
    try {
        ByteArrayOutputStream buf = new ByteArrayOutputStream();
        buf.write(VoIPService.getSharedInstance().getEncryptionKey());
        buf.write(VoIPService.getSharedInstance().getGA());
        encryptedChat.auth_key = buf.toByteArray();
    } catch (Exception checkedExceptionsAreBad) {
    }
    byte[] sha256 = Utilities.computeSHA256(encryptedChat.auth_key, 0, encryptedChat.auth_key.length);
    String[] emoji = EncryptionKeyEmojifier.emojifyForCall(sha256);
    //keyEmojiText.setText(Emoji.replaceEmoji(TextUtils.join(" ", emoji), keyEmojiText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(32), false));
    emojiWrap.setContentDescription(LocaleController.getString("EncryptionKey", R.string.EncryptionKey) + ", " + TextUtils.join(", ", emoji));
    for (int i = 0; i < 4; i++) {
        Drawable drawable = Emoji.getEmojiDrawable(emoji[i]);
        if (drawable != null) {
            drawable.setBounds(0, 0, AndroidUtilities.dp(22), AndroidUtilities.dp(22));
            keyEmojiViews[i].setImageDrawable(drawable);
        }
    }
}
 
Example 16
Source File: SecretChatHelper.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void sendAcceptKeyMessage(final TLRPC.EncryptedChat encryptedChat, TLRPC.Message resendMessage) {
    if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
        return;
    }

    TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();
    TLRPC.Message message;

    if (resendMessage != null) {
        message = resendMessage;
        reqSend.action = message.action.encryptedAction;
    } else {
        reqSend.action = new TLRPC.TL_decryptedMessageActionAcceptKey();
        reqSend.action.exchange_id = encryptedChat.exchange_id;
        reqSend.action.key_fingerprint = encryptedChat.future_key_fingerprint;
        reqSend.action.g_b = encryptedChat.g_a_or_b;

        message = createServiceSecretMessage(encryptedChat, reqSend.action);
    }
    reqSend.random_id = message.random_id;

    performSendEncryptedRequest(reqSend, message, encryptedChat, null, null, null);
}
 
Example 17
Source File: SecretChatHelper.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void sendTTLMessage(TLRPC.EncryptedChat encryptedChat, TLRPC.Message resendMessage) {
    if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
        return;
    }

    TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();
    TLRPC.Message message;

    if (resendMessage != null) {
        message = resendMessage;
        reqSend.action = message.action.encryptedAction;
    } else {
        reqSend.action = new TLRPC.TL_decryptedMessageActionSetMessageTTL();
        reqSend.action.ttl_seconds = encryptedChat.ttl;
        message = createServiceSecretMessage(encryptedChat, reqSend.action);

        MessageObject newMsgObj = new MessageObject(currentAccount, message, false);
        newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
        ArrayList<MessageObject> objArr = new ArrayList<>();
        objArr.add(newMsgObj);
        MessagesController.getInstance(currentAccount).updateInterfaceWithMessages(message.dialog_id, objArr);
        NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.dialogsNeedReload);
    }
    reqSend.random_id = message.random_id;

    performSendEncryptedRequest(reqSend, message, encryptedChat, null, null, null);
}
 
Example 18
Source File: SecretChatHelper.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void sendScreenshotMessage(TLRPC.EncryptedChat encryptedChat, ArrayList<Long> random_ids, TLRPC.Message resendMessage) {
    if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
        return;
    }

    TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();

    TLRPC.Message message;

    if (resendMessage != null) {
        message = resendMessage;
        reqSend.action = message.action.encryptedAction;
    } else {
        reqSend.action = new TLRPC.TL_decryptedMessageActionScreenshotMessages();
        reqSend.action.random_ids = random_ids;
        message = createServiceSecretMessage(encryptedChat, reqSend.action);

        MessageObject newMsgObj = new MessageObject(currentAccount, message, false);
        newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
        ArrayList<MessageObject> objArr = new ArrayList<>();
        objArr.add(newMsgObj);
        MessagesController.getInstance(currentAccount).updateInterfaceWithMessages(message.dialog_id, objArr);
        NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.dialogsNeedReload);
    }
    reqSend.random_id = message.random_id;

    performSendEncryptedRequest(reqSend, message, encryptedChat, null, null, null);
}
 
Example 19
Source File: SecretChatHelper.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void sendScreenshotMessage(TLRPC.EncryptedChat encryptedChat, ArrayList<Long> random_ids, TLRPC.Message resendMessage) {
    if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
        return;
    }

    TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();

    TLRPC.Message message;

    if (resendMessage != null) {
        message = resendMessage;
        reqSend.action = message.action.encryptedAction;
    } else {
        reqSend.action = new TLRPC.TL_decryptedMessageActionScreenshotMessages();
        reqSend.action.random_ids = random_ids;
        message = createServiceSecretMessage(encryptedChat, reqSend.action);

        MessageObject newMsgObj = new MessageObject(currentAccount, message, false);
        newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
        ArrayList<MessageObject> objArr = new ArrayList<>();
        objArr.add(newMsgObj);
        getMessagesController().updateInterfaceWithMessages(message.dialog_id, objArr, false);
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload);
    }
    reqSend.random_id = message.random_id;

    performSendEncryptedRequest(reqSend, message, encryptedChat, null, null, null);
}
 
Example 20
Source File: MediaController.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void checkScreenshots(ArrayList<Long> dates) {
    if (dates == null || dates.isEmpty() || lastChatEnterTime == 0 || (lastUser == null && !(lastSecretChat instanceof TLRPC.TL_encryptedChat))) {
        return;
    }
    long dt = 2000;
    boolean send = false;
    for (int a = 0; a < dates.size(); a++) {
        Long date = dates.get(a);
        if (lastMediaCheckTime != 0 && date <= lastMediaCheckTime) {
            continue;
        }

        if (date >= lastChatEnterTime) {
            if (lastChatLeaveTime == 0 || date <= lastChatLeaveTime + dt) {
                lastMediaCheckTime = Math.max(lastMediaCheckTime, date);
                send = true;
            }
        }
    }
    if (send) {
        if (lastSecretChat != null) {
            SecretChatHelper.getInstance(lastChatAccount).sendScreenshotMessage(lastSecretChat, lastChatVisibleMessages, null);
        } else {
            SendMessagesHelper.getInstance(lastChatAccount).sendScreenshotMessage(lastUser, lastMessageId, null);
        }
    }
}