Revision
16124
Author
jmesquita
Date
2010-01-02 23:12:39 -0600 (Sat, 02 Jan 2010)

Log Message

Initial adaptation of mod_qsettings to the Qt way.

Modified Paths

Diff

Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/conf/freeswitch.xml (16123 => 16124)


--- freeswitch/trunk/contrib/jmesquita/FSPhone/conf/freeswitch.xml	2010-01-03 04:22:30 UTC (rev 16123)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/conf/freeswitch.xml	2010-01-03 05:12:39 UTC (rev 16124)
@@ -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"/>

Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp (16123 => 16124)


--- freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp	2010-01-03 04:22:30 UTC (rev 16123)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp	2010-01-03 05:12:39 UTC (rev 16124)
@@ -38,6 +38,8 @@
         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);

Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/mod_qsettings/mod_qsettings.cpp (16123 => 16124)


--- freeswitch/trunk/contrib/jmesquita/FSPhone/mod_qsettings/mod_qsettings.cpp	2010-01-03 04:22:30 UTC (rev 16123)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/mod_qsettings/mod_qsettings.cpp	2010-01-03 05:12:39 UTC (rev 16124)
@@ -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 @@
 	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,37 +72,28 @@
 
 	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;
+        QString *bind_mask = new QString(switch_xml_attr_soft(bindings_tag, "value"));
 
-		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();
 
-                binding = new xml_binding_t();
+        if (!bind_mask->isEmpty()) {
+                binding->bindings = bind_mask;
+        }
 
-		if (bind_mask) {
-			binding->bindings = strdup(bind_mask);
-		}
 
+        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;
 
-		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;
-	}
+        switch_xml_free(xml);
+        return SWITCH_STATUS_SUCCESS;
+}
 
-  done:
-	switch_xml_free(xml);
-
-	return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
-}*/
-
 SWITCH_MODULE_LOAD_FUNCTION(mod_qsettings_load)
 {
         /*switch_api_interface_t *qsettings_api_interface;*/
@@ -114,13 +104,13 @@
 	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 */
 	return SWITCH_STATUS_SUCCESS;