Implemented contact deletion
This commit is contained in:
parent
9642f83d85
commit
519d3f78db
@ -632,8 +632,7 @@ void gsm_callback_on_message_deleted(GSM * gsm)
|
||||
/* gsm_contact_delete */
|
||||
int gsm_contact_delete(GSM * gsm, unsigned int index)
|
||||
{
|
||||
/* FIXME implement */
|
||||
return 1;
|
||||
return gsm_modem_contact_delete(gsm->modem, index);
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,6 +57,7 @@ typedef enum _GSMError
|
||||
GSM_ERROR_BUSY,
|
||||
GSM_ERROR_CALL_FAILED,
|
||||
GSM_ERROR_CALL_WAITING_FAILED,
|
||||
GSM_ERROR_CONTACT_DELETE_FAILED,
|
||||
GSM_ERROR_CONTACT_EDIT_FAILED,
|
||||
GSM_ERROR_CONTACT_FETCH_FAILED,
|
||||
GSM_ERROR_CONTACT_LIST_FAILED,
|
||||
|
19
src/modem.c
19
src/modem.c
@ -199,6 +199,25 @@ static void _modem_call_reject_callback(GSM * gsm)
|
||||
}
|
||||
|
||||
|
||||
/* gsm_modem_contact_delete */
|
||||
int gsm_modem_contact_delete(GSMModem * gsmm, unsigned int index)
|
||||
{
|
||||
int ret;
|
||||
char const cmd[] = "AT+CPBW=";
|
||||
size_t len;
|
||||
char * buf;
|
||||
|
||||
len = sizeof(cmd) + 11 + 1;
|
||||
if((buf = malloc(len)) == NULL)
|
||||
return 1;
|
||||
snprintf(buf, len, "%s%u,", cmd, index);
|
||||
ret = gsm_queue_with_error(gsmm->gsm, buf,
|
||||
GSM_ERROR_CONTACT_DELETE_FAILED);
|
||||
free(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* gsm_modem_contact_edit */
|
||||
static void _modem_contact_edit_callback(GSM * gsm);
|
||||
|
||||
|
@ -56,6 +56,7 @@ int gsm_modem_call_hangup(GSMModem * gsmm);
|
||||
int gsm_modem_call_last(GSMModem * gsmm, GSMCallType calltype);
|
||||
int gsm_modem_call_reject(GSMModem * gsmm);
|
||||
|
||||
int gsm_modem_contact_delete(GSMModem * gsmm, unsigned int index);
|
||||
int gsm_modem_contact_edit(GSMModem * gsmm, unsigned int index,
|
||||
char const * name, char const * number);
|
||||
int gsm_modem_contact_new(GSMModem * gsmm, char const * name,
|
||||
|
@ -561,7 +561,11 @@ void phone_contacts_delete_selected(Phone * phone)
|
||||
return;
|
||||
gtk_tree_model_get(GTK_TREE_MODEL(phone->co_store), &iter,
|
||||
PHONE_CONTACT_COLUMN_ID, &index, -1);
|
||||
/* FIXME ask for confirmation and implement */
|
||||
if(_phone_confirm(phone, phone->co_window, _("Delete this contact?"))
|
||||
!= 0)
|
||||
return;
|
||||
gtk_list_store_remove(phone->co_store, &iter); /* XXX it may fail */
|
||||
gsm_contact_delete(phone->gsm, index);
|
||||
}
|
||||
|
||||
|
||||
@ -2440,7 +2444,6 @@ static void _on_contacts_dialog_response(GtkWidget * widget, gint response,
|
||||
return;
|
||||
name = gtk_entry_get_text(GTK_ENTRY(phone->co_name));
|
||||
number = gtk_entry_get_text(GTK_ENTRY(phone->co_number));
|
||||
/* FIXME also update the GtkListStore */
|
||||
if(phone->co_index < 0)
|
||||
gsm_contact_new(phone->gsm, name, number);
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user