diff -ur gammu-1.34.0/smsd/services/sql.c gammu-1.34.0-patched/smsd/services/sql.c --- gammu-1.34.0/smsd/services/sql.c 2014-12-30 09:44:56.000000000 +0100 +++ gammu-1.34.0-patched/smsd/services/sql.c 2015-02-05 17:45:31.587009457 +0100 @@ -262,8 +262,8 @@ } } -static SQL_Error SMSDSQL_NamedQuery(GSM_SMSDConfig * Config, const char *sql_query, GSM_SMSMessage *sms, - const SQL_Var *params, SQL_result * res) +static SQL_Error SMSDSQL_NamedQuery2(GSM_SMSDConfig * Config, const char *sql_query, GSM_SMSMessage *sms, + const SQL_Var *params, SQL_result * res, int refreshPhoneStatus) { char buff[65536], *ptr, c, static_buff[8192]; char *buffer2, *end; @@ -279,11 +279,13 @@ NetCode = empty; NetName = empty; - - if ( GSM_GetNetworkInfo(Config->gsm, &NetInfo) == ERR_NONE) { - NetCode = NetInfo.NetworkCode; - if (NetInfo.NetworkName[0] != 0x00 || NetInfo.NetworkName[1] != 0x00) { - NetName = DecodeUnicodeConsole(NetInfo.NetworkName); + if (refreshPhoneStatus == 1) + { + if ( GSM_GetNetworkInfo(Config->gsm, &NetInfo) == ERR_NONE) { + NetCode = NetInfo.NetworkCode; + if (NetInfo.NetworkName[0] != 0x00 || NetInfo.NetworkName[1] != 0x00) { + NetName = DecodeUnicodeConsole(NetInfo.NetworkName); + } } } @@ -451,6 +453,12 @@ } +static SQL_Error SMSDSQL_NamedQuery(GSM_SMSDConfig * Config, const char *sql_query, GSM_SMSMessage *sms, + const SQL_Var *params, SQL_result * res) +{ + return SMSDSQL_NamedQuery2(Config, sql_query, sms, params, res, 0); +} + static GSM_Error SMSDSQL_CheckTable(GSM_SMSDConfig * Config, const char *table) { SQL_result res; @@ -561,7 +569,7 @@ vars[0].v.s = Config->enable_send ? "yes" : "no"; vars[1].v.s = Config->enable_receive ? "yes" : "no"; - if (SMSDSQL_NamedQuery(Config, Config->SMSDSQL_queries[SQL_QUERY_INSERT_PHONE], NULL, vars, &res) != SQL_OK) { + if (SMSDSQL_NamedQuery2(Config, Config->SMSDSQL_queries[SQL_QUERY_INSERT_PHONE], NULL, vars, &res, 1) != SQL_OK) { SMSD_Log(DEBUG_INFO, Config, "Error inserting into database (%s)", __FUNCTION__); return ERR_UNKNOWN; } @@ -1053,7 +1061,7 @@ vars[0].v.i = Config->Status->Charge.BatteryPercent; vars[1].v.i = Config->Status->Network.SignalPercent; - if (SMSDSQL_NamedQuery(Config, Config->SMSDSQL_queries[SQL_QUERY_REFRESH_PHONE_STATUS], NULL, vars, &res) != SQL_OK) { + if (SMSDSQL_NamedQuery2(Config, Config->SMSDSQL_queries[SQL_QUERY_REFRESH_PHONE_STATUS], NULL, vars, &res, 1) != SQL_OK) { SMSD_Log(DEBUG_INFO, Config, "Error writing to database (%s)", __FUNCTION__); return ERR_UNKNOWN; }