diff options
author | Remko Tronçon <git@el-tramo.be> | 2013-05-15 19:44:37 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2013-05-17 19:00:55 (GMT) |
commit | de39ce6ec44647cee92853e2928cf5475af992e6 (patch) | |
tree | 1f86dd075900aeeb9b91cdd120d71052458ca6ff /SwifTools/Notifier | |
parent | 927d62cc54c8a5087dba6b61afa9ad30dc528a23 (diff) | |
download | swift-de39ce6ec44647cee92853e2928cf5475af992e6.zip swift-de39ce6ec44647cee92853e2928cf5475af992e6.tar.bz2 |
Fixed unicode path handling.
- Use boost::filesystem::path consistently for referring to files.
- Use boost::filesystem streams for I/O, such that paths are always handled
correctly.
- Use stringToPath and pathToString for conversion between strings and
boost::filesystem::path, to ensure we have consistent unicode handling
across platforms and environments. The default constructor and string
conversion uses platform-dependent encoding, depending on the global
locale set in the application, which causes problems. So, unless you are
in platform dependent code, the default constructor and string() function
should not be used. When constructing paths from other paths (e.g. using
operator/), also use stringToPath (instead of string arguments) if the path
can contain unicode characters.
Change-Id: If286bd9e71c8414afc0b24ba67e26ab7608ef6ea
Diffstat (limited to 'SwifTools/Notifier')
-rw-r--r-- | SwifTools/Notifier/GNTPNotifier.cpp | 5 | ||||
-rw-r--r-- | SwifTools/Notifier/GrowlNotifier.mm | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/SwifTools/Notifier/GNTPNotifier.cpp b/SwifTools/Notifier/GNTPNotifier.cpp index 9bc05bd..757594f 100644 --- a/SwifTools/Notifier/GNTPNotifier.cpp +++ b/SwifTools/Notifier/GNTPNotifier.cpp @@ -14,6 +14,7 @@ #include <sstream> #include <Swiften/Base/foreach.h> +#include <Swiften/Base/Path.h> #include <Swiften/Network/ConnectionFactory.h> namespace Swift { @@ -23,7 +24,7 @@ GNTPNotifier::GNTPNotifier(const std::string& name, const boost::filesystem::pat std::ostringstream message; message << "GNTP/1.0 REGISTER NONE\r\n"; message << "Application-Name: " << name << "\r\n"; - message << "Application-Icon: file://" << icon.string() << "\r\n"; + message << "Application-Icon: file://" << pathToString(icon) << "\r\n"; message << "Notifications-Count: " << getAllTypes().size() << "\r\n"; std::vector<Notifier::Type> defaultTypes = getDefaultTypes(); std::vector<Notifier::Type> allTypes = getAllTypes(); @@ -59,7 +60,7 @@ void GNTPNotifier::showMessage(Type type, const std::string& subject, const std: message << "Notification-Name: " << typeToString(type) << "\r\n"; message << "Notification-Title: " << subject << "\r\n"; message << "Notification-Text: " << description << "\r\n"; - message << "Notification-Icon: " << picture.string() << "\r\n"; + message << "Notification-Icon: " << pathToString(picture) << "\r\n"; message << "\r\n"; send(message.str()); } diff --git a/SwifTools/Notifier/GrowlNotifier.mm b/SwifTools/Notifier/GrowlNotifier.mm index c1996d9..2ababf4 100644 --- a/SwifTools/Notifier/GrowlNotifier.mm +++ b/SwifTools/Notifier/GrowlNotifier.mm @@ -65,7 +65,7 @@ GrowlNotifier::~GrowlNotifier() { void GrowlNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picturePath, boost::function<void()> callback) { ByteArray picture; - readByteArrayFromFile(picture, picturePath.string()); + readByteArrayFromFile(picture, picturePath); Context* context = new Context(callback); // Growl sometimes sends timeout notifications twice for the same message. We therefore need |