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
3bbd8e52
Commit
3bbd8e52
authored
Oct 01, 2015
by
V V
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed json
parent
70b0aed3
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
50 deletions
+83
-50
json-tg.c
json-tg.c
+24
-2
lua-tg.c
lua-tg.c
+58
-47
lua-tg.h
lua-tg.h
+1
-1
No files found.
json-tg.c
View file @
3bbd8e52
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include "json-tg.h"
#include "json-tg.h"
#include <tgl/tgl.h>
#include <tgl/tgl.h>
#include <tgl/tgl-layout.h>
#include <tgl/tgl-layout.h>
#include "interface.h"
#include <assert.h>
#include <assert.h>
//format time:
//format time:
#include <time.h>
#include <time.h>
...
@@ -27,6 +28,9 @@ void json_pack_peer_type (json_t *res, tgl_peer_id_t id) {
...
@@ -27,6 +28,9 @@ void json_pack_peer_type (json_t *res, tgl_peer_id_t id) {
case
TGL_PEER_ENCR_CHAT
:
case
TGL_PEER_ENCR_CHAT
:
assert
(
json_object_set
(
res
,
"type"
,
json_string
(
"encr_chat"
))
>=
0
);
assert
(
json_object_set
(
res
,
"type"
,
json_string
(
"encr_chat"
))
>=
0
);
break
;
break
;
case
TGL_PEER_CHANNEL
:
assert
(
json_object_set
(
res
,
"type"
,
json_string
(
"channel"
))
>=
0
);
break
;
default:
default:
assert
(
0
);
assert
(
0
);
}
}
...
@@ -77,6 +81,14 @@ void json_pack_chat (json_t *res, tgl_peer_t *P) {
...
@@ -77,6 +81,14 @@ void json_pack_chat (json_t *res, tgl_peer_t *P) {
}
}
}
}
void
json_pack_channel
(
json_t
*
res
,
tgl_peer_t
*
P
)
{
assert
(
P
->
channel
.
title
);
assert
(
json_object_set
(
res
,
"title"
,
json_string
(
P
->
channel
.
title
))
>=
0
);
assert
(
json_object_set
(
res
,
"participants_count"
,
json_integer
(
P
->
channel
.
participants_count
))
>=
0
);
assert
(
json_object_set
(
res
,
"admins_count"
,
json_integer
(
P
->
channel
.
admins_count
))
>=
0
);
assert
(
json_object_set
(
res
,
"kicked_count"
,
json_integer
(
P
->
channel
.
kicked_count
))
>=
0
);
}
void
json_pack_encr_chat
(
json_t
*
res
,
tgl_peer_t
*
P
)
{
void
json_pack_encr_chat
(
json_t
*
res
,
tgl_peer_t
*
P
)
{
assert
(
json_object_set
(
res
,
"user"
,
json_pack_peer
(
TGL_MK_USER
(
P
->
encr_chat
.
user_id
)))
>=
0
);
assert
(
json_object_set
(
res
,
"user"
,
json_pack_peer
(
TGL_MK_USER
(
P
->
encr_chat
.
user_id
)))
>=
0
);
...
@@ -86,7 +98,7 @@ json_t *json_pack_peer (tgl_peer_id_t id) {
...
@@ -86,7 +98,7 @@ json_t *json_pack_peer (tgl_peer_id_t id) {
tgl_peer_t
*
P
=
tgl_peer_get
(
TLS
,
id
);
tgl_peer_t
*
P
=
tgl_peer_get
(
TLS
,
id
);
//assert (P);
//assert (P);
json_t
*
res
=
json_object
();
json_t
*
res
=
json_object
();
assert
(
json_object_set
(
res
,
"id"
,
json_
integer
(
tgl_ge
t_peer_id
(
id
)))
>=
0
);
assert
(
json_object_set
(
res
,
"id"
,
json_
string
(
print_permanen
t_peer_id
(
id
)))
>=
0
);
json_pack_peer_type
(
res
,
id
);
json_pack_peer_type
(
res
,
id
);
...
@@ -101,6 +113,9 @@ json_t *json_pack_peer (tgl_peer_id_t id) {
...
@@ -101,6 +113,9 @@ json_t *json_pack_peer (tgl_peer_id_t id) {
case
TGL_PEER_CHAT
:
case
TGL_PEER_CHAT
:
sprintf
(
s
,
"chat#%d"
,
tgl_get_peer_id
(
id
));
sprintf
(
s
,
"chat#%d"
,
tgl_get_peer_id
(
id
));
break
;
break
;
case
TGL_PEER_CHANNEL
:
sprintf
(
s
,
"channel#%d"
,
tgl_get_peer_id
(
id
));
break
;
case
TGL_PEER_ENCR_CHAT
:
case
TGL_PEER_ENCR_CHAT
:
sprintf
(
s
,
"encr_chat#%d"
,
tgl_get_peer_id
(
id
));
sprintf
(
s
,
"encr_chat#%d"
,
tgl_get_peer_id
(
id
));
break
;
break
;
...
@@ -128,6 +143,9 @@ json_t *json_pack_peer (tgl_peer_id_t id) {
...
@@ -128,6 +143,9 @@ json_t *json_pack_peer (tgl_peer_id_t id) {
case
TGL_PEER_ENCR_CHAT
:
case
TGL_PEER_ENCR_CHAT
:
json_pack_encr_chat
(
res
,
P
);
json_pack_encr_chat
(
res
,
P
);
break
;
break
;
case
TGL_PEER_CHANNEL
:
json_pack_channel
(
res
,
P
);
break
;
default:
default:
assert
(
0
);
assert
(
0
);
}
}
...
@@ -377,6 +395,10 @@ json_t *json_pack_service (struct tgl_message *M) {
...
@@ -377,6 +395,10 @@ json_t *json_pack_service (struct tgl_message *M) {
case
tgl_message_action_abort_key
:
case
tgl_message_action_abort_key
:
assert
(
json_object_set
(
res
,
"type"
,
json_string
(
"abort_key"
))
>=
0
);
assert
(
json_object_set
(
res
,
"type"
,
json_string
(
"abort_key"
))
>=
0
);
break
;
break
;
case
tgl_message_action_channel_create
:
assert
(
json_object_set
(
res
,
"type"
,
json_string
(
"channel_created"
))
>=
0
);
assert
(
json_object_set
(
res
,
"title"
,
json_string
(
M
->
action
.
title
))
>=
0
);
break
;
default:
default:
assert
(
json_object_set
(
res
,
"type"
,
json_string
(
"???"
))
>=
0
);
assert
(
json_object_set
(
res
,
"type"
,
json_string
(
"???"
))
>=
0
);
break
;
break
;
...
@@ -389,7 +411,7 @@ json_t *json_pack_message (struct tgl_message *M) {
...
@@ -389,7 +411,7 @@ json_t *json_pack_message (struct tgl_message *M) {
assert
(
json_object_set
(
res
,
"event"
,
json_string
(
"message"
))
>=
0
);
assert
(
json_object_set
(
res
,
"event"
,
json_string
(
"message"
))
>=
0
);
//will overwriten to service, if service.
//will overwriten to service, if service.
assert
(
json_object_set
(
res
,
"id"
,
json_
integer
(
M
->
id
))
>=
0
);
assert
(
json_object_set
(
res
,
"id"
,
json_
string
(
print_permanent_msg_id
(
M
->
permanent_id
)
))
>=
0
);
if
(
!
(
M
->
flags
&
TGLMF_CREATED
))
{
return
res
;
}
if
(
!
(
M
->
flags
&
TGLMF_CREATED
))
{
return
res
;
}
assert
(
json_object_set
(
res
,
"flags"
,
json_integer
(
M
->
flags
))
>=
0
);
assert
(
json_object_set
(
res
,
"flags"
,
json_integer
(
M
->
flags
))
>=
0
);
...
...
lua-tg.c
View file @
3bbd8e52
This diff is collapsed.
Click to expand it.
lua-tg.h
View file @
3bbd8e52
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
void
lua_init
(
const
char
*
file
);
void
lua_init
(
const
char
*
file
);
void
lua_new_msg
(
struct
tgl_message
*
M
);
void
lua_new_msg
(
struct
tgl_message
*
M
);
void
lua_our_id
(
in
t
id
);
void
lua_our_id
(
tgl_peer_id_
t
id
);
void
lua_secret_chat_update
(
struct
tgl_secret_chat
*
U
,
unsigned
flags
);
void
lua_secret_chat_update
(
struct
tgl_secret_chat
*
U
,
unsigned
flags
);
void
lua_user_update
(
struct
tgl_user
*
U
,
unsigned
flags
);
void
lua_user_update
(
struct
tgl_user
*
U
,
unsigned
flags
);
void
lua_chat_update
(
struct
tgl_chat
*
C
,
unsigned
flags
);
void
lua_chat_update
(
struct
tgl_chat
*
C
,
unsigned
flags
);
...
...
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