Java Code Examples for org.telegram.tgnet.TLRPC#EncryptedChat
The following examples show how to use
org.telegram.tgnet.TLRPC#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: DialogsSearchAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void setRecentSearch(ArrayList<RecentSearchObject> arrayList, LongSparseArray<RecentSearchObject> hashMap) { recentSearchObjects = arrayList; recentSearchObjectsById = hashMap; for (int a = 0; a < recentSearchObjects.size(); a++) { RecentSearchObject recentSearchObject = recentSearchObjects.get(a); if (recentSearchObject.object instanceof TLRPC.User) { MessagesController.getInstance(currentAccount).putUser((TLRPC.User) recentSearchObject.object, true); } else if (recentSearchObject.object instanceof TLRPC.Chat) { MessagesController.getInstance(currentAccount).putChat((TLRPC.Chat) recentSearchObject.object, true); } else if (recentSearchObject.object instanceof TLRPC.EncryptedChat) { MessagesController.getInstance(currentAccount).putEncryptedChat((TLRPC.EncryptedChat) recentSearchObject.object, true); } } notifyDataSetChanged(); }
Example 2
Source File: SecretChatHelper.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
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 3
Source File: SecretChatHelper.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
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 4
Source File: SecretChatHelper.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
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 5
Source File: ContactsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void didReceivedNotification(int id, int account, Object... args) { if (id == NotificationCenter.contactsDidLoaded) { if (listViewAdapter != null) { listViewAdapter.notifyDataSetChanged(); } } else if (id == NotificationCenter.updateInterfaces) { int mask = (Integer)args[0]; if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) { updateVisibleRows(mask); } } else if (id == NotificationCenter.encryptedChatCreated) { if (createSecretChat && creatingChat) { TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat)args[0]; Bundle args2 = new Bundle(); args2.putInt("enc_id", encryptedChat.id); NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats); presentFragment(new ChatActivity(args2), true); } } else if (id == NotificationCenter.closeChats) { if (!creatingChat) { removeSelfFromStack(); } } }
Example 6
Source File: SecretChatHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private TLRPC.Message createDeleteMessage(int mid, int seq_out, int seq_in, long random_id, TLRPC.EncryptedChat encryptedChat) { TLRPC.TL_messageService newMsg = new TLRPC.TL_messageService(); newMsg.action = new TLRPC.TL_messageEncryptedAction(); newMsg.action.encryptedAction = new TLRPC.TL_decryptedMessageActionDeleteMessages(); newMsg.action.encryptedAction.random_ids.add(random_id); newMsg.local_id = newMsg.id = mid; newMsg.from_id = getUserConfig().getClientUserId(); newMsg.unread = true; newMsg.out = true; newMsg.flags = TLRPC.MESSAGE_FLAG_HAS_FROM_ID; newMsg.dialog_id = ((long) encryptedChat.id) << 32; newMsg.to_id = new TLRPC.TL_peerUser(); newMsg.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING; newMsg.seq_in = seq_in; newMsg.seq_out = seq_out; if (encryptedChat.participant_id == getUserConfig().getClientUserId()) { newMsg.to_id.user_id = encryptedChat.admin_id; } else { newMsg.to_id.user_id = encryptedChat.participant_id; } newMsg.date = 0; newMsg.random_id = random_id; return newMsg; }
Example 7
Source File: SecretChatHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
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: UserCell.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public void setData(Object object, TLRPC.EncryptedChat ec, CharSequence name, CharSequence status, int resId, boolean divider) { if (object == null && name == null && status == null) { currentStatus = null; currentName = null; currentObject = null; nameTextView.setText(""); statusTextView.setText(""); avatarImageView.setImageDrawable(null); return; } encryptedChat = ec; currentStatus = status; currentName = name; currentObject = object; currentDrawable = resId; needDivider = divider; setWillNotDraw(!needDivider); update(0); }
Example 9
Source File: UserCell.java From Telegram with GNU General Public License v2.0 | 6 votes |
public void setData(Object object, TLRPC.EncryptedChat ec, CharSequence name, CharSequence status, int resId, boolean divider) { if (object == null && name == null && status == null) { currentStatus = null; currentName = null; currentObject = null; nameTextView.setText(""); statusTextView.setText(""); avatarImageView.setImageDrawable(null); return; } encryptedChat = ec; currentStatus = status; currentName = name; currentObject = object; currentDrawable = resId; needDivider = divider; setWillNotDraw(!needDivider); update(0); }
Example 10
Source File: SecretChatHelper.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
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 11
Source File: SecretChatHelper.java From Telegram with GNU General Public License v2.0 | 6 votes |
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 12
Source File: SecretChatHelper.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public void requestNewSecretChatKey(final TLRPC.EncryptedChat encryptedChat) { if (AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) < 20) { return; } final byte[] salt = new byte[256]; Utilities.random.nextBytes(salt); BigInteger i_g_a = BigInteger.valueOf(MessagesStorage.getInstance(currentAccount).getSecretG()); i_g_a = i_g_a.modPow(new BigInteger(1, salt), new BigInteger(1, MessagesStorage.getInstance(currentAccount).getSecretPBytes())); byte[] g_a = i_g_a.toByteArray(); if (g_a.length > 256) { byte[] correctedAuth = new byte[256]; System.arraycopy(g_a, 1, correctedAuth, 0, 256); g_a = correctedAuth; } encryptedChat.exchange_id = SendMessagesHelper.getInstance(currentAccount).getNextRandomId(); encryptedChat.a_or_b = salt; encryptedChat.g_a = g_a; MessagesStorage.getInstance(currentAccount).updateEncryptedChat(encryptedChat); sendRequestKeyMessage(encryptedChat, null); }
Example 13
Source File: IdenticonDrawable.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void setEncryptedChat(TLRPC.EncryptedChat encryptedChat) { data = encryptedChat.key_hash; if (data == null) { encryptedChat.key_hash = data = AndroidUtilities.calcAuthKeyHash(encryptedChat.auth_key); } invalidateSelf(); }
Example 14
Source File: DialogsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void addShortcut(long selectedDialog) { TLRPC.TL_dialog dialg = MessagesController.getInstance(currentAccount).dialogs_dict.get(selectedDialog); try { long did = 0; long dialog_id = dialg.id; int lower_id = (int) dialog_id; int high_id = (int) (dialog_id >> 32); if (lower_id != 0) did = lower_id; else { TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance(currentAccount).getEncryptedChat(high_id); if (encryptedChat != null) did = ((long) encryptedChat.id) << 32; } if (did != 0) DataQuery.getInstance(currentAccount).installShortcut(did); } catch (Exception e) { FileLog.e(e); } }
Example 15
Source File: SecretChatHelper.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
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 16
Source File: SecretChatHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private TLRPC.TL_messageService createServiceSecretMessage(final TLRPC.EncryptedChat encryptedChat, TLRPC.DecryptedMessageAction decryptedMessage) { TLRPC.TL_messageService newMsg = new TLRPC.TL_messageService(); newMsg.action = new TLRPC.TL_messageEncryptedAction(); newMsg.action.encryptedAction = decryptedMessage; newMsg.local_id = newMsg.id = getUserConfig().getNewMessageId(); newMsg.from_id = getUserConfig().getClientUserId(); newMsg.unread = true; newMsg.out = true; newMsg.flags = TLRPC.MESSAGE_FLAG_HAS_FROM_ID; newMsg.dialog_id = ((long) encryptedChat.id) << 32; newMsg.to_id = new TLRPC.TL_peerUser(); newMsg.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING; if (encryptedChat.participant_id == getUserConfig().getClientUserId()) { newMsg.to_id.user_id = encryptedChat.admin_id; } else { newMsg.to_id.user_id = encryptedChat.participant_id; } if (decryptedMessage instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages || decryptedMessage instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) { newMsg.date = getConnectionsManager().getCurrentTime(); } else { newMsg.date = 0; } newMsg.random_id = getSendMessagesHelper().getNextRandomId(); getUserConfig().saveConfig(false); ArrayList<TLRPC.Message> arr = new ArrayList<>(); arr.add(newMsg); getMessagesStorage().putMessages(arr, false, true, true, 0, false); return newMsg; }
Example 17
Source File: DialogsSearchAdapter.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void setRecentSearch(ArrayList<RecentSearchObject> arrayList, LongSparseArray<RecentSearchObject> hashMap) { recentSearchObjects = arrayList; recentSearchObjectsById = hashMap; for (int a = 0; a < recentSearchObjects.size(); a++) { RecentSearchObject recentSearchObject = recentSearchObjects.get(a); if (recentSearchObject.object instanceof TLRPC.User) { MessagesController.getInstance(currentAccount).putUser((TLRPC.User) recentSearchObject.object, true); } else if (recentSearchObject.object instanceof TLRPC.Chat) { MessagesController.getInstance(currentAccount).putChat((TLRPC.Chat) recentSearchObject.object, true); } else if (recentSearchObject.object instanceof TLRPC.EncryptedChat) { MessagesController.getInstance(currentAccount).putEncryptedChat((TLRPC.EncryptedChat) recentSearchObject.object, true); } } notifyDataSetChanged(); }
Example 18
Source File: SecretChatHelper.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
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: PopupNotificationActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void updateInterfaceForCurrentMessage(int move) { if (actionBar == null) { return; } if (lastResumedAccount != currentMessageObject.currentAccount) { if (lastResumedAccount >= 0) { ConnectionsManager.getInstance(lastResumedAccount).setAppPaused(true, false); } lastResumedAccount = currentMessageObject.currentAccount; ConnectionsManager.getInstance(lastResumedAccount).setAppPaused(false, false); } currentChat = null; currentUser = null; long dialog_id = currentMessageObject.getDialogId(); chatActivityEnterView.setDialogId(dialog_id, currentMessageObject.currentAccount); if ((int) dialog_id != 0) { int lower_id = (int) dialog_id; if (lower_id > 0) { currentUser = MessagesController.getInstance(currentMessageObject.currentAccount).getUser(lower_id); } else { currentChat = MessagesController.getInstance(currentMessageObject.currentAccount).getChat(-lower_id); currentUser = MessagesController.getInstance(currentMessageObject.currentAccount).getUser(currentMessageObject.messageOwner.from_id); } } else { TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance(currentMessageObject.currentAccount).getEncryptedChat((int) (dialog_id >> 32)); currentUser = MessagesController.getInstance(currentMessageObject.currentAccount).getUser(encryptedChat.user_id); } if (currentChat != null && currentUser != null) { nameTextView.setText(currentChat.title); onlineTextView.setText(UserObject.getUserName(currentUser)); nameTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); nameTextView.setCompoundDrawablePadding(0); } else if (currentUser != null) { nameTextView.setText(UserObject.getUserName(currentUser)); if ((int) dialog_id == 0) { nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0); nameTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4)); } else { nameTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); nameTextView.setCompoundDrawablePadding(0); } } prepareLayouts(move); updateSubtitle(); checkAndUpdateAvatar(); applyViewsLayoutParams(0); }
Example 20
Source File: PopupNotificationActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private void updateInterfaceForCurrentMessage(int move) { if (actionBar == null) { return; } if (lastResumedAccount != currentMessageObject.currentAccount) { if (lastResumedAccount >= 0) { ConnectionsManager.getInstance(lastResumedAccount).setAppPaused(true, false); } lastResumedAccount = currentMessageObject.currentAccount; ConnectionsManager.getInstance(lastResumedAccount).setAppPaused(false, false); } currentChat = null; currentUser = null; long dialog_id = currentMessageObject.getDialogId(); chatActivityEnterView.setDialogId(dialog_id, currentMessageObject.currentAccount); if ((int) dialog_id != 0) { int lower_id = (int) dialog_id; if (lower_id > 0) { currentUser = MessagesController.getInstance(currentMessageObject.currentAccount).getUser(lower_id); } else { currentChat = MessagesController.getInstance(currentMessageObject.currentAccount).getChat(-lower_id); currentUser = MessagesController.getInstance(currentMessageObject.currentAccount).getUser(currentMessageObject.messageOwner.from_id); } } else { TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance(currentMessageObject.currentAccount).getEncryptedChat((int) (dialog_id >> 32)); currentUser = MessagesController.getInstance(currentMessageObject.currentAccount).getUser(encryptedChat.user_id); } if (currentChat != null && currentUser != null) { nameTextView.setText(currentChat.title); onlineTextView.setText(UserObject.getUserName(currentUser)); nameTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); nameTextView.setCompoundDrawablePadding(0); } else if (currentUser != null) { nameTextView.setText(UserObject.getUserName(currentUser)); if ((int) dialog_id == 0) { nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0); nameTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4)); } else { nameTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); nameTextView.setCompoundDrawablePadding(0); } } prepareLayouts(move); updateSubtitle(); checkAndUpdateAvatar(); applyViewsLayoutParams(0); }