From 826f83e8bfc8052656ebea84f3e538135949ca82 Mon Sep 17 00:00:00 2001
From: Andreas Preikschat <googol@lavabit.com>
Date: Mon, 18 Jun 2012 19:00:27 +0200
Subject: [PATCH 1/4] fixed 1014684 (OpenLP doesn't start on Windows XP)

Fixes: https://launchpad.net/bugs/1014684
---
 openlp/core/ui/firsttimeform.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py
index 1866b88b5..75f87aa65 100644
--- a/openlp/core/ui/firsttimeform.py
+++ b/openlp/core/ui/firsttimeform.py
@@ -114,7 +114,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
         Set up display at start of theme edit.
         """
         self.restart()
-        check_directory_exists(os.path.join(gettempdir(), u'openlp'))
+        check_directory_exists(os.path.join(uniocde(gettempdir()), u'openlp'))
         self.noInternetFinishButton.setVisible(False)
         # Check if this is a re-run of the wizard.
         self.hasRunWizard = Settings().value(

From 155e99d307fba0396da7f68624efd07763e13bea Mon Sep 17 00:00:00 2001
From: Andreas Preikschat <googol@lavabit.com>
Date: Tue, 19 Jun 2012 18:09:59 +0200
Subject: [PATCH 2/4] fixed other occurrences

---
 openlp/core/ui/firsttimeform.py                 | 6 +++---
 openlp/plugins/bibles/forms/bibleupgradeform.py | 2 +-
 openlp/plugins/songs/songsplugin.py             | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py
index 75f87aa65..3e902b368 100644
--- a/openlp/core/ui/firsttimeform.py
+++ b/openlp/core/ui/firsttimeform.py
@@ -64,7 +64,7 @@ class ThemeScreenshotThread(QtCore.QThread):
             filename = config.get(u'theme_%s' % theme, u'filename')
             screenshot = config.get(u'theme_%s' % theme, u'screenshot')
             urllib.urlretrieve(u'%s%s' % (self.parent().web, screenshot),
-                os.path.join(gettempdir(), u'openlp', screenshot))
+                os.path.join(unicode(gettempdir()), u'openlp', screenshot))
             item = QtGui.QListWidgetItem(title, self.parent().themesListWidget)
             item.setData(QtCore.Qt.UserRole, QtCore.QVariant(filename))
             item.setCheckState(QtCore.Qt.Unchecked)
@@ -114,7 +114,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
         Set up display at start of theme edit.
         """
         self.restart()
-        check_directory_exists(os.path.join(uniocde(gettempdir()), u'openlp'))
+        check_directory_exists(os.path.join(unicode(gettempdir()), u'openlp'))
         self.noInternetFinishButton.setVisible(False)
         # Check if this is a re-run of the wizard.
         self.hasRunWizard = Settings().value(
@@ -304,7 +304,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
                 if item.data(QtCore.Qt.UserRole) == QtCore.QVariant(filename):
                     break
             item.setIcon(build_icon(
-                os.path.join(gettempdir(), u'openlp', screenshot)))
+                os.path.join(unicode(gettempdir()), u'openlp', screenshot)))
 
     def _getFileSize(self, url):
         site = urllib.urlopen(url)
diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py
index 4013284e4..d0c4333f4 100644
--- a/openlp/plugins/bibles/forms/bibleupgradeform.py
+++ b/openlp/plugins/bibles/forms/bibleupgradeform.py
@@ -71,7 +71,7 @@ class BibleUpgradeForm(OpenLPWizard):
         self.suffix = u'.sqlite'
         self.settingsSection = u'bibles'
         self.path = AppLocation.get_section_data_path(self.settingsSection)
-        self.temp_dir = os.path.join(gettempdir(), u'openlp')
+        self.temp_dir = os.path.join(unicode(gettempdir()), u'openlp')
         self.files = self.manager.old_bible_databases
         self.success = {}
         self.newbibles = {}
diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py
index 468c02968..0beead20a 100644
--- a/openlp/plugins/songs/songsplugin.py
+++ b/openlp/plugins/songs/songsplugin.py
@@ -233,7 +233,7 @@ class SongsPlugin(Plugin):
         new songs into the database.
         """
         self.onToolsReindexItemTriggered()
-        db_dir = unicode(os.path.join(gettempdir(), u'openlp'))
+        db_dir = unicode(os.path.join(unicode(gettempdir()), u'openlp'))
         if not os.path.exists(db_dir):
             return
         song_dbs = []

From ab8e6ee30ae0e1d7bc150e932f75a7594599568d Mon Sep 17 00:00:00 2001
From: Andreas Preikschat <googol@lavabit.com>
Date: Fri, 22 Jun 2012 22:12:43 +0200
Subject: [PATCH 3/4] use get_filesystem_encoding

---
 openlp/core/ui/firsttimeform.py                 | 14 ++++++++------
 openlp/core/ui/mainwindow.py                    |  4 ++--
 openlp/plugins/bibles/forms/bibleupgradeform.py |  5 +++--
 openlp/plugins/songs/songsplugin.py             |  4 +++-
 4 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py
index 3e902b368..4597c6a16 100644
--- a/openlp/core/ui/firsttimeform.py
+++ b/openlp/core/ui/firsttimeform.py
@@ -40,7 +40,7 @@ from PyQt4 import QtCore, QtGui
 from openlp.core.lib import translate, PluginStatus, Receiver, build_icon, \
     check_directory_exists
 from openlp.core.lib.settings import Settings
-from openlp.core.utils import get_web_page, AppLocation
+from openlp.core.utils import get_web_page, AppLocation, get_filesystem_encoding
 from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage
 
 log = logging.getLogger(__name__)
@@ -64,7 +64,7 @@ class ThemeScreenshotThread(QtCore.QThread):
             filename = config.get(u'theme_%s' % theme, u'filename')
             screenshot = config.get(u'theme_%s' % theme, u'screenshot')
             urllib.urlretrieve(u'%s%s' % (self.parent().web, screenshot),
-                os.path.join(unicode(gettempdir()), u'openlp', screenshot))
+                os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp', screenshot))
             item = QtGui.QListWidgetItem(title, self.parent().themesListWidget)
             item.setData(QtCore.Qt.UserRole, QtCore.QVariant(filename))
             item.setCheckState(QtCore.Qt.Unchecked)
@@ -114,7 +114,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
         Set up display at start of theme edit.
         """
         self.restart()
-        check_directory_exists(os.path.join(unicode(gettempdir()), u'openlp'))
+        check_directory_exists(os.path.join(
+            unicode(gettempdir(), get_filesystem_encoding()), u'openlp'))
         self.noInternetFinishButton.setVisible(False)
         # Check if this is a re-run of the wizard.
         self.hasRunWizard = Settings().value(
@@ -303,8 +304,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
                 item = self.themesListWidget.item(index)
                 if item.data(QtCore.Qt.UserRole) == QtCore.QVariant(filename):
                     break
-            item.setIcon(build_icon(
-                os.path.join(unicode(gettempdir()), u'openlp', screenshot)))
+            item.setIcon(build_icon(os.path.join(unicode(gettempdir(),
+                get_filesystem_encoding()), u'openlp', screenshot)))
 
     def _getFileSize(self, url):
         site = urllib.urlopen(url)
@@ -425,7 +426,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
         self._setPluginStatus(self.alertCheckBox, u'alerts/status')
         if self.webAccess:
             # Build directories for downloads
-            songs_destination = os.path.join(unicode(gettempdir()), u'openlp')
+            songs_destination = os.path.join(
+                unicode(gettempdir(), get_filesystem_encoding()), u'openlp')
             bibles_destination = AppLocation.get_section_data_path(u'bibles')
             themes_destination = AppLocation.get_section_data_path(u'themes')
             # Download songs
diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py
index be58e1cd6..9db774153 100644
--- a/openlp/core/ui/mainwindow.py
+++ b/openlp/core/ui/mainwindow.py
@@ -1034,8 +1034,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
             # Make sure it's a .conf file.
         if not export_file_name.endswith(u'conf'):
             export_file_name = export_file_name + u'.conf'
-        temp_file = os.path.join(unicode(gettempdir()),
-            u'openlp', u'exportConf.tmp')
+        temp_file = os.path.join(unicode(gettempdir(),
+            get_filesystem_encoding()), u'openlp', u'exportConf.tmp')
         self.saveSettings()
         setting_sections = []
         # Add main sections.
diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py
index d0c4333f4..f799205c6 100644
--- a/openlp/plugins/bibles/forms/bibleupgradeform.py
+++ b/openlp/plugins/bibles/forms/bibleupgradeform.py
@@ -38,7 +38,7 @@ from openlp.core.lib import Receiver, SettingsManager, translate, \
 from openlp.core.lib.ui import UiStrings, critical_error_message_box
 from openlp.core.lib.settings import Settings
 from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
-from openlp.core.utils import AppLocation, delete_file
+from openlp.core.utils import AppLocation, delete_file, get_filesystem_encoding
 from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, OldBibleDB, \
     BiblesResourcesDB
 from openlp.plugins.bibles.lib.http import BSExtract, BGExtract, CWExtract
@@ -71,7 +71,8 @@ class BibleUpgradeForm(OpenLPWizard):
         self.suffix = u'.sqlite'
         self.settingsSection = u'bibles'
         self.path = AppLocation.get_section_data_path(self.settingsSection)
-        self.temp_dir = os.path.join(unicode(gettempdir()), u'openlp')
+        self.temp_dir = os.path.join(
+            unicode(gettempdir(), get_filesystem_encoding()), u'openlp')
         self.files = self.manager.old_bible_databases
         self.success = {}
         self.newbibles = {}
diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py
index 0beead20a..be92f615d 100644
--- a/openlp/plugins/songs/songsplugin.py
+++ b/openlp/plugins/songs/songsplugin.py
@@ -35,6 +35,7 @@ from openlp.core.lib import Plugin, StringContent, build_icon, translate, \
     Receiver
 from openlp.core.lib.db import Manager
 from openlp.core.lib.ui import UiStrings, create_action
+from openlp.core.utils import get_filesystem_encoding
 from openlp.core.utils.actions import ActionList
 from openlp.plugins.songs.lib import clean_song, upgrade, SongMediaItem, \
     SongsTab
@@ -233,7 +234,8 @@ class SongsPlugin(Plugin):
         new songs into the database.
         """
         self.onToolsReindexItemTriggered()
-        db_dir = unicode(os.path.join(unicode(gettempdir()), u'openlp'))
+        db_dir = unicode(os.path.join(
+            unicode(gettempdir(), get_filesystem_encoding()), u'openlp'))
         if not os.path.exists(db_dir):
             return
         song_dbs = []

From d3e8950db8bb0f00a8770923d70ba7ffa52fb0f1 Mon Sep 17 00:00:00 2001
From: Andreas Preikschat <googol@lavabit.com>
Date: Fri, 22 Jun 2012 22:18:50 +0200
Subject: [PATCH 4/4] fixed long line

---
 openlp/core/ui/firsttimeform.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py
index 4597c6a16..eda0eefec 100644
--- a/openlp/core/ui/firsttimeform.py
+++ b/openlp/core/ui/firsttimeform.py
@@ -64,7 +64,8 @@ class ThemeScreenshotThread(QtCore.QThread):
             filename = config.get(u'theme_%s' % theme, u'filename')
             screenshot = config.get(u'theme_%s' % theme, u'screenshot')
             urllib.urlretrieve(u'%s%s' % (self.parent().web, screenshot),
-                os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp', screenshot))
+                os.path.join(unicode(gettempdir(), get_filesystem_encoding()),
+                u'openlp', screenshot))
             item = QtGui.QListWidgetItem(title, self.parent().themesListWidget)
             item.setData(QtCore.Qt.UserRole, QtCore.QVariant(filename))
             item.setCheckState(QtCore.Qt.Unchecked)