Skip to content

Commit

Permalink
Perfect forward secrecy in secret chats, phone change, telegram.me li…
Browse files Browse the repository at this point in the history
…nks support
  • Loading branch information
DrKLO committed Dec 1, 2014
1 parent 95de265 commit 8233e89
Show file tree
Hide file tree
Showing 142 changed files with 4,813 additions and 2,305 deletions.
4 changes: 2 additions & 2 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
versionCode 397
versionName "2.0.5"
versionCode 403
versionName "2.1.0"
}
}
2 changes: 1 addition & 1 deletion TMessagesProj/config/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
android:icon="@drawable/ic_launcher"
android:label="@string/AppName"
android:theme="@style/Theme.TMessages.Start"
android:name="org.telegram.ui.ApplicationLoader"
android:name=".ApplicationLoader"
android:hardwareAccelerated="true"
android:largeHeap="true">

Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/config/foss/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:icon="@drawable/ic_launcher"
android:label="@string/AppName"
android:theme="@style/Theme.TMessages.Start"
android:name="org.telegram.ui.ApplicationLoader"
android:name=".ApplicationLoader"
android:hardwareAccelerated="true"
android:largeHeap="true">

Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/config/release/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
android:icon="@drawable/ic_launcher"
android:label="@string/AppName"
android:theme="@style/Theme.TMessages.Start"
android:name="org.telegram.ui.ApplicationLoader"
android:name=".ApplicationLoader"
android:hardwareAccelerated="true"
android:largeHeap="true">

Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE := tmessages.3
LOCAL_MODULE := tmessages.4
LOCAL_CFLAGS := -w -std=gnu99 -O2 -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -fno-math-errno
LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -DHAVE_STRCHRNUL=0
Expand Down
28 changes: 14 additions & 14 deletions TMessagesProj/jni/gif.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ static jint open(GifFileType *GifFileIn, int Error, int startPos, JNIEnv *env, j
return (jint)(Error == 0 ? info : NULL);
}

JNIEXPORT jlong JNICALL Java_org_telegram_ui_Views_GifDrawable_getAllocationByteCount(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT jlong JNICALL Java_org_telegram_ui_Components_GifDrawable_getAllocationByteCount(JNIEnv *env, jclass class, jobject gifInfo) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL) {
return 0;
Expand All @@ -602,23 +602,23 @@ JNIEXPORT jlong JNICALL Java_org_telegram_ui_Views_GifDrawable_getAllocationByte
return sum;
}

JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_reset(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT void JNICALL Java_org_telegram_ui_Components_GifDrawable_reset(JNIEnv *env, jclass class, jobject gifInfo) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL) {
return;
}
reset(info);
}

JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_setSpeedFactor(JNIEnv *env, jclass class, jobject gifInfo, jfloat factor) {
JNIEXPORT void JNICALL Java_org_telegram_ui_Components_GifDrawable_setSpeedFactor(JNIEnv *env, jclass class, jobject gifInfo, jfloat factor) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL) {
return;
}
info->speedFactor = factor;
}

JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_seekToTime(JNIEnv *env, jclass class, jobject gifInfo, jint desiredPos, jintArray jPixels) {
JNIEXPORT void JNICALL Java_org_telegram_ui_Components_GifDrawable_seekToTime(JNIEnv *env, jclass class, jobject gifInfo, jint desiredPos, jintArray jPixels) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL || jPixels == NULL) {
return;
Expand Down Expand Up @@ -665,7 +665,7 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_seekToTime(JNIEnv
}
}

JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_seekToFrame(JNIEnv *env, jclass class, jobject gifInfo, jint desiredIdx, jintArray jPixels) {
JNIEXPORT void JNICALL Java_org_telegram_ui_Components_GifDrawable_seekToFrame(JNIEnv *env, jclass class, jobject gifInfo, jint desiredIdx, jintArray jPixels) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL|| jPixels==NULL) {
return;
Expand Down Expand Up @@ -701,7 +701,7 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_seekToFrame(JNIEnv
}
}

JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_renderFrame(JNIEnv *env, jclass class, jintArray jPixels, jobject gifInfo, jintArray metaData) {
JNIEXPORT void JNICALL Java_org_telegram_ui_Components_GifDrawable_renderFrame(JNIEnv *env, jclass class, jintArray jPixels, jobject gifInfo, jintArray metaData) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL || jPixels == NULL) {
return;
Expand Down Expand Up @@ -752,7 +752,7 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_renderFrame(JNIEnv
(*env)->ReleaseIntArrayElements(env, metaData, rawMetaData, 0);
}

JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_free(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT void JNICALL Java_org_telegram_ui_Components_GifDrawable_free(JNIEnv *env, jclass class, jobject gifInfo) {
if (gifInfo == NULL) {
return;
}
Expand All @@ -765,22 +765,22 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_free(JNIEnv *env,
cleanUp(info);
}

JNIEXPORT jstring JNICALL Java_org_telegram_ui_Views_GifDrawable_getComment(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT jstring JNICALL Java_org_telegram_ui_Components_GifDrawable_getComment(JNIEnv *env, jclass class, jobject gifInfo) {
if (gifInfo == NULL) {
return NULL;
}
GifInfo *info = (GifInfo *)gifInfo;
return (*env)->NewStringUTF(env, info->comment);
}

JNIEXPORT jint JNICALL Java_org_telegram_ui_Views_GifDrawable_getLoopCount(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT jint JNICALL Java_org_telegram_ui_Components_GifDrawable_getLoopCount(JNIEnv *env, jclass class, jobject gifInfo) {
if (gifInfo == NULL) {
return 0;
}
return ((GifInfo *)gifInfo)->loopCount;
}

JNIEXPORT jint JNICALL Java_org_telegram_ui_Views_GifDrawable_getDuration(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT jint JNICALL Java_org_telegram_ui_Components_GifDrawable_getDuration(JNIEnv *env, jclass class, jobject gifInfo) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL) {
return 0;
Expand All @@ -793,7 +793,7 @@ JNIEXPORT jint JNICALL Java_org_telegram_ui_Views_GifDrawable_getDuration(JNIEnv
return sum;
}

JNIEXPORT jint JNICALL Java_org_telegram_ui_Views_GifDrawable_getCurrentPosition(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT jint JNICALL Java_org_telegram_ui_Components_GifDrawable_getCurrentPosition(JNIEnv *env, jclass class, jobject gifInfo) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL) {
return 0;
Expand All @@ -811,15 +811,15 @@ JNIEXPORT jint JNICALL Java_org_telegram_ui_Views_GifDrawable_getCurrentPosition
return (int) (sum + remainder);
}

JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_saveRemainder(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT void JNICALL Java_org_telegram_ui_Components_GifDrawable_saveRemainder(JNIEnv *env, jclass class, jobject gifInfo) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL) {
return;
}
info->lastFrameReaminder = getRealTime() - info->nextStartTime;
}

JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_restoreRemainder(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT void JNICALL Java_org_telegram_ui_Components_GifDrawable_restoreRemainder(JNIEnv *env, jclass class, jobject gifInfo) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL || info->lastFrameReaminder == ULONG_MAX) {
return;
Expand All @@ -828,7 +828,7 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_restoreRemainder(J
info->lastFrameReaminder = ULONG_MAX;
}

JNIEXPORT jint JNICALL Java_org_telegram_ui_Views_GifDrawable_openFile(JNIEnv *env, jclass class, jintArray metaData, jstring jfname) {
JNIEXPORT jint JNICALL Java_org_telegram_ui_Components_GifDrawable_openFile(JNIEnv *env, jclass class, jintArray metaData, jstring jfname) {
if (jfname == NULL) {
setMetaData(0, 0, 0, D_GIF_ERR_OPEN_FAILED, env, metaData);
return (jint) NULL;
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
39 changes: 25 additions & 14 deletions TMessagesProj/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
android:installLocation="auto">

<supports-screens android:anyDensity="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true"/>

<uses-feature android:glEsVersion="0x00020000" android:required="false"/>
Expand Down Expand Up @@ -41,20 +41,20 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<application
android:name=".ApplicationLoader"
android:allowBackup="false"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/AppName"
android:theme="@style/Theme.TMessages.Start"
android:name="org.telegram.ui.ApplicationLoader"
android:hardwareAccelerated="true"
android:largeHeap="true">
android:largeHeap="true"
android:theme="@style/Theme.TMessages.Start">

<activity
android:name="org.telegram.ui.LaunchActivity"
android:windowSoftInputMode="adjustPan"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:hardwareAccelerated="true"
android:launchMode="singleTask"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down Expand Up @@ -95,6 +95,19 @@
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="vnd.android.cursor.item/vnd.org.telegram.messenger.android.profile"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="telegram.me" android:scheme="http" />
<data android:host="telegram.me" android:scheme="https" />
</intent-filter>
<intent-filter android:icon="@drawable/ic_launcher" android:priority="1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tg" />
</intent-filter>
</activity>
<activity
android:name="org.telegram.ui.IntroActivity"
Expand All @@ -105,9 +118,9 @@
android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize|stateHidden"
android:taskAffinity=""
android:theme="@style/Theme.TMessages.PopupNotification">
android:theme="@style/Theme.TMessages.PopupNotification"
android:windowSoftInputMode="adjustResize|stateHidden">
</activity>

<receiver android:name="org.telegram.android.SmsListener">
Expand All @@ -116,17 +129,15 @@
</intent-filter>
</receiver>

<service android:name="org.telegram.android.AuthenticatorService"
android:exported="true">
<service android:name="org.telegram.android.AuthenticatorService" android:exported="true">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator"/>
</intent-filter>
<meta-data android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/auth"/>
</service>

<service android:name="org.telegram.android.ContactsSyncAdapterService"
android:exported="true">
<service android:name="org.telegram.android.ContactsSyncAdapterService" android:exported="true">
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

package org.telegram.PhoneFormat;

import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
package org.telegram.SQLite;

import org.telegram.messenger.FileLog;
import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;

public class SQLiteDatabase {
private final int sqliteHandle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Environment;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.util.StateSet;
import android.view.Display;
import android.view.Surface;
Expand All @@ -35,12 +38,14 @@
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.ui.ApplicationLoader;
import org.telegram.ui.Views.NumberPicker;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.ui.Components.NumberPicker;
import org.telegram.ui.Components.TypefaceSpan;

import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Hashtable;

public class AndroidUtilities {
Expand Down Expand Up @@ -389,7 +394,7 @@ public void onClick(DialogInterface dialog, int which) {
encryptedChat.ttl = 60 * 60 * 24 * 7;
}
if (oldValue != encryptedChat.ttl) {
SendMessagesHelper.getInstance().sendTTLMessage(encryptedChat, null);
SecretChatHelper.getInstance().sendTTLMessage(encryptedChat, null);
MessagesStorage.getInstance().updateEncryptedChatTTL(encryptedChat);
}
}
Expand Down Expand Up @@ -502,4 +507,21 @@ public static void clearDrawableAnimation(View view) {
}
}
}

public static Spannable replaceBold(String str) {
int start;
ArrayList<Integer> bolds = new ArrayList<Integer>();
while ((start = str.indexOf("<b>")) != -1) {
int end = str.indexOf("</b>") - 3;
str = str.replaceFirst("<b>", "").replaceFirst("</b>", "");
bolds.add(start);
bolds.add(end);
}
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(str);
for (int a = 0; a < bolds.size() / 2; a++) {
TypefaceSpan span = new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
stringBuilder.setSpan(span, bolds.get(a * 2), bolds.get(a * 2 + 1), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
}
return stringBuilder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import android.content.Context;
import android.content.Intent;

import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;

public class AppStartReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;

import java.util.ArrayList;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import org.telegram.messenger.FileLog;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;

public class Emoji {
private static HashMap<Long, DrawableInfo> rects = new HashMap<Long, DrawableInfo>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.json.JSONObject;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog;
import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;

public class GcmBroadcastReceiver extends BroadcastReceiver {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;

import java.io.ByteArrayOutputStream;
import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;
import org.xmlpull.v1.XmlPullParser;

import java.io.File;
Expand Down
Loading

0 comments on commit 8233e89

Please sign in to comment.