Skinny: store accessory status in db instead of memory
(this is not used yet)
This commit is contained in:
parent
2b6f70708c
commit
6105757898
|
@ -58,7 +58,10 @@ static char devices_sql[] =
|
|||
" type INTEGER,\n"
|
||||
" max_streams INTEGER,\n"
|
||||
" port INTEGER,\n"
|
||||
" codec_string VARCHAR(255)\n"
|
||||
" codec_string VARCHAR(255),\n"
|
||||
" headset INTEGER,\n"
|
||||
" handset INTEGER,\n"
|
||||
" speaker INTEGER\n"
|
||||
");\n";
|
||||
|
||||
static char lines_sql[] =
|
||||
|
@ -1916,10 +1919,10 @@ static switch_status_t load_skinny_config(void)
|
|||
switch_odbc_handle_exec(profile->master_odbc, active_lines_sql, NULL, NULL);
|
||||
} else {
|
||||
if ((db = switch_core_db_open_file(profile->dbname))) {
|
||||
switch_core_db_test_reactive(db, "SELECT * FROM skinny_devices", NULL, devices_sql);
|
||||
switch_core_db_test_reactive(db, "SELECT * FROM skinny_lines", NULL, lines_sql);
|
||||
switch_core_db_test_reactive(db, "SELECT * FROM skinny_buttons", NULL, buttons_sql);
|
||||
switch_core_db_test_reactive(db, "SELECT * FROM skinny_active_lines", NULL, active_lines_sql);
|
||||
switch_core_db_test_reactive(db, "SELECT headset FROM skinny_devices", "DROP TABLE skinny_devices", devices_sql);
|
||||
switch_core_db_test_reactive(db, "SELECT * FROM skinny_lines", "DROP TABLE skinny_lines", lines_sql);
|
||||
switch_core_db_test_reactive(db, "SELECT * FROM skinny_buttons", "DROP TABLE skinny_buttons", buttons_sql);
|
||||
switch_core_db_test_reactive(db, "SELECT * FROM skinny_active_lines", "DROP TABLE skinny_active_lines", active_lines_sql);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open SQL Database!\n");
|
||||
continue;
|
||||
|
|
|
@ -136,9 +136,6 @@ struct listener {
|
|||
char device_name[16];
|
||||
uint32_t device_instance;
|
||||
uint32_t device_type;
|
||||
uint32_t headset;
|
||||
uint32_t handset;
|
||||
uint32_t speaker;
|
||||
|
||||
char firmware_version[16];
|
||||
char *soft_key_set_set;
|
||||
|
|
|
@ -1900,16 +1900,20 @@ switch_status_t skinny_handle_soft_key_template_request(listener_t *listener, sk
|
|||
|
||||
switch_status_t skinny_headset_status_message(listener_t *listener, skinny_message_t *request)
|
||||
{
|
||||
char *sql;
|
||||
|
||||
skinny_check_data_length(request, sizeof(request->data.headset_status));
|
||||
|
||||
switch(request->data.headset_status.mode) {
|
||||
case 1:
|
||||
listener->headset = SKINNY_ACCESSORY_STATE_OFFHOOK;
|
||||
break;
|
||||
default:
|
||||
listener->headset = SKINNY_ACCESSORY_STATE_ONHOOK;
|
||||
break;
|
||||
if ((sql = switch_mprintf(
|
||||
"UPDATE skinny_devices SET headset=%d WHERE name='%s' and instance=%d",
|
||||
(request->data.headset_status.mode==1) ? SKINNY_ACCESSORY_STATE_OFFHOOK : SKINNY_ACCESSORY_STATE_ONHOOK,
|
||||
listener->device_name,
|
||||
listener->device_instance
|
||||
))) {
|
||||
skinny_execute_sql(listener->profile, sql, listener->profile->sql_mutex);
|
||||
switch_safe_free(sql);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2037,17 +2041,43 @@ switch_status_t skinny_handle_dialed_phone_book_message(listener_t *listener, sk
|
|||
}
|
||||
switch_status_t skinny_handle_accessory_status_message(listener_t *listener, skinny_message_t *request)
|
||||
{
|
||||
char *sql;
|
||||
|
||||
skinny_check_data_length(request, sizeof(request->data.accessory_status));
|
||||
|
||||
switch(request->data.accessory_status.accessory_id) {
|
||||
case SKINNY_ACCESSORY_HEADSET:
|
||||
listener->headset = request->data.accessory_status.accessory_status;
|
||||
if ((sql = switch_mprintf(
|
||||
"UPDATE skinny_devices SET headset=%d WHERE name='%s' and instance=%d",
|
||||
request->data.accessory_status.accessory_status,
|
||||
listener->device_name,
|
||||
listener->device_instance
|
||||
))) {
|
||||
skinny_execute_sql(listener->profile, sql, listener->profile->sql_mutex);
|
||||
switch_safe_free(sql);
|
||||
}
|
||||
break;
|
||||
case SKINNY_ACCESSORY_HANDSET:
|
||||
listener->handset = request->data.accessory_status.accessory_status;
|
||||
if ((sql = switch_mprintf(
|
||||
"UPDATE skinny_devices SET handset=%d WHERE name='%s' and instance=%d",
|
||||
request->data.accessory_status.accessory_status,
|
||||
listener->device_name,
|
||||
listener->device_instance
|
||||
))) {
|
||||
skinny_execute_sql(listener->profile, sql, listener->profile->sql_mutex);
|
||||
switch_safe_free(sql);
|
||||
}
|
||||
break;
|
||||
case SKINNY_ACCESSORY_SPEAKER:
|
||||
listener->speaker = request->data.accessory_status.accessory_status;
|
||||
if ((sql = switch_mprintf(
|
||||
"UPDATE skinny_devices SET speaker=%d WHERE name='%s' and instance=%d",
|
||||
request->data.accessory_status.accessory_status,
|
||||
listener->device_name,
|
||||
listener->device_instance
|
||||
))) {
|
||||
skinny_execute_sql(listener->profile, sql, listener->profile->sql_mutex);
|
||||
switch_safe_free(sql);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue