Skip to content

Commit aa93362

Browse files
author
virco
committed
Merge branch 'master' of gitlab.pcloud.com:pcloud/synclib
2 parents d5afa21 + 2a0d727 commit aa93362

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed

pbusinessaccount.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,3 +611,65 @@ int api_error_result(binresult* res) {
611611
}
612612
return 0;
613613
}
614+
615+
616+
void psync_update_cryptostatus(){
617+
binresult *res;
618+
const binresult *cres;
619+
psync_sql_res *q;
620+
uint64_t u, crexp, crsub = 0, is_business = 0;
621+
int crst = 0,crstat;
622+
623+
binparam params[] = { P_STR("auth", psync_my_auth) };
624+
res = psync_api_run_command("userinfo", params);
625+
if (!res) {
626+
debug(D_WARNING, "Send command returned invalid result.\n");
627+
return;
628+
}
629+
630+
if (api_error_result(res))
631+
return;
632+
633+
q=psync_sql_prep_statement("REPLACE INTO setting (id, value) VALUES (?, ?)");
634+
635+
is_business=psync_find_result(res, "business", PARAM_BOOL)->num;
636+
637+
u=psync_find_result(res, "cryptosetup", PARAM_BOOL)->num;
638+
psync_sql_bind_string(q, 1, "cryptosetup");
639+
psync_sql_bind_uint(q, 2, u);
640+
psync_sql_run(q);
641+
if (u)
642+
crst = 1;
643+
psync_sql_bind_string(q, 1, "cryptosubscription");
644+
crsub = psync_find_result(res, "cryptosubscription", PARAM_BOOL)->num;
645+
psync_sql_bind_uint(q, 2, crsub);
646+
psync_sql_run(q);
647+
648+
cres=psync_check_result(res, "cryptoexpires", PARAM_NUM);
649+
crexp = cres?cres->num:0;
650+
psync_sql_bind_string(q, 1, "cryptoexpires");
651+
psync_sql_bind_uint(q, 2, crexp);
652+
psync_sql_run(q);
653+
654+
if (is_business || crsub){
655+
if (crst)
656+
crstat = 5;
657+
else crstat = 4;
658+
} else {
659+
if (!crst)
660+
crstat = 1;
661+
else
662+
{
663+
if (psync_time() > crexp)
664+
crstat = 3;
665+
else
666+
crstat = 2;
667+
}
668+
}
669+
psync_sql_bind_string(q, 1, "cryptostatus");
670+
psync_sql_bind_uint(q, 2, crstat);
671+
psync_sql_run(q);
672+
psync_sql_free_result(q);
673+
674+
675+
}

plibs.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,7 @@ int psync_sql_connect(const char *db){
365365
int code;
366366

367367
assert(sqlite3_libversion_number()==SQLITE_VERSION_NUMBER);
368-
const char * sourcdid = sqlite3_sourceid();
369-
assert(!strcmp(sourcdid, SQLITE_SOURCE_ID));
368+
assert(!strcmp(sqlite3_sourceid(), SQLITE_SOURCE_ID));
370369
assert(!strcmp(sqlite3_libversion(), SQLITE_VERSION));
371370
debug(D_NOTICE, "Using sqlite version %s source %s", sqlite3_libversion(), sqlite3_sourceid());
372371
if (!sqlite3_threadsafe()){

psynclib.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,10 @@ void psync_start_overlay_callbacks();
11741174

11751175
int psync_setlanguage(const char *language, char **err);
11761176

1177+
1178+
// Update crypto status information from userinfo.
1179+
void psync_update_cryptostatus();
1180+
11771181
#ifdef __cplusplus
11781182
}
11791183
#endif

0 commit comments

Comments
 (0)