Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
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
tg
Commits
2b2cc686
Commit
2b2cc686
authored
Aug 18, 2014
by
vvaltman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updates
parent
cedc1d17
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
328 additions
and
134 deletions
+328
-134
.gitignore
.gitignore
+1
-0
Makefile.in
Makefile.in
+14
-8
binlog.c
binlog.c
+80
-7
interface.c
interface.c
+98
-67
net.c
net.c
+1
-1
queries.c
queries.c
+28
-6
structures.c
structures.c
+58
-41
tgl-layout.h
tgl-layout.h
+35
-2
tgl.h
tgl.h
+13
-2
No files found.
.gitignore
View file @
2b2cc686
...
@@ -11,3 +11,4 @@ bin/
...
@@ -11,3 +11,4 @@ bin/
objs/
objs/
dep/
dep/
auto/
auto/
libs/
Makefile.in
View file @
2b2cc686
...
@@ -4,7 +4,7 @@ CFLAGS=@CFLAGS@
...
@@ -4,7 +4,7 @@ CFLAGS=@CFLAGS@
LDFLAGS
=
@LDFLAGS@
LDFLAGS
=
@LDFLAGS@
CPPFLAGS
=
@CPPFLAGS@
CPPFLAGS
=
@CPPFLAGS@
DEFS
=
@DEFS@
DEFS
=
@DEFS@
COMPILE_FLAGS
=
${
CFLAGS
}
${
CPPFLAGS
}
${
DEFS
}
-Wall
-Wextra
-Werror
-Wno-deprecated-declarations
-fno-strict-aliasing
-fno-omit-frame-pointer
-ggdb
-Wno-unused-parameter
COMPILE_FLAGS
=
${
CFLAGS
}
${
CPPFLAGS
}
${
DEFS
}
-Wall
-Wextra
-Werror
-Wno-deprecated-declarations
-fno-strict-aliasing
-fno-omit-frame-pointer
-ggdb
-Wno-unused-parameter
-fPIC
EXTRA_LIBS
=
@LIBS@ @EXTRA_LIBS@
EXTRA_LIBS
=
@LIBS@ @EXTRA_LIBS@
LOCAL_LDFLAGS
=
-rdynamic
-ggdb
-levent
${
EXTRA_LIBS
}
LOCAL_LDFLAGS
=
-rdynamic
-ggdb
-levent
${
EXTRA_LIBS
}
...
@@ -14,16 +14,19 @@ DEP=${srcdir}/dep
...
@@ -14,16 +14,19 @@ DEP=${srcdir}/dep
AUTO
=
${
srcdir
}
/auto
AUTO
=
${
srcdir
}
/auto
EXE
=
${
srcdir
}
/bin
EXE
=
${
srcdir
}
/bin
OBJ
=
${
srcdir
}
/objs
OBJ
=
${
srcdir
}
/objs
DIR_LIST
=
${
DEP
}
${
AUTO
}
${
EXE
}
${
OBJ
}
${
DEP
}
/auto
${
OBJ
}
/auto
LIB
=
${
srcdir
}
/libs
DIR_LIST
=
${
DEP
}
${
AUTO
}
${
EXE
}
${
OBJ
}
${
LIB
}
${
DEP
}
/auto
${
OBJ
}
/auto
EXE_LIST
=
${
EXE
}
/generate
${
EXE
}
/tlc
${
EXE
}
/telegram-cli
EXE_LIST
=
${
EXE
}
/generate
${
EXE
}
/tlc
${
EXE
}
/telegram-cli
LIB_LIST
=
${
LIB
}
/libtgl.a
TG_OBJECTS
=
${
OBJ
}
/main.o
${
OBJ
}
/loop.o
${
OBJ
}
/interface.o
${
OBJ
}
/net.o
${
OBJ
}
/mtproto-common.o
${
OBJ
}
/mtproto-client.o
${
OBJ
}
/queries.o
${
OBJ
}
/structures.o
${
OBJ
}
/binlog.o
${
OBJ
}
/lua-tg.o
${
OBJ
}
/auto/auto.o
${
OBJ
}
/tgl.o
${
OBJ
}
/updates.o
TG_OBJECTS
=
${
OBJ
}
/main.o
${
OBJ
}
/loop.o
${
OBJ
}
/interface.o
${
OBJ
}
/lua-tg.o
TGL_OBJECTS
=
${
OBJ
}
/net.o
${
OBJ
}
/mtproto-common.o
${
OBJ
}
/mtproto-client.o
${
OBJ
}
/queries.o
${
OBJ
}
/structures.o
${
OBJ
}
/binlog.o
${
OBJ
}
/auto/auto.o
${
OBJ
}
/tgl.o
${
OBJ
}
/updates.o
TLC_OBJECTS
=
${
OBJ
}
/tlc.o
${
OBJ
}
/tl-parser.o
${
OBJ
}
/crc32.o
TLC_OBJECTS
=
${
OBJ
}
/tlc.o
${
OBJ
}
/tl-parser.o
${
OBJ
}
/crc32.o
GENERATE_OBJECTS
=
${
OBJ
}
/generate.o
GENERATE_OBJECTS
=
${
OBJ
}
/generate.o
COMMON_OBJECTS
=
${
OBJ
}
/tools.o
COMMON_OBJECTS
=
${
OBJ
}
/tools.o
OBJ_LIST
=
${
TG_OBJECTS
}
${
TLC_OBJECTS
}
${
GENERATE_OBJECTS
}
${
COMMON_OBJECTS
}
OBJ_LIST
=
${
TG_OBJECTS
}
${
TLC_OBJECTS
}
${
GENERATE_OBJECTS
}
${
COMMON_OBJECTS
}
${
TGL_OBJECTS
}
OBJ_C
=
${
TLC_OBJECTS
}
${
GENERATE_OBJECTS
}
${
COMMON_OBJECTS
}
OBJ_C
=
${
TLC_OBJECTS
}
${
GENERATE_OBJECTS
}
${
COMMON_OBJECTS
}
${
TGL_OBJECTS
}
DEPENDENCE
=
$
(
subst
${
OBJ
}
/,
${
DEP
}
/,
$
(
patsubst %.o,%.d,
${
OBJ_LIST
}
))
DEPENDENCE
=
$
(
subst
${
OBJ
}
/,
${
DEP
}
/,
$
(
patsubst %.o,%.d,
${
OBJ_LIST
}
))
DEPENDENCE_LIST
=
${
DEPENDENCE
}
DEPENDENCE_LIST
=
${
DEPENDENCE
}
...
@@ -35,7 +38,7 @@ CC=@CC@
...
@@ -35,7 +38,7 @@ CC=@CC@
.SUFFIXES
:
.c .h .o
.SUFFIXES
:
.c .h .o
all
:
${EXE_LIST} ${DIR_LIST}
all
:
${EXE_LIST} ${DIR_LIST}
${LIB_LIST}
create_dirs_and_headers
:
${DIR_LIST} ${AUTO}/auto.c ${AUTO}/auto-header.h ${AUTO}/constants.h
create_dirs_and_headers
:
${DIR_LIST} ${AUTO}/auto.c ${AUTO}/auto-header.h ${AUTO}/constants.h
create_dirs
:
${DIR_LIST}
create_dirs
:
${DIR_LIST}
...
@@ -53,8 +56,11 @@ ${OBJ_C}: ${OBJ}/%.o: %.c | create_dirs
...
@@ -53,8 +56,11 @@ ${OBJ_C}: ${OBJ}/%.o: %.c | create_dirs
${EXE}/tlc
:
${TLC_OBJECTS} ${COMMON_OBJECTS}
${EXE}/tlc
:
${TLC_OBJECTS} ${COMMON_OBJECTS}
${
CC
}
${
TLC_OBJECTS
}
${
COMMON_OBJECTS
}
${
LINK_FLAGS
}
-o
$@
${
CC
}
${
TLC_OBJECTS
}
${
COMMON_OBJECTS
}
${
LINK_FLAGS
}
-o
$@
${EXE}/telegram-cli
:
${TG_OBJECTS} ${COMMON_OBJECTS}
${EXE}/telegram-cli
:
${TG_OBJECTS} ${COMMON_OBJECTS} ${LIB}/libtgl.a
${
CC
}
${
TG_OBJECTS
}
${
COMMON_OBJECTS
}
${
LINK_FLAGS
}
-o
$@
${
CC
}
${
TG_OBJECTS
}
${
COMMON_OBJECTS
}
${
LINK_FLAGS
}
-L
${
LIB
}
-l
tgl
-o
$@
${LIB}/libtgl.a
:
${TGL_OBJECTS} ${COMMON_OBJECTS}
ar ruv
$@
${
TGL_OBJECTS
}
${
COMMON_OBJECTS
}
${EXE}/generate
:
${GENERATE_OBJECTS} ${COMMON_OBJECTS}
${EXE}/generate
:
${GENERATE_OBJECTS} ${COMMON_OBJECTS}
${
CC
}
${
GENERATE_OBJECTS
}
${
COMMON_OBJECTS
}
${
LINK_FLAGS
}
-o
$@
${
CC
}
${
GENERATE_OBJECTS
}
${
COMMON_OBJECTS
}
${
LINK_FLAGS
}
-o
$@
...
...
binlog.c
View file @
2b2cc686
...
@@ -198,6 +198,9 @@ static int fetch_comb_binlog_user_add (void *extra) {
...
@@ -198,6 +198,9 @@ static int fetch_comb_binlog_user_add (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_user_update
(
U
);
lua_user_update
(
U
);
#endif
#endif
if
(
tgl_state
.
callback
.
new_user
)
{
tgl_state
.
callback
.
new_user
(
U
);
}
return
0
;
return
0
;
}
}
...
@@ -210,6 +213,9 @@ static int fetch_comb_binlog_user_delete (void *extra) {
...
@@ -210,6 +213,9 @@ static int fetch_comb_binlog_user_delete (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_user_update
(
&
U
->
user
);
lua_user_update
(
&
U
->
user
);
#endif
#endif
if
(
tgl_state
.
callback
.
delete_user
)
{
tgl_state
.
callback
.
delete_user
((
void
*
)
U
);
}
return
0
;
return
0
;
}
}
...
@@ -237,6 +243,10 @@ static int fetch_comb_binlog_user_set_phone (void *extra) {
...
@@ -237,6 +243,10 @@ static int fetch_comb_binlog_user_set_phone (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_user_update
(
&
U
->
user
);
lua_user_update
(
&
U
->
user
);
#endif
#endif
if
(
tgl_state
.
callback
.
update_user_info
)
{
tgl_state
.
callback
.
update_user_info
((
void
*
)
U
);
}
return
0
;
return
0
;
}
}
...
@@ -254,6 +264,9 @@ static int fetch_comb_binlog_user_set_friend (void *extra) {
...
@@ -254,6 +264,9 @@ static int fetch_comb_binlog_user_set_friend (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_user_update
(
&
U
->
user
);
lua_user_update
(
&
U
->
user
);
#endif
#endif
if
(
tgl_state
.
callback
.
update_user_info
)
{
tgl_state
.
callback
.
update_user_info
((
void
*
)
U
);
}
return
0
;
return
0
;
}
}
...
@@ -269,6 +282,9 @@ static int fetch_comb_binlog_user_set_full_photo (void *extra) {
...
@@ -269,6 +282,9 @@ static int fetch_comb_binlog_user_set_full_photo (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_user_update
(
&
U
->
user
);
lua_user_update
(
&
U
->
user
);
#endif
#endif
if
(
tgl_state
.
callback
.
update_user_info
)
{
tgl_state
.
callback
.
update_user_info
((
void
*
)
U
);
}
return
0
;
return
0
;
}
}
...
@@ -282,6 +298,9 @@ static int fetch_comb_binlog_user_set_blocked (void *extra) {
...
@@ -282,6 +298,9 @@ static int fetch_comb_binlog_user_set_blocked (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_user_update
(
&
U
->
user
);
lua_user_update
(
&
U
->
user
);
#endif
#endif
if
(
tgl_state
.
callback
.
update_user_info
)
{
tgl_state
.
callback
.
update_user_info
((
void
*
)
U
);
}
return
0
;
return
0
;
}
}
...
@@ -298,6 +317,9 @@ static int fetch_comb_binlog_user_set_real_name (void *extra) {
...
@@ -298,6 +317,9 @@ static int fetch_comb_binlog_user_set_real_name (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_user_update
(
&
U
->
user
);
lua_user_update
(
&
U
->
user
);
#endif
#endif
if
(
tgl_state
.
callback
.
update_user_info
)
{
tgl_state
.
callback
.
update_user_info
((
void
*
)
U
);
}
return
0
;
return
0
;
}
}
...
@@ -320,6 +342,9 @@ static int fetch_comb_binlog_user_set_name (void *extra) {
...
@@ -320,6 +342,9 @@ static int fetch_comb_binlog_user_set_name (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_user_update
(
&
U
->
user
);
lua_user_update
(
&
U
->
user
);
#endif
#endif
if
(
tgl_state
.
callback
.
update_user_info
)
{
tgl_state
.
callback
.
update_user_info
((
void
*
)
U
);
}
return
0
;
return
0
;
}
}
...
@@ -344,6 +369,9 @@ static int fetch_comb_binlog_user_set_photo (void *extra) {
...
@@ -344,6 +369,9 @@ static int fetch_comb_binlog_user_set_photo (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_user_update
(
&
U
->
user
);
lua_user_update
(
&
U
->
user
);
#endif
#endif
if
(
tgl_state
.
callback
.
update_user_info
)
{
tgl_state
.
callback
.
update_user_info
((
void
*
)
U
);
}
return
0
;
return
0
;
}
}
...
@@ -367,6 +395,9 @@ static int fetch_comb_binlog_encr_chat_delete (void *extra) {
...
@@ -367,6 +395,9 @@ static int fetch_comb_binlog_encr_chat_delete (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_secret_chat_update
(
U
);
lua_secret_chat_update
(
U
);
#endif
#endif
if
(
tgl_state
.
callback
.
secret_chat_deleted
)
{
tgl_state
.
callback
.
secret_chat_deleted
(
U
);
}
return
0
;
return
0
;
}
}
...
@@ -407,6 +438,9 @@ static int fetch_comb_binlog_encr_chat_requested (void *extra) {
...
@@ -407,6 +438,9 @@ static int fetch_comb_binlog_encr_chat_requested (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_secret_chat_update
(
U
);
lua_secret_chat_update
(
U
);
#endif
#endif
if
(
tgl_state
.
callback
.
secret_chat_request
)
{
tgl_state
.
callback
.
secret_chat_request
(
U
);
}
return
0
;
return
0
;
}
}
...
@@ -470,6 +504,9 @@ static int fetch_comb_binlog_encr_chat_accepted (void *extra) {
...
@@ -470,6 +504,9 @@ static int fetch_comb_binlog_encr_chat_accepted (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_secret_chat_update
(
U
);
lua_secret_chat_update
(
U
);
#endif
#endif
if
(
tgl_state
.
callback
.
secret_chat_accepted
)
{
tgl_state
.
callback
.
secret_chat_accepted
(
U
);
}
return
0
;
return
0
;
}
}
...
@@ -507,6 +544,9 @@ static int fetch_comb_binlog_encr_chat_init (void *extra) {
...
@@ -507,6 +544,9 @@ static int fetch_comb_binlog_encr_chat_init (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_secret_chat_update
(
U
);
lua_secret_chat_update
(
U
);
#endif
#endif
if
(
tgl_state
.
callback
.
secret_chat_created
)
{
tgl_state
.
callback
.
secret_chat_created
((
void
*
)
P
);
}
return
0
;
return
0
;
}
}
...
@@ -536,6 +576,9 @@ static int fetch_comb_binlog_chat_create (void *extra) {
...
@@ -536,6 +576,9 @@ static int fetch_comb_binlog_chat_create (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_chat_update
(
C
);
lua_chat_update
(
C
);
#endif
#endif
if
(
tgl_state
.
callback
.
chat_created
)
{
tgl_state
.
callback
.
chat_created
(
C
);
}
return
0
;
return
0
;
}
}
...
@@ -548,6 +591,9 @@ static int fetch_comb_binlog_chat_change_flags (void *extra) {
...
@@ -548,6 +591,9 @@ static int fetch_comb_binlog_chat_change_flags (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_chat_update
(
&
C
->
chat
);
lua_chat_update
(
&
C
->
chat
);
#endif
#endif
if
(
tgl_state
.
callback
.
chat_update
)
{
tgl_state
.
callback
.
chat_update
((
void
*
)
C
);
}
return
0
;
return
0
;
}
}
...
@@ -567,6 +613,9 @@ static int fetch_comb_binlog_chat_set_title (void *extra) {
...
@@ -567,6 +613,9 @@ static int fetch_comb_binlog_chat_set_title (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_chat_update
(
&
C
->
chat
);
lua_chat_update
(
&
C
->
chat
);
#endif
#endif
if
(
tgl_state
.
callback
.
chat_update
)
{
tgl_state
.
callback
.
chat_update
((
void
*
)
C
);
}
return
0
;
return
0
;
}
}
...
@@ -579,6 +628,9 @@ static int fetch_comb_binlog_chat_set_photo (void *extra) {
...
@@ -579,6 +628,9 @@ static int fetch_comb_binlog_chat_set_photo (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_chat_update
(
&
C
->
chat
);
lua_chat_update
(
&
C
->
chat
);
#endif
#endif
if
(
tgl_state
.
callback
.
chat_update
)
{
tgl_state
.
callback
.
chat_update
((
void
*
)
C
);
}
return
0
;
return
0
;
}
}
...
@@ -590,6 +642,9 @@ static int fetch_comb_binlog_chat_set_date (void *extra) {
...
@@ -590,6 +642,9 @@ static int fetch_comb_binlog_chat_set_date (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_chat_update
(
&
C
->
chat
);
lua_chat_update
(
&
C
->
chat
);
#endif
#endif
if
(
tgl_state
.
callback
.
chat_update
)
{
tgl_state
.
callback
.
chat_update
((
void
*
)
C
);
}
return
0
;
return
0
;
}
}
...
@@ -602,6 +657,9 @@ static int fetch_comb_binlog_chat_set_version (void *extra) {
...
@@ -602,6 +657,9 @@ static int fetch_comb_binlog_chat_set_version (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_chat_update
(
&
C
->
chat
);
lua_chat_update
(
&
C
->
chat
);
#endif
#endif
if
(
tgl_state
.
callback
.
chat_update
)
{
tgl_state
.
callback
.
chat_update
((
void
*
)
C
);
}
return
0
;
return
0
;
}
}
...
@@ -613,6 +671,9 @@ static int fetch_comb_binlog_chat_set_admin (void *extra) {
...
@@ -613,6 +671,9 @@ static int fetch_comb_binlog_chat_set_admin (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_chat_update
(
&
C
->
chat
);
lua_chat_update
(
&
C
->
chat
);
#endif
#endif
if
(
tgl_state
.
callback
.
chat_update
)
{
tgl_state
.
callback
.
chat_update
((
void
*
)
C
);
}
return
0
;
return
0
;
}
}
...
@@ -628,6 +689,9 @@ static int fetch_comb_binlog_chat_set_participants (void *extra) {
...
@@ -628,6 +689,9 @@ static int fetch_comb_binlog_chat_set_participants (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_chat_update
(
&
C
->
chat
);
lua_chat_update
(
&
C
->
chat
);
#endif
#endif
if
(
tgl_state
.
callback
.
chat_update
)
{
tgl_state
.
callback
.
chat_update
((
void
*
)
C
);
}
return
0
;
return
0
;
}
}
...
@@ -644,6 +708,9 @@ static int fetch_comb_binlog_chat_set_full_photo (void *extra) {
...
@@ -644,6 +708,9 @@ static int fetch_comb_binlog_chat_set_full_photo (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_chat_update
(
&
C
->
chat
);
lua_chat_update
(
&
C
->
chat
);
#endif
#endif
if
(
tgl_state
.
callback
.
chat_update
)
{
tgl_state
.
callback
.
chat_update
((
void
*
)
C
);
}
return
0
;
return
0
;
}
}
...
@@ -674,6 +741,9 @@ static int fetch_comb_binlog_chat_add_participant (void *extra) {
...
@@ -674,6 +741,9 @@ static int fetch_comb_binlog_chat_add_participant (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_chat_update
(
C
);
lua_chat_update
(
C
);
#endif
#endif
if
(
tgl_state
.
callback
.
chat_update
)
{
tgl_state
.
callback
.
chat_update
(
C
);
}
return
0
;
return
0
;
}
}
...
@@ -704,6 +774,9 @@ static int fetch_comb_binlog_chat_del_participant (void *extra) {
...
@@ -704,6 +774,9 @@ static int fetch_comb_binlog_chat_del_participant (void *extra) {
#ifdef USE_LUA
#ifdef USE_LUA
lua_chat_update
(
C
);
lua_chat_update
(
C
);
#endif
#endif
if
(
tgl_state
.
callback
.
chat_update
)
{
tgl_state
.
callback
.
chat_update
(
C
);
}
return
0
;
return
0
;
}
}
...
@@ -734,9 +807,9 @@ static int fetch_comb_binlog_create_message_text (void *extra) {
...
@@ -734,9 +807,9 @@ static int fetch_comb_binlog_create_message_text (void *extra) {
M
->
message_len
=
l
;
M
->
message_len
=
l
;
if
(
t
==
TGL_PEER_ENCR_CHAT
)
{
if
(
t
==
TGL_PEER_ENCR_CHAT
)
{
M
->
media
.
type
=
CODE_decrypted_message_media_empty
;
M
->
media
.
type
=
tgl_message_media_none
;
}
else
{
}
else
{
M
->
media
.
type
=
CODE_message_media_empty
;
M
->
media
.
type
=
tgl_message_media_none
;
}
}
M
->
unread
=
1
;
M
->
unread
=
1
;
...
@@ -777,9 +850,9 @@ static int fetch_comb_binlog_send_message_text (void *extra) {
...
@@ -777,9 +850,9 @@ static int fetch_comb_binlog_send_message_text (void *extra) {
M
->
message_len
=
l
;
M
->
message_len
=
l
;
if
(
t
==
TGL_PEER_ENCR_CHAT
)
{
if
(
t
==
TGL_PEER_ENCR_CHAT
)
{
M
->
media
.
type
=
CODE_decrypted_message_media_empty
;
M
->
media
.
type
=
tgl_message_media_none
;
}
else
{
}
else
{
M
->
media
.
type
=
CODE_message_media_empty
;
M
->
media
.
type
=
tgl_message_media_none
;
}
}
M
->
unread
=
1
;
M
->
unread
=
1
;
...
@@ -812,7 +885,7 @@ static int fetch_comb_binlog_send_message_action_encr (void *extra) {
...
@@ -812,7 +885,7 @@ static int fetch_comb_binlog_send_message_action_encr (void *extra) {
M
->
to_id
=
tgl_set_peer_id
(
t
,
fetch_int
());
M
->
to_id
=
tgl_set_peer_id
(
t
,
fetch_int
());
M
->
date
=
fetch_int
();
M
->
date
=
fetch_int
();
M
->
media
.
type
=
CODE_decrypted_message_media_empty
;
M
->
media
.
type
=
tgl_message_media_none
;
tglf_fetch_message_action_encrypted
(
&
M
->
action
);
tglf_fetch_message_action_encrypted
(
&
M
->
action
);
M
->
unread
=
1
;
M
->
unread
=
1
;
...
@@ -859,9 +932,9 @@ static int fetch_comb_binlog_create_message_text_fwd (void *extra) {
...
@@ -859,9 +932,9 @@ static int fetch_comb_binlog_create_message_text_fwd (void *extra) {
M
->
message_len
=
l
;
M
->
message_len
=
l
;
if
(
t
==
TGL_PEER_ENCR_CHAT
)
{
if
(
t
==
TGL_PEER_ENCR_CHAT
)
{
M
->
media
.
type
=
CODE_decrypted_message_media_empty
;
M
->
media
.
type
=
tgl_message_media_none
;
}
else
{
}
else
{
M
->
media
.
type
=
CODE_message_media_empty
;
M
->
media
.
type
=
tgl_message_media_none
;
}
}
M
->
unread
=
1
;
M
->
unread
=
1
;
...
...
interface.c
View file @
2b2cc686
This diff is collapsed.
Click to expand it.
net.c
View file @
2b2cc686
...
@@ -236,7 +236,7 @@ static void try_write (struct connection *c);
...
@@ -236,7 +236,7 @@ static void try_write (struct connection *c);
static
void
conn_try_read
(
evutil_socket_t
fd
,
short
what
,
void
*
arg
)
{
static
void
conn_try_read
(
evutil_socket_t
fd
,
short
what
,
void
*
arg
)
{
struct
connection
*
c
=
arg
;
struct
connection
*
c
=
arg
;
vlogprintf
(
2
,
"Try read. Fd = %d
\n
"
,
c
->
fd
);
vlogprintf
(
E_DEBUG
+
1
,
"Try read. Fd = %d
\n
"
,
c
->
fd
);
try_read
(
c
);
try_read
(
c
);
}
}
static
void
conn_try_write
(
evutil_socket_t
fd
,
short
what
,
void
*
arg
)
{
static
void
conn_try_write
(
evutil_socket_t
fd
,
short
what
,
void
*
arg
)
{
...
...
queries.c
View file @
2b2cc686
...
@@ -757,7 +757,7 @@ void tgl_do_send_encr_chat_layer (struct tgl_secret_chat *E) {
...
@@ -757,7 +757,7 @@ void tgl_do_send_encr_chat_layer (struct tgl_secret_chat *E) {
long
long
t
;
long
long
t
;
tglt_secure_random
(
&
t
,
8
);
tglt_secure_random
(
&
t
,
8
);
int
action
[
2
];
int
action
[
2
];
action
[
0
]
=
CODE_decrypted
_message_action_notify_layer
;
action
[
0
]
=
tgl
_message_action_notify_layer
;
action
[
1
]
=
15
;
action
[
1
]
=
15
;
bl_do_send_message_action_encr
(
t
,
tgl_state
.
our_id
,
tgl_get_peer_type
(
E
->
id
),
tgl_get_peer_id
(
E
->
id
),
time
(
0
),
2
,
action
);
bl_do_send_message_action_encr
(
t
,
tgl_state
.
our_id
,
tgl_get_peer_type
(
E
->
id
),
tgl_get_peer_id
(
E
->
id
),
time
(
0
),
2
,
action
);
...
@@ -886,7 +886,7 @@ void tgl_do_send_encr_msg_action (struct tgl_message *M, void (*callback)(void *
...
@@ -886,7 +886,7 @@ void tgl_do_send_encr_msg_action (struct tgl_message *M, void (*callback)(void *
out_cstring
((
void
*
)
buf
,
16
);
out_cstring
((
void
*
)
buf
,
16
);
switch
(
M
->
action
.
type
)
{
switch
(
M
->
action
.
type
)
{
case
CODE_decrypted
_message_action_notify_layer
:
case
tgl
_message_action_notify_layer
:
out_int
(
M
->
action
.
type
);
out_int
(
M
->
action
.
type
);
out_int
(
M
->
action
.
layer
);
out_int
(
M
->
action
.
layer
);
break
;
break
;
...
@@ -1081,6 +1081,9 @@ static int get_history_on_answer (struct query *q UU) {
...
@@ -1081,6 +1081,9 @@ static int get_history_on_answer (struct query *q UU) {
int
i
;
int
i
;
int
x
=
fetch_int
();
int
x
=
fetch_int
();
assert
(
x
==
(
int
)
CODE_messages_messages_slice
||
x
==
(
int
)
CODE_messages_messages
);
assert
(
x
==
(
int
)
CODE_messages_messages_slice
||
x
==
(
int
)
CODE_messages_messages
);
if
(
x
==
(
int
)
CODE_messages_messages_slice
)
{
fetch_int
();
}
assert
(
fetch_int
()
==
CODE_vector
);
assert
(
fetch_int
()
==
CODE_vector
);
int
n
=
fetch_int
();
int
n
=
fetch_int
();
struct
tgl_message
**
ML
=
talloc
(
sizeof
(
void
*
)
*
n
);
struct
tgl_message
**
ML
=
talloc
(
sizeof
(
void
*
)
*
n
);
...
@@ -1555,7 +1558,7 @@ static void send_part (struct send_file *f, void *callback, void *callback_extra
...
@@ -1555,7 +1558,7 @@ static void send_part (struct send_file *f, void *callback, void *callback_extra
tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &send_file_part_methods, f, callback, callback_extra);
tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &send_file_part_methods, f, callback, callback_extra);
}*/
}*/
void
tgl_do_send_photo
(
int
type
,
tgl_peer_id_t
to_id
,
char
*
file_name
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
struct
tgl_message
*
M
),
void
*
callback_extra
)
{
void
tgl_do_send_photo
(
enum
tgl_message_media_type
type
,
tgl_peer_id_t
to_id
,
char
*
file_name
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
struct
tgl_message
*
M
),
void
*
callback_extra
)
{
int
fd
=
open
(
file_name
,
O_RDONLY
);
int
fd
=
open
(
file_name
,
O_RDONLY
);
if
(
fd
<
0
)
{
if
(
fd
<
0
)
{
vlogprintf
(
E_WARNING
,
"No such file '%s'
\n
"
,
file_name
);
vlogprintf
(
E_WARNING
,
"No such file '%s'
\n
"
,
file_name
);
...
@@ -1592,7 +1595,26 @@ void tgl_do_send_photo (int type, tgl_peer_id_t to_id, char *file_name, void (*c
...
@@ -1592,7 +1595,26 @@ void tgl_do_send_photo (int type, tgl_peer_id_t to_id, char *file_name, void (*c
f
->
id
=
lrand48
()
*
(
1ll
<<
32
)
+
lrand48
();
f
->
id
=
lrand48
()
*
(
1ll
<<
32
)
+
lrand48
();
f
->
to_id
=
to_id
;
f
->
to_id
=
to_id
;
f
->
media_type
=
type
;
switch
(
type
)
{
case
tgl_message_media_photo
:
f
->
media_type
=
CODE_input_media_uploaded_photo
;
break
;
case
tgl_message_media_video
:
f
->
media_type
=
CODE_input_media_uploaded_video
;
break
;
case
tgl_message_media_audio
:
f
->
media_type
=
CODE_input_media_uploaded_audio
;
break
;
case
tgl_message_media_document
:
f
->
media_type
=
CODE_input_media_uploaded_document
;
break
;
default:
close
(
fd
);
vlogprintf
(
E_WARNING
,
"Unknown type %d.
\n
"
,
type
);
tfree
(
f
,
sizeof
(
*
f
));
callback
(
callback_extra
,
0
,
0
);
return
;
}
f
->
file_name
=
tstrdup
(
file_name
);
f
->
file_name
=
tstrdup
(
file_name
);
if
(
tgl_get_peer_type
(
f
->
to_id
)
==
TGL_PEER_ENCR_CHAT
)
{
if
(
tgl_get_peer_type
(
f
->
to_id
)
==
TGL_PEER_ENCR_CHAT
)
{
f
->
encr
=
1
;
f
->
encr
=
1
;
...
@@ -1728,7 +1750,7 @@ static int chat_info_on_answer (struct query *q UU) {
...
@@ -1728,7 +1750,7 @@ static int chat_info_on_answer (struct query *q UU) {
struct
tgl_chat
*
C
=
tglf_fetch_alloc_chat_full
();
struct
tgl_chat
*
C
=
tglf_fetch_alloc_chat_full
();
//print_chat_info (C);
//print_chat_info (C);
if
(
q
->
callback
)
{
if
(
q
->
callback
)
{
((
void
(
*
)(
void
*
,
int
,
struct
tgl_chat
*
))
q
->
callback
)
(
q
->
callback_extra
,
0
,
C
);
((
void
(
*
)(
void
*
,
int
,
struct
tgl_chat
*
))
q
->
callback
)
(
q
->
callback_extra
,
1
,
C
);
}
}
return
0
;
return
0
;
}
}
...
@@ -1783,7 +1805,7 @@ void tgl_do_get_chat_info (tgl_peer_id_t id, int offline_mode, void (*callback)(
...
@@ -1783,7 +1805,7 @@ void tgl_do_get_chat_info (tgl_peer_id_t id, int offline_mode, void (*callback)(
static
int
user_info_on_answer
(
struct
query
*
q
UU
)
{
static
int
user_info_on_answer
(
struct
query
*
q
UU
)
{
struct
tgl_user
*
U
=
tglf_fetch_alloc_user_full
();
struct
tgl_user
*
U
=
tglf_fetch_alloc_user_full
();
if
(
q
->
callback
)
{
if
(
q
->
callback
)
{
((
void
(
*
)(
void
*
,
int
,
struct
tgl_user
*
))
q
->
callback
)
(
q
->
callback_extra
,
0
,
U
);
((
void
(
*
)(
void
*
,
int
,
struct
tgl_user
*
))
q
->
callback
)
(
q
->
callback_extra
,
1
,
U
);
}
}
return
0
;
return
0
;
}
}
...
...
structures.c
View file @
2b2cc686
This diff is collapsed.
Click to expand it.
tgl-layout.h
View file @
2b2cc686
...
@@ -22,6 +22,39 @@
...
@@ -22,6 +22,39 @@
typedef
struct
{
int
type
;
int
id
;
}
tgl_peer_id_t
;
typedef
struct
{
int
type
;
int
id
;
}
tgl_peer_id_t
;
enum
tgl_message_media_type
{
tgl_message_media_none
,
tgl_message_media_photo
,
tgl_message_media_video
,
tgl_message_media_audio
,
tgl_message_media_document
,
tgl_message_media_geo
,
tgl_message_media_contact
,
tgl_message_media_unsupported
,
tgl_message_media_photo_encr
,
tgl_message_media_video_encr
,
tgl_message_media_audio_encr
,
tgl_message_media_document_encr
,
};
enum
tgl_message_action_type
{
tgl_message_action_none
,
tgl_message_action_geo_chat_create
,
tgl_message_action_geo_chat_checkin
,
tgl_message_action_chat_create
,
tgl_message_action_chat_edit_title
,
tgl_message_action_chat_edit_photo
,
tgl_message_action_chat_delete_photo
,
tgl_message_action_chat_add_user
,
tgl_message_action_chat_delete_user
,
tgl_message_action_set_message_ttl
,
tgl_message_action_read_messages
,
tgl_message_action_delete_messages
,
tgl_message_action_screenshot_messages
,
tgl_message_action_flush_history
,
tgl_message_action_notify_layer
};
struct
tgl_file_location
{
struct
tgl_file_location
{
int
dc
;
int
dc
;
long
long
volume
;
long
long
volume
;
...
@@ -251,7 +284,7 @@ struct tgl_document {
...
@@ -251,7 +284,7 @@ struct tgl_document {
};
};
struct
tgl_message_action
{
struct
tgl_message_action
{
unsigned
type
;
enum
tgl_message_action_type
type
;
union
{
union
{
struct
{
struct
{
char
*
title
;
char
*
title
;
...
@@ -270,7 +303,7 @@ struct tgl_message_action {
...
@@ -270,7 +303,7 @@ struct tgl_message_action {
};
};
struct
tgl_message_media
{
struct
tgl_message_media
{
unsigned
type
;
enum
tgl_message_media_type
type
;
union
{
union
{
struct
tgl_photo
photo
;
struct
tgl_photo
photo
;
struct
tgl_video
video
;
struct
tgl_video
video
;
...
...
tgl.h
View file @
2b2cc686
...
@@ -25,9 +25,20 @@ struct tgl_update_callback {
...
@@ -25,9 +25,20 @@ struct tgl_update_callback {
void
(
*
user_registered
)(
struct
tgl_user
*
U
);
void
(
*
user_registered
)(
struct
tgl_user
*
U
);
void
(
*
user_activated
)(
struct
tgl_user
*
U
);
void
(
*
user_activated
)(
struct
tgl_user
*
U
);
void
(
*
new_authorization
)(
const
char
*
device
,
const
char
*
location
);
void
(
*
new_authorization
)(
const
char
*
device
,
const
char
*
location
);
void
(
*
secret_chat_created
)(
struct
tgl_secret_chat
*
E
);
void
(
*
secret_chat_request
)(
struct
tgl_secret_chat
*
E
);
void
(
*
secret_chat_request
)(
struct
tgl_secret_chat
*
E
);
void
(
*
secret_chat_established
)(
struct
tgl_secret_chat
*
E
);
void
(
*
secret_chat_established
)(
struct
tgl_secret_chat
*
E
);
void
(
*
secret_chat_deleted
)(
struct
tgl_secret_chat
*
E
);
void
(
*
secret_chat_deleted
)(
struct
tgl_secret_chat
*
E
);
void
(
*
secret_chat_accepted
)(
struct
tgl_secret_chat
*
E
);
void
(
*
new_user
)(
struct
tgl_user
*
U
);
void
(
*
delete_user
)(
struct
tgl_user
*
U
);
void
(
*
update_user_info
)(
struct
tgl_user
*
U
);
//void (*secret_chat_delete)(struct tgl_secret_chat *U);
//void (*secret_chat_requested)(struct tgl_secret_chat *U);
//void (*secret_chat_accepted)(struct tgl_secret_chat *U);
//void (*secret_chat_created)(struct tgl_secret_chat *U);
void
(
*
chat_created
)(
struct
tgl_chat
*
C
);
void
(
*
chat_update
)(
struct
tgl_chat
*
C
);
};
};
struct
tgl_net_methods
{
struct
tgl_net_methods
{
...
@@ -165,7 +176,7 @@ void tgl_do_send_text (tgl_peer_id_t id, char *file, void (*callback)(void *call
...
@@ -165,7 +176,7 @@ void tgl_do_send_text (tgl_peer_id_t id, char *file, void (*callback)(void *call
void
tgl_do_mark_read
(
tgl_peer_id_t
id
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
),
void
*
callback_extra
);
void
tgl_do_mark_read
(
tgl_peer_id_t
id
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
),
void
*
callback_extra
);
void
tgl_do_get_history
(
tgl_peer_id_t
id
,
int
limit
,
int
offline_mode
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
int
size
,
struct
tgl_message
*
list
[]),
void
*
callback_extra
);
void
tgl_do_get_history
(
tgl_peer_id_t
id
,
int
limit
,
int
offline_mode
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
int
size
,
struct
tgl_message
*
list
[]),
void
*
callback_extra
);
void
tgl_do_get_dialog_list
(
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
int
size
,
tgl_peer_id_t
peers
[],
int
last_msg_id
[],
int
unread_count
[]),
void
*
callback_extra
);
void
tgl_do_get_dialog_list
(
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
int
size
,
tgl_peer_id_t
peers
[],
int
last_msg_id
[],
int
unread_count
[]),
void
*
callback_extra
);
void
tgl_do_send_photo
(
int
type
,
tgl_peer_id_t
to_id
,
char
*
file_name
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
struct
tgl_message
*
M
),
void
*
callback_extra
);
void
tgl_do_send_photo
(
enum
tgl_message_media_type
type
,
tgl_peer_id_t
to_id
,
char
*
file_name
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
struct
tgl_message
*
M
),
void
*
callback_extra
);
void
tgl_do_forward_message
(
tgl_peer_id_t
id
,
int
n
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
struct
tgl_message
*
M
),
void
*
callback_extra
);
void
tgl_do_forward_message
(
tgl_peer_id_t
id
,
int
n
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
struct
tgl_message
*
M
),
void
*
callback_extra
);
void
tgl_do_rename_chat
(
tgl_peer_id_t
id
,
char
*
name
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
struct
tgl_message
*
M
),
void
*
callback_extra
);
void
tgl_do_rename_chat
(
tgl_peer_id_t
id
,
char
*
name
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
struct
tgl_message
*
M
),
void
*
callback_extra
);
void
tgl_do_get_chat_info
(
tgl_peer_id_t
id
,
int
offline_mode
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
struct
tgl_chat
*
C
),
void
*
callback_extra
);
void
tgl_do_get_chat_info
(
tgl_peer_id_t
id
,
int
offline_mode
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
struct
tgl_chat
*
C
),
void
*
callback_extra
);
...
...
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