Skip to content

Commit

Permalink
Update to 3.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DrKLO committed Mar 16, 2016
1 parent 6154c89 commit a7513b3
Show file tree
Hide file tree
Showing 145 changed files with 12,339 additions and 5,547 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Telegram messenger for Android

[Telegram](http://telegram.org) is a messaging app with a focus on speed and security. It’s superfast, simple and free.
[Telegram](https://telegram.org) is a messaging app with a focus on speed and security. It’s superfast, simple and free.
This repo contains the official source code for [Telegram App for Android](https://play.google.com/store/apps/details?id=org.telegram.messenger).

##Creating your Telegram Application
Expand All @@ -16,9 +16,9 @@ There are several things we require from **all developers** for the moment.

### API, Protocol documentation

Telegram API manuals: http://core.telegram.org/api
Telegram API manuals: https://core.telegram.org/api

MTproto protocol manuals: http://core.telegram.org/mtproto
MTproto protocol manuals: https://core.telegram.org/mtproto

### Usage

Expand Down
36 changes: 33 additions & 3 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repositories {
}

dependencies {
compile 'com.android.support:support-v4:23.1.+'
compile 'com.android.support:support-v4:23.2.1'
compile "com.google.android.gms:play-services-gcm:8.4.0"
compile "com.google.android.gms:play-services-maps:8.4.0"
compile 'net.hockeyapp.android:HockeySDK:3.6.+'
Expand Down Expand Up @@ -63,6 +63,8 @@ android {
}
}

defaultConfig.versionCode = 767

sourceSets.main {
jniLibs.srcDir 'libs'
jni.srcDirs = [] //disable automatic ndk-build call
Expand All @@ -80,10 +82,38 @@ android {
manifest.srcFile 'config/foss/AndroidManifest.xml'
}

productFlavors {
x86 {
ndk {
abiFilter "x86"
}
versionCode = 2
}
arm {
ndk {
abiFilter "armeabi"
}
versionCode = 0
}
armv7 {
ndk {
abiFilter "armeabi-v7a"
}
versionCode = 1
}
fat {
versionCode = 3
}
}

applicationVariants.all { variant ->
def abiVersion = variant.productFlavors.get(0).versionCode
variant.mergedFlavor.versionCode = defaultConfig.versionCode * 10 + abiVersion;
}

defaultConfig {
minSdkVersion 9
targetSdkVersion 23
versionCode 755
versionName "3.6.1"
versionName "3.7.0"
}
}
2 changes: 1 addition & 1 deletion TMessagesProj/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false

LOCAL_MODULE := tmessages.19
LOCAL_MODULE := tmessages.20
LOCAL_CFLAGS := -w -std=c11 -Os -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 -ffast-math -D__STDC_CONSTANT_MACROS
Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
APP_PLATFORM := android-9
APP_ABI := armeabi armeabi-v7a x86
NDK_TOOLCHAIN_VERSION := 4.8
NDK_TOOLCHAIN_VERSION := 4.9
APP_STL := gnustl_static
7 changes: 3 additions & 4 deletions TMessagesProj/jni/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,7 @@ JNIEXPORT int Java_org_telegram_messenger_MediaController_isOpusFile(JNIEnv *env
return result;
}

static inline void set_bits(uint8_t *bytes, int32_t bitOffset, int32_t numBits, int32_t value) {
numBits = (unsigned int) (2 << (numBits - 1)) - 1;
static inline void set_bits(uint8_t *bytes, int32_t bitOffset, int32_t value) {
bytes += bitOffset / 8;
bitOffset %= 8;
*((int32_t *) bytes) |= (value << bitOffset);
Expand Down Expand Up @@ -727,7 +726,7 @@ JNIEXPORT jbyteArray Java_org_telegram_messenger_MediaController_getWaveform2(JN

for (int i = 0; i < resultSamples; i++) {
int32_t value = min(31, abs((int32_t) samples[i]) * 31 / peak);
set_bits(bytes, i * 5, 5, value & 31);
set_bits(bytes, i * 5, value & 31);
}

(*env)->ReleaseByteArrayElements(env, result, bytes, JNI_COMMIT);
Expand Down Expand Up @@ -805,7 +804,7 @@ JNIEXPORT jbyteArray Java_org_telegram_messenger_MediaController_getWaveform(JNI

for (int i = 0; i < resultSamples; i++) {
int32_t value = min(31, abs((int32_t) samples[i]) * 31 / peak);
set_bits(bytes, i * 5, 5, value & 31);
set_bits(bytes, i * 5, value & 31);
}

(*env)->ReleaseByteArrayElements(env, result, bytes, JNI_COMMIT);
Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/jni/jni.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <inttypes.h>
#include <stdlib.h>
#include <openssl/aes.h>
#include <unistd.h>
#include "utils.h"
#include "sqlite.h"
#include "image.h"
Expand Down
33 changes: 14 additions & 19 deletions TMessagesProj/jni/sqlite_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jint sqliteOnJNILoad(JavaVM *vm, void *reserved, JNIEnv *env) {
return JNI_VERSION_1_6;
}

int Java_org_telegram_SQLite_SQLitePreparedStatement_step(JNIEnv* env, jobject object, int statementHandle) {
sqlite3_stmt *handle = (sqlite3_stmt *)statementHandle;
int Java_org_telegram_SQLite_SQLitePreparedStatement_step(JNIEnv *env, jobject object, int statementHandle) {
sqlite3_stmt *handle = (sqlite3_stmt *) statementHandle;

int errcode = sqlite3_step(handle);
if (errcode == SQLITE_ROW) {
Expand All @@ -23,7 +23,7 @@ int Java_org_telegram_SQLite_SQLitePreparedStatement_step(JNIEnv* env, jobject o
}

int Java_org_telegram_SQLite_SQLitePreparedStatement_prepare(JNIEnv *env, jobject object, int sqliteHandle, jstring sql) {
sqlite3* handle = (sqlite3 *)sqliteHandle;
sqlite3 *handle = (sqlite3 *) sqliteHandle;

char const *sqlStr = (*env)->GetStringUTFChars(env, sql, 0);

Expand All @@ -41,11 +41,11 @@ int Java_org_telegram_SQLite_SQLitePreparedStatement_prepare(JNIEnv *env, jobjec
(*env)->ReleaseStringUTFChars(env, sql, sqlStr);
}

return (int)stmt_handle;
return (int) stmt_handle;
}

void Java_org_telegram_SQLite_SQLitePreparedStatement_reset(JNIEnv *env, jobject object, int statementHandle) {
sqlite3_stmt *handle = (sqlite3_stmt *)statementHandle;
sqlite3_stmt *handle = (sqlite3_stmt *) statementHandle;

int errcode = sqlite3_reset(handle);
if (SQLITE_OK != errcode) {
Expand All @@ -54,16 +54,11 @@ void Java_org_telegram_SQLite_SQLitePreparedStatement_reset(JNIEnv *env, jobject
}

void Java_org_telegram_SQLite_SQLitePreparedStatement_finalize(JNIEnv *env, jobject object, int statementHandle) {
sqlite3_stmt *handle = (sqlite3_stmt *)statementHandle;

int errcode = sqlite3_finalize (handle);
if (SQLITE_OK != errcode) {
throw_sqlite3_exception(env, sqlite3_db_handle(handle), errcode);
}
sqlite3_finalize((sqlite3_stmt *) statementHandle);
}

void Java_org_telegram_SQLite_SQLitePreparedStatement_bindByteBuffer(JNIEnv *env, jobject object, int statementHandle, int index, jobject value, int length) {
sqlite3_stmt *handle = (sqlite3_stmt *)statementHandle;
sqlite3_stmt *handle = (sqlite3_stmt *) statementHandle;
jbyte *buf = (*env)->GetDirectBufferAddress(env, value);

int errcode = sqlite3_bind_blob(handle, index, buf, length, SQLITE_STATIC);
Expand All @@ -73,7 +68,7 @@ void Java_org_telegram_SQLite_SQLitePreparedStatement_bindByteBuffer(JNIEnv *env
}

void Java_org_telegram_SQLite_SQLitePreparedStatement_bindString(JNIEnv *env, jobject object, int statementHandle, int index, jstring value) {
sqlite3_stmt *handle = (sqlite3_stmt*)statementHandle;
sqlite3_stmt *handle = (sqlite3_stmt *) statementHandle;

char const *valueStr = (*env)->GetStringUTFChars(env, value, 0);

Expand All @@ -88,7 +83,7 @@ void Java_org_telegram_SQLite_SQLitePreparedStatement_bindString(JNIEnv *env, jo
}

void Java_org_telegram_SQLite_SQLitePreparedStatement_bindInt(JNIEnv *env, jobject object, int statementHandle, int index, int value) {
sqlite3_stmt *handle = (sqlite3_stmt*)statementHandle;
sqlite3_stmt *handle = (sqlite3_stmt *) statementHandle;

int errcode = sqlite3_bind_int(handle, index, value);
if (SQLITE_OK != errcode) {
Expand All @@ -97,25 +92,25 @@ void Java_org_telegram_SQLite_SQLitePreparedStatement_bindInt(JNIEnv *env, jobje
}

void Java_org_telegram_SQLite_SQLitePreparedStatement_bindLong(JNIEnv *env, jobject object, int statementHandle, int index, long long value) {
sqlite3_stmt *handle = (sqlite3_stmt*)statementHandle;
sqlite3_stmt *handle = (sqlite3_stmt *) statementHandle;

int errcode = sqlite3_bind_int64(handle, index, value);
if (SQLITE_OK != errcode) {
throw_sqlite3_exception(env, sqlite3_db_handle(handle), errcode);
}
}

void Java_org_telegram_SQLite_SQLitePreparedStatement_bindDouble(JNIEnv* env, jobject object, int statementHandle, int index, double value) {
sqlite3_stmt *handle = (sqlite3_stmt*)statementHandle;
void Java_org_telegram_SQLite_SQLitePreparedStatement_bindDouble(JNIEnv *env, jobject object, int statementHandle, int index, double value) {
sqlite3_stmt *handle = (sqlite3_stmt *) statementHandle;

int errcode = sqlite3_bind_double(handle, index, value);
if (SQLITE_OK != errcode) {
throw_sqlite3_exception(env, sqlite3_db_handle(handle), errcode);
}
}

void Java_org_telegram_SQLite_SQLitePreparedStatement_bindNull(JNIEnv* env, jobject object, int statementHandle, int index) {
sqlite3_stmt *handle = (sqlite3_stmt*)statementHandle;
void Java_org_telegram_SQLite_SQLitePreparedStatement_bindNull(JNIEnv *env, jobject object, int statementHandle, int index) {
sqlite3_stmt *handle = (sqlite3_stmt *) statementHandle;

int errcode = sqlite3_bind_null(handle, index);
if (SQLITE_OK != errcode) {
Expand Down
14 changes: 7 additions & 7 deletions TMessagesProj/jni/tgnet/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void Connection::suspendConnection() {
}

void Connection::onReceivedData(NativeByteBuffer *buffer) {
//AES_ctr128_encrypt(buffer->bytes(), buffer->bytes(), buffer->limit(), &decryptKey, decryptIv, decryptCount, &decryptNum);
AES_ctr128_encrypt(buffer->bytes(), buffer->bytes(), buffer->limit(), &decryptKey, decryptIv, decryptCount, &decryptNum);

failedConnectionCount = 0;

Expand Down Expand Up @@ -323,11 +323,11 @@ void Connection::sendData(NativeByteBuffer *buff, bool reportAck) {
uint32_t val = (bytes[3] << 24) | (bytes[2] << 16) | (bytes[1] << 8) | (bytes[0]);
uint32_t val2 = (bytes[7] << 24) | (bytes[6] << 16) | (bytes[5] << 8) | (bytes[4]);
if (bytes[0] != 0xef && val != 0x44414548 && val != 0x54534f50 && val != 0x20544547 && val != 0x4954504f && val != 0xeeeeeeee && val2 != 0x00000000) {
//bytes[56] = bytes[57] = bytes[58] = bytes[59] = 0xef;
bytes[56] = bytes[57] = bytes[58] = bytes[59] = 0xef;
break;
}
}
/*for (int a = 0; a < 48; a++) {
for (int a = 0; a < 48; a++) {
temp[a] = bytes[55 - a];
}

Expand All @@ -348,7 +348,7 @@ void Connection::sendData(NativeByteBuffer *buff, bool reportAck) {
memcpy(decryptIv, temp + 32, 16);

AES_ctr128_encrypt(bytes, temp, 64, &encryptKey, encryptIv, encryptCount, &encryptNum);
memcpy(bytes + 56, temp + 56, 8);*/
memcpy(bytes + 56, temp + 56, 8);

firstPacketSent = true;
}
Expand All @@ -358,21 +358,21 @@ void Connection::sendData(NativeByteBuffer *buff, bool reportAck) {
}
buffer->writeByte((uint8_t) packetLength);
bytes += (buffer->limit() - 1);
//AES_ctr128_encrypt(bytes, bytes, 1, &encryptKey, encryptIv, encryptCount, &encryptNum);
AES_ctr128_encrypt(bytes, bytes, 1, &encryptKey, encryptIv, encryptCount, &encryptNum);
} else {
packetLength = (packetLength << 8) + 0x7f;
if (reportAck) {
packetLength |= (1 << 7);
}
buffer->writeInt32(packetLength);
bytes += (buffer->limit() - 4);
//AES_ctr128_encrypt(bytes, bytes, 4, &encryptKey, encryptIv, encryptCount, &encryptNum);
AES_ctr128_encrypt(bytes, bytes, 4, &encryptKey, encryptIv, encryptCount, &encryptNum);
}

buffer->rewind();
writeBuffer(buffer);
buff->rewind();
//AES_ctr128_encrypt(buff->bytes(), buff->bytes(), buff->limit(), &encryptKey, encryptIv, encryptCount, &encryptNum);
AES_ctr128_encrypt(buff->bytes(), buff->bytes(), buff->limit(), &encryptKey, encryptIv, encryptCount, &encryptNum);
writeBuffer(buff);
}

Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/jni/tgnet/Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#define USE_DEBUG_SESSION false
#define READ_BUFFER_SIZE 1024 * 128
//#define DEBUG_VERSION
#define DEBUG_VERSION
#define DEFAULT_DATACENTER_ID INT_MAX
#define DC_UPDATE_TIME 60 * 60
#define DOWNLOAD_CONNECTIONS_COUNT 2
Expand Down
2 changes: 2 additions & 0 deletions TMessagesProj/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="telegram.me" android:scheme="http" />
<data android:host="telegram.me" android:scheme="https" />
<data android:host="telegram.dog" android:scheme="http" />
<data android:host="telegram.dog" android:scheme="https" />
</intent-filter>
<intent-filter android:icon="@drawable/ic_launcher" android:priority="1">
<action android:name="android.intent.action.VIEW" />
Expand Down
Loading

0 comments on commit a7513b3

Please sign in to comment.