1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-05 02:29:28 +02:00

prepare cli to create group-join-qr-codes

This commit is contained in:
B. Petersen 2018-04-30 01:53:07 +02:00
parent 46ed43522c
commit 7358377d3e
2 changed files with 11 additions and 5 deletions

View file

@ -492,7 +492,7 @@ char* mrmailbox_cmdline(mrmailbox_t* mailbox, const char* cmdline)
"delcontact <contact-id>\n"
"cleanupcontacts\n"
"======================================Misc.==\n"
"getqr\n"
"getqr [<chat-id>]\n"
"getbadqr\n"
"checkqr <qr-contenct>\n"
"event <event-id to test>\n"
@ -1223,7 +1223,7 @@ char* mrmailbox_cmdline(mrmailbox_t* mailbox, const char* cmdline)
else if( strcmp(cmd, "getqr")==0 )
{
ret = mrmailbox_get_securejoin_qr(mailbox, 0);
ret = mrmailbox_get_securejoin_qr(mailbox, arg1? atoi(arg1) : 0);
}
else if( strcmp(cmd, "checkqr")==0 )
{

View file

@ -126,6 +126,7 @@ static uintptr_t receive_event(mrmailbox_t* mailbox, int event, uintptr_t data1,
int main(int argc, char ** argv)
{
char* cmd = NULL;
mrmailbox_t* mailbox = mrmailbox_new(receive_event, NULL, "CLI");
mrmailbox_cmdline_skip_auth(mailbox); /* disable the need to enter the command `auth <password>` for all mailboxes. */
@ -150,7 +151,11 @@ int main(int argc, char ** argv)
while(1)
{
/* read command */
const char* cmd = read_cmd();
const char* cmdline = read_cmd();
free(cmd);
cmd = safe_strdup(cmdline);
char* arg1 = strchr(cmd, ' ');
if( arg1 ) { *arg1 = 0; arg1++; }
if( strcmp(cmd, "clear")==0 )
{
@ -160,7 +165,7 @@ int main(int argc, char ** argv)
else if( strcmp(cmd, "getqr")==0 || strcmp(cmd, "getbadqr")==0 )
{
mrmailbox_connect(mailbox);
char* qrstr = mrmailbox_get_securejoin_qr(mailbox, 0);
char* qrstr = mrmailbox_get_securejoin_qr(mailbox, arg1? atoi(arg1) : 0);
if( strcmp(cmd, "getbadqr")==0 && strlen(qrstr)>40 ) {
for( int i = 12; i < 22; i++ ) { qrstr[i] = '0'; }
}
@ -180,7 +185,7 @@ int main(int argc, char ** argv)
}
else
{
char* execute_result = mrmailbox_cmdline(mailbox, cmd);
char* execute_result = mrmailbox_cmdline(mailbox, cmdline);
if( execute_result ) {
printf("%s\n", execute_result);
free(execute_result);
@ -188,6 +193,7 @@ int main(int argc, char ** argv)
}
}
free(cmd);
mrmailbox_close(mailbox);
mrmailbox_unref(mailbox);
mailbox = NULL;