Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
apk
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
apk
Commits
358a067a
Commit
358a067a
authored
Jun 16, 2014
by
DrKLO
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid uploading same file twice, bug fixes
parent
a87968ce
Changes
20
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
398 additions
and
231 deletions
+398
-231
build.gradle
TMessagesProj/build.gradle
+2
-2
ConnectionsManager.java
.../main/java/org/telegram/messenger/ConnectionsManager.java
+54
-31
ContactsController.java
.../main/java/org/telegram/messenger/ContactsController.java
+16
-0
FileLoader.java
...Proj/src/main/java/org/telegram/messenger/FileLoader.java
+8
-8
FileUploadOperation.java
...main/java/org/telegram/messenger/FileUploadOperation.java
+85
-49
MessagesController.java
.../main/java/org/telegram/messenger/MessagesController.java
+36
-41
MessagesStorage.java
...src/main/java/org/telegram/messenger/MessagesStorage.java
+78
-0
NativeLoader.java
...oj/src/main/java/org/telegram/messenger/NativeLoader.java
+34
-15
TLRPC.java
...sagesProj/src/main/java/org/telegram/messenger/TLRPC.java
+10
-8
TcpConnection.java
...j/src/main/java/org/telegram/messenger/TcpConnection.java
+2
-2
Utilities.java
...sProj/src/main/java/org/telegram/messenger/Utilities.java
+3
-0
ChatActivity.java
...sagesProj/src/main/java/org/telegram/ui/ChatActivity.java
+33
-50
ContactAddActivity.java
...roj/src/main/java/org/telegram/ui/ContactAddActivity.java
+1
-0
CountrySelectActivity.java
.../src/main/java/org/telegram/ui/CountrySelectActivity.java
+1
-1
DocumentSelectActivity.java
...src/main/java/org/telegram/ui/DocumentSelectActivity.java
+2
-2
LaunchActivity.java
...gesProj/src/main/java/org/telegram/ui/LaunchActivity.java
+2
-2
UserProfileActivity.java
...oj/src/main/java/org/telegram/ui/UserProfileActivity.java
+22
-12
ActionBarLayer.java
.../java/org/telegram/ui/Views/ActionBar/ActionBarLayer.java
+2
-2
AvatarUpdater.java
...oj/src/main/java/org/telegram/ui/Views/AvatarUpdater.java
+1
-1
updating_state_layout.xml
TMessagesProj/src/main/res/layout/updating_state_layout.xml
+6
-5
No files found.
TMessagesProj/build.gradle
View file @
358a067a
...
...
@@ -81,7 +81,7 @@ android {
defaultConfig
{
minSdkVersion
8
targetSdkVersion
19
versionCode
25
7
versionName
"1.5.
4
"
versionCode
25
8
versionName
"1.5.
5
"
}
}
TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java
View file @
358a067a
...
...
@@ -63,7 +63,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
private
boolean
paused
=
false
;
private
long
lastPingTime
=
System
.
currentTimeMillis
();
private
long
lastPushPingTime
=
System
.
currentTimeMillis
();
private
long
lastPushPingTime
=
0
;
private
boolean
sendingPushPing
=
false
;
private
int
nextSleepTimeout
=
30000
;
private
long
nextPingId
=
0
;
...
...
@@ -88,7 +89,11 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
Utilities
.
stageQueue
.
handler
.
removeCallbacks
(
stageRunnable
);
t
=
System
.
currentTimeMillis
();
if
(
datacenters
!=
null
)
{
if
(
lastPushPingTime
<
System
.
currentTimeMillis
()
-
29000
)
{
if
(
sendingPushPing
&&
lastPushPingTime
<
System
.
currentTimeMillis
()
-
30000
||
Math
.
abs
(
lastPushPingTime
-
System
.
currentTimeMillis
())
>
60000
*
4
)
{
lastPushPingTime
=
0
;
sendingPushPing
=
false
;
}
if
(
lastPushPingTime
<
System
.
currentTimeMillis
()
-
60000
*
3
)
{
lastPushPingTime
=
System
.
currentTimeMillis
();
Datacenter
datacenter
=
datacenterWithId
(
currentDatacenterId
);
if
(
datacenter
!=
null
)
{
...
...
@@ -1955,14 +1960,15 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if
(
UserConfig
.
isClientActivated
()
&&
!
UserConfig
.
registeredForInternalPush
&&
(
connection
.
transportRequestClass
&
RPCRequest
.
RPCRequestClassPush
)
!=
0
)
{
registerForPush
();
}
TLRPC
.
TL_pong
pong
=
(
TLRPC
.
TL_pong
)
message
;
if
((
connection
.
transportRequestClass
&
RPCRequest
.
RPCRequestClassPush
)
==
0
)
{
TLRPC
.
TL_pong
pong
=
(
TLRPC
.
TL_pong
)
message
;
long
pingId
=
pong
.
ping_id
;
ArrayList
<
Long
>
itemsToDelete
=
new
ArrayList
<
Long
>();
for
(
Long
pid
:
pingIdToDate
.
keySet
())
{
if
(
pid
==
pingId
)
{
int
time
=
pingIdToDate
.
get
(
pid
);
int
pingTime
=
(
int
)
(
System
.
currentTimeMillis
()
/
1000
)
-
time
;
int
pingTime
=
(
int
)
(
System
.
currentTimeMillis
()
/
1000
)
-
time
;
if
(
Math
.
abs
(
pingTime
)
<
10
)
{
currentPingTime
=
(
pingTime
+
currentPingTime
)
/
2
;
...
...
@@ -1970,7 +1976,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if
(
messageId
!=
0
)
{
long
timeMessage
=
getTimeFromMsgId
(
messageId
);
long
currentTime
=
System
.
currentTimeMillis
();
timeDifference
=
(
int
)
((
timeMessage
-
currentTime
)
/
1000
-
currentPingTime
/
2.0
);
timeDifference
=
(
int
)
((
timeMessage
-
currentTime
)
/
1000
-
currentPingTime
/
2.0
);
}
}
itemsToDelete
.
add
(
pid
);
...
...
@@ -1981,6 +1987,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
for
(
Long
pid
:
itemsToDelete
)
{
pingIdToDate
.
remove
(
pid
);
}
}
else
{
sendingPushPing
=
false
;
}
}
else
if
(
message
instanceof
TLRPC
.
TL_futuresalts
)
{
TLRPC
.
TL_futuresalts
futureSalts
=
(
TLRPC
.
TL_futuresalts
)
message
;
long
requestMid
=
futureSalts
.
req_msg_id
;
...
...
@@ -2345,8 +2354,11 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
TLRPC
.
TL_ping_delay_disconnect
ping
=
new
TLRPC
.
TL_ping_delay_disconnect
();
ping
.
ping_id
=
nextPingId
++;
if
((
connection
.
transportRequestClass
&
RPCRequest
.
RPCRequestClassPush
)
!=
0
)
{
ping
.
disconnect_delay
=
60
*
7
;
}
else
{
ping
.
disconnect_delay
=
35
;
pingIdToDate
.
put
(
ping
.
ping_id
,
(
int
)
(
System
.
currentTimeMillis
()
/
1000
));
pingIdToDate
.
put
(
ping
.
ping_id
,
(
int
)
(
System
.
currentTimeMillis
()
/
1000
));
if
(
pingIdToDate
.
size
()
>
20
)
{
ArrayList
<
Long
>
itemsToDelete
=
new
ArrayList
<
Long
>();
for
(
Long
pid
:
pingIdToDate
.
keySet
())
{
...
...
@@ -2358,6 +2370,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
pingIdToDate
.
remove
(
pid
);
}
}
}
NetworkMessage
networkMessage
=
new
NetworkMessage
();
networkMessage
.
protoMessage
=
wrapMessage
(
ping
,
connection
,
false
);
...
...
@@ -2377,6 +2390,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if
(
connection
!=
null
&&
(
push
||
!
push
&&
connection
.
channelToken
!=
0
))
{
ByteBufferDesc
transportData
=
generatePingData
(
connection
);
if
(
transportData
!=
null
)
{
if
(
push
)
{
sendingPushPing
=
true
;
}
connection
.
sendData
(
null
,
transportData
,
false
);
}
}
...
...
@@ -2558,6 +2574,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
NotificationCenter
.
getInstance
().
postNotificationName
(
703
,
stateCopy
);
}
});
}
else
if
((
connection
.
transportRequestClass
&
RPCRequest
.
RPCRequestClassPush
)
!=
0
)
{
sendingPushPing
=
false
;
lastPushPingTime
=
System
.
currentTimeMillis
()
-
60000
*
3
+
5000
;
}
}
...
...
@@ -2566,6 +2585,10 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
Datacenter
datacenter
=
datacenterWithId
(
connection
.
getDatacenterId
());
if
(
datacenter
.
authKey
!=
null
)
{
processRequestQueue
(
connection
.
transportRequestClass
,
connection
.
getDatacenterId
());
if
((
connection
.
transportRequestClass
&
RPCRequest
.
RPCRequestClassPush
)
!=
0
)
{
sendingPushPing
=
false
;
lastPushPingTime
=
System
.
currentTimeMillis
()
-
60000
*
3
+
10000
;
}
}
}
...
...
TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java
View file @
358a067a
...
...
@@ -181,6 +181,10 @@ public class ContactsController {
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
finally
{
if
(
pCur
!=
null
)
{
pCur
.
close
();
}
}
try
{
pCur
=
cr
.
query
(
ContactsContract
.
CommonDataKinds
.
Phone
.
CONTENT_URI
,
new
String
[]{
ContactsContract
.
CommonDataKinds
.
Phone
.
_COUNT
},
null
,
null
,
null
);
...
...
@@ -195,6 +199,10 @@ public class ContactsController {
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
finally
{
if
(
pCur
!=
null
)
{
pCur
.
close
();
}
}
try
{
pCur
=
cr
.
query
(
ContactsContract
.
Data
.
CONTENT_URI
,
new
String
[]{
ContactsContract
.
Data
.
_COUNT
},
ContactsContract
.
Data
.
MIMETYPE
+
" = '"
+
ContactsContract
.
CommonDataKinds
.
StructuredName
.
CONTENT_ITEM_TYPE
+
"'"
,
null
,
null
);
...
...
@@ -209,6 +217,10 @@ public class ContactsController {
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
finally
{
if
(
pCur
!=
null
)
{
pCur
.
close
();
}
}
try
{
pCur
=
cr
.
query
(
ContactsContract
.
Data
.
CONTENT_URI
,
new
String
[]{
ContactsContract
.
Data
.
_ID
},
ContactsContract
.
Data
.
MIMETYPE
+
" = '"
+
ContactsContract
.
CommonDataKinds
.
StructuredName
.
CONTENT_ITEM_TYPE
+
"'"
,
null
,
ContactsContract
.
Data
.
_ID
+
" desc LIMIT 1"
);
...
...
@@ -223,6 +235,10 @@ public class ContactsController {
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
finally
{
if
(
pCur
!=
null
)
{
pCur
.
close
();
}
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
...
...
TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java
View file @
358a067a
...
...
@@ -337,11 +337,11 @@ public class FileLoader {
return
memCache
.
get
(
key
)
!=
null
;
}
public
void
uploadFile
(
final
String
location
,
final
byte
[]
key
,
final
byte
[]
iv
)
{
public
void
uploadFile
(
final
String
location
,
final
String
originalLocation
,
final
boolean
encrypted
)
{
fileLoaderQueue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
key
!=
null
)
{
if
(
encrypted
)
{
if
(
uploadOperationPathsEnc
.
containsKey
(
location
))
{
return
;
}
...
...
@@ -350,8 +350,8 @@ public class FileLoader {
return
;
}
}
FileUploadOperation
operation
=
new
FileUploadOperation
(
location
,
key
,
iv
);
if
(
key
!=
null
)
{
FileUploadOperation
operation
=
new
FileUploadOperation
(
location
,
originalLocation
,
encrypted
);
if
(
encrypted
)
{
uploadOperationPathsEnc
.
put
(
location
,
operation
);
}
else
{
uploadOperationPaths
.
put
(
location
,
operation
);
...
...
@@ -369,7 +369,7 @@ public class FileLoader {
fileProgresses
.
remove
(
location
);
}
});
if
(
key
!=
null
)
{
if
(
encrypted
)
{
uploadOperationPathsEnc
.
remove
(
location
);
}
else
{
uploadOperationPaths
.
remove
(
location
);
...
...
@@ -396,11 +396,11 @@ public class FileLoader {
public
void
run
()
{
fileProgresses
.
remove
(
location
);
if
(
operation
.
state
!=
2
)
{
NotificationCenter
.
getInstance
().
postNotificationName
(
FileDidFailUpload
,
location
,
key
!=
null
);
NotificationCenter
.
getInstance
().
postNotificationName
(
FileDidFailUpload
,
location
,
encrypted
);
}
}
});
if
(
key
!=
null
)
{
if
(
encrypted
)
{
uploadOperationPathsEnc
.
remove
(
location
);
}
else
{
uploadOperationPaths
.
remove
(
location
);
...
...
@@ -428,7 +428,7 @@ public class FileLoader {
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
NotificationCenter
.
getInstance
().
postNotificationName
(
FileUploadProgressChanged
,
location
,
progress
,
key
!=
null
);
NotificationCenter
.
getInstance
().
postNotificationName
(
FileUploadProgressChanged
,
location
,
progress
,
encrypted
);
}
});
}
...
...
TMessagesProj/src/main/java/org/telegram/messenger/FileUploadOperation.java
View file @
358a067a
...
...
@@ -13,11 +13,14 @@ import java.io.FileInputStream;
import
java.math.BigInteger
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.ArrayList
;
import
java.util.Locale
;
import
java.util.concurrent.Semaphore
;
public
class
FileUploadOperation
{
private
int
uploadChunkSize
=
1024
*
32
;
private
String
uploadingFilePath
;
private
String
originalPath
;
public
int
state
=
0
;
private
byte
[]
readBuffer
;
public
FileUploadOperationDelegate
delegate
;
...
...
@@ -30,6 +33,7 @@ public class FileUploadOperation {
private
long
currentUploaded
=
0
;
private
byte
[]
key
;
private
byte
[]
iv
;
private
byte
[]
ivChange
;
private
int
fingerprint
;
private
boolean
isBigFile
=
false
;
FileInputStream
stream
;
...
...
@@ -41,12 +45,16 @@ public class FileUploadOperation {
public
abstract
void
didChangedUploadProgress
(
FileUploadOperation
operation
,
float
progress
);
}
public
FileUploadOperation
(
String
location
,
byte
[]
keyarr
,
byte
[]
ivarr
)
{
public
FileUploadOperation
(
String
location
,
String
originalLocaltion
,
boolean
encrypted
)
{
uploadingFilePath
=
location
;
if
(
ivarr
!=
null
&&
keyarr
!=
null
)
{
originalPath
=
originalLocaltion
;
if
(
encrypted
)
{
iv
=
new
byte
[
32
];
key
=
keyarr
;
System
.
arraycopy
(
ivarr
,
0
,
iv
,
0
,
32
);
key
=
new
byte
[
32
];
ivChange
=
new
byte
[
32
];
Utilities
.
random
.
nextBytes
(
iv
);
Utilities
.
random
.
nextBytes
(
key
);
System
.
arraycopy
(
iv
,
0
,
ivChange
,
0
,
32
);
try
{
java
.
security
.
MessageDigest
md
=
java
.
security
.
MessageDigest
.
getInstance
(
"MD5"
);
byte
[]
arr
=
new
byte
[
64
];
...
...
@@ -98,6 +106,26 @@ public class FileUploadOperation {
try
{
if
(
stream
==
null
)
{
if
(
originalPath
!=
null
)
{
Semaphore
semaphore
=
new
Semaphore
(
0
);
ArrayList
<
TLObject
>
result
=
new
ArrayList
<
TLObject
>();
String
path
=
originalPath
;
if
(
key
!=
null
)
{
path
+=
"e"
;
}
MessagesStorage
.
getInstance
().
getSentFile
(
path
,
semaphore
,
result
);
semaphore
.
acquire
();
if
(!
result
.
isEmpty
())
{
TLObject
object
=
result
.
get
(
0
);
if
(
object
instanceof
TLRPC
.
InputFile
)
{
delegate
.
didFinishUploadingFile
(
FileUploadOperation
.
this
,
(
TLRPC
.
InputFile
)
object
,
null
);
return
;
}
else
if
(
object
instanceof
TLRPC
.
InputEncryptedFile
)
{
delegate
.
didFinishUploadingFile
(
FileUploadOperation
.
this
,
null
,
(
TLRPC
.
InputEncryptedFile
)
object
);
return
;
}
}
}
File
cacheFile
=
new
File
(
uploadingFilePath
);
stream
=
new
FileInputStream
(
cacheFile
);
totalFileSize
=
cacheFile
.
length
();
...
...
@@ -106,7 +134,7 @@ public class FileUploadOperation {
isBigFile
=
true
;
}
uploadChunkSize
=
(
int
)
Math
.
max
(
32
,
Math
.
ceil
(
totalFileSize
/
(
1024.0f
*
3000
)));
uploadChunkSize
=
(
int
)
Math
.
max
(
32
,
Math
.
ceil
(
totalFileSize
/
(
1024.0f
*
3000
)));
if
(
1024
%
uploadChunkSize
!=
0
)
{
int
chunkSize
=
64
;
while
(
uploadChunkSize
>
chunkSize
)
{
...
...
@@ -116,7 +144,7 @@ public class FileUploadOperation {
}
uploadChunkSize
*=
1024
;
totalPartsCount
=
(
int
)
Math
.
ceil
((
float
)
totalFileSize
/
(
float
)
uploadChunkSize
);
totalPartsCount
=
(
int
)
Math
.
ceil
((
float
)
totalFileSize
/
(
float
)
uploadChunkSize
);
readBuffer
=
new
byte
[
uploadChunkSize
];
}
...
...
@@ -134,7 +162,7 @@ public class FileUploadOperation {
for
(
int
a
=
0
;
a
<
toAdd
;
a
++)
{
sendBuffer
.
writeByte
(
0
);
}
Utilities
.
aesIgeEncryption2
(
sendBuffer
.
buffer
,
key
,
iv
,
true
,
true
,
readed
+
toAdd
);
Utilities
.
aesIgeEncryption2
(
sendBuffer
.
buffer
,
key
,
iv
Change
,
true
,
true
,
readed
+
toAdd
);
}
sendBuffer
.
rewind
();
if
(!
isBigFile
)
{
...
...
@@ -167,7 +195,7 @@ public class FileUploadOperation {
if
(
error
==
null
)
{
if
(
response
instanceof
TLRPC
.
TL_boolTrue
)
{
currentPartNum
++;
delegate
.
didChangedUploadProgress
(
FileUploadOperation
.
this
,
(
float
)
currentUploaded
/
(
float
)
totalFileSize
);
delegate
.
didChangedUploadProgress
(
FileUploadOperation
.
this
,
(
float
)
currentUploaded
/
(
float
)
totalFileSize
);
if
(
isLastPart
)
{
state
=
3
;
if
(
key
==
null
)
{
...
...
@@ -182,6 +210,9 @@ public class FileUploadOperation {
result
.
id
=
currentFileId
;
result
.
name
=
uploadingFilePath
.
substring
(
uploadingFilePath
.
lastIndexOf
(
"/"
)
+
1
);
delegate
.
didFinishUploadingFile
(
FileUploadOperation
.
this
,
result
,
null
);
if
(
originalPath
!=
null
)
{
MessagesStorage
.
getInstance
().
putSentFile
(
originalPath
,
result
,
null
,
null
);
}
}
else
{
TLRPC
.
InputEncryptedFile
result
;
if
(
isBigFile
)
{
...
...
@@ -193,7 +224,12 @@ public class FileUploadOperation {
result
.
parts
=
currentPartNum
;
result
.
id
=
currentFileId
;
result
.
key_fingerprint
=
fingerprint
;
result
.
iv
=
iv
;
result
.
key
=
key
;
delegate
.
didFinishUploadingFile
(
FileUploadOperation
.
this
,
null
,
result
);
if
(
originalPath
!=
null
)
{
MessagesStorage
.
getInstance
().
putSentFile
(
originalPath
+
"e"
,
result
,
key
,
iv
);
}
}
}
else
{
startUploadRequest
();
...
...
TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java
View file @
358a067a
This diff is collapsed.
Click to expand it.
TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java
View file @
358a067a
...
...
@@ -97,6 +97,8 @@ public class MessagesStorage {
database
.
executeFast
(
"CREATE TABLE user_contacts_v6(uid INTEGER PRIMARY KEY, fname TEXT, sname TEXT)"
).
stepThis
().
dispose
();
database
.
executeFast
(
"CREATE TABLE user_phones_v6(uid INTEGER, phone TEXT, sphone TEXT, deleted INTEGER, PRIMARY KEY (uid, phone))"
).
stepThis
().
dispose
();
database
.
executeFast
(
"CREATE TABLE sent_files(uid TEXT PRIMARY KEY, data BLOB, key BLOB, iv BLOB)"
).
stepThis
().
dispose
();
database
.
executeFast
(
"CREATE INDEX IF NOT EXISTS mid_idx_randoms ON randoms(mid);"
).
stepThis
().
dispose
();
database
.
executeFast
(
"CREATE INDEX IF NOT EXISTS sphone_deleted_idx_user_phones ON user_phones_v6(sphone, deleted);"
).
stepThis
().
dispose
();
...
...
@@ -166,6 +168,8 @@ public class MessagesStorage {
database
.
executeFast
(
"CREATE INDEX IF NOT EXISTS sphone_deleted_idx_user_phones ON user_phones_v6(sphone, deleted);"
).
stepThis
().
dispose
();
database
.
executeFast
(
"CREATE INDEX IF NOT EXISTS mid_idx_randoms ON randoms(mid);"
).
stepThis
().
dispose
();
database
.
executeFast
(
"CREATE TABLE IF NOT EXISTS sent_files(uid TEXT PRIMARY KEY, data BLOB, key BLOB, iv BLOB)"
).
stepThis
().
dispose
();
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
...
...
@@ -1496,6 +1500,80 @@ public class MessagesStorage {
});
}
public
void
getSentFile
(
final
String
path
,
final
Semaphore
semaphore
,
final
ArrayList
<
TLObject
>
result
)
{
if
(
path
==
null
||
semaphore
==
null
||
result
==
null
)
{
return
;
}
storageQueue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
String
id
=
Utilities
.
MD5
(
path
);
if
(
id
!=
null
)
{
SQLiteCursor
cursor
=
database
.
queryFinalized
(
"SELECT data, key, iv FROM sent_files WHERE uid = '"
+
id
+
"'"
);
if
(
cursor
.
next
())
{
byte
[]
fileData
=
cursor
.
byteArrayValue
(
0
);
if
(
fileData
!=
null
)
{
SerializedData
data
=
new
SerializedData
(
fileData
);
TLObject
file
=
TLClassStore
.
Instance
().
TLdeserialize
(
data
,
data
.
readInt32
());
if
(
file
instanceof
TLRPC
.
InputEncryptedFile
)
{
TLRPC
.
InputEncryptedFile
encFile
=
(
TLRPC
.
InputEncryptedFile
)
file
;
encFile
.
key
=
cursor
.
byteArrayValue
(
1
);
encFile
.
iv
=
cursor
.
byteArrayValue
(
2
);
if
(
encFile
.
key
!=
null
&&
encFile
.
iv
!=
null
)
{
result
.
add
(
file
);
}
}
else
if
(
file
instanceof
TLRPC
.
InputFile
)
{
result
.
add
(
file
);
}
}
}
cursor
.
dispose
();
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
finally
{
semaphore
.
release
();
}
}
});
}
public
void
putSentFile
(
final
String
path
,
final
TLObject
file
,
final
byte
[]
key
,
final
byte
[]
iv
)
{
if
(
path
==
null
||
file
==
null
)
{
return
;
}
storageQueue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
String
id
=
Utilities
.
MD5
(
path
);
if
(
id
!=
null
)
{
SQLitePreparedStatement
state
=
null
;
if
(
key
!=
null
&&
iv
!=
null
)
{
state
=
database
.
executeFast
(
"REPLACE INTO sent_files VALUES(?, ?, ?, ?)"
);
}
else
{
state
=
database
.
executeFast
(
"REPLACE INTO sent_files VALUES(?, ?, NULL, NULL)"
);
}
state
.
requery
();
SerializedData
data
=
new
SerializedData
();
file
.
serializeToStream
(
data
);
state
.
bindString
(
1
,
id
);
state
.
bindByteArray
(
2
,
data
.
toByteArray
());
if
(
key
!=
null
&&
iv
!=
null
)
{
state
.
bindByteArray
(
3
,
key
);
state
.
bindByteArray
(
4
,
iv
);
}
state
.
step
();
state
.
dispose
();
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
}
});
}
public
void
getEncryptedChat
(
final
int
chat_id
,
final
Semaphore
semaphore
,
final
ArrayList
<
TLObject
>
result
)
{
if
(
semaphore
==
null
||
result
==
null
)
{
return
;
...
...
TMessagesProj/src/main/java/org/telegram/messenger/NativeLoader.java
View file @
358a067a
...
...
@@ -47,8 +47,25 @@ public class NativeLoader {
}
}
private
static
OutputStreamWriter
streamWriter
=
null
;
private
static
FileOutputStream
stream
=
null
;
private
static
void
closeStream
()
{
try
{
if
(
stream
!=
null
)
{
streamWriter
.
close
();
stream
.
close
();
stream
=
null
;
streamWriter
=
null
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
static
void
writeNativeError
(
Context
context
,
String
info
,
Throwable
throwable
)
{
try
{
if
(
stream
==
null
)
{
File
sdCard
=
context
.
getFilesDir
();
if
(
sdCard
==
null
)
{
return
;
...
...
@@ -58,17 +75,16 @@ public class NativeLoader {
return
;
}
FileOutputStream
stream
=
new
FileOutputStream
(
file
);
OutputStreamWriter
streamWriter
=
new
OutputStreamWriter
(
stream
);
streamWriter
.
write
(
"info"
+
"\n"
);
stream
=
new
FileOutputStream
(
file
);
streamWriter
=
new
OutputStreamWriter
(
stream
);
}
streamWriter
.
write
(
info
+
"\n"
);
streamWriter
.
write
(
throwable
+
"\n"
);
StackTraceElement
[]
stack
=
throwable
.
getStackTrace
();
for
(
StackTraceElement
el
:
stack
)
{
streamWriter
.
write
(
el
+
"\n"
);
}
streamWriter
.
flush
();
streamWriter
.
close
();
stream
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -147,9 +163,9 @@ public class NativeLoader {
return
;
}
try
{
cleanNativeLog
(
context
);
try
{
String
folder
=
null
;
long
libSize
=
0
;
long
libSize2
=
0
;
...
...
@@ -191,6 +207,7 @@ public class NativeLoader {
try
{
System
.
loadLibrary
(
"tmessages"
);
nativeLoaded
=
true
;
closeStream
();
return
;
}
catch
(
Error
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
...
...
@@ -206,6 +223,7 @@ public class NativeLoader {
FileLog
.
d
(
"tmessages"
,
"Load local lib"
);
System
.
load
(
destLocalFile
.
getAbsolutePath
());
nativeLoaded
=
true
;
closeStream
();
return
;
}
catch
(
Error
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
...
...
@@ -230,6 +248,7 @@ public class NativeLoader {
try
{
System
.
loadLibrary
(
"tmessages"
);
nativeLoaded
=
true
;
closeStream
();
}
catch
(
Error
e
)
{
writeNativeError
(
context
,
"last chance"
,
e
);
FileLog
.
e
(
"tmessages"
,
e
);
...
...
TMessagesProj/src/main/java/org/telegram/messenger/TLRPC.java
View file @
358a067a
...
...
@@ -3783,14 +3783,6 @@ public class TLRPC {
}
}
public
static
class
InputEncryptedFile
extends
TLObject
{
public
long
id
;
public
long
access_hash
;
public
int
parts
;
public
int
key_fingerprint
;
public
String
md5_checksum
;
}
public
static
class
TL_inputEncryptedFile
extends
InputEncryptedFile
{
public
static
int
constructor
=
0x5a17b5e5
;
...
...
@@ -9212,4 +9204,14 @@ public class TLRPC {
}
}
}
public
static
class
InputEncryptedFile
extends
TLObject
{
public
long
id
;
public
long
access_hash
;
public
int
parts
;
public
int
key_fingerprint
;
public
String
md5_checksum
;
public
byte
[]
key
;
public
byte
[]
iv
;
}
}
TMessagesProj/src/main/java/org/telegram/messenger/TcpConnection.java
View file @
358a067a
...
...
@@ -135,7 +135,7 @@ public class TcpConnection extends ConnectionContext {
client
.
addListener
(
TcpConnection
.
this
);
if
((
transportRequestClass
&
RPCRequest
.
RPCRequestClassPush
)
!=
0
)
{
if
(
isNextPort
)
{
client
.
setTimeout
(
15
000
);
client
.
setTimeout
(
20
000
);
}
else
{
client
.
setTimeout
(
30000
);
}
...
...
@@ -424,7 +424,7 @@ public class TcpConnection extends ConnectionContext {
datacenter
.
storeCurrentAddressAndPortNum
();
isNextPort
=
false
;
if
((
transportRequestClass
&
RPCRequest
.
RPCRequestClassPush
)
!=
0
)
{
client
.
setTimeout
(
4
0000
);
client
.
setTimeout
(
60000
*
3
+
2
0000
);
}
else
{
client
.
setTimeout
(
25000
);
}
...
...
TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java
View file @
358a067a
...
...
@@ -747,6 +747,9 @@ public class Utilities {
}
public
static
String
MD5
(
String
md5
)
{
if
(
md5
==
null
)
{
return
null
;
}
try
{
java
.
security
.
MessageDigest
md
=
java
.
security
.
MessageDigest
.
getInstance
(
"MD5"
);
byte
[]
array
=
md
.
digest
(
md5
.
getBytes
());
...
...
TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
View file @
358a067a
This diff is collapsed.
Click to expand it.
TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java
View file @
358a067a
...
...
@@ -102,6 +102,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
onlineText
=
(
TextView
)
fragmentView
.
findViewById
(
R
.
id
.
settings_online
);
avatarImage
=
(
BackupImageView
)
fragmentView
.
findViewById
(
R
.
id
.
settings_avatar_image
);
avatarImage
.
processDetach
=
false
;
phoneText
=
(
TextView
)
fragmentView
.
findViewById
(
R
.
id
.
settings_name
);
Typeface
typeface
=
Utilities
.
getTypeface
(
"fonts/rmedium.ttf"
);
phoneText
.
setTypeface
(
typeface
);
...
...
TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java
View file @
358a067a
...
...
@@ -85,7 +85,7 @@ public class CountrySelectActivity extends BaseFragment {
}
arr
.
add
(
c
);
}
reader
.
close
();
//TODO
reader
.
close
();
stream
.
close
();
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
...
...
TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java
View file @
358a067a
...
...
@@ -45,7 +45,7 @@ import java.util.HashMap;
public
class
DocumentSelectActivity
extends
BaseFragment
{
public
static
abstract
interface
DocumentSelectActivityDelegate
{
public
void
didSelectFile
(
DocumentSelectActivity
activity
,
String
path
,
String
name
,
String
ext
,
long
size
);
public
void
didSelectFile
(
DocumentSelectActivity
activity
,
String
path
);
public
void
startDocumentSelectActivity
();
}
...
...
@@ -186,7 +186,7 @@ public class DocumentSelectActivity extends BaseFragment {
return
;
}
if
(
delegate
!=
null
)
{
delegate
.
didSelectFile
(
DocumentSelectActivity
.
this
,
file
.
getAbsolutePath
()
,
item
.
title
,
item
.
ext
,
file
.
length
()
);
delegate
.
didSelectFile
(
DocumentSelectActivity
.
this
,
file
.
getAbsolutePath
());
}
}
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
View file @
358a067a
...
...
@@ -498,14 +498,14 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
fragment
.
processSendingText
(
sendingText
);
}
if
(
documentPath
!=
null
)
{
fragment
.
processSendingDocument
(
documentPath
);
fragment
.
processSendingDocument
(
documentPath
,
null
);
}
if
(
imagesPathArray
!=
null
)
{
fragment
.
processSendingPhotos
(
null
,
imagesPathArray
);
}
if
(
documentsPathArray
!=
null
)
{
for
(
String
path
:
documentsPathArray
)
{
fragment
.
processSendingDocument
(
path
);
fragment
.
processSendingDocument
(
path
,
null
);
}
}
if
(
contactsToSend
!=
null
&&
!
contactsToSend
.
isEmpty
())
{
...
...
TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java
View file @
358a067a
...
...
@@ -148,6 +148,12 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
if
(
id
==
-
1
)
{
finishFragment
();
}
else
if
(
id
==
block_contact
)
{
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
getParentActivity
());
builder
.
setMessage
(
LocaleController
.
getString
(
"AreYouSure"
,
R
.
string
.
AreYouSure
));
builder
.
setTitle
(
LocaleController
.
getString
(
"AppName"
,
R
.
string
.
AppName
));
builder
.
setPositiveButton
(
LocaleController
.
getString
(
"OK"
,
R
.
string
.
OK
),
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
TLRPC
.
User
user
=
MessagesController
.
getInstance
().
users
.
get
(
user_id
);
if
(
user
==
null
)
{
return
;
...
...
@@ -163,6 +169,10 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
}
},
null
,
true
,
RPCRequest
.
RPCRequestClassGeneric
);
}
});
builder
.
setNegativeButton
(
LocaleController
.
getString
(
"Cancel"
,
R
.
string
.
Cancel
),
null
);
showAlertDialog
(
builder
);
}
else
if
(
id
==
add_contact
)
{
TLRPC
.
User
user
=
MessagesController
.
getInstance
().
users
.
get
(
user_id
);
Bundle
args
=
new
Bundle
();
...
...
TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarLayer.java
View file @
358a067a
...
...
@@ -377,7 +377,7 @@ public class ActionBarLayer extends FrameLayout {
}
actionMode
.
setVisibility
(
GONE
);
if
(
backButtonFrameLayout
!=
null
)
{
backButtonFrameLayout
.
setVisibility
(
VISIBLE
);
backButtonFrameLayout
.
setVisibility
(
isSearchFieldVisible
||
actionOverlay
==
null
||
actionOverlay
.
getVisibility
()
==
GONE
?
VISIBLE
:
IN
VISIBLE
);
}
if
(
menu
!=
null
)
{
menu
.
setVisibility
(
VISIBLE
);
...
...
@@ -471,10 +471,10 @@ public class ActionBarLayer extends FrameLayout {
return
;
}
isBackOverlayVisible
=
visible
;
positionBackOverlay
(
getMeasuredWidth
(),
getMeasuredHeight
());
if
(
visible
)
{
((
ActionBarActivity
)
getContext
()).
onOverlayShow
(
actionOverlay
,
parentFragment
);
}
positionBackOverlay
(
getMeasuredWidth
(),
getMeasuredHeight
());
}
private
void
positionBackOverlay
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
...
...
TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarUpdater.java
View file @
358a067a
...
...
@@ -129,7 +129,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
uploadingAvatar
=
Utilities
.
getCacheDir
()
+
"/"
+
bigPhoto
.
location
.
volume_id
+
"_"
+
bigPhoto
.
location
.
local_id
+
".jpg"
;
NotificationCenter
.
getInstance
().
addObserver
(
AvatarUpdater
.
this
,
FileLoader
.
FileDidUpload
);
NotificationCenter
.
getInstance
().
addObserver
(
AvatarUpdater
.
this
,
FileLoader
.
FileDidFailUpload
);
FileLoader
.
getInstance
().
uploadFile
(
uploadingAvatar
,
null
,
null
);
FileLoader
.
getInstance
().
uploadFile
(
uploadingAvatar
,
null
,
false
);
}
}
}
...
...
TMessagesProj/src/main/res/layout/updating_state_layout.xml
View file @
358a067a
<
FrameLayout
<
org.telegram.ui.Views.FrameLayoutFixed
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"400dp"
android:layout_height=
"fill_parent"
android:background=
"@drawable/bar_selector"
android:id=
"@+id/back_button_background"
>
android:id=
"@+id/back_button_background"
android:layout_gravity=
"top"
>
<ProgressBar
android:layout_height=
"32dp"
...
...
@@ -26,15 +27,15 @@
<TextView
android:layout_height=
"wrap_content"
android:layout_width=
"
fill_par
ent"
android:layout_width=
"
wrap_cont
ent"
android:layout_marginLeft=
"52dp"
android:textColor=
"#ffffff"
android:textSize=
"17dp"
android:layout_gravity=
"center_vertical|left"
android:gravity=
"left"
android:gravity=
"
top|
left"
android:ellipsize=
"end"
android:singleLine=
"true"
android:paddingRight=
"2dp"
android:id=
"@+id/status_text"
/>
</FrameLayout>
\ No newline at end of file
</org.telegram.ui.Views.FrameLayoutFixed>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment