summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2014-05-18 09:29:04 (GMT)
committerRemko Tronçon <git@el-tramo.be>2014-05-18 15:49:08 (GMT)
commit9bba31c6ce54290011a96723f720d872ecdbabca (patch)
treeeec68d77764e85957d4c25878010e34f29ee8410
parenta507d029d8995e27adf96a46f60a8ba696667f7e (diff)
downloadswift-contrib-9bba31c6ce54290011a96723f720d872ecdbabca.zip
swift-contrib-9bba31c6ce54290011a96723f720d872ecdbabca.tar.bz2
Fix uninitialized variables
Change-Id: I95b6b67dcafe338561d3dfb28664bc3bba6d1159
-rw-r--r--Swift/Controllers/HistoryController.cpp9
-rw-r--r--Swift/Controllers/Roster/ItemOperations/SetMUC.h3
-rw-r--r--Swift/Controllers/Storages/FileStorages.cpp4
-rw-r--r--Swift/Controllers/WhiteboardManager.cpp4
-rw-r--r--Swift/QtUI/QtAvatarWidget.cpp6
-rw-r--r--Swift/QtUI/QtPlainChatView.h1
-rw-r--r--Swift/QtUI/QtRosterHeader.cpp4
-rw-r--r--Swift/QtUI/QtSystemTray.cpp4
-rw-r--r--Swift/QtUI/QtVCardWidget/QtResizableLineEdit.cpp9
-rw-r--r--Swiften/Client/MemoryStorages.cpp4
-rw-r--r--Swiften/Elements/JingleContentPayload.h3
-rw-r--r--Swiften/Elements/JingleIBBTransportPayload.h5
-rw-r--r--Swiften/Elements/PubSubRetract.cpp2
-rw-r--r--Swiften/Elements/PubSubSubscribeOptions.cpp2
-rw-r--r--Swiften/Elements/StreamManagementEnabled.cpp4
-rw-r--r--Swiften/Elements/Whiteboard/WhiteboardLineElement.h9
-rw-r--r--Swiften/Elements/Whiteboard/WhiteboardRectElement.h8
-rw-r--r--Swiften/FileTransfer/FileTransfer.cpp4
-rw-r--r--Swiften/Network/BOSHConnection.cpp1
-rw-r--r--Swiften/Network/SOCKS5ProxiedConnection.cpp9
-rw-r--r--Swiften/Network/SOCKS5ProxiedConnection.h3
21 files changed, 71 insertions, 27 deletions
diff --git a/Swift/Controllers/HistoryController.cpp b/Swift/Controllers/HistoryController.cpp
index d730236..5732382 100644
--- a/Swift/Controllers/HistoryController.cpp
+++ b/Swift/Controllers/HistoryController.cpp
@@ -1,49 +1,56 @@
/*
* Copyright (c) 2012 Catalin Badea
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * Copyright (c) 2014 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+
#include <Swift/Controllers/HistoryController.h>
#include <Swiften/History/HistoryStorage.h>
#include <Swiften/History/HistoryMessage.h>
#include <boost/date_time/c_local_time_adjustor.hpp>
namespace Swift {
-HistoryController::HistoryController(HistoryStorage* localHistoryStorage) : localHistory_(localHistoryStorage) {
+HistoryController::HistoryController(HistoryStorage* localHistoryStorage) : localHistory_(localHistoryStorage), remoteArchiveSupported_(false) {
}
HistoryController::~HistoryController() {
}
void HistoryController::addMessage(const std::string& message, const JID& fromJID, const JID& toJID, HistoryMessage::Type type, const boost::posix_time::ptime& timeStamp) {
// note: using localtime timestamps
boost::posix_time::ptime localTime = boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local(timeStamp);
int offset = (localTime - timeStamp).hours();
HistoryMessage historyMessage(message, fromJID, toJID, type, localTime, offset);
localHistory_->addMessage(historyMessage);
onNewMessage(historyMessage);
}
std::vector<HistoryMessage> HistoryController::getMessagesFromDate(const JID& selfJID, const JID& contactJID, HistoryMessage::Type type, const boost::gregorian::date& date) const {
return localHistory_->getMessagesFromDate(selfJID, contactJID, type, date);
}
std::vector<HistoryMessage> HistoryController::getMUCContext(const JID& selfJID, const JID& mucJID, const boost::posix_time::ptime& timeStamp) const {
boost::posix_time::ptime localTime = boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local(timeStamp);
return getMessagesFromDate(selfJID, mucJID, HistoryMessage::Groupchat, localTime.date());
}
std::vector<HistoryMessage> HistoryController::getMessagesFromPreviousDate(const JID& selfJID, const JID& contactJID, HistoryMessage::Type type, const boost::gregorian::date& date) const {
return localHistory_->getMessagesFromPreviousDate(selfJID, contactJID, type, date);
}
std::vector<HistoryMessage> HistoryController::getMessagesFromNextDate(const JID& selfJID, const JID& contactJID, HistoryMessage::Type type, const boost::gregorian::date& date) const {
return localHistory_->getMessagesFromNextDate(selfJID, contactJID, type, date);
}
ContactsMap HistoryController::getContacts(const JID& selfJID, HistoryMessage::Type type, const std::string& keyword) const {
return localHistory_->getContacts(selfJID, type, keyword);
diff --git a/Swift/Controllers/Roster/ItemOperations/SetMUC.h b/Swift/Controllers/Roster/ItemOperations/SetMUC.h
index de40e04..598e5f5 100644
--- a/Swift/Controllers/Roster/ItemOperations/SetMUC.h
+++ b/Swift/Controllers/Roster/ItemOperations/SetMUC.h
@@ -1,39 +1,38 @@
/*
- * Copyright (c) 2013 Kevin Smith and Remko Tronçon
+ * Copyright (c) 2013-2014 Kevin Smith and Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma once
#include <Swiften/JID/JID.h>
#include <Swift/Controllers/Roster/ItemOperations/RosterItemOperation.h>
#include <Swift/Controllers/Roster/ContactRosterItem.h>
namespace Swift {
class RosterItem;
class SetMUC : public RosterItemOperation {
public:
SetMUC(const JID& jid, const MUCOccupant::Role& role, const MUCOccupant::Affiliation& affiliation)
: RosterItemOperation(true, jid), jid_(jid), mucRole_(role), mucAffiliation_(affiliation) {
}
virtual void operator() (RosterItem* item) const {
ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item);
if (contact && contact->getJID().equals(jid_, JID::WithResource)) {
contact->setMUCRole(mucRole_);
contact->setMUCAffiliation(mucAffiliation_);
}
}
private:
JID jid_;
- bool mucParticipant_;
MUCOccupant::Role mucRole_;
MUCOccupant::Affiliation mucAffiliation_;
};
}
diff --git a/Swift/Controllers/Storages/FileStorages.cpp b/Swift/Controllers/Storages/FileStorages.cpp
index 52a5e00..e1b681f 100644
--- a/Swift/Controllers/Storages/FileStorages.cpp
+++ b/Swift/Controllers/Storages/FileStorages.cpp
@@ -1,62 +1,62 @@
/*
* Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include "Swift/Controllers/Storages/FileStorages.h"
#include "Swift/Controllers/Storages/VCardFileStorage.h"
#include "Swift/Controllers/Storages/AvatarFileStorage.h"
#include "Swift/Controllers/Storages/CapsFileStorage.h"
#include "Swift/Controllers/Storages/RosterFileStorage.h"
#include <Swiften/History/SQLiteHistoryStorage.h>
#include <Swiften/Base/Path.h>
namespace Swift {
FileStorages::FileStorages(const boost::filesystem::path& baseDir, const JID& jid, CryptoProvider* crypto) {
boost::filesystem::path profile = stringToPath(jid.toBare());
vcardStorage = new VCardFileStorage(baseDir / profile / "vcards", crypto);
capsStorage = new CapsFileStorage(baseDir / "caps");
avatarStorage = new AvatarFileStorage(baseDir / "avatars", baseDir / profile / "avatars", crypto);
rosterStorage = new RosterFileStorage(baseDir / profile / "roster.xml");
#ifdef SWIFT_EXPERIMENTAL_HISTORY
historyStorage = new SQLiteHistoryStorage(baseDir / "history.db");
+#else
+ historyStorage = NULL;
#endif
}
FileStorages::~FileStorages() {
delete rosterStorage;
delete avatarStorage;
delete capsStorage;
delete vcardStorage;
-#ifdef SWIFT_EXPERIMENTAL_HISTORY
delete historyStorage;
-#endif
}
VCardStorage* FileStorages::getVCardStorage() const {
return vcardStorage;
}
CapsStorage* FileStorages::getCapsStorage() const {
return capsStorage;
}
AvatarStorage* FileStorages::getAvatarStorage() const {
return avatarStorage;
}
RosterStorage* FileStorages::getRosterStorage() const {
return rosterStorage;
}
HistoryStorage* FileStorages::getHistoryStorage() const {
#ifdef SWIFT_EXPERIMENTAL_HISTORY
return historyStorage;
#else
return NULL;
#endif
}
}
diff --git a/Swift/Controllers/WhiteboardManager.cpp b/Swift/Controllers/WhiteboardManager.cpp
index 50aba6f..d8d89eb 100644
--- a/Swift/Controllers/WhiteboardManager.cpp
+++ b/Swift/Controllers/WhiteboardManager.cpp
@@ -93,44 +93,46 @@ namespace Swift {
}
onSessionRequest(session->getTo(), true);
}
void WhiteboardManager::cancelSession(const JID& from) {
WhiteboardSession::ref session = whiteboardSessionManager_->getSession(from);
if (session) {
session->cancel();
}
}
void WhiteboardManager::handleIncomingSession(IncomingWhiteboardSession::ref session) {
session->onSessionTerminated.connect(boost::bind(&WhiteboardManager::handleSessionTerminate, this, _1));
session->onRequestAccepted.connect(boost::bind(&WhiteboardManager::handleSessionAccept, this, _1));
WhiteboardWindow* window = findWhiteboardWindow(session->getTo());
if (window == NULL) {
createNewWhiteboardWindow(session->getTo(), session);
} else {
window->setSession(session);
}
onSessionRequest(session->getTo(), false);
}
void WhiteboardManager::handleSessionTerminate(const JID& contact) {
onSessionTerminate(contact);
}
void WhiteboardManager::handleSessionCancel(const JID& contact) {
onSessionTerminate(contact);
}
void WhiteboardManager::handleSessionAccept(const JID& contact) {
WhiteboardWindow* window = findWhiteboardWindow(contact);
- window->show();
+ if (window != NULL) {
+ window->show();
+ }
onRequestAccepted(contact);
}
void WhiteboardManager::handleRequestReject(const JID& contact) {
onRequestRejected(contact);
}
}
diff --git a/Swift/QtUI/QtAvatarWidget.cpp b/Swift/QtUI/QtAvatarWidget.cpp
index 015c2da..fa08c27 100644
--- a/Swift/QtUI/QtAvatarWidget.cpp
+++ b/Swift/QtUI/QtAvatarWidget.cpp
@@ -1,61 +1,63 @@
/*
- * Copyright (c) 2011-2013 Remko Tronçon
+ * Copyright (c) 2011-2014 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
+
+
#include "QtAvatarWidget.h"
#include <QLabel>
#include <QVBoxLayout>
#include <QPixmap>
#include <QMenu>
#include <QAction>
#include <QMouseEvent>
#include <QFileDialog>
#include <QImageReader>
#include <QBuffer>
#include <QMessageBox>
#include <QPainter>
#include <QtSwiftUtil.h>
#include <Swiften/Base/Path.h>
namespace Swift {
-QtAvatarWidget::QtAvatarWidget(QWidget* parent) : QWidget(parent) {
+QtAvatarWidget::QtAvatarWidget(QWidget* parent) : QWidget(parent), editable(false) {
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setContentsMargins(0,0,0,0);
QSizePolicy sp(QSizePolicy::Fixed, QSizePolicy::Fixed);
sp.setHorizontalStretch(0);
sp.setVerticalStretch(0);
setSizePolicy(sp);
setMinimumSize(QSize(96, 96));
setMaximumSize(QSize(96, 96));
label = new QLabel(this);
label->setWordWrap(true);
label->setSizePolicy(sp);
label->setMinimumSize(QSize(96, 96));
label->setMaximumSize(QSize(96, 96));
label->setAlignment(Qt::AlignCenter);
layout->addWidget(label);
}
void QtAvatarWidget::setAvatar(const ByteArray& data, const std::string& type) {
this->data = data;
this->type = type;
QImage image;
if (!data.empty()) {
image.loadFromData(reinterpret_cast<const uchar*>(vecptr(data)), data.size());
}
if (image.isNull()) {
image = QImage(":/icons/no-avatar.png");
QPainter painter(&image);
painter.setPen(Qt::gray);
QFont font = painter.font();
font.setPointSize(14);
painter.setFont(font);
diff --git a/Swift/QtUI/QtPlainChatView.h b/Swift/QtUI/QtPlainChatView.h
index 01b5925..cf65fb3 100644
--- a/Swift/QtUI/QtPlainChatView.h
+++ b/Swift/QtUI/QtPlainChatView.h
@@ -92,42 +92,41 @@ namespace Swift {
PopupDialog *parent_;
JID jid_;
std::string senderName_;
std::string password_;
bool isImpromptu_;
bool isContinuation_;
};
struct FileTransfer : public PopupDialog {
struct Action : QPushButton {
Action(const std::string& text, const std::string& id)
: QPushButton(P2QSTRING(text)), id_(id) {}
std::string id_;
};
FileTransfer(QtPlainChatView* parent, bool senderIsSelf, const std::string& ftId, const std::string& filename, const ChatWindow::FileTransferState state, const std::string& desc, const std::string& msg, bool initializing);
QProgressBar* bar_;
bool senderIsSelf_;
std::string ftId_;
std::string filename_;
std::string description_;
std::string message_;
bool initializing_;
};
class LogTextEdit : public QTextEdit {
public:
LogTextEdit(QWidget* parent) : QTextEdit(parent) {}
virtual ~LogTextEdit() {}
virtual void contextMenuEvent(QContextMenuEvent *event);
};
typedef std::map<std::string, FileTransfer*> FileTransferMap;
QtChatWindow* window_;
UIEventStream* eventStream_;
LogTextEdit* log_;
- QMenu* logMenu_;
FileTransferMap fileTransfers_;
std::map<std::string, boost::shared_ptr<SecurityLabel> > lastMessageLabel_;
int idGenerator_;
};
}
diff --git a/Swift/QtUI/QtRosterHeader.cpp b/Swift/QtUI/QtRosterHeader.cpp
index 44459d5..b9e7798 100644
--- a/Swift/QtUI/QtRosterHeader.cpp
+++ b/Swift/QtUI/QtRosterHeader.cpp
@@ -1,61 +1,61 @@
/*
- * Copyright (c) 2010 Kevin Smith
+ * Copyright (c) 2010-2014 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include "QtRosterHeader.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QFileInfo>
#include <QIcon>
#include <QSizePolicy>
#include <qdebug.h>
#include <QMouseEvent>
#include <QPainter>
#include <QBitmap>
#include "QtStatusWidget.h"
#include <Swift/QtUI/QtElidingLabel.h>
#include <Swift/QtUI/QtClickableLabel.h>
#include <Swift/QtUI/QtNameWidget.h>
#include "QtScaledAvatarCache.h"
namespace Swift {
-QtRosterHeader::QtRosterHeader(SettingsProvider* settings, StatusCache* statusCache, QWidget* parent) : QWidget(parent) {
+QtRosterHeader::QtRosterHeader(SettingsProvider* settings, StatusCache* statusCache, QWidget* parent) : QWidget(parent), statusEdit_(false) {
QHBoxLayout* topLayout = new QHBoxLayout();
topLayout->setSpacing(3);
topLayout->setContentsMargins(4,4,4,4);
setLayout(topLayout);
setMinimumHeight(50);
setMaximumHeight(50);
avatarLabel_ = new QtClickableLabel(this);
avatarLabel_->setMinimumSize(avatarSize_, avatarSize_);
avatarLabel_->setMaximumSize(avatarSize_, avatarSize_);
avatarLabel_->setAlignment(Qt::AlignCenter);
setAvatar(":/icons/avatar.png");
avatarLabel_->setScaledContents(false);
topLayout->addWidget(avatarLabel_);
connect(avatarLabel_, SIGNAL(clicked()), this, SIGNAL(onEditProfileRequest()));
QVBoxLayout* rightLayout = new QVBoxLayout();
rightLayout->setSpacing(4);
rightLayout->setContentsMargins(4,0,0,0);
topLayout->addLayout(rightLayout);
QHBoxLayout* nameAndSecurityLayout = new QHBoxLayout();
nameAndSecurityLayout->setContentsMargins(4,0,0,0);
nameWidget_ = new QtNameWidget(settings, this);
connect(nameWidget_, SIGNAL(onChangeNickRequest()), this, SIGNAL(onEditProfileRequest()));
nameAndSecurityLayout->addWidget(nameWidget_);
securityInfoButton_ = new QToolButton(this);
securityInfoButton_->setStyleSheet("QToolButton { border: none; } QToolButton:hover { border: 1px solid #bebebe; } QToolButton:pressed { border: 1px solid #757575; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #777777, stop: 1 #d4d4d4);}");
//securityInfoButton_->setAutoRaise(true);
securityInfoButton_->setIcon(QIcon(":/icons/lock.png"));
securityInfoButton_->setToolTip(tr("Connection is secured"));
connect(securityInfoButton_, SIGNAL(clicked()), this, SIGNAL(onShowCertificateInfo()));
nameAndSecurityLayout->addWidget(securityInfoButton_);
diff --git a/Swift/QtUI/QtSystemTray.cpp b/Swift/QtUI/QtSystemTray.cpp
index 456a56f..83018b8 100644
--- a/Swift/QtUI/QtSystemTray.cpp
+++ b/Swift/QtUI/QtSystemTray.cpp
@@ -1,57 +1,57 @@
/*
- * Copyright (c) 2010 Kevin Smith
+ * Copyright (c) 2010-2014 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma GCC diagnostic ignored "-Wredundant-decls"
#include "Swift/QtUI/QtSystemTray.h"
#include <QtDebug>
#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC)
#include <QDBusInterface>
#endif
#include <QIcon>
#include <QPixmap>
#include <QResource>
#include <QMenu>
#include <QAction>
namespace Swift {
-QtSystemTray::QtSystemTray() : QObject(), trayMenu_(0), onlineIcon_(":icons/online.png"), awayIcon_(":icons/away.png"), dndIcon_(":icons/dnd.png"), offlineIcon_(":icons/offline.png"), newMessageIcon_(":icons/new-chat.png"), throbberMovie_(":/icons/connecting.mng"), unreadMessages_(false), connecting_(false) {
+QtSystemTray::QtSystemTray() : QObject(), statusType_(StatusShow::None), trayMenu_(0), onlineIcon_(":icons/online.png"), awayIcon_(":icons/away.png"), dndIcon_(":icons/dnd.png"), offlineIcon_(":icons/offline.png"), newMessageIcon_(":icons/new-chat.png"), throbberMovie_(":/icons/connecting.mng"), unreadMessages_(false), connecting_(false) {
trayIcon_ = new QSystemTrayIcon(offlineIcon_);
trayIcon_->setToolTip("Swift");
connect(trayIcon_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(handleIconActivated(QSystemTrayIcon::ActivationReason)));
connect(&throbberMovie_, SIGNAL(frameChanged(int)), this, SLOT(handleThrobberFrameChanged(int)));
#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC)
bool isUnity = QDBusInterface("com.canonical.Unity.Launcher", "/com/canonical/Unity/Launcher").isValid();
if (isUnity) {
// Add an activation menu, because this is the only way to get the application to the
// front on Unity. See the README for sni-qt (which handles Qt tray icons for Unity)
trayMenu_ = new QMenu();
QAction* showAction = new QAction(QString("Show/Hide"), this);
connect(showAction, SIGNAL(triggered()), SIGNAL(clicked()));
trayMenu_->addAction(showAction);
trayIcon_->setContextMenu(trayMenu_);
}
#endif
trayIcon_->show();
}
QtSystemTray::~QtSystemTray() {
delete trayMenu_;
delete trayIcon_;
}
void QtSystemTray::setUnreadMessages(bool some) {
unreadMessages_ = some;
updateStatusIcon();
}
void QtSystemTray::handleThrobberFrameChanged(int /*frameNumber*/) {
trayIcon_->setIcon(QIcon(throbberMovie_.currentPixmap()));
}
void QtSystemTray::setConnecting() {
connecting_ = true;
diff --git a/Swift/QtUI/QtVCardWidget/QtResizableLineEdit.cpp b/Swift/QtUI/QtVCardWidget/QtResizableLineEdit.cpp
index 4f1d3ab..877a598 100644
--- a/Swift/QtUI/QtVCardWidget/QtResizableLineEdit.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtResizableLineEdit.cpp
@@ -1,47 +1,54 @@
/*
* Copyright (c) 2012 Tobias Markmann
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * Copyright (c) 2014 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+
#include "QtResizableLineEdit.h"
namespace Swift {
QtResizableLineEdit::QtResizableLineEdit(QWidget* parent) :
- QLineEdit(parent) {
+ QLineEdit(parent), editable(false) {
connect(this, SIGNAL(textChanged(QString)), SLOT(textChanged(QString)));
setMinimumWidth(30);
}
QtResizableLineEdit::~QtResizableLineEdit() {
}
bool QtResizableLineEdit::isEditable() const {
return editable;
}
void QtResizableLineEdit::setEditable(const bool editable) {
this->editable = editable;
if (editable) {
setReadOnly(false);
} else {
setReadOnly(true);
}
}
QSize QtResizableLineEdit::sizeHint() const {
int horizontalMargin = 10;
int verticalMargin = 6;
QSize textDimensions;
#if QT_VERSION >= 0x040700
textDimensions = fontMetrics().boundingRect(text().isEmpty() ? placeholderText() : text()).size();
#else
textDimensions = fontMetrics().boundingRect(text().isEmpty() ? QString(" ") : text()).size();
#endif
textDimensions.setWidth(textDimensions.width() + horizontalMargin);
textDimensions.setHeight(textDimensions.height() + verticalMargin);
return textDimensions;
}
void QtResizableLineEdit::textChanged(QString) {
diff --git a/Swiften/Client/MemoryStorages.cpp b/Swiften/Client/MemoryStorages.cpp
index 885d74f..850c1b2 100644
--- a/Swiften/Client/MemoryStorages.cpp
+++ b/Swiften/Client/MemoryStorages.cpp
@@ -1,61 +1,61 @@
/*
* Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Client/MemoryStorages.h>
#include <Swiften/VCards/VCardMemoryStorage.h>
#include <Swiften/Avatars/AvatarMemoryStorage.h>
#include <Swiften/Disco/CapsMemoryStorage.h>
#include <Swiften/Roster/RosterMemoryStorage.h>
#include <Swiften/History/SQLiteHistoryStorage.h>
namespace Swift {
MemoryStorages::MemoryStorages(CryptoProvider* crypto) {
vcardStorage = new VCardMemoryStorage(crypto);
capsStorage = new CapsMemoryStorage();
avatarStorage = new AvatarMemoryStorage();
rosterStorage = new RosterMemoryStorage();
#ifdef SWIFT_EXPERIMENTAL_HISTORY
historyStorage = new SQLiteHistoryStorage(":memory:");
+#else
+ historyStorage = NULL;
#endif
}
MemoryStorages::~MemoryStorages() {
delete rosterStorage;
delete avatarStorage;
delete capsStorage;
delete vcardStorage;
-#ifdef SWIFT_EXPERIMENTAL_HISTORY
delete historyStorage;
-#endif
}
VCardStorage* MemoryStorages::getVCardStorage() const {
return vcardStorage;
}
CapsStorage* MemoryStorages::getCapsStorage() const {
return capsStorage;
}
AvatarStorage* MemoryStorages::getAvatarStorage() const {
return avatarStorage;
}
RosterStorage* MemoryStorages::getRosterStorage() const {
return rosterStorage;
}
HistoryStorage* MemoryStorages::getHistoryStorage() const {
#ifdef SWIFT_EXPERIMENTAL_HISTORY
return historyStorage;
#else
return NULL;
#endif
}
}
diff --git a/Swiften/Elements/JingleContentPayload.h b/Swiften/Elements/JingleContentPayload.h
index 547fc70..ac62866 100644
--- a/Swiften/Elements/JingleContentPayload.h
+++ b/Swiften/Elements/JingleContentPayload.h
@@ -1,63 +1,66 @@
/*
* Copyright (c) 2011 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma once
#include <vector>
#include <boost/optional.hpp>
#include <string>
#include <Swiften/JID/JID.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/JingleDescription.h>
#include <Swiften/Elements/JingleTransportPayload.h>
namespace Swift {
class JingleContentPayload : public Payload {
public:
typedef boost::shared_ptr<JingleContentPayload> ref;
enum Creator {
UnknownCreator,
InitiatorCreator,
ResponderCreator
};
+ JingleContentPayload() : creator(UnknownCreator) {
+ }
+
/*enum Senders {
NoSenders,
InitiatorSender,
ResponderSender,
BothSenders,
};*/
Creator getCreator() const {
return creator;
}
void setCreator(Creator creator) {
this->creator = creator;
}
const std::string& getName() const {
return name;
}
void setName(const std::string& name) {
this->name = name;
}
const std::vector<JingleDescription::ref>& getDescriptions() const {
return descriptions;
}
void addDescription(JingleDescription::ref description) {
descriptions.push_back(description);
}
const std::vector<boost::shared_ptr<JingleTransportPayload> >& getTransports() const {
return transports;
}
diff --git a/Swiften/Elements/JingleIBBTransportPayload.h b/Swiften/Elements/JingleIBBTransportPayload.h
index a329ff0..5704c00 100644
--- a/Swiften/Elements/JingleIBBTransportPayload.h
+++ b/Swiften/Elements/JingleIBBTransportPayload.h
@@ -1,45 +1,48 @@
/*
- * Copyright (c) 2011-2013 Remko Tronçon
+ * Copyright (c) 2011-2014 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma once
#include <boost/shared_ptr.hpp>
#include <boost/optional.hpp>
#include <string>
#include <Swiften/Elements/JingleTransportPayload.h>
namespace Swift {
class JingleIBBTransportPayload : public JingleTransportPayload {
public:
typedef boost::shared_ptr<JingleIBBTransportPayload> ref;
enum StanzaType {
IQStanza,
MessageStanza
};
+ JingleIBBTransportPayload() : stanzaType(IQStanza) {
+ }
+
void setStanzaType(StanzaType stanzaType) {
this->stanzaType = stanzaType;
}
StanzaType getStanzaType() const {
return stanzaType;
}
boost::optional<unsigned int> getBlockSize() const {
return blockSize;
}
void setBlockSize(unsigned int blockSize) {
this->blockSize = blockSize;
}
private:
boost::optional<unsigned int> blockSize;
StanzaType stanzaType;
};
}
diff --git a/Swiften/Elements/PubSubRetract.cpp b/Swiften/Elements/PubSubRetract.cpp
index 7e5b720..41b9346 100644
--- a/Swiften/Elements/PubSubRetract.cpp
+++ b/Swiften/Elements/PubSubRetract.cpp
@@ -1,15 +1,15 @@
/*
* Copyright (c) 2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Elements/PubSubRetract.h>
using namespace Swift;
-PubSubRetract::PubSubRetract() {
+PubSubRetract::PubSubRetract() : notify(false) {
}
PubSubRetract::~PubSubRetract() {
}
diff --git a/Swiften/Elements/PubSubSubscribeOptions.cpp b/Swiften/Elements/PubSubSubscribeOptions.cpp
index 3423d02..19cf084 100644
--- a/Swiften/Elements/PubSubSubscribeOptions.cpp
+++ b/Swiften/Elements/PubSubSubscribeOptions.cpp
@@ -1,15 +1,15 @@
/*
* Copyright (c) 2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Elements/PubSubSubscribeOptions.h>
using namespace Swift;
-PubSubSubscribeOptions::PubSubSubscribeOptions() {
+PubSubSubscribeOptions::PubSubSubscribeOptions() : required(false) {
}
PubSubSubscribeOptions::~PubSubSubscribeOptions() {
}
diff --git a/Swiften/Elements/StreamManagementEnabled.cpp b/Swiften/Elements/StreamManagementEnabled.cpp
index bab7516..1f1a1f5 100644
--- a/Swiften/Elements/StreamManagementEnabled.cpp
+++ b/Swiften/Elements/StreamManagementEnabled.cpp
@@ -1,15 +1,15 @@
/*
- * Copyright (c) 2011 Remko Tronçon
+ * Copyright (c) 2011-2014 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Elements/StreamManagementEnabled.h>
using namespace Swift;
-StreamManagementEnabled::StreamManagementEnabled() {
+StreamManagementEnabled::StreamManagementEnabled() : resumeSupported(false) {
}
StreamManagementEnabled::~StreamManagementEnabled() {
}
diff --git a/Swiften/Elements/Whiteboard/WhiteboardLineElement.h b/Swiften/Elements/Whiteboard/WhiteboardLineElement.h
index 3c63afc..df6e7d6 100644
--- a/Swiften/Elements/Whiteboard/WhiteboardLineElement.h
+++ b/Swiften/Elements/Whiteboard/WhiteboardLineElement.h
@@ -1,52 +1,59 @@
/*
* Copyright (c) 2012 Mateusz Piękos
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * Copyright (c) 2014 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+
#pragma once
#include <Swiften/Elements/Whiteboard/WhiteboardElement.h>
#include <Swiften/Elements/Whiteboard/WhiteboardColor.h>
namespace Swift {
class WhiteboardLineElement : public WhiteboardElement {
public:
typedef boost::shared_ptr<WhiteboardLineElement> ref;
public:
- WhiteboardLineElement(int x1, int y1, int x2, int y2) {
+ WhiteboardLineElement(int x1, int y1, int x2, int y2) : penWidth_(1) {
x1_ = x1;
y1_ = y1;
x2_ = x2;
y2_ = y2;
}
int x1() const {
return x1_;
}
int y1() const {
return y1_;
}
int x2() const {
return x2_;
}
int y2() const {
return y2_;
}
const WhiteboardColor& getColor() const {
return color_;
}
void setColor(const WhiteboardColor& color) {
color_ = color;
}
int getPenWidth() const {
return penWidth_;
}
void setPenWidth(const int penWidth) {
diff --git a/Swiften/Elements/Whiteboard/WhiteboardRectElement.h b/Swiften/Elements/Whiteboard/WhiteboardRectElement.h
index 233b3fa..0fd1338 100644
--- a/Swiften/Elements/Whiteboard/WhiteboardRectElement.h
+++ b/Swiften/Elements/Whiteboard/WhiteboardRectElement.h
@@ -1,52 +1,58 @@
/*
* Copyright (c) 2012 Mateusz Piękos
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * Copyright (c) 2014 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
#pragma once
#include <Swiften/Elements/Whiteboard/WhiteboardElement.h>
#include <Swiften/Elements/Whiteboard/WhiteboardColor.h>
namespace Swift {
class WhiteboardRectElement : public WhiteboardElement {
public:
typedef boost::shared_ptr<WhiteboardRectElement> ref;
public:
- WhiteboardRectElement(int x, int y, int width, int height) {
+ WhiteboardRectElement(int x, int y, int width, int height) : penWidth_(1) {
x_ = x;
y_ = y;
width_ = width;
height_ = height;
}
int getX() const {
return x_;
}
int getY() const {
return y_;
}
int getWidth() const {
return width_;
}
int getHeight() const {
return height_;
}
const WhiteboardColor& getPenColor() const {
return penColor_;
}
void setPenColor(const WhiteboardColor& color) {
penColor_ = color;
}
const WhiteboardColor& getBrushColor() const {
return brushColor_;
}
void setBrushColor(const WhiteboardColor& color) {
diff --git a/Swiften/FileTransfer/FileTransfer.cpp b/Swiften/FileTransfer/FileTransfer.cpp
index c11e8e4..912a78a 100644
--- a/Swiften/FileTransfer/FileTransfer.cpp
+++ b/Swiften/FileTransfer/FileTransfer.cpp
@@ -1,20 +1,20 @@
/*
- * Copyright (c) 2013 Remko Tronçon
+ * Copyright (c) 2013-2014 Remko Tronçon
* Licensed under the GNU General Public License.
* See the COPYING file for more information.
*/
#include <Swiften/FileTransfer/FileTransfer.h>
using namespace Swift;
-FileTransfer::FileTransfer() {
+FileTransfer::FileTransfer() : fileSizeInBytes(0) {
}
FileTransfer::~FileTransfer() {
}
void FileTransfer::setFileInfo(const std::string& name, boost::uintmax_t size) {
filename = name;
fileSizeInBytes = size;
}
diff --git a/Swiften/Network/BOSHConnection.cpp b/Swiften/Network/BOSHConnection.cpp
index 83f12f7..bde689e 100644
--- a/Swiften/Network/BOSHConnection.cpp
+++ b/Swiften/Network/BOSHConnection.cpp
@@ -1,69 +1,70 @@
/*
* Copyright (c) 2011 Thilo Cestonaro
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
/*
* Copyright (c) 2011-2014 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Network/BOSHConnection.h>
#include <boost/bind.hpp>
#include <boost/thread.hpp>
#include <boost/lexical_cast.hpp>
#include <string>
#include <Swiften/Base/Log.h>
#include <Swiften/Base/String.h>
#include <Swiften/Base/Concat.h>
#include <Swiften/Base/ByteArray.h>
#include <Swiften/Network/HostAddressPort.h>
#include <Swiften/Parser/BOSHBodyExtractor.h>
namespace Swift {
BOSHConnection::BOSHConnection(const URL& boshURL, Connector::ref connector, XMLParserFactory* parserFactory)
: boshURL_(boshURL),
connector_(connector),
parserFactory_(parserFactory),
sid_(),
waitingForStartResponse_(false),
+ rid_(~0ULL),
pending_(false),
connectionReady_(false)
{
}
BOSHConnection::~BOSHConnection() {
cancelConnector();
if (connection_) {
connection_->onDataRead.disconnect(boost::bind(&BOSHConnection::handleDataRead, shared_from_this(), _1));
connection_->onDisconnected.disconnect(boost::bind(&BOSHConnection::handleDisconnected, shared_from_this(), _1));
}
disconnect();
}
void BOSHConnection::connect() {
connector_->onConnectFinished.connect(boost::bind(&BOSHConnection::handleConnectFinished, shared_from_this(), _1));
connector_->start();
}
void BOSHConnection::cancelConnector() {
if (connector_) {
connector_->onConnectFinished.disconnect(boost::bind(&BOSHConnection::handleConnectFinished, shared_from_this(), _1));
connector_->stop();
connector_.reset();
}
}
void BOSHConnection::disconnect() {
if (connection_) {
connection_->disconnect();
sid_ = "";
}
else {
/* handleDisconnected takes care of the connector_ as well */
handleDisconnected(boost::optional<Connection::Error>());
diff --git a/Swiften/Network/SOCKS5ProxiedConnection.cpp b/Swiften/Network/SOCKS5ProxiedConnection.cpp
index a9243d6..3fd8184 100644
--- a/Swiften/Network/SOCKS5ProxiedConnection.cpp
+++ b/Swiften/Network/SOCKS5ProxiedConnection.cpp
@@ -1,62 +1,69 @@
/*
* Copyright (c) 2010-2011 Thilo Cestonaro
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * Copyright (c) 2014 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
#include <Swiften/Network/SOCKS5ProxiedConnection.h>
#include <iostream>
#include <boost/bind.hpp>
#include <boost/thread.hpp>
#include <Swiften/Network/ConnectionFactory.h>
#include <Swiften/Base/Log.h>
#include <Swiften/Base/String.h>
#include <Swiften/Base/ByteArray.h>
#include <Swiften/Network/HostAddressPort.h>
using namespace Swift;
SOCKS5ProxiedConnection::SOCKS5ProxiedConnection(
DomainNameResolver* resolver,
ConnectionFactory* connectionFactory,
TimerFactory* timerFactory,
const std::string& proxyHost,
int proxyPort) :
- ProxiedConnection(resolver, connectionFactory, timerFactory, proxyHost, proxyPort) {
+ ProxiedConnection(resolver, connectionFactory, timerFactory, proxyHost, proxyPort),
+ proxyState_(Initial) {
}
void SOCKS5ProxiedConnection::initializeProxy() {
proxyState_ = ProxyAuthenticating;
SafeByteArray socksConnect;
socksConnect.push_back(0x05); // VER = SOCKS5 = 0x05
socksConnect.push_back(0x01); // Number of authentication methods after this byte.
socksConnect.push_back(0x00); // 0x00 == no authentication
// buffer.push_back(0x01); // 0x01 == GSSAPI
// buffer.push_back(0x02); // 0x02 == Username/Password
// rest see RFC 1928 (http://tools.ietf.org/html/rfc1928)
write(socksConnect);
}
void SOCKS5ProxiedConnection::handleProxyInitializeData(boost::shared_ptr<SafeByteArray> data) {
SafeByteArray socksConnect;
boost::asio::ip::address rawAddress = getServer().getAddress().getRawAddress();
assert(rawAddress.is_v4() || rawAddress.is_v6());
if (proxyState_ == ProxyAuthenticating) {
SWIFT_LOG(debug) << "ProxyAuthenticating response received, reply with the connect BYTEs" << std::endl;
unsigned char choosenMethod = static_cast<unsigned char> ((*data)[1]);
if ((*data)[0] == 0x05 && choosenMethod != 0xFF) {
switch(choosenMethod) { // use the correct Method
case 0x00:
try {
proxyState_ = ProxyConnecting;
socksConnect.push_back(0x05); // VER = SOCKS5 = 0x05
socksConnect.push_back(0x01); // Construct a TCP connection. (CMD)
socksConnect.push_back(0x00); // reserved.
socksConnect.push_back(rawAddress.is_v4() ? 0x01 : 0x04); // IPv4 == 0x01, Hostname == 0x02, IPv6 == 0x04. (ATYP)
size_t size = rawAddress.is_v4() ? rawAddress.to_v4().to_bytes().size() : rawAddress.to_v6().to_bytes().size();
for (size_t s = 0; s < size; s++) {
unsigned char uc;
if(rawAddress.is_v4()) {
diff --git a/Swiften/Network/SOCKS5ProxiedConnection.h b/Swiften/Network/SOCKS5ProxiedConnection.h
index 7906879..2c93468 100644
--- a/Swiften/Network/SOCKS5ProxiedConnection.h
+++ b/Swiften/Network/SOCKS5ProxiedConnection.h
@@ -1,36 +1,37 @@
/*
* Copyright (c) 2010-2011 Thilo Cestonaro
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
#pragma once
#include <Swiften/Network/ProxiedConnection.h>
namespace Swift {
class ConnectionFactory;
class DomainNameResolver;
class TimerFactory;
class SOCKS5ProxiedConnection : public ProxiedConnection {
public:
typedef boost::shared_ptr<SOCKS5ProxiedConnection> ref;
static ref create(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, int proxyPort) {
return ref(new SOCKS5ProxiedConnection(resolver, connectionFactory, timerFactory, proxyHost, proxyPort));
}
private:
SOCKS5ProxiedConnection(DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory, const std::string& proxyHost, int proxyPort);
virtual void initializeProxy();
virtual void handleProxyInitializeData(boost::shared_ptr<SafeByteArray> data);
private:
enum {
- ProxyAuthenticating = 0,
+ Initial = 0,
+ ProxyAuthenticating,
ProxyConnecting
} proxyState_;
};
}