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
d96450cd
Commit
d96450cd
authored
Nov 25, 2013
by
Vysheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added [offline] modifier
parent
168c6b7a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
14 deletions
+63
-14
interface.c
interface.c
+24
-2
queries.c
queries.c
+33
-5
structures.c
structures.c
+6
-7
No files found.
interface.c
View file @
d96450cd
...
@@ -42,6 +42,8 @@
...
@@ -42,6 +42,8 @@
#include "structures.h"
#include "structures.h"
#include "mtproto-common.h"
#include "mtproto-common.h"
#define ALLOW_MULT 1
char
*
default_prompt
=
"> "
;
char
*
default_prompt
=
"> "
;
int
unread_messages
;
int
unread_messages
;
...
@@ -493,13 +495,24 @@ char **complete_text (char *text, int start UU, int end UU) {
...
@@ -493,13 +495,24 @@ char **complete_text (char *text, int start UU, int end UU) {
return
(
char
**
)
rl_completion_matches
(
text
,
command_generator
);
return
(
char
**
)
rl_completion_matches
(
text
,
command_generator
);
}
}
void
work_modifier
(
const
char
*
s
UU
)
{
int
offline_mode
;
int
count
=
1
;
void
work_modifier
(
const
char
*
s
,
int
l
)
{
if
(
is_same_word
(
s
,
l
,
"[offline]"
))
{
offline_mode
=
1
;
}
#ifdef ALLOW_MULT
if
(
sscanf
(
s
,
"[x%d]"
,
&
count
)
>=
1
)
{
}
#endif
}
}
void
interpreter
(
char
*
line
UU
)
{
void
interpreter
(
char
*
line
UU
)
{
line_ptr
=
line
;
line_ptr
=
line
;
assert
(
!
in_readline
);
assert
(
!
in_readline
);
in_readline
=
1
;
in_readline
=
1
;
offline_mode
=
0
;
count
=
1
;
if
(
!
line
)
{
if
(
!
line
)
{
in_readline
=
0
;
in_readline
=
0
;
return
;
return
;
...
@@ -514,12 +527,20 @@ void interpreter (char *line UU) {
...
@@ -514,12 +527,20 @@ void interpreter (char *line UU) {
command
=
next_token
(
&
l
);
command
=
next_token
(
&
l
);
if
(
!
command
)
{
in_readline
=
0
;
return
;
}
if
(
!
command
)
{
in_readline
=
0
;
return
;
}
if
(
*
command
==
'['
&&
command
[
l
-
1
]
==
']'
)
{
if
(
*
command
==
'['
&&
command
[
l
-
1
]
==
']'
)
{
work_modifier
(
command
);
work_modifier
(
command
,
l
);
}
else
{
}
else
{
break
;
break
;
}
}
}
}
int
_
;
char
*
save
=
line_ptr
;
int
ll
=
l
;
char
*
cs
=
command
;
for
(
_
=
0
;
_
<
count
;
_
++
)
{
line_ptr
=
save
;
l
=
ll
;
command
=
cs
;
#define IS_WORD(s) is_same_word (command, l, (s))
#define IS_WORD(s) is_same_word (command, l, (s))
#define RET in_readline = 0; return;
#define RET in_readline = 0; return;
...
@@ -970,6 +991,7 @@ void interpreter (char *line UU) {
...
@@ -970,6 +991,7 @@ void interpreter (char *line UU) {
}
else
if
(
IS_WORD
(
"quit"
))
{
}
else
if
(
IS_WORD
(
"quit"
))
{
exit
(
0
);
exit
(
0
);
}
}
}
#undef IS_WORD
#undef IS_WORD
#undef RET
#undef RET
update_prompt
();
update_prompt
();
...
...
queries.c
View file @
d96450cd
...
@@ -50,6 +50,7 @@
...
@@ -50,6 +50,7 @@
char
*
get_downloads_directory
(
void
);
char
*
get_downloads_directory
(
void
);
int
verbosity
;
int
verbosity
;
extern
int
offline_mode
;
long
long
cur_uploading_bytes
;
long
long
cur_uploading_bytes
;
long
long
cur_uploaded_bytes
;
long
long
cur_uploaded_bytes
;
...
@@ -1080,7 +1081,7 @@ void do_get_local_history (peer_id_t id, int limit) {
...
@@ -1080,7 +1081,7 @@ void do_get_local_history (peer_id_t id, int limit) {
}
}
void
do_get_history
(
peer_id_t
id
,
int
limit
)
{
void
do_get_history
(
peer_id_t
id
,
int
limit
)
{
if
(
get_peer_type
(
id
)
==
PEER_ENCR_CHAT
)
{
if
(
get_peer_type
(
id
)
==
PEER_ENCR_CHAT
||
offline_mode
)
{
do_get_local_history
(
id
,
limit
);
do_get_local_history
(
id
,
limit
);
do_mark_read
(
id
);
do_mark_read
(
id
);
return
;
return
;
...
@@ -1609,8 +1610,7 @@ void do_rename_chat (peer_id_t id, char *name) {
...
@@ -1609,8 +1610,7 @@ void do_rename_chat (peer_id_t id, char *name) {
/* }}} */
/* }}} */
/* {{{ Chat info */
/* {{{ Chat info */
int
chat_info_on_answer
(
struct
query
*
q
UU
)
{
void
print_chat_info
(
struct
chat
*
C
)
{
struct
chat
*
C
=
fetch_alloc_chat_full
();
peer_t
*
U
=
(
void
*
)
C
;
peer_t
*
U
=
(
void
*
)
C
;
print_start
();
print_start
();
push_color
(
COLOR_YELLOW
);
push_color
(
COLOR_YELLOW
);
...
@@ -1632,6 +1632,11 @@ int chat_info_on_answer (struct query *q UU) {
...
@@ -1632,6 +1632,11 @@ int chat_info_on_answer (struct query *q UU) {
}
}
pop_color
();
pop_color
();
print_end
();
print_end
();
}
int
chat_info_on_answer
(
struct
query
*
q
UU
)
{
struct
chat
*
C
=
fetch_alloc_chat_full
();
print_chat_info
(
C
);
return
0
;
return
0
;
}
}
...
@@ -1640,6 +1645,15 @@ struct query_methods chat_info_methods = {
...
@@ -1640,6 +1645,15 @@ struct query_methods chat_info_methods = {
};
};
void
do_get_chat_info
(
peer_id_t
id
)
{
void
do_get_chat_info
(
peer_id_t
id
)
{
if
(
offline_mode
)
{
peer_t
*
C
=
user_chat_get
(
id
);
if
(
!
C
)
{
rprintf
(
"No such chat
\n
"
);
}
else
{
print_chat_info
(
&
C
->
chat
);
}
return
;
}
clear_packet
();
clear_packet
();
out_int
(
CODE_messages_get_full_chat
);
out_int
(
CODE_messages_get_full_chat
);
assert
(
get_peer_type
(
id
)
==
PEER_CHAT
);
assert
(
get_peer_type
(
id
)
==
PEER_CHAT
);
...
@@ -1649,8 +1663,8 @@ void do_get_chat_info (peer_id_t id) {
...
@@ -1649,8 +1663,8 @@ void do_get_chat_info (peer_id_t id) {
/* }}} */
/* }}} */
/* {{{ User info */
/* {{{ User info */
int
user_info_on_answer
(
struct
query
*
q
UU
)
{
struct
user
*
U
=
fetch_alloc_user_full
();
void
print_user_info
(
struct
user
*
U
)
{
peer_t
*
C
=
(
void
*
)
U
;
peer_t
*
C
=
(
void
*
)
U
;
print_start
();
print_start
();
push_color
(
COLOR_YELLOW
);
push_color
(
COLOR_YELLOW
);
...
@@ -1668,6 +1682,11 @@ int user_info_on_answer (struct query *q UU) {
...
@@ -1668,6 +1682,11 @@ int user_info_on_answer (struct query *q UU) {
}
}
pop_color
();
pop_color
();
print_end
();
print_end
();
}
int
user_info_on_answer
(
struct
query
*
q
UU
)
{
struct
user
*
U
=
fetch_alloc_user_full
();
print_user_info
(
U
);
return
0
;
return
0
;
}
}
...
@@ -1676,6 +1695,15 @@ struct query_methods user_info_methods = {
...
@@ -1676,6 +1695,15 @@ struct query_methods user_info_methods = {
};
};
void
do_get_user_info
(
peer_id_t
id
)
{
void
do_get_user_info
(
peer_id_t
id
)
{
if
(
offline_mode
)
{
peer_t
*
C
=
user_chat_get
(
id
);
if
(
!
C
)
{
rprintf
(
"No such user
\n
"
);
}
else
{
print_user_info
(
&
C
->
user
);
}
return
;
}
clear_packet
();
clear_packet
();
out_int
(
CODE_users_get_full_user
);
out_int
(
CODE_users_get_full_user
);
assert
(
get_peer_type
(
id
)
==
PEER_USER
);
assert
(
get_peer_type
(
id
)
==
PEER_USER
);
...
...
structures.c
View file @
d96450cd
...
@@ -135,6 +135,7 @@ char *create_print_name (peer_id_t id, const char *a1, const char *a2, const cha
...
@@ -135,6 +135,7 @@ char *create_print_name (peer_id_t id, const char *a1, const char *a2, const cha
s
++
;
s
++
;
}
}
s
=
buf
;
s
=
buf
;
int
fl
=
strlen
(
s
);
int
cc
=
0
;
int
cc
=
0
;
while
(
1
)
{
while
(
1
)
{
int
ok
=
1
;
int
ok
=
1
;
...
@@ -149,17 +150,15 @@ char *create_print_name (peer_id_t id, const char *a1, const char *a2, const cha
...
@@ -149,17 +150,15 @@ char *create_print_name (peer_id_t id, const char *a1, const char *a2, const cha
break
;
break
;
}
}
cc
++
;
cc
++
;
assert
(
cc
<=
99
);
assert
(
cc
<=
99
99
);
if
(
cc
==
1
)
{
if
(
cc
==
1
)
{
int
l
=
strlen
(
s
);
int
l
=
strlen
(
s
);
s
[
l
+
2
]
=
0
;
s
[
l
+
2
]
=
0
;
s
[
l
]
=
'#'
;
s
[
l
]
=
'#'
;
s
[
l
+
1
]
=
'1'
;
s
[
l
+
1
]
=
'1'
;
}
else
if
(
cc
==
10
)
{
}
else
if
(
cc
==
10
||
cc
==
100
||
cc
==
1000
)
{
int
l
=
strlen
(
s
);
// int l = strlen (s);
s
[
l
+
1
]
=
0
;
sprintf
(
s
+
fl
,
"#%d"
,
cc
);
s
[
l
]
=
'0'
;
s
[
l
-
1
]
=
'1'
;
}
else
{
}
else
{
int
l
=
strlen
(
s
);
int
l
=
strlen
(
s
);
s
[
l
-
1
]
++
;
s
[
l
-
1
]
++
;
...
@@ -548,7 +547,7 @@ void fetch_chat_full (struct chat *C) {
...
@@ -548,7 +547,7 @@ void fetch_chat_full (struct chat *C) {
users_num
=
fetch_int
();
users_num
=
fetch_int
();
users
=
malloc
(
sizeof
(
struct
chat_user
)
*
users_num
);
users
=
malloc
(
sizeof
(
struct
chat_user
)
*
users_num
);
int
i
;
int
i
;
for
(
i
=
0
;
i
<
C
->
users_num
;
i
++
)
{
for
(
i
=
0
;
i
<
users_num
;
i
++
)
{
assert
(
fetch_int
()
==
(
int
)
CODE_chat_participant
);
assert
(
fetch_int
()
==
(
int
)
CODE_chat_participant
);
users
[
i
].
user_id
=
fetch_int
();
users
[
i
].
user_id
=
fetch_int
();
users
[
i
].
inviter_id
=
fetch_int
();
users
[
i
].
inviter_id
=
fetch_int
();
...
...
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