[dasher: 167/217] Fix the linux build.



commit d967b9b2467acd4e2f2e886d419ce9f13b3e044b
Author: lbaudoin <lbaudoin google com>
Date:   Sun Jan 10 07:24:34 2016 -0700

    Fix the linux build.

 Data/Makefile.am         |   51 ----------------------------------------------
 Src/Gtk2/FileUtils.cpp   |   28 ++++++++++---------------
 Src/Gtk2/Makefile.am     |    2 -
 Src/Gtk2/dasher_main.cpp |    8 +++++-
 configure.ac             |    1 +
 5 files changed, 18 insertions(+), 72 deletions(-)
---
diff --git a/Data/Makefile.am b/Data/Makefile.am
index da4de15..eff4a64 100644
--- a/Data/Makefile.am
+++ b/Data/Makefile.am
@@ -17,57 +17,6 @@ svgicon_DATA = dasher.svg
 
 gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
 
-if USE_GCONF
-if GCONF_SCHEMAS_INSTALL
-schemasdir = $(GCONF_SCHEMA_FILE_DIR)
-schemas_DATA = dasher.schemas
-
-install-data-local: install-schemas
-
-# A note on what happens here, as it's a custome step. The GConf
-# schema is generated directely from the data structures in the
-# SettingsStore and AppSettings objects, so they stay in sync. This is
-# done by building generate-schema, a small, non-installed program in
-# Src/Gtk2/. At install time this gets run to build the schema file,
-# which is then moved installed in the usual way. None of this happens
-# if configure is told not to install schemas.
-
-dasher.schemas: $(top_builddir)/Src/Gtk2/generate-schema
-       @echo -n "Generating GConf schema ... "; \
-       $(top_builddir)/Src/Gtk2/generate-schema -c > dasher.schemas; \
-       echo "done.";
-
-install-schemas: dasher.schemas
-       GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \
-       gconftool-2 --makefile-install-rule dasher.schemas
-
-compile-schemas:
-# GCONF_SCHEMAS_INSTALL
-endif
-# !USE_GCONF
-else
-if USE_GSETTINGS
-schemasdir = $(datadir)/glib-2.0/schemas
-schemas_DATA = dasher.gschema.xml
-
-check-local: check-schemas
-
-dasher.gschema.xml: $(top_builddir)/Src/Gtk2/generate-schema
-       @echo -n "Generating GSettings schema ... "; \
-       $(top_builddir)/Src/Gtk2/generate-schema -s > dasher.gschema.xml; \
-       echo "done.";
-
-compile-schemas: dasher.gschema.xml
-       $(GLIB_COMPILE_SCHEMAS) --allow-any-name $(schemasdir)
-
-check-schemas: dasher.gschema.xml
-       $(GLIB_COMPILE_SCHEMAS) --allow-any-name --dry-run --schema-file=dasher.gschema.xml
-else
-compile-schemas:
-endif
-endif
-
-
 install-data-hook: update-icon-cache compile-schemas
 
 uninstall-hook: update-icon-cache
diff --git a/Src/Gtk2/FileUtils.cpp b/Src/Gtk2/FileUtils.cpp
index 58f72e9..d0f07dc 100644
--- a/Src/Gtk2/FileUtils.cpp
+++ b/Src/Gtk2/FileUtils.cpp
@@ -1,4 +1,5 @@
 #include <string>
+#include <stdio.h>
 
 #include "../Common/Globber.h"
 #include "../DasherCore/AbstractXMLParser.h"
@@ -36,24 +37,17 @@ void FileUtils::ScanFiles(AbstractParser *parser, const std::string &strPattern)
   globScan(parser, user, sys);
 }
 
-
 bool FileUtils::WriteUserDataFile(const std::string &filename, const std::string &strNewText, bool append) {
   if (strNewText.length() == 0)
     return true;
-
-  std::string user_data_dir = getenv("HOME");
-  user_data_dir += "/.dasher/";
-  std::string strFilename(user_data_dir);
-  strFilename = filename;
-  int mode = O_CREAT | O_WRONLY;
-  if (append)
-  {
-    mode = O_CREAT | O_WRONLY | O_APPEND;
-  }
-  int fd = open(strFilename.c_str(), mode, S_IRUSR | S_IWUSR);
-  if (!fd) return false;
- 
-  int written = write(fd, strNewText.c_str(), strNewText.length());
-  close(fd);
+  std::string strFilename = getenv("HOME");
+  strFilename += "/.dasher/";
+  strFilename += filename;
+  FILE* f = fopen(strFilename.c_str(), append ? "a+" : "w+");
+  if (f == nullptr)
+    return false;
+
+  int written = fwrite(strNewText.c_str(), 1, strNewText.length(), f);
+  fclose(f);
   return written == strNewText.length();
-
+}
\ No newline at end of file
diff --git a/Src/Gtk2/Makefile.am b/Src/Gtk2/Makefile.am
index ea912fb..d8d3f1c 100644
--- a/Src/Gtk2/Makefile.am
+++ b/Src/Gtk2/Makefile.am
@@ -45,8 +45,6 @@ libdashercontrol_la_SOURCES = \
                mouse_input.h \
                $(settings_store)
 
-endif
-
 if USE_SPEECHDISPATCHER
 libdashercontrol_la_SOURCES += SpeechDispatcher.cpp
 endif
diff --git a/Src/Gtk2/dasher_main.cpp b/Src/Gtk2/dasher_main.cpp
index 7164e65..96d980d 100644
--- a/Src/Gtk2/dasher_main.cpp
+++ b/Src/Gtk2/dasher_main.cpp
@@ -27,6 +27,7 @@
 
 #include "dasher_main_private.h"
 #include "XmlSettingsStore.h"
+#include "FileUtils.h"
 
 enum {
   REALIZED,
@@ -173,8 +174,11 @@ dasher_main_new(int *argc, char ***argv, SCommandLine *pCommandLine) {
     DasherMain *pDasherMain = (DasherMain *)(g_object_new(dasher_main_get_type(), NULL));
     DasherMainPrivate *pPrivate = DASHER_MAIN_GET_PRIVATE(pDasherMain);
   string configFileName = "settings.xml";
-  if (pCommandLine->szConfigFile != nullptr)
-    configFileName = "settings." + pCommandLine->szConfigFile + ".xml";
+  if (pCommandLine->szConfigFile != nullptr) {
+    configFileName = "settings.";
+    configFileName += pCommandLine->szConfigFile;
+    configFileName += ".xml";
+  }
   static XmlErrorDisplay display;
   // TODO Pass that instance of fileutils to DasherControl, instead of creating new one. 
   static FileUtils fileUtils;
diff --git a/configure.ac b/configure.ac
index 4497ab0..0dd6aff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -452,6 +452,7 @@ AC_CONFIG_FILES([Data/dasher.desktop.in
                 Data/GUI/Makefile
                 Data/Help/Makefile
                 Data/Help/Gnome/Makefile
+                Data/settings/Makefile
                 Doc/Makefile
                 Doc/user/Makefile
                 Makefile


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]