Implemented contact deletion

This commit is contained in:
Pierre Pronchery 2010-07-24 17:02:11 +00:00
parent 9642f83d85
commit 519d3f78db
5 changed files with 27 additions and 4 deletions

View File

@ -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);
}

View File

@ -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,

View File

@ -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);

View File

@ -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,

View File

@ -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