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:
parent
46ed43522c
commit
7358377d3e
2 changed files with 11 additions and 5 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue