[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Btelepathy-chat-handler=5D_/=3A_Part_3of3_-_ADD_new_?=
From: Francesco Nwokeka <francesco.nwokeka () gmail ! com>
Date: 2011-06-18 10:14:40
Message-ID: 20110618101440.8FD56A60A4 () git ! kde ! org
[Download RAW message or body]
Git commit cb7113f10b0d60a0d843be8c6569fec8f962a550 by Francesco Nwokeka.
Committed on 18/06/2011 at 12:15.
Pushed by nwokeka into branch 'master'.
Part 3of3 - ADD new action buttons to chat handler
Buttons are activated according to both self and contact capabilities.
REVIEW: 101645
Reviewed By: David Edmundson
M +51 -1 app/chat-window.cpp
M +6 -0 app/chat-window.h
M +1 -0 lib/chat-widget.h
http://commits.kde.org/telepathy-chat-handler/cb7113f10b0d60a0d843be8c6569fec8f962a550
diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index b5b8b7a..e550c83 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -1,6 +1,7 @@
/*
Copyright (C) 2010 David Edmundson <kde@davidedmundson.co.uk>
Copyright (C) 2011 Dominik Schmidt <dev@dominik-schmidt.de>
+ Copyright (C) 2011 Francesco Nwokeka <francesco.nwokeka@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -40,6 +41,7 @@
#include <KLineEdit>
#include <TelepathyQt4/Account>
+#include <TelepathyQt4/ContactCapabilities>
#include <TelepathyQt4/PendingChannelRequest>
#include <TelepathyQt4/TextChannel>
@@ -186,7 +188,7 @@ void ChatWindow::onCurrentIndexChanged(int index)
{
kDebug() << index;
- if(index == -1) {
+ if (index == -1) {
close();
return;
}
@@ -201,6 +203,17 @@ void ChatWindow::onCurrentIndexChanged(int index)
} else {
onEnableSearchActions(true);
}
+
+ // check which capabilities the contact and user supports
+ Tp::ContactCapabilities contactCapabilites = \
currentChatTab->textChannel()->targetContact()->capabilities(); + \
Tp::ContactCapabilities selfCapabilities = \
currentChatTab->account()->connection()->selfContact()->capabilities(); +
+ setAudioCallEnabled(selfCapabilities.streamedMediaAudioCalls() && \
contactCapabilites.streamedMediaAudioCalls()); + \
setFileTransferEnabled(selfCapabilities.fileTransfers() && \
contactCapabilites.fileTransfers()); + \
setVideoCallEnabled(selfCapabilities.streamedMediaVideoCalls() && \
contactCapabilites.streamedMediaVideoCalls()); +
+ /// TODO re-activate check when invitation to chat has been sorted out
+ setInviteToChatEnabled(false);
}
void ChatWindow::onEnableSearchActions(bool enable)
@@ -423,6 +436,43 @@ void ChatWindow::setupCustomActions()
actionCollection()->addAction("invite-to-chat", inviteToChat);
}
+void ChatWindow::setAudioCallEnabled(bool enable)
+{
+ QAction *action = actionCollection()->action("audio-call");
+
+ // don't want to segfault. Should never happen
+ if (action) {
+ action->setEnabled(enable);
+ }
+}
+
+void ChatWindow::setFileTransferEnabled(bool enable)
+{
+ QAction *action = actionCollection()->action("send-file");
+
+ if (action) {
+ action->setEnabled(enable);
+ }
+}
+
+void ChatWindow::setInviteToChatEnabled(bool enable)
+{
+ QAction *action = actionCollection()->action("invite-to-chat");
+
+ if (action) {
+ action->setEnabled(enable);
+ }
+}
+
+void ChatWindow::setVideoCallEnabled(bool enable)
+{
+ QAction *action = actionCollection()->action("video-call");
+
+ if (action) {
+ action->setEnabled(enable);
+ }
+}
+
void ChatWindow::startAudioCall(const Tp::AccountPtr& account, const Tp::ContactPtr& \
contact) {
Tp::PendingChannelRequest* channelRequest = \
account->ensureStreamedMediaAudioCall(contact,
diff --git a/app/chat-window.h b/app/chat-window.h
index 661cbea..3a14401 100644
--- a/app/chat-window.h
+++ b/app/chat-window.h
@@ -97,6 +97,12 @@ private:
/** creates and adds custom actions for the chat window */
void setupCustomActions();
+ /** setters for chat actions */
+ void setAudioCallEnabled(bool enable);
+ void setFileTransferEnabled(bool enable);
+ void setInviteToChatEnabled(bool enable);
+ void setVideoCallEnabled(bool enable);
+
/** starts audio call with given contact
* @param account account sending the audio call request
* @param contact contact with whom to start audio call
diff --git a/lib/chat-widget.h b/lib/chat-widget.h
index feacc7b..0255beb 100644
--- a/lib/chat-widget.h
+++ b/lib/chat-widget.h
@@ -1,5 +1,6 @@
/***************************************************************************
* Copyright (C) 2010 by David Edmundson <kde@davidedmundson.co.uk> *
+ * Copyright (C) 2011 by Francesco Nwokeka <francesco.nwokeka@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic