summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-01-18 20:10:44 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-01-18 20:27:37 (GMT)
commit0d3d7579032959203c5c52f5ced9de5494c7b0bf (patch)
tree1e166cbae3dac23e8f815bc32f856b6c0a666fbd /Swiften
parentc2580661a20e30abaa23c61808d6370a575665c1 (diff)
downloadswift-contrib-0d3d7579032959203c5c52f5ced9de5494c7b0bf.zip
swift-contrib-0d3d7579032959203c5c52f5ced9de5494c7b0bf.tar.bz2
Cleaned up some code.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Compress/ZLibCodecompressor.cpp1
-rw-r--r--Swiften/Config/swiften-config.cpp13
-rw-r--r--Swiften/Elements/FormField.h2
-rw-r--r--Swiften/Elements/MUCUserPayload.h2
-rw-r--r--Swiften/EventLoop/Event.h3
-rw-r--r--Swiften/EventLoop/EventLoop.cpp17
-rw-r--r--Swiften/MUC/MUCBookmark.h2
-rw-r--r--Swiften/Parser/PayloadParsers/CommandParser.cpp2
-rw-r--r--Swiften/Parser/PayloadParsers/RosterParser.cpp2
-rw-r--r--Swiften/Roster/ContactRosterItem.h1
-rw-r--r--Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp6
-rw-r--r--Swiften/Server/ServerFromClientSession.cpp3
12 files changed, 36 insertions, 18 deletions
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) {
}