Skip to content

Commit 3230af8

Browse files
author
Ivan Stoev
committed
some fixes and new crypto status.
1 parent 78c9c29 commit 3230af8

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

pdiff.c

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,9 @@ static void stop_crypto_thread(){
12061206
static void process_modifyuserinfo(const binresult *entry){
12071207
const binresult *res, *cres;
12081208
psync_sql_res *q;
1209-
uint64_t u;
1209+
uint64_t u, crexp, crsub = 0;
1210+
int crst = 0,crstat;
1211+
12101212
if (!entry)
12111213
return;
12121214
res=psync_find_result(entry, "userinfo", PARAM_HASH);
@@ -1244,15 +1246,39 @@ static void process_modifyuserinfo(const binresult *entry){
12441246
psync_sql_run(q);
12451247
if (!u)
12461248
psync_run_thread("stop crypto moduserinfo", stop_crypto_thread);
1249+
else
1250+
crst = 1;
12471251
psync_sql_bind_string(q, 1, "cryptosubscription");
1248-
psync_sql_bind_uint(q, 2, psync_find_result(res, "cryptosubscription", PARAM_BOOL)->num);
1252+
crsub = psync_find_result(res, "cryptosubscription", PARAM_BOOL)->num;
1253+
psync_sql_bind_uint(q, 2, crsub);
12491254
psync_sql_run(q);
12501255
cres=psync_check_result(res, "cryptoexpires", PARAM_NUM);
1256+
crexp = cres?cres->num:0;
12511257
psync_sql_bind_string(q, 1, "cryptoexpires");
1252-
psync_sql_bind_uint(q, 2, cres?cres->num:0);
1258+
psync_sql_bind_uint(q, 2, crexp);
1259+
psync_sql_run(q);
1260+
if (psync_is_business || crsub){
1261+
if (crst)
1262+
crstat = 5;
1263+
else crstat = 4;
1264+
} else {
1265+
if (!crst)
1266+
crstat = 1;
1267+
else
1268+
{
1269+
if (psync_millitime() > crexp)
1270+
crstat = 3;
1271+
else
1272+
crstat = 2;
1273+
}
1274+
}
1275+
psync_sql_bind_string(q, 1, "cryptostatus");
1276+
psync_sql_bind_uint(q, 2, crstat);
12531277
psync_sql_run(q);
12541278
psync_sql_free_result(q);
12551279
psync_send_eventid(PEVENT_USERINFO_CHANGED);
1280+
1281+
12561282
}
12571283

12581284
#define fill_str(f, s, sl)\

poverlay.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,14 @@ static int get_item_from_cache(const char* key, external_status* stat){
7777
now = psync_millitime();
7878
if ((now - rec->timestamp) < 100) {
7979
*stat = rec->stat;
80+
psync_cache_add(reckey, rec, 1, psync_free, 1);
81+
psync_free(reckey);
8082
return 1;
8183
} else {
8284
psync_free(rec);
8385
}
8486
}
87+
psync_free(reckey);
8588
return 0;
8689
}
8790

@@ -95,7 +98,8 @@ static void add_item_to_cache(const char* key, external_status* stat){
9598

9699
rec->stat = *stat;
97100
rec->timestamp = psync_millitime();
98-
psync_cache_add(key, rec, 1, psync_free, 1);
101+
psync_cache_add(reckey, rec, 1, psync_free, 1);
102+
psync_free(reckey);
99103
}
100104

101105

psynclib.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,12 @@ typedef struct pstatus_struct_ {
262262
#define PSYNC_CRYPTO_FOLDER_NOT_ENCRYPTED -7
263263
#define PSYNC_CRYPTO_INTERNAL_ERROR -8
264264

265+
#define PSYNC_CRYPTO_STATUS_NEW 1
266+
#define PSYNC_CRYPTO_STATUS_TRIAL 2
267+
#define PSYNC_CRYPTO_STATUS_EXPIRED 3
268+
#define PSYNC_CRYPTO_STATUS_ACTIVE 4
269+
#define PSYNC_CRYPTO_STATUS_SETUP 5
270+
265271
#define PSYNC_CRYPTO_INVALID_FOLDERID ((psync_folderid_t)-1)
266272

267273
#ifndef DEFAULT_FUSE_VOLUME_NAME
@@ -1148,7 +1154,6 @@ void psync_start_overlay_callbacks();
11481154

11491155
int psync_setlanguage(const char *language, char **err);
11501156

1151-
11521157
#ifdef __cplusplus
11531158
}
11541159
#endif

0 commit comments

Comments
 (0)