atmodem: Use g_at_chat_clone

This commit is contained in:
Denis Kenzior 2010-08-12 16:40:40 -05:00
parent 5f47eca7ed
commit ac524be99f
17 changed files with 71 additions and 27 deletions

View File

@ -197,7 +197,7 @@ static int at_call_barring_probe(struct ofono_call_barring *cb,
{
GAtChat *chat = user;
ofono_call_barring_set_data(cb, chat);
ofono_call_barring_set_data(cb, g_at_chat_clone(chat));
g_idle_add(at_call_barring_register, cb);
return 0;
@ -205,6 +205,10 @@ static int at_call_barring_probe(struct ofono_call_barring *cb,
static void at_call_barring_remove(struct ofono_call_barring *cb)
{
GAtChat *chat = ofono_call_barring_get_data(cb);
g_at_chat_unref(chat);
ofono_call_barring_set_data(cb, NULL);
}
static struct ofono_call_barring_driver driver = {

View File

@ -259,7 +259,7 @@ static int at_ccfc_probe(struct ofono_call_forwarding *cf, unsigned int vendor,
{
GAtChat *chat = data;
ofono_call_forwarding_set_data(cf, chat);
ofono_call_forwarding_set_data(cf, g_at_chat_clone(chat));
g_idle_add(at_ccfc_register, cf);
return 0;
@ -267,6 +267,10 @@ static int at_ccfc_probe(struct ofono_call_forwarding *cf, unsigned int vendor,
static void at_ccfc_remove(struct ofono_call_forwarding *cf)
{
GAtChat *chat = ofono_call_forwarding_get_data(cf);
g_at_chat_unref(chat);
ofono_call_forwarding_set_data(cf, NULL);
}
static struct ofono_call_forwarding_driver driver = {

View File

@ -348,6 +348,7 @@ static int at_caoc_probe(struct ofono_call_meter *cm, unsigned int vendor,
{
GAtChat *chat = data;
chat = g_at_chat_clone(chat);
ofono_call_meter_set_data(cm, chat);
g_at_chat_send(chat, "AT+CAOC=2", NULL, NULL, NULL, NULL);
@ -359,6 +360,10 @@ static int at_caoc_probe(struct ofono_call_meter *cm, unsigned int vendor,
static void at_caoc_remove(struct ofono_call_meter *cm)
{
GAtChat *chat = ofono_call_meter_get_data(cm);
g_at_chat_unref(chat);
ofono_call_meter_set_data(cm, NULL);
}
static struct ofono_call_meter_driver driver = {

View File

@ -339,7 +339,7 @@ static int at_call_settings_probe(struct ofono_call_settings *cs,
{
GAtChat *chat = data;
ofono_call_settings_set_data(cs, chat);
ofono_call_settings_set_data(cs, g_at_chat_clone(chat));
g_idle_add(at_call_settings_register, cs);
return 0;
@ -347,6 +347,10 @@ static int at_call_settings_probe(struct ofono_call_settings *cs,
static void at_call_settings_remove(struct ofono_call_settings *cs)
{
GAtChat *chat = ofono_call_settings_get_data(cs);
g_at_chat_unref(chat);
ofono_call_settings_set_data(cs, NULL);
}
static struct ofono_call_settings_driver driver = {

View File

@ -189,15 +189,15 @@ static int at_call_volume_probe(struct ofono_call_volume *cv,
DBG("%p", cv);
cvd = g_new0(struct cv_data, 1);
cvd->chat = chat;
cvd->chat = g_at_chat_clone(chat);
ofono_call_volume_set_data(cv, cvd);
g_at_chat_send(chat, "AT+CMUT?", cmut_prefix,
g_at_chat_send(cvd->chat, "AT+CMUT?", cmut_prefix,
cmut_query, cv, NULL);
g_at_chat_send(chat, "AT+CLVL=?", clvl_prefix,
g_at_chat_send(cvd->chat, "AT+CLVL=?", clvl_prefix,
clvl_range_query, cv, NULL);
g_at_chat_send(chat, "AT+CLVL?", clvl_prefix,
g_at_chat_send(cvd->chat, "AT+CLVL?", clvl_prefix,
clvl_query, cv, NULL);
/* Generic driver does not support microphone level */
@ -212,6 +212,7 @@ static void at_call_volume_remove(struct ofono_call_volume *cv)
ofono_call_volume_set_data(cv, NULL);
g_at_chat_unref(cvd->chat);
g_free(cvd);
}

View File

@ -237,12 +237,12 @@ static int at_cbs_probe(struct ofono_cbs *cbs, unsigned int vendor,
struct cbs_data *data;
data = g_new0(struct cbs_data, 1);
data->chat = chat;
data->chat = g_at_chat_clone(chat);
data->vendor = vendor;
ofono_cbs_set_data(cbs, data);
g_at_chat_send(chat, "AT+CSCB=?", cscb_prefix,
g_at_chat_send(data->chat, "AT+CSCB=?", cscb_prefix,
at_cscb_support_cb, cbs, NULL);
return 0;
@ -254,6 +254,7 @@ static void at_cbs_remove(struct ofono_cbs *cbs)
ofono_cbs_set_data(cbs, NULL);
g_at_chat_unref(data->chat);
g_free(data);
}

View File

@ -188,7 +188,7 @@ static int at_devinfo_probe(struct ofono_devinfo *info, unsigned int vendor,
{
GAtChat *chat = data;
ofono_devinfo_set_data(info, chat);
ofono_devinfo_set_data(info, g_at_chat_clone(chat));
g_idle_add(at_devinfo_register, info);
return 0;
@ -196,6 +196,10 @@ static int at_devinfo_probe(struct ofono_devinfo *info, unsigned int vendor,
static void at_devinfo_remove(struct ofono_devinfo *info)
{
GAtChat *chat = ofono_devinfo_get_data(info);
g_at_chat_unref(chat);
ofono_devinfo_set_data(info, NULL);
}
static struct ofono_devinfo_driver driver = {

View File

@ -249,7 +249,7 @@ static int at_gprs_context_probe(struct ofono_gprs_context *gc,
struct gprs_context_data *gcd;
gcd = g_new0(struct gprs_context_data, 1);
gcd->chat = chat;
gcd->chat = g_at_chat_clone(chat);
ofono_gprs_context_set_data(gc, gcd);
@ -268,6 +268,8 @@ static void at_gprs_context_remove(struct ofono_gprs_context *gc)
}
ofono_gprs_context_set_data(gc, NULL);
g_at_chat_unref(gcd->chat);
g_free(gcd);
}

View File

@ -306,12 +306,12 @@ static int at_gprs_probe(struct ofono_gprs *gprs,
struct gprs_data *gd;
gd = g_new0(struct gprs_data, 1);
gd->chat = chat;
gd->chat = g_at_chat_clone(chat);
gd->vendor = vendor;
ofono_gprs_set_data(gprs, gd);
g_at_chat_send(chat, "AT+CGDCONT=?", cgdcont_prefix,
g_at_chat_send(gd->chat, "AT+CGDCONT=?", cgdcont_prefix,
at_cgdcont_test_cb, gprs, NULL);
return 0;
@ -322,6 +322,8 @@ static void at_gprs_remove(struct ofono_gprs *gprs)
struct gprs_data *gd = ofono_gprs_get_data(gprs);
ofono_gprs_set_data(gprs, NULL);
g_at_chat_unref(gd->chat);
g_free(gd);
}

View File

@ -1083,12 +1083,12 @@ static int at_netreg_probe(struct ofono_netreg *netreg, unsigned int vendor,
nd = g_new0(struct netreg_data, 1);
nd->chat = chat;
nd->chat = g_at_chat_clone(chat);
nd->vendor = vendor;
nd->tech = -1;
ofono_netreg_set_data(netreg, nd);
g_at_chat_send(chat, "AT+CREG=?", creg_prefix,
g_at_chat_send(nd->chat, "AT+CREG=?", creg_prefix,
at_creg_test_cb, netreg, NULL);
return 0;
@ -1100,6 +1100,7 @@ static void at_netreg_remove(struct ofono_netreg *netreg)
ofono_netreg_set_data(netreg, NULL);
g_at_chat_unref(nd->chat);
g_free(nd);
}

View File

@ -511,7 +511,7 @@ static int at_phonebook_probe(struct ofono_phonebook *pb, unsigned int vendor,
struct pb_data *pbd;
pbd = g_new0(struct pb_data, 1);
pbd->chat = chat;
pbd->chat = g_at_chat_clone(chat);
ofono_phonebook_set_data(pb, pbd);
@ -529,6 +529,7 @@ static void at_phonebook_remove(struct ofono_phonebook *pb)
ofono_phonebook_set_data(pb, NULL);
g_at_chat_unref(pbd->chat);
g_free(pbd);
}

View File

@ -810,15 +810,15 @@ static int at_sim_probe(struct ofono_sim *sim, unsigned int vendor,
struct sim_data *sd;
sd = g_new0(struct sim_data, 1);
sd->chat = chat;
sd->chat = g_at_chat_clone(chat);
sd->vendor = vendor;
switch (sd->vendor) {
case OFONO_VENDOR_WAVECOM:
g_at_chat_add_terminator(chat, "+CPIN:", 6, TRUE);
g_at_chat_add_terminator(sd->chat, "+CPIN:", 6, TRUE);
break;
case OFONO_VENDOR_MBM:
g_at_chat_send(chat, "AT*EPEE=1", NULL, NULL, NULL, NULL);
g_at_chat_send(sd->chat, "AT*EPEE=1", NULL, NULL, NULL, NULL);
break;
default:
break;
@ -839,6 +839,7 @@ static void at_sim_remove(struct ofono_sim *sim)
if (sd->epev_source)
g_source_remove(sd->epev_source);
g_at_chat_unref(sd->chat);
g_free(sd);
}

View File

@ -1212,12 +1212,12 @@ static int at_sms_probe(struct ofono_sms *sms, unsigned int vendor,
struct sms_data *data;
data = g_new0(struct sms_data, 1);
data->chat = chat;
data->chat = g_at_chat_clone(chat);
data->vendor = vendor;
ofono_sms_set_data(sms, data);
g_at_chat_send(chat, "AT+CSMS=?", csms_prefix,
g_at_chat_send(data->chat, "AT+CSMS=?", csms_prefix,
at_csms_query_cb, sms, NULL);
return 0;
@ -1233,6 +1233,7 @@ static void at_sms_remove(struct ofono_sms *sms)
if (data->timeout_source > 0)
g_source_remove(data->timeout_source);
g_at_chat_unref(data->chat);
g_free(data);
}

View File

@ -113,6 +113,8 @@ static int at_ssn_probe(struct ofono_ssn *ssn, unsigned int vendor,
{
GAtChat *chat = data;
chat = g_at_chat_clone(chat);
ofono_ssn_set_data(ssn, chat);
g_at_chat_send(chat, "AT+CSSN=1,1", none_prefix,
at_ssn_initialized, ssn, NULL);
@ -122,6 +124,10 @@ static int at_ssn_probe(struct ofono_ssn *ssn, unsigned int vendor,
static void at_ssn_remove(struct ofono_ssn *ssn)
{
GAtChat *chat = ofono_ssn_get_data(ssn);
g_at_chat_unref(chat);
ofono_ssn_set_data(ssn, NULL);
}
static struct ofono_ssn_driver driver = {

View File

@ -312,7 +312,7 @@ static int at_stk_probe(struct ofono_stk *stk, unsigned int vendor, void *data)
struct stk_data *sd;
sd = g_new0(struct stk_data, 1);
sd->chat = chat;
sd->chat = g_at_chat_clone(chat);
sd->vendor = vendor;
ofono_stk_set_data(stk, sd);
@ -327,6 +327,7 @@ static void at_stk_remove(struct ofono_stk *stk)
ofono_stk_set_data(stk, NULL);
g_at_chat_unref(sd->chat);
g_free(sd);
}

View File

@ -224,6 +224,7 @@ static int at_ussd_probe(struct ofono_ussd *ussd, unsigned int vendor,
{
GAtChat *chat = data;
chat = g_at_chat_clone(chat);
ofono_ussd_set_data(ussd, chat);
g_at_chat_send(chat, "AT+CUSD=1", NULL, at_ussd_register, ussd, NULL);
@ -233,6 +234,10 @@ static int at_ussd_probe(struct ofono_ussd *ussd, unsigned int vendor,
static void at_ussd_remove(struct ofono_ussd *ussd)
{
GAtChat *chat = ofono_ussd_get_data(ussd);
g_at_chat_unref(chat);
ofono_ussd_set_data(ussd, NULL);
}
static struct ofono_ussd_driver driver = {

View File

@ -841,14 +841,14 @@ static int at_voicecall_probe(struct ofono_voicecall *vc, unsigned int vendor,
struct voicecall_data *vd;
vd = g_new0(struct voicecall_data, 1);
vd->chat = chat;
vd->chat = g_at_chat_clone(chat);
ofono_voicecall_set_data(vc, vd);
g_at_chat_send(chat, "AT+CRC=1", NULL, NULL, NULL, NULL);
g_at_chat_send(chat, "AT+CLIP=1", NULL, NULL, NULL, NULL);
g_at_chat_send(chat, "AT+COLP=1", NULL, NULL, NULL, NULL);
g_at_chat_send(chat, "AT+CCWA=1", NULL,
g_at_chat_send(vd->chat, "AT+CRC=1", NULL, NULL, NULL, NULL);
g_at_chat_send(vd->chat, "AT+CLIP=1", NULL, NULL, NULL, NULL);
g_at_chat_send(vd->chat, "AT+COLP=1", NULL, NULL, NULL, NULL);
g_at_chat_send(vd->chat, "AT+CCWA=1", NULL,
at_voicecall_initialized, vc, NULL);
return 0;
}
@ -865,6 +865,7 @@ static void at_voicecall_remove(struct ofono_voicecall *vc)
ofono_voicecall_set_data(vc, NULL);
g_at_chat_unref(vd->chat);
g_free(vd);
}