diff options
-rw-r--r-- | SwifTools/Application/UnixApplicationPathProvider.cpp | 3 | ||||
-rw-r--r-- | SwifTools/Idle/IdleDetector.h | 4 | ||||
-rw-r--r-- | Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp | 4 | ||||
-rw-r--r-- | Swift/QtUI/ContextMenus/QtRosterContextMenu.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/MUCSearch/MUCSearchModel.cpp | 9 | ||||
-rw-r--r-- | Swift/QtUI/QtSwift.cpp | 2 | ||||
-rw-r--r-- | Swift/QtUI/QtSwift.h | 2 | ||||
-rw-r--r-- | Swiften/Compress/ZLibCodecompressor.cpp | 1 | ||||
-rw-r--r-- | Swiften/Config/swiften-config.cpp | 13 | ||||
-rw-r--r-- | Swiften/Elements/FormField.h | 2 | ||||
-rw-r--r-- | Swiften/Elements/MUCUserPayload.h | 2 | ||||
-rw-r--r-- | Swiften/EventLoop/Event.h | 3 | ||||
-rw-r--r-- | Swiften/EventLoop/EventLoop.cpp | 17 | ||||
-rw-r--r-- | Swiften/MUC/MUCBookmark.h | 2 | ||||
-rw-r--r-- | Swiften/Parser/PayloadParsers/CommandParser.cpp | 2 | ||||
-rw-r--r-- | Swiften/Parser/PayloadParsers/RosterParser.cpp | 2 | ||||
-rw-r--r-- | Swiften/Roster/ContactRosterItem.h | 1 | ||||
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp | 6 | ||||
-rw-r--r-- | Swiften/Server/ServerFromClientSession.cpp | 3 |
19 files changed, 51 insertions, 29 deletions
diff --git a/SwifTools/Application/UnixApplicationPathProvider.cpp b/SwifTools/Application/UnixApplicationPathProvider.cpp index c5a2782..06fa977 100644 --- a/SwifTools/Application/UnixApplicationPathProvider.cpp +++ b/SwifTools/Application/UnixApplicationPathProvider.cpp @@ -25,7 +25,8 @@ UnixApplicationPathProvider::UnixApplicationPathProvider(const String& name) : A } boost::filesystem::path UnixApplicationPathProvider::getHomeDir() const { - return boost::filesystem::path(getenv("HOME")); + char* home = getenv("HOME"); + return home ? boost::filesystem::path(home) : boost::filesystem::path(); } boost::filesystem::path UnixApplicationPathProvider::getDataDir() const { diff --git a/SwifTools/Idle/IdleDetector.h b/SwifTools/Idle/IdleDetector.h index 051facc..746e281 100644 --- a/SwifTools/Idle/IdleDetector.h +++ b/SwifTools/Idle/IdleDetector.h @@ -12,7 +12,7 @@ namespace Swift { class IdleDetector { public: - IdleDetector() : idle(false) {} + IdleDetector() : idle(false), idleTimeSeconds(300) {} virtual ~IdleDetector(); void setIdleTimeSeconds(int time) { @@ -38,7 +38,7 @@ namespace Swift { } private: - int idleTimeSeconds; bool idle; + int idleTimeSeconds; }; } diff --git a/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp b/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp index 1c2fc4b..9bbbbca 100644 --- a/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp +++ b/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp @@ -28,9 +28,7 @@ namespace Swift { -QtRosterContextMenu::QtRosterContextMenu(UIEventStream* eventStream, QtTreeWidget* treeWidget) { - eventStream_ = eventStream; - treeWidget_ = treeWidget; +QtRosterContextMenu::QtRosterContextMenu(UIEventStream* eventStream, QtTreeWidget* treeWidget) : eventStream_(eventStream), treeWidget_(treeWidget), item_(NULL) { } void QtRosterContextMenu::show(RosterItem* item) { diff --git a/Swift/QtUI/ContextMenus/QtRosterContextMenu.h b/Swift/QtUI/ContextMenus/QtRosterContextMenu.h index 53f4bdd..0a88a8e 100644 --- a/Swift/QtUI/ContextMenus/QtRosterContextMenu.h +++ b/Swift/QtUI/ContextMenus/QtRosterContextMenu.h @@ -27,8 +27,8 @@ namespace Swift { void handleRegroupContact(); private: - RosterItem* item_; UIEventStream* eventStream_; QtTreeWidget* treeWidget_; + RosterItem* item_; }; } diff --git a/Swift/QtUI/MUCSearch/MUCSearchModel.cpp b/Swift/QtUI/MUCSearch/MUCSearchModel.cpp index eb7fe20..2526039 100644 --- a/Swift/QtUI/MUCSearch/MUCSearchModel.cpp +++ b/Swift/QtUI/MUCSearch/MUCSearchModel.cpp @@ -59,8 +59,13 @@ QModelIndex MUCSearchModel::parent(const QModelIndex& index) const { return QModelIndex(); } MUCSearchServiceItem* parent = dynamic_cast<MUCSearchRoomItem*>(item)->getParent(); - int row = services_.indexOf(parent); - return parent ? createIndex(row, 1, parent) : QModelIndex(); + if (parent) { + int row = services_.indexOf(parent); + return createIndex(row, 1, parent); + } + else { + return QModelIndex(); + } } int MUCSearchModel::rowCount(const QModelIndex& parentIndex) const { diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp index 8852d54..1c14dee 100644 --- a/Swift/QtUI/QtSwift.cpp +++ b/Swift/QtUI/QtSwift.cpp @@ -70,7 +70,7 @@ po::options_description QtSwift::getOptionsDescription() { } -QtSwift::QtSwift(po::variables_map options) : networkFactories_(&clientMainThreadCaller_), autoUpdater_(NULL) { +QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMainThreadCaller_), autoUpdater_(NULL) { if (options.count("netbook-mode")) { splitter_ = new QSplitter(); } else { diff --git a/Swift/QtUI/QtSwift.h b/Swift/QtUI/QtSwift.h index ca6e126..cc9eb38 100644 --- a/Swift/QtUI/QtSwift.h +++ b/Swift/QtUI/QtSwift.h @@ -48,7 +48,7 @@ namespace Swift { class QtSwift : public QObject { Q_OBJECT public: - QtSwift(po::variables_map options); + QtSwift(const po::variables_map& options); static po::options_description getOptionsDescription(); ~QtSwift(); private: diff --git a/Swiften/Compress/ZLibCodecompressor.cpp b/Swiften/Compress/ZLibCodecompressor.cpp index 4a3c6b6..39f318b 100644 --- a/Swiften/Compress/ZLibCodecompressor.cpp +++ b/Swiften/Compress/ZLibCodecompressor.cpp @@ -15,6 +15,7 @@ namespace Swift { static const int CHUNK_SIZE = 1024; // If you change this, also change the unittest ZLibCodecompressor::ZLibCodecompressor() { + memset(&stream_, 0, sizeof(z_stream)); stream_.zalloc = Z_NULL; stream_.zfree = Z_NULL; stream_.opaque = Z_NULL; diff --git a/Swiften/Config/swiften-config.cpp b/Swiften/Config/swiften-config.cpp index 832618d..4f4016e 100644 --- a/Swiften/Config/swiften-config.cpp +++ b/Swiften/Config/swiften-config.cpp @@ -40,14 +40,19 @@ int main(int argc, char* argv[]) { boost::program_options::variables_map vm; try { boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm); - } catch (boost::program_options::unknown_option option) { + boost::program_options::notify(vm); + } + catch (const boost::program_options::unknown_option& option) { #if BOOST_VERSION >= 104200 - std::cout << "Ignoring unknown option " << option.get_option_name() << " but continuing." << std::endl; + std::cout << "Ignoring unknown option " << option.get_option_name() << std::endl; #else - std::cout << "Error: " << option.what() << " (continuing)" << std::endl; + std::cout << "Error: " << option.what() << std::endl; #endif } - boost::program_options::notify(vm); + catch (const boost::program_options::error& e) { + std::cout << "Error: " << e.what() << std::endl; + return -1; + } if (vm.count("help") > 0) { std::cout << desc << "\n"; diff --git a/Swiften/Elements/FormField.h b/Swiften/Elements/FormField.h index a0240e1..0221dae 100644 --- a/Swiften/Elements/FormField.h +++ b/Swiften/Elements/FormField.h @@ -79,7 +79,7 @@ namespace Swift { } protected: - GenericFormField() {} + GenericFormField() : value() {} GenericFormField(const T& value) : value(value) {} private: diff --git a/Swiften/Elements/MUCUserPayload.h b/Swiften/Elements/MUCUserPayload.h index 2014bc4..2364b6c 100644 --- a/Swiften/Elements/MUCUserPayload.h +++ b/Swiften/Elements/MUCUserPayload.h @@ -28,7 +28,7 @@ namespace Swift { }; struct StatusCode { - StatusCode() {} + StatusCode() : code(0) {} int code; }; diff --git a/Swiften/EventLoop/Event.h b/Swiften/EventLoop/Event.h index 763fe00..6f5a9e5 100644 --- a/Swiften/EventLoop/Event.h +++ b/Swiften/EventLoop/Event.h @@ -14,8 +14,7 @@ namespace Swift { class Event { public: - Event(boost::shared_ptr<EventOwner> owner, const boost::function<void()>& callback) : - owner(owner), callback(callback) { + Event(boost::shared_ptr<EventOwner> owner, const boost::function<void()>& callback) : id(~0U), owner(owner), callback(callback) { } bool operator==(const Event& o) const { diff --git a/Swiften/EventLoop/EventLoop.cpp b/Swiften/EventLoop/EventLoop.cpp index f787e73..c6d42d8 100644 --- a/Swiften/EventLoop/EventLoop.cpp +++ b/Swiften/EventLoop/EventLoop.cpp @@ -10,6 +10,8 @@ #include <boost/bind.hpp> #include <iostream> +#include <Swiften/Base/Log.h> + namespace Swift { EventLoop::EventLoop() : nextEventID_(0), handlingEvents_(false) { @@ -37,13 +39,24 @@ void EventLoop::handleEvent(const Event& event) { } if (doCallback) { handlingEvents_ = true; - event.callback(); + try { + event.callback(); + } + catch (const boost::bad_function_call&) { + SWIFT_LOG(error) << "Invalid function call" << std::endl; + } + // Process events that were passed to handleEvent during the callback // (i.e. through recursive calls of handleEvent) while (!eventsToHandle_.empty()) { Event nextEvent = eventsToHandle_.front(); eventsToHandle_.pop_front(); - nextEvent.callback(); + try { + nextEvent.callback(); + } + catch (const boost::bad_function_call&) { + SWIFT_LOG(error) << "Invalid function call" << std::endl; + } } handlingEvents_ = false; } diff --git a/Swiften/MUC/MUCBookmark.h b/Swiften/MUC/MUCBookmark.h index 28530d8..65797e5 100644 --- a/Swiften/MUC/MUCBookmark.h +++ b/Swiften/MUC/MUCBookmark.h @@ -23,7 +23,7 @@ namespace Swift { autojoin_ = room.autoJoin; } - MUCBookmark(const JID& room, const String& bookmarkName) : room_(room), name_(bookmarkName) { + MUCBookmark(const JID& room, const String& bookmarkName) : room_(room), name_(bookmarkName), autojoin_(false) { } void setAutojoin(bool enabled) { diff --git a/Swiften/Parser/PayloadParsers/CommandParser.cpp b/Swiften/Parser/PayloadParsers/CommandParser.cpp index b07b806..76e4564 100644 --- a/Swiften/Parser/PayloadParsers/CommandParser.cpp +++ b/Swiften/Parser/PayloadParsers/CommandParser.cpp @@ -10,7 +10,7 @@ namespace Swift { -CommandParser::CommandParser() : level_(TopLevel), inNote_(false), inActions_(false), formParser_(0) { +CommandParser::CommandParser() : level_(TopLevel), inNote_(false), inActions_(false), noteType_(Command::Note::Info), formParser_(0) { formParserFactory_ = new FormParserFactory(); } diff --git a/Swiften/Parser/PayloadParsers/RosterParser.cpp b/Swiften/Parser/PayloadParsers/RosterParser.cpp index 6db2b30..a8dd63e 100644 --- a/Swiften/Parser/PayloadParsers/RosterParser.cpp +++ b/Swiften/Parser/PayloadParsers/RosterParser.cpp @@ -9,7 +9,7 @@ namespace Swift { -RosterParser::RosterParser() : level_(TopLevel), unknownContentParser_(0) { +RosterParser::RosterParser() : level_(TopLevel), inItem_(false), unknownContentParser_(0) { } void RosterParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { diff --git a/Swiften/Roster/ContactRosterItem.h b/Swiften/Roster/ContactRosterItem.h index 707dd42..cb30989 100644 --- a/Swiften/Roster/ContactRosterItem.h +++ b/Swiften/Roster/ContactRosterItem.h @@ -44,7 +44,6 @@ class ContactRosterItem : public RosterItem { JID jid_; JID displayJID_; String avatarPath_; - bool hidden_; std::map<String, boost::shared_ptr<Presence> > presences_; boost::shared_ptr<Presence> offlinePresence_; boost::shared_ptr<Presence> shownPresence_; diff --git a/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp b/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp index eb45ca2..b29a634 100644 --- a/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp @@ -62,9 +62,9 @@ String CommandSerializer::serializePayload(boost::shared_ptr<Command> command) c boost::shared_ptr<XMLElement> noteElement(new XMLElement("note")); String type; switch (note.type) { - case Command::Note::Info: type = "info"; - case Command::Note::Warn: type = "warn"; - case Command::Note::Error: type = "error"; + case Command::Note::Info: type = "info"; break; + case Command::Note::Warn: type = "warn"; break; + case Command::Note::Error: type = "error"; break; } if (!type.isEmpty()) { noteElement->setAttribute("type", type); diff --git a/Swiften/Server/ServerFromClientSession.cpp b/Swiften/Server/ServerFromClientSession.cpp index e63b9e2..1c47cef 100644 --- a/Swiften/Server/ServerFromClientSession.cpp +++ b/Swiften/Server/ServerFromClientSession.cpp @@ -33,7 +33,8 @@ ServerFromClientSession::ServerFromClientSession( id_(id), userRegistry_(userRegistry), authenticated_(false), - initialized(false) { + initialized(false), + allowSASLEXTERNAL(false) { } |