Revision
16123
Author
jmesquita
Date
2010-01-02 22:22:30 -0600 (Sat, 02 Jan 2010)

Log Message

Change the directories to the home user directory and copy templates if not there.

Modified Paths

Diff

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


--- freeswitch/trunk/contrib/jmesquita/FSPhone/conf/accounts/example.xml	2010-01-02 22:06:42 UTC (rev 16122)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/conf/accounts/example.xml	2010-01-03 04:22:30 UTC (rev 16123)
@@ -1,7 +1,7 @@
 <include>
-  <gateway name="voicetechnology.com.ar">
+  <!--<gateway name="default">-->
   <!--/// account username *required* ///-->
-  <param name="username" value="1001"/>
+  <!--<param name="username" value="cluecon"/>-->
   <!--/// auth realm: *optional* same as gateway name, if blank ///-->
   <!--<param name="realm" value="asterlink.com"/>-->
   <!--/// username to use in from: *optional* same as  username, if blank ///-->
@@ -9,7 +9,7 @@
   <!--/// domain to use in from: *optional* same as  realm, if blank ///-->
   <!--<param name="from-domain" value="asterlink.com"/>-->
   <!--/// account password *required* ///-->
-  <param name="password" value="cerrito2p"/>
+  <!--<param name="password" value="cluecon"/>-->
   <!--/// extension for inbound calls: *optional* same as username, if blank ///-->
   <!--<param name="extension" value="cluecon"/>-->
   <!--/// proxy host: *optional* same as realm, if blank ///-->
@@ -30,5 +30,5 @@
   <!--<param name="contact-params" value="tport=tcp"/>-->
   <!--send an options ping every x seconds, failure will unregister and/or mark it down-->
   <!--<param name="ping" value="25"/>-->
-  </gateway>
+  <!--</gateway>-->
 </include>

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


--- freeswitch/trunk/contrib/jmesquita/FSPhone/conf/freeswitch.xml	2010-01-02 22:06:42 UTC (rev 16122)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/conf/freeswitch.xml	2010-01-03 04:22:30 UTC (rev 16123)
@@ -9,7 +9,7 @@
   <X-PRE-PROCESS cmd="set" data="outbound_caller_name=FreeSWITCH"/>
   <X-PRE-PROCESS cmd="set" data="outbound_caller_id=0000000000"/>
   <X-PRE-PROCESS cmd="set" data="console_loglevel=info"/>
-  <X-PRE-PROCESS cmd="set" data="default_gateway=voicetechnology.com.ar"/>
+  <X-PRE-PROCESS cmd="set" data="default_gateway=default"/>
   <X-PRE-PROCESS cmd="set" data="us-ring=%(2000, 4000, 440.0, 480.0)"/>
   <X-PRE-PROCESS cmd="set" data="bong-ring=v=-7;%(100,0,941.0,1477.0);v=-7;>=2;+=.1;%(1400,0,350,440)"/>
   <X-PRE-PROCESS cmd="set" data="sit=%(274,0,913.8);%(274,0,1370.6);%(380,0,1776.7)"/>

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


--- freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp	2010-01-02 22:06:42 UTC (rev 16122)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp	2010-01-03 04:22:30 UTC (rev 16123)
@@ -20,20 +20,61 @@
 
 void FSHost::run(void)
 {
-    switch_core_flag_t flags = SCF_USE_SQL; //| SCF_USE_AUTO_NAT;
+    switch_core_flag_t flags = SCF_USE_SQL | SCF_USE_AUTO_NAT;
     const char *err = NULL;
     switch_bool_t console = SWITCH_FALSE;
     switch_status_t destroy_status;
 
-    QDir conf_dir = QDir(QCoreApplication::applicationDirPath());
-    if (conf_dir.cd("conf"))
+    /* Create directory structure for softphone with default configs */
+    QDir conf_dir = QDir(QDir::home());
+    if (!conf_dir.exists(".fsphone"))
     {
-        SWITCH_GLOBAL_dirs.conf_dir = (char *) malloc(strlen(conf_dir.absolutePath().toAscii().constData()) + 1);
+        conf_dir.mkpath(".fsphone/conf/accounts");
+        QFile rootXML(":/confs/freeswitch.xml");
+        QString dest = QString("%1/.fsphone/conf/freeswitch.xml").arg(conf_dir.absolutePath());
+        rootXML.copy(dest);
+
+        QFile defaultAccount(":/confs/example.xml");
+        dest = QString("%1/.fsphone/conf/accounts/example.xml").arg(conf_dir.absolutePath());
+        defaultAccount.copy(dest);
+    }
+    if (conf_dir.cd(".fsphone"))
+    {
+        SWITCH_GLOBAL_dirs.conf_dir = (char *) malloc(strlen(QString("%1/conf").arg(conf_dir.absolutePath()).toAscii().constData()) + 1);
         if (!SWITCH_GLOBAL_dirs.conf_dir) {
-            fprintf(stderr, "Allocation error\n");
-            emit coreLoadingError(err);
+            emit coreLoadingError("Cannot allocate memory for conf_dir.");
         }
-        strcpy(SWITCH_GLOBAL_dirs.conf_dir, conf_dir.absolutePath().toAscii().constData());
+        strcpy(SWITCH_GLOBAL_dirs.conf_dir, QString("%1/conf").arg(conf_dir.absolutePath()).toAscii().constData());
+
+        SWITCH_GLOBAL_dirs.log_dir = (char *) malloc(strlen(QString("%1/log").arg(conf_dir.absolutePath()).toAscii().constData()) + 1);
+        if (!SWITCH_GLOBAL_dirs.log_dir) {
+            emit coreLoadingError("Cannot allocate memory for log_dir.");
+        }
+        strcpy(SWITCH_GLOBAL_dirs.log_dir, QString("%1/log").arg(conf_dir.absolutePath()).toAscii().constData());
+
+        SWITCH_GLOBAL_dirs.run_dir = (char *) malloc(strlen(QString("%1/run").arg(conf_dir.absolutePath()).toAscii().constData()) + 1);
+        if (!SWITCH_GLOBAL_dirs.run_dir) {
+            emit coreLoadingError("Cannot allocate memory for run_dir.");
+        }
+        strcpy(SWITCH_GLOBAL_dirs.run_dir, QString("%1/run").arg(conf_dir.absolutePath()).toAscii().constData());
+
+        SWITCH_GLOBAL_dirs.db_dir = (char *) malloc(strlen(QString("%1/db").arg(conf_dir.absolutePath()).toAscii().constData()) + 1);
+        if (!SWITCH_GLOBAL_dirs.db_dir) {
+            emit coreLoadingError("Cannot allocate memory for db_dir.");
+        }
+        strcpy(SWITCH_GLOBAL_dirs.db_dir, QString("%1/db").arg(conf_dir.absolutePath()).toAscii().constData());
+
+        SWITCH_GLOBAL_dirs.script_dir = (char *) malloc(strlen(QString("%1/script").arg(conf_dir.absolutePath()).toAscii().constData()) + 1);
+        if (!SWITCH_GLOBAL_dirs.script_dir) {
+            emit coreLoadingError("Cannot allocate memory for script_dir.");
+        }
+        strcpy(SWITCH_GLOBAL_dirs.script_dir, QString("%1/script").arg(conf_dir.absolutePath()).toAscii().constData());
+
+        SWITCH_GLOBAL_dirs.htdocs_dir = (char *) malloc(strlen(QString("%1/htdocs").arg(conf_dir.absolutePath()).toAscii().constData()) + 1);
+        if (!SWITCH_GLOBAL_dirs.htdocs_dir) {
+            emit coreLoadingError("Cannot allocate memory for htdocs_dir.");
+        }
+        strcpy(SWITCH_GLOBAL_dirs.htdocs_dir, QString("%1/htdocs").arg(conf_dir.absolutePath()).toAscii().constData());
     }
 
     /* If you need to override configuration directories, you need to change them in the SWITCH_GLOBAL_dirs global structure */

Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/resources.qrc (16122 => 16123)


--- freeswitch/trunk/contrib/jmesquita/FSPhone/resources.qrc	2010-01-02 22:06:42 UTC (rev 16122)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/resources.qrc	2010-01-03 04:22:30 UTC (rev 16123)
@@ -2,4 +2,8 @@
     <qresource prefix="/images">
         <file alias="splash.png">resources/splash.png</file>
     </qresource>
+    <qresource prefix="/confs">
+        <file alias="freeswitch.xml">conf/freeswitch.xml</file>
+        <file alias="example.xml">conf/accounts/example.xml</file>
+    </qresource>
 </RCC>