[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:20:38 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=3a65257
The following commit has been merged in the master branch:
commit 3a65257a599d2a2ac8c5650975e26df2519c8050
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Wed Dec 21 14:17:41 2011 +0000
Use KTelepathy in the Text UI
Use KTp::Presence instead of Tp::Presence
Review: 103493
Reviewed by: Martin Klapetek
---
CMakeLists.txt | 5 +-
cmake/modules/FindKTelepathy.cmake | 36 +++++++++++++
lib/CMakeLists.txt | 1 +
lib/channel-contact-model.cpp | 19 +------
lib/channel-contact-model.h | 4 +-
lib/chat-widget.cpp | 103 +++++++++----------------------------
lib/chat-widget.h | 9 ++--
7 files changed, 73 insertions(+), 104 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dbbce99..bcf5912 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,7 @@
project(ktp-text-ui)
+set(IS_TELEPATHY_KDE_INTERNAL_MODULE TRUE)
+
# Include our extra FindFoo.cmake files.
set (CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
@@ -9,6 +11,7 @@ set (CMAKE_MODULE_PATH
set(KDE_MIN_VERSION "4.4.75")
find_package (KDE4 ${KDE_MIN_VERSION} REQUIRED)
find_package (TelepathyQt4 0.8.9 REQUIRED)
+find_package (KTelepathy REQUIRED)
include (CheckIncludeFiles)
include (KDE4Defaults)
@@ -16,8 +19,8 @@ include (MacroLibrary)
include_directories (${KDE4_INCLUDES}
${TELEPATHY_QT4_INCLUDE_DIR}
- ${NEPOMUK_INCLUDES}
${QT_QTWEBKIT_INCLUDES}
+ ${KTELEPATHY_INCLUDE_DIR}
)
add_definitions (${KDE4_DEFINITIONS}
diff --git a/cmake/modules/FindKTelepathy.cmake b/cmake/modules/FindKTelepathy.cmake
new file mode 100644
index 0000000..c9aa9dc
--- /dev/null
+++ b/cmake/modules/FindKTelepathy.cmake
@@ -0,0 +1,36 @@
+# Try to find the KTelepathy library
+# KTELEPATHY_FOUND
+# KTELEPATHY_INCLUDE_DIR
+# KTELEPATHY_LIBRARIES
+# KTELEPATHY_MODELS_LIBRARIES
+
+# Copyright (c) 2011, Dario Freddi <drf at kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+if (NOT IS_TELEPATHY_KDE_INTERNAL_MODULE)
+ message (FATAL_ERROR "KTelepathy can be used just from internal components at this time")
+endif (NOT IS_TELEPATHY_KDE_INTERNAL_MODULE)
+
+SET (KTELEPATHY_FIND_REQUIRED ${KTelepathy_FIND_REQUIRED})
+if (KTELEPATHY_INCLUDE_DIRS AND KTELEPATHY_LIBRARIES)
+ # Already in cache, be silent
+ set(KTELEPATHY_FIND_QUIETLY TRUE)
+endif (KTELEPATHY_INCLUDE_DIRS AND KTELEPATHY_LIBRARIES)
+
+find_path(KTELEPATHY_INCLUDE_DIR
+ NAMES KTelepathy/presence.h
+ PATHS ${KDE4_INCLUDE_DIR}
+)
+
+find_library(KTELEPATHY_LIBRARIES NAMES telepathykdecommoninternalsprivate )
+find_library(KTELEPATHY_MODELS_LIBRARIES NAMES telepathykdemodelsprivate )
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(KTelepathy DEFAULT_MSG
+ KTELEPATHY_LIBRARIES
+ KTELEPATHY_MODELS_LIBRARIES
+ KTELEPATHY_INCLUDE_DIR)
+
+mark_as_advanced(KTELEPATHY_INCLUDE_DIRS KTELEPATHY_LIBRARIES)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 0c5c6a6..8c7f3f1 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -74,6 +74,7 @@ target_link_libraries(ktpchat
${QT_QTWEBKIT_LIBRARY}
${KDE4_KEMOTICONS_LIBS}
${KDE4_KCMUTILS_LIBS}
+ ${KTELEPATHY_LIBRARIES}
)
install(TARGETS ktpchat ${INSTALL_TARGETS_DEFAULT_ARGS})
diff --git a/lib/channel-contact-model.cpp b/lib/channel-contact-model.cpp
index 78bd7be..d731322 100644
--- a/lib/channel-contact-model.cpp
+++ b/lib/channel-contact-model.cpp
@@ -69,22 +69,7 @@ QVariant ChannelContactModel::data(const QModelIndex &index, int role) const
return QVariant(m_contacts[row]->alias());
case Qt::DecorationRole:
- switch(m_contacts[row]->presence().type()) {
- case Tp::ConnectionPresenceTypeAvailable:
- return QVariant(KIcon(QLatin1String("im-user")));
- case Tp::ConnectionPresenceTypeAway:
- //fall through
- case Tp::ConnectionPresenceTypeExtendedAway:
- return QVariant(KIcon(QLatin1String("im-user-away")));
- case Tp::ConnectionPresenceTypeBusy:
- return QVariant(KIcon(QLatin1String("im-user-busy")));
- case Tp::ConnectionPresenceTypeOffline:
- //fall through
- case Tp::ConnectionPresenceTypeHidden:
- return QVariant(KIcon(QLatin1String("im-user-offline")));
- default: //presence unknown or error
- return QVariant(KIcon(QLatin1String("dialog-warning")));
- }
+ return KTp::Presence(m_contacts[row]->presence()).icon();
default:
return QVariant();
@@ -114,7 +99,7 @@ void ChannelContactModel::onContactPresenceChanged(const Tp::Presence &presence)
QModelIndex index = createIndex(m_contacts.lastIndexOf(contact), 0);
Q_EMIT dataChanged(index, index);
- Q_EMIT contactPresenceChanged(contact, presence);
+ Q_EMIT contactPresenceChanged(contact, KTp::Presence(presence));
}
void ChannelContactModel::onContactAliasChanged(const QString &alias)
diff --git a/lib/channel-contact-model.h b/lib/channel-contact-model.h
index 4ebdafe..0250e1d 100644
--- a/lib/channel-contact-model.h
+++ b/lib/channel-contact-model.h
@@ -28,6 +28,8 @@
#include <TelepathyQt/Channel>
#include <TelepathyQt/Presence>
+#include <KTelepathy/presence.h>
+
/** A model of all users in the channel.
Also acts as a proxy for emiting presence and alias changes of any contacts in the channel
so that the main class doesn't need to monitor this and keep connection/disconnecting to alias change/presence
@@ -43,7 +45,7 @@ public:
void setTextChannel(const Tp::TextChannelPtr &channel);
Q_SIGNALS:
- void contactPresenceChanged(const Tp::ContactPtr &contact, const Tp::Presence &presence);
+ void contactPresenceChanged(const Tp::ContactPtr &contact, const KTp::Presence &presence);
void contactAliasChanged(const Tp::ContactPtr &contact, const QString &alias);
protected:
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index ff41ef1..f096959 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -45,6 +45,8 @@
#include <TelepathyQt/Connection>
#include <TelepathyQt/Presence>
+#include <KTelepathy/presence.h>
+
class ChatWidgetPrivate
{
public:
@@ -235,16 +237,16 @@ KIcon ChatWidget::icon() const
//find the other contact which isn't self.
Q_FOREACH(const Tp::ContactPtr & contact, d->channel->groupContacts()) {
if (contact != d->channel->groupSelfContact()) {
- return iconForPresence(contact->presence().type());
+ return KTp::Presence(contact->presence()).icon();
}
}
}
-
- //group chat
- return iconForPresence(Tp::ConnectionPresenceTypeAvailable);
- } else {
- return iconForPresence(Tp::ConnectionPresenceTypeOffline);
+ else {
+ //group chat
+ return KTp::Presence(Tp::Presence::available()).icon();
+ }
}
+ return KTp::Presence(Tp::Presence::offline()).icon();
}
bool ChatWidget::isGroupChat() const
@@ -391,8 +393,8 @@ void ChatWidget::setupChannelSignals()
void ChatWidget::setupContactModelSignals()
{
- connect(d->contactModel, SIGNAL(contactPresenceChanged(Tp::ContactPtr,Tp::Presence)),
- SLOT(onContactPresenceChange(Tp::ContactPtr,Tp::Presence)));
+ connect(d->contactModel, SIGNAL(contactPresenceChanged(Tp::ContactPtr,KTp::Presence)),
+ SLOT(onContactPresenceChange(Tp::ContactPtr,KTp::Presence)));
connect(d->contactModel, SIGNAL(contactAliasChanged(Tp::ContactPtr,QString)),
SLOT(onContactAliasChanged(Tp::ContactPtr,QString)));
}
@@ -750,56 +752,25 @@ void ChatWidget::onChatStatusChanged(const Tp::ContactPtr & contact, Tp::Channel
-void ChatWidget::onContactPresenceChange(const Tp::ContactPtr & contact, const Tp::Presence & presence)
+void ChatWidget::onContactPresenceChange(const Tp::ContactPtr & contact, const KTp::Presence &presence)
{
QString message;
bool isYou = (contact == d->channel->groupSelfContact());
- switch (presence.type()) {
- case Tp::ConnectionPresenceTypeOffline:
- if (!isYou) {
- message = i18n("%1 is offline", contact->alias());
- } else {
- message = i18n("You went offline");
- }
- break;
- case Tp::ConnectionPresenceTypeAvailable:
- if (!isYou) {
- message = i18n("%1 is online", contact->alias());
- } else {
- message = i18n("You are now marked as online");
- }
- break;
- case Tp::ConnectionPresenceTypeBusy:
- if (!isYou) {
- message = i18n("%1 is busy", contact->alias());
- } else {
- message = i18n("You are now marked as busy");
- }
- break;
- case Tp::ConnectionPresenceTypeAway:
- if (!isYou) {
- message = i18n("%1 is away", contact->alias());
- } else {
- message = i18n("You are now marked as away");
- }
- break;
- case Tp::ConnectionPresenceTypeExtendedAway:
- if (!isYou) {
- message = i18n("%1 is not available", contact->alias());
+ if (isYou) {
+ message = i18n("You are now marked as %1", presence.displayString());
+ }
+ else {
+ if (presence.statusMessage().isEmpty()) {
+ message = i18nc("User's name, with their new presence status (i.e online/away)","%1 is %2", contact->alias(), presence.displayString());
} else {
- message = i18n("You are now marked as not available");
+ message = i18nc("User's name, with their new presence status (i.e online/away) and a sepecified presence message","%1 is %2 - %3",
+ contact->alias(),
+ presence.displayString(),
+ presence.statusMessage());
}
- break;
- default:
- /*Do nothing*/
- ;
- }
-
- if (!isYou && !presence.statusMessage().isEmpty()) {
- message = QString::fromUtf8("%1 - \"%2\"").arg(message, presence.statusMessage());
}
-
+
if (!message.isNull()) {
AdiumThemeStatusInfo statusMessage;
statusMessage.setMessage(message);
@@ -810,7 +781,7 @@ void ChatWidget::onContactPresenceChange(const Tp::ContactPtr & contact, const T
//if in a non-group chat situation, and the other contact has changed state...
if (!d->isGroupChat && !isYou) {
- Q_EMIT iconChanged(iconForPresence(presence.type()));
+ Q_EMIT iconChanged(presence.icon());
}
Q_EMIT contactPresenceChanged(presence);
@@ -900,34 +871,6 @@ void ChatWidget::onFormatColorReleased()
d->ui.sendMessageBox->setTextColor(color);
}
-KIcon ChatWidget::iconForPresence(Tp::ConnectionPresenceType presence)
-{
- QString iconName;
-
- switch (presence) {
- case Tp::ConnectionPresenceTypeAvailable:
- iconName = QLatin1String("user-online");
- break;
- case Tp::ConnectionPresenceTypeAway:
- iconName = QLatin1String("user-away");
- break;
- case Tp::ConnectionPresenceTypeExtendedAway:
- iconName = QLatin1String("user-away-extended");
- break;
- case Tp::ConnectionPresenceTypeHidden:
- iconName = QLatin1String("user-invisible");
- break;
- case Tp::ConnectionPresenceTypeBusy:
- iconName = QLatin1String("user-busy");
- break;
- default:
- iconName = QLatin1String("user-offline");
- break;
- }
-
- return KIcon(iconName);
-}
-
bool ChatWidget::isUserTyping() const
{
return d->remoteContactIsTyping;
diff --git a/lib/chat-widget.h b/lib/chat-widget.h
index 6255204..9720cc2 100644
--- a/lib/chat-widget.h
+++ b/lib/chat-widget.h
@@ -32,6 +32,8 @@
#include <TelepathyQt/ReceivedMessage>
+#include <KTelepathy/presence.h>
+
class AdiumThemeContentInfo;
class ChatSearchBar;
class ChatWidgetPrivate;
@@ -115,7 +117,7 @@ protected Q_SLOTS:
void onChatStatusChanged(const Tp::ContactPtr &contact, Tp::ChannelChatState state);
- void onContactPresenceChange(const Tp::ContactPtr &contact, const Tp::Presence &presence);
+ void onContactPresenceChange(const Tp::ContactPtr &contact, const KTp::Presence &presence);
void onContactAliasChanged(const Tp::ContactPtr &contact, const QString &alias);
@@ -141,7 +143,7 @@ Q_SIGNALS:
/** Emitted when another contact in the channel starts/stops typing (if supported by the protocol)*/
void userTypingChanged(bool);
- void contactPresenceChanged(Tp::Presence presence);
+ void contactPresenceChanged(KTp::Presence presence);
void unreadMessagesChanged(int messages);
@@ -166,9 +168,6 @@ private:
void incrementUnreadMessageCount();
virtual bool isOnTop() const;
- //FIXME this should be in the ktelepathy lib
- static KIcon iconForPresence(Tp::ConnectionPresenceType presence);
-
ChatWidgetPrivate * const d;
};
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list