profileWidget::profileWidget(ProfileModel *profileModel, QWidget *parent) : profileWidgetUI(parent) { profile_model = profileModel; if (!profile_model) { qDebug() << "ProfileModel is NULL!"; return; } listView->setModel(profile_model); listView->setModelColumn(1); listView->setIconSize(QSize(22, 22)); connect(listView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(_update())); connect(listView, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(mod_profile(const QModelIndex&))); connect(kpushbutton_add, SIGNAL(clicked()), this, SLOT(add_profile())); connect(kpushbutton_rem, SIGNAL(clicked()), this, SLOT(rem_profile())); connect(kpushbutton_mod, SIGNAL(clicked()), this, SLOT(mod_profile())); connect(kpushbutton_copy, SIGNAL(clicked()), this, SLOT(copy_profile())); connect(kpushbutton_load, SIGNAL(clicked()), this, SLOT(load_profiles())); connect(kpushbutton_save, SIGNAL(clicked()), this, SLOT(save_profiles())); connect(kpushbutton_init, SIGNAL(clicked()), this, SLOT(init_profiles())); kpushbutton_add->setIcon(QIcon::fromTheme("list-add")); kpushbutton_rem->setIcon(QIcon::fromTheme("list-remove")); kpushbutton_load->setIcon(QIcon::fromTheme("document-open")); kpushbutton_save->setIcon(QIcon::fromTheme("document-save")); kpushbutton_init->setIcon(QIcon::fromTheme("view-refresh")); _update(); }
/* Create an MRCP client. * * Some code and ideas borrowed from unimrcp-client.c * Please check $unimrcp_dir$/platforms/libunimrcp-client/src/unimrcp_client.c * when upgrading the UniMRCP library to ensure nothing new needs to be set up. */ mrcp_client_t *mod_unimrcp_client_create(apr_pool_t *mod_pool) { mrcp_client_t *client = NULL; apt_dir_layout_t *dir_layout = NULL; apr_pool_t *pool = NULL; mrcp_resource_factory_t *resource_factory = NULL; mpf_codec_manager_t *codec_manager = NULL; apr_size_t max_connection_count = 0; apt_bool_t offer_new_connection = FALSE; mrcp_connection_agent_t *shared_connection_agent = NULL; mpf_engine_t *shared_media_engine = NULL; if (!globals.profiles) { ast_log(LOG_ERROR, "Profiles hash is NULL\n"); return NULL; } /* Create the client. */ if ((dir_layout = apt_default_dir_layout_create("../", mod_pool)) == NULL) { ast_log(LOG_ERROR, "Unable to create directory layout\n"); return NULL; } if ((client = mrcp_client_create(dir_layout)) == NULL) { ast_log(LOG_ERROR, "Unable to create MRCP client stack\n"); return NULL; } if ((pool = mrcp_client_memory_pool_get(client)) == NULL) { ast_log(LOG_ERROR, "MRCP client pool is NULL\n"); return NULL; } mrcp_resource_loader_t *resource_loader = mrcp_resource_loader_create(FALSE, pool); if (resource_loader == NULL) { ast_log(LOG_ERROR, "Unable to create MRCP resource loader.\n"); return NULL; } apt_str_t resource_class_synth; apt_str_t resource_class_recog; apt_string_set(&resource_class_synth, "speechsynth"); apt_string_set(&resource_class_recog, "speechrecog"); mrcp_resource_load(resource_loader, &resource_class_synth); mrcp_resource_load(resource_loader, &resource_class_recog); resource_factory = mrcp_resource_factory_get(resource_loader); if (!mrcp_client_resource_factory_register(client, resource_factory)) ast_log(LOG_WARNING, "Unable to register MRCP client resource factory\n"); if ((codec_manager = mpf_engine_codec_manager_create(pool)) != NULL) { if (!mrcp_client_codec_manager_register(client, codec_manager)) ast_log(LOG_WARNING, "Unable to register MRCP client codec manager\n"); } /* Set up MRCPv2 connection agent that will be shared with all profiles. */ if ((globals.unimrcp_max_connection_count != NULL) && (strlen(globals.unimrcp_max_connection_count) > 0)) max_connection_count = atoi(globals.unimrcp_max_connection_count); if (max_connection_count <= 0) max_connection_count = DEFAULT_UNIMRCP_MAX_CONNECTION_COUNT; if (globals.unimrcp_offer_new_connection != NULL) { if (strcasecmp(globals.unimrcp_offer_new_connection, "true") == 0 || atoi(globals.unimrcp_offer_new_connection) == 1) offer_new_connection = TRUE; } else { offer_new_connection = DEFAULT_UNIMRCP_OFFER_NEW_CONNECTION; } if ((shared_connection_agent = mrcp_client_connection_agent_create("MRCPv2ConnectionAgent", max_connection_count, offer_new_connection, pool)) != NULL) { if (shared_connection_agent != NULL) { if (globals.unimrcp_rx_buffer_size != NULL) { apr_size_t rx_buffer_size = (apr_size_t)atol(globals.unimrcp_rx_buffer_size); if (rx_buffer_size > 0) { mrcp_client_connection_rx_size_set(shared_connection_agent, rx_buffer_size); } } if (globals.unimrcp_tx_buffer_size != NULL) { apr_size_t tx_buffer_size = (apr_size_t)atol(globals.unimrcp_tx_buffer_size); if (tx_buffer_size > 0) { mrcp_client_connection_tx_size_set(shared_connection_agent, tx_buffer_size); } } if (globals.unimrcp_request_timeout != NULL) { apr_size_t request_timeout = (apr_size_t)atol(globals.unimrcp_request_timeout); if (request_timeout > 0) { mrcp_client_connection_timeout_set(shared_connection_agent, request_timeout); } } } if (!mrcp_client_connection_agent_register(client, shared_connection_agent)) ast_log(LOG_WARNING, "Unable to register MRCP client connection agent\n"); } /* Set up the media engine that will be shared with all profiles. */ if ((shared_media_engine = mpf_engine_create("MediaEngine", pool)) != NULL) { unsigned long realtime_rate = 1; if (!mpf_engine_scheduler_rate_set(shared_media_engine, realtime_rate)) ast_log(LOG_WARNING, "Unable to set scheduler rate for MRCP client media engine\n"); if (!mrcp_client_media_engine_register(client, shared_media_engine)) ast_log(LOG_WARNING, "Unable to register MRCP client media engine\n"); } if (globals.profiles) { if(load_profiles(client, shared_connection_agent, shared_media_engine, pool) !=0) return NULL; } return client; }