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
949aa7f9
Commit
949aa7f9
authored
Aug 29, 2014
by
vvaltman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added export_card/import_card queries
parent
201e2dea
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
110 additions
and
0 deletions
+110
-0
append.tl
append.tl
+3
-0
interface.c
interface.c
+51
-0
queries.c
queries.c
+54
-0
tgl.h
tgl.h
+2
-0
No files found.
append.tl
View file @
949aa7f9
...
...
@@ -2,3 +2,6 @@ decryptedMessageMediaVideoL12#4cee6ef3 thumb:bytes thumb_w:int thumb_h:int durat
decryptedMessageMediaAudioL12#6080758f duration:int size:int key:bytes iv:bytes = DecryptedMessageMedia;
auth.bindTempAuthKey perm_auth_key_id:long nonce:long expires_at:int encrypted_message:string = Bool;
contacts.exportCard = Vector<int>;
contacts.importCard export_card:Vector<int> = User;
interface.c
View file @
949aa7f9
...
...
@@ -374,6 +374,8 @@ struct command commands[] = {
{
"chat_set_photo"
,
{
ca_chat
,
ca_file_name_end
}},
{
"set_profile_photo"
,
{
ca_file_name_end
}},
{
"accept_secret_chat"
,
{
ca_secret_chat
,
ca_none
}},
{
"export_card"
,
{
ca_none
}},
{
"import_card"
,
{
ca_string
,
ca_none
}},
{
0
,
{
ca_none
}}
};
...
...
@@ -559,6 +561,14 @@ void print_user_list_gw (void *extra, int success, int num, struct tgl_user *UL[
print_end
();
}
void
print_user_gw
(
void
*
extra
,
int
success
,
struct
tgl_user
*
U
)
{
if
(
!
success
)
{
return
;
}
print_start
();
print_user_name
(
U
->
id
,
(
void
*
)
U
);
printf
(
"
\n
"
);
print_end
();
}
void
print_filename_gw
(
void
*
extra
,
int
success
,
char
*
name
)
{
if
(
!
success
)
{
return
;
}
print_start
();
...
...
@@ -972,6 +982,17 @@ void secret_chat_update_gw (struct tgl_secret_chat *U, unsigned flags) {
}
}
void
print_card_gw
(
void
*
extra
,
int
success
,
int
size
,
int
*
card
)
{
assert
(
success
);
print_start
();
printf
(
"Card: "
);
int
i
;
for
(
i
=
0
;
i
<
size
;
i
++
)
{
printf
(
"%08x%c"
,
card
[
i
],
i
==
size
-
1
?
'\n'
:
':'
);
}
print_end
();
}
struct
tgl_update_callback
upd_cb
=
{
.
new_msg
=
print_message_gw
,
.
marked_read
=
mark_read_upd
,
...
...
@@ -1572,6 +1593,36 @@ void interpreter (char *line UU) {
}
tgl_do_delete_msg
(
num
,
0
,
0
);
tgl_do_restore_msg
(
num
,
0
,
0
);
}
else
if
(
IS_WORD
(
"export_card"
))
{
tgl_do_export_card
(
print_card_gw
,
0
);
}
else
if
(
IS_WORD
(
"import_card"
))
{
int
l
;
char
*
s
=
next_token
(
&
l
);
if
(
l
>
0
)
{
int
i
;
static
int
p
[
10
];
int
pp
=
0
;
int
cur
=
0
;
int
ok
=
1
;
for
(
i
=
0
;
i
<
l
;
i
++
)
{
if
(
s
[
i
]
>=
'0'
&&
s
[
i
]
<=
'9'
)
{
cur
=
cur
*
16
+
s
[
i
]
-
'0'
;
}
else
if
(
s
[
i
]
>=
'a'
&&
s
[
i
]
<=
'f'
)
{
cur
=
cur
*
16
+
s
[
i
]
-
'a'
+
10
;
}
else
if
(
s
[
i
]
==
':'
)
{
if
(
pp
>=
9
)
{
ok
=
0
;
break
;
}
p
[
pp
++
]
=
cur
;
cur
=
0
;
}
}
if
(
ok
)
{
p
[
pp
++
]
=
cur
;
tgl_do_import_card
(
pp
,
p
,
print_user_gw
,
0
);
}
}
}
else
if
(
IS_WORD
(
"quit"
))
{
exit
(
0
);
}
else
if
(
IS_WORD
(
"accept_secret_chat"
))
{
...
...
queries.c
View file @
949aa7f9
...
...
@@ -3208,6 +3208,60 @@ void tgl_do_restore_msg (long long id, void (*callback)(void *callback_extra, in
}
/* }}} */
/* {{{ Export card */
static
int
export_card_on_answer
(
struct
query
*
q
UU
)
{
assert
(
fetch_int
()
==
CODE_vector
);
int
n
=
fetch_int
();
//logprintf ("Restored %d messages\n", n);
int
*
r
=
talloc
(
4
*
n
);
fetch_ints
(
r
,
n
);
if
(
q
->
callback
)
{
((
void
(
*
)(
void
*
,
int
,
int
,
int
*
))
q
->
callback
)
(
q
->
callback_extra
,
1
,
n
,
r
);
}
free
(
r
);
return
0
;
}
static
struct
query_methods
export_card_methods
=
{
.
on_answer
=
export_card_on_answer
,
.
type
=
TYPE_TO_PARAM_1
(
vector
,
TYPE_TO_PARAM
(
bare_int
))
};
void
tgl_do_export_card
(
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
int
size
,
int
*
card
),
void
*
callback_extra
)
{
clear_packet
();
out_int
(
CODE_contacts_export_card
);
tglq_send_query
(
tgl_state
.
DC_working
,
packet_ptr
-
packet_buffer
,
packet_buffer
,
&
export_card_methods
,
0
,
callback
,
callback_extra
);
}
/* }}} */
/* {{{ Import card */
static
int
import_card_on_answer
(
struct
query
*
q
UU
)
{
struct
tgl_user
*
U
=
tglf_fetch_alloc_user
();
if
(
q
->
callback
)
{
((
void
(
*
)(
void
*
,
int
,
struct
tgl_user
*
))
q
->
callback
)
(
q
->
callback_extra
,
1
,
U
);
}
return
0
;
}
static
struct
query_methods
import_card_methods
=
{
.
on_answer
=
import_card_on_answer
,
.
type
=
TYPE_TO_PARAM
(
user
)
};
void
tgl_do_import_card
(
int
size
,
int
*
card
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
struct
tgl_user
*
U
),
void
*
callback_extra
)
{
clear_packet
();
out_int
(
CODE_contacts_import_card
);
out_int
(
CODE_vector
);
out_int
(
size
);
out_ints
(
card
,
size
);
tglq_send_query
(
tgl_state
.
DC_working
,
packet_ptr
-
packet_buffer
,
packet_buffer
,
&
import_card_methods
,
0
,
callback
,
callback_extra
);
}
/* }}} */
static
void
set_flag_4
(
void
*
_D
,
int
success
)
{
struct
tgl_dc
*
D
=
_D
;
assert
(
success
);
...
...
tgl.h
View file @
949aa7f9
...
...
@@ -274,6 +274,8 @@ void tgl_do_delete_msg (long long id, void (*callback)(void *callback_extra, int
void
tgl_do_restore_msg
(
long
long
id
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
),
void
*
callback_extra
);
void
tgl_do_update_status
(
int
online
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
),
void
*
callback_extra
);
void
tgl_do_help_get_config_dc
(
struct
tgl_dc
*
D
,
void
(
*
callback
)(
void
*
,
int
),
void
*
callback_extra
);
void
tgl_do_export_card
(
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
int
size
,
int
*
card
),
void
*
callback_extra
);
void
tgl_do_import_card
(
int
size
,
int
*
card
,
void
(
*
callback
)(
void
*
callback_extra
,
int
success
,
struct
tgl_user
*
U
),
void
*
callback_extra
);
void
tgl_do_visualize_key
(
tgl_peer_id_t
id
,
unsigned
char
buf
[
16
]);
...
...
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