提交 cdd5b4cc authored 作者: João Mesquita's avatar João Mesquita

Initial adaptation of mod_qsettings to the Qt way.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk/contrib@16124 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 4672474a
......@@ -48,6 +48,10 @@
</routes>
</configuration>
<configuration name="qsettings.conf" description="configures our mod_qsettings">
<bindings value="dialplan" />
</configuration>
<configuration name="local_stream.conf" description="stream files from local dir">
<directory name="moh/48000" path="$${base_dir}/sounds/music/48000">
<param name="rate" value="48000"/>
......@@ -143,7 +147,7 @@
</gateways>
<settings>
<!--<param name="media-option" value="bypass-media-after-att-xfer"/>-->
<param name="user-agent-string" value="FreeSWITCH/SoftPhone"/>
<param name="user-agent-string" value="FreeSWITCH/FSPhone"/>
<!-- <param name="user-agent-string" value="FreeSWITCH Rocks!"/> -->
<param name="debug" value="0"/>
<param name="sip-trace" value="no"/>
......
......@@ -38,6 +38,8 @@ void FSHost::run(void)
dest = QString("%1/.fsphone/conf/accounts/example.xml").arg(conf_dir.absolutePath());
defaultAccount.copy(dest);
}
/* Set all directories to the home user directory */
if (conf_dir.cd(".fsphone"))
{
SWITCH_GLOBAL_dirs.conf_dir = (char *) malloc(strlen(QString("%1/conf").arg(conf_dir.absolutePath()).toAscii().constData()) + 1);
......
......@@ -30,11 +30,11 @@
* Module to load configurations from Qt preference system QSettings
*
*/
#include <QString>
#include "mod_qsettings/mod_qsettings.h"
struct xml_binding {
char *bindings;
QString *bindings;
};
typedef struct xml_binding xml_binding_t;
......@@ -59,12 +59,11 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
return NULL;
}
/*static switch_status_t do_config(void)
static switch_status_t do_config(void)
{
char *cf = "qsettings.conf";
switch_xml_t cfg, xml, bindings_tag, binding_tag, param;
switch_xml_t cfg, xml, bindings_tag;
xml_binding_t *binding = NULL;
int x = 0;
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
......@@ -73,36 +72,27 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
if (!(bindings_tag = switch_xml_child(cfg, "bindings"))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing <bindings> tag!\n");
goto done;
switch_xml_free(xml);
return SWITCH_STATUS_FALSE;
}
for (binding_tag = switch_xml_child(bindings_tag, "binding"); binding_tag; binding_tag = binding_tag->next) {
char *bname = (char *) switch_xml_attr_soft(binding_tag, "name");
char *bind_mask = NULL;
for (param = switch_xml_child(binding_tag, "param"); param; param = param->next) {
bind_mask = (char *) switch_xml_attr_soft(param, "value");
}
binding = new xml_binding_t();
QString *bind_mask = new QString(switch_xml_attr_soft(bindings_tag, "value"));
if (bind_mask) {
binding->bindings = strdup(bind_mask);
}
binding = new xml_binding_t();
if (!bind_mask->isEmpty()) {
binding->bindings = bind_mask;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding [%s] XML Fetch Function [%s]\n",
zstr(bname) ? "N/A" : bname, binding->bindings ? binding->bindings : "all");
switch_xml_bind_search_function(xml_url_fetch, switch_xml_parse_section_string(binding->bindings), binding);
x++;
binding = NULL;
}
done:
switch_xml_free(xml);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding XML Fetch Function [%s]\n",
binding->bindings->isEmpty() ? "all" : binding->bindings->toAscii().constData());
switch_xml_bind_search_function(xml_url_fetch, switch_xml_parse_section_string(binding->bindings->toAscii().constData()), binding);
binding = NULL;
return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
}*/
switch_xml_free(xml);
return SWITCH_STATUS_SUCCESS;
}
SWITCH_MODULE_LOAD_FUNCTION(mod_qsettings_load)
{
......@@ -114,12 +104,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_qsettings_load)
memset(&globals,0,sizeof(globals));
globals.pool = pool;
/* if (do_config() == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding worked!");
if (do_config() == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Sucessfully configured.\n");
} else {
return SWITCH_STATUS_FALSE;
}
*/
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "We loaded mod_qsettings.\n");
/* indicate that the module should continue to be loaded */
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论