From b84ddbea51b1247117891be301667feb2fa8975e Mon Sep 17 00:00:00 2001 From: ache Date: Thu, 7 Feb 2019 10:59:50 +0100 Subject: Delete contact --- main.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 830c209..353e157 100644 --- a/main.c +++ b/main.c @@ -264,8 +264,19 @@ int main(int argc, char* argv[]){ resize(); } break; + case 'd': + { + contact* selected = getContactSelected(); + readline_n("Delete contact | Type 'yes' to confirm : ", ""); + if( strcmp(msg_win_str, "yes") == 0) { + deleteContact(selected); + writeContactList(config.CONTACT_FILENAME); + showContactListW(); + } + break; + } case 'e': - if( tabed ) { + { contact* selected = getContactSelected(); readline_n("Edit contact | Name : ", selected->name); strcpy(selected->name, msg_win_str); @@ -279,15 +290,17 @@ int main(int argc, char* argv[]){ if( !tabed ) { contact newContact = {"", "", "", 0, NULL}; readline_n("New contact | Name : ", ""); + if( !*msg_win_str ) break; strcpy(newContact.name, msg_win_str); readline_n("New contact | Display name : ", ""); strcpy(newContact.display_name, msg_win_str); + if( !*msg_win_str ) break; readline_n("New contact | Number : ", ""); strcpy(newContact.number, msg_win_str); addContact(&newContact); - if( *config.CONTACT_FILENAME == '\0' ) { + if( !*config.CONTACT_FILENAME ) { wordexp_t p; r = wordexp("~/.mesms_contacts.csv", &p, 0); if( r == 0 && p.we_wordc > 0 ) { -- cgit v1.2.3