diff options
Diffstat (limited to 'Swift')
| -rw-r--r-- | Swift/Controllers/HistoryController.cpp | 9 | ||||
| -rw-r--r-- | Swift/Controllers/Roster/ItemOperations/SetMUC.h | 3 | ||||
| -rw-r--r-- | Swift/Controllers/Storages/FileStorages.cpp | 4 | ||||
| -rw-r--r-- | Swift/Controllers/WhiteboardManager.cpp | 4 | ||||
| -rw-r--r-- | Swift/QtUI/QtAvatarWidget.cpp | 6 | ||||
| -rw-r--r-- | Swift/QtUI/QtPlainChatView.h | 1 | ||||
| -rw-r--r-- | Swift/QtUI/QtRosterHeader.cpp | 4 | ||||
| -rw-r--r-- | Swift/QtUI/QtSystemTray.cpp | 4 | ||||
| -rw-r--r-- | Swift/QtUI/QtVCardWidget/QtResizableLineEdit.cpp | 9 |
9 files changed, 30 insertions, 14 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) { |
Swift