From 32aa4bdd5bd3f243adafeeb2a6b14ea0ba8e9f71 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage <emmanuel@etudiant-nb1.(none)> Date: Fri, 7 May 2010 10:38:45 -0400 Subject: [PATCH] Merging the last changes to the stable qt-client branch --- sflphone-client-kde/src/CMakeLists.txt | 1 - sflphone-client-kde/src/Call.cpp | 16 +++++- sflphone-client-kde/src/Call.h | 1 + sflphone-client-kde/src/CallModel.cpp | 66 ++++++++++++------------ sflphone-client-kde/src/CallModel.h | 11 ++-- sflphone-client-kde/src/CallTreeItem.cpp | 20 ++++--- sflphone-client-kde/src/CallTreeItem.h | 1 + sflphone-client-kde/src/SFLPhone.h | 2 +- sflphone-client-kde/src/SFLPhoneView.cpp | 8 +-- sflphone-client-kde/src/SFLPhoneView.h | 10 ++-- 10 files changed, 80 insertions(+), 56 deletions(-) diff --git a/sflphone-client-kde/src/CMakeLists.txt b/sflphone-client-kde/src/CMakeLists.txt index a8e8bd4eb3..4bf5e151cc 100755 --- a/sflphone-client-kde/src/CMakeLists.txt +++ b/sflphone-client-kde/src/CMakeLists.txt @@ -32,7 +32,6 @@ SET( sflphone_client_kde_SRCS CallTreeItem.cpp configurationmanager_interface_singleton.cpp callmanager_interface_singleton.cpp - #calllist_interface_singleton.cpp instance_interface_singleton.cpp AccountWizard.cpp AccountItemWidget.cpp diff --git a/sflphone-client-kde/src/Call.cpp b/sflphone-client-kde/src/Call.cpp index 2738ebb1e3..0f2bbabee6 100644 --- a/sflphone-client-kde/src/Call.cpp +++ b/sflphone-client-kde/src/Call.cpp @@ -715,6 +715,18 @@ void Call::setConfId(QString value) { QString Call::getCurrentCodecName() { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Codec name: " << callManager.getCurrentCodecName(callId); sleep(5); return callManager.getCurrentCodecName(callId); -} \ No newline at end of file +} + +//This function could also be called mayBeSecure or haveChancesToBeEncryptedButWeCantTell. +bool Call::isSecure() { + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + //MapStringInt addressBookSettings = configurationManager.getAddressbookSettings().value(); + AccountList accountList; + Account* currentAccount = accountList.getAccountById(account); + + if ((currentAccount->getAccountDetail(TLS_ENABLE ) == "true") || (currentAccount->getAccountDetail(TLS_METHOD).toInt())) { + return true; + } + return false; +} diff --git a/sflphone-client-kde/src/Call.h b/sflphone-client-kde/src/Call.h index 7f688e5a52..aee93c53da 100644 --- a/sflphone-client-kde/src/Call.h +++ b/sflphone-client-kde/src/Call.h @@ -259,6 +259,7 @@ public: QString getStopTimeStamp() const; QString getStartTimeStamp() const; QString getCurrentCodecName(); + bool isSecure(); bool isConference() const; void setConference(bool value); diff --git a/sflphone-client-kde/src/CallModel.cpp b/sflphone-client-kde/src/CallModel.cpp index dce32049d1..743707f0bd 100644 --- a/sflphone-client-kde/src/CallModel.cpp +++ b/sflphone-client-kde/src/CallModel.cpp @@ -87,11 +87,11 @@ bool CallModel::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData QByteArray encodedData = data->data(MIME_CALLID); if (!QString(encodedData).isEmpty()) { - clearArtefact(privateCallList_callId[encodedData]->currentItem); + clearArtefact(privateCallList_callId[encodedData]->treeItem); if (!parent) { qDebug() << "Call dropped on empty space"; - if (privateCallList_callId[encodedData]->currentItem->parent()) + if (privateCallList_callId[encodedData]->treeItem->parent()) detachParticipant(privateCallList_callId[encodedData]->call_real); else qDebug() << "The call is not in a conversation (doing nothing)"; @@ -106,12 +106,12 @@ bool CallModel::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData if ((parent->parent()) || (parent->childCount())) { qDebug() << "Call dropped on a conference"; - if ((privateCallList_callId[encodedData]->currentItem->childCount()) && (!parent->childCount())) { + if ((privateCallList_callId[encodedData]->treeItem->childCount()) && (!parent->childCount())) { qDebug() << "Conference dropped on a call (doing nothing)"; return true; } - QTreeWidgetItem* call1 = privateCallList_callId[encodedData]->currentItem; + QTreeWidgetItem* call1 = privateCallList_callId[encodedData]->treeItem; QTreeWidgetItem* call2 = (parent->parent())?parent->parent():parent; if (call1->parent()) { @@ -119,7 +119,7 @@ bool CallModel::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData qDebug() << "Call dropped on it's own conversation (doing nothing)"; return true; } - else if (privateCallList_item[call1]->currentItem->childCount()) { + else if (privateCallList_item[call1]->treeItem->childCount()) { qDebug() << "Merging two conferences"; mergeConferences(privateCallList_item[call1]->call_real,privateCallList_item[call2]->call_real); } @@ -208,8 +208,8 @@ void CallModel::setTitle(QString title) ///Select an item in the TreeView bool CallModel::selectItem(Call* item) { - if (privateCallList_call[item]->currentItem) { - setCurrentItem(privateCallList_call[item]->currentItem); + if (privateCallList_call[item]->treeItem) { + setCurrentItem(privateCallList_call[item]->treeItem); return true; } else @@ -228,8 +228,8 @@ Call* CallModel::getCurrentItem() ///Remove a TreeView item and delete it bool CallModel::removeItem(Call* item) { - if (indexOfTopLevelItem(privateCallList_call[item]->currentItem) != -1) {//TODO To remove once safe - removeItemWidget(privateCallList_call[item]->currentItem,0); + if (indexOfTopLevelItem(privateCallList_call[item]->treeItem) != -1) {//TODO To remove once safe + removeItemWidget(privateCallList_call[item]->treeItem,0); return true; } else @@ -245,7 +245,7 @@ QWidget* CallModel::getWidget() ///Convenience wrapper around extractItem(QTreeWidgetItem*) QTreeWidgetItem* CallModel::extractItem(QString callId) { - QTreeWidgetItem* currentItem = privateCallList_callId[callId]->currentItem; + QTreeWidgetItem* currentItem = privateCallList_callId[callId]->treeItem; return extractItem(currentItem); } @@ -271,7 +271,7 @@ QTreeWidgetItem* CallModel::extractItem(QTreeWidgetItem* item) ///Convenience wrapper around insertItem(QTreeWidgetItem*, QTreeWidgetItem*) CallTreeItem* CallModel::insertItem(QTreeWidgetItem* item, Call* parent) { - return insertItem(item,(parent)?privateCallList_call[parent]->currentItem:0); + return insertItem(item,(parent)?privateCallList_call[parent]->treeItem:0); } ///Insert a TreeView item in the TreeView as child of parent or as a top level item, also restore the item Widget @@ -301,13 +301,13 @@ CallTreeItem* CallModel::insertItem(QTreeWidgetItem* item, QTreeWidgetItem* pare ///Remove a call from the interface void CallModel::destroyCall(Call* toDestroy) { - if (privateCallList_call[toDestroy]->currentItem == currentItem()) + if (privateCallList_call[toDestroy]->treeItem == currentItem()) setCurrentItem(0); - if (indexOfTopLevelItem(privateCallList_call[toDestroy]->currentItem) != -1) - takeTopLevelItem(indexOfTopLevelItem(privateCallList_call[toDestroy]->currentItem)); - else if (privateCallList_call[toDestroy]->currentItem->parent()) - privateCallList_call[toDestroy]->currentItem->parent()->removeChild(privateCallList_call[toDestroy]->currentItem); + if (indexOfTopLevelItem(privateCallList_call[toDestroy]->treeItem) != -1) + takeTopLevelItem(indexOfTopLevelItem(privateCallList_call[toDestroy]->treeItem)); + else if (privateCallList_call[toDestroy]->treeItem->parent()) + privateCallList_call[toDestroy]->treeItem->parent()->removeChild(privateCallList_call[toDestroy]->treeItem); else qDebug() << "Call not found"; } @@ -333,7 +333,7 @@ Call* CallModel::addCall(Call* call, Call* parent) aNewStruct->call_real = call; QTreeWidgetItem* callItem = new QTreeWidgetItem(); - aNewStruct->currentItem = callItem; + aNewStruct->treeItem = callItem; aNewStruct->conference = false; privateCallList_item[callItem] = aNewStruct; @@ -419,7 +419,7 @@ Call* CallModel::addConference(const QString & confID) aNewStruct->conference = true; QTreeWidgetItem* confItem = new QTreeWidgetItem(); - aNewStruct->currentItem = confItem; + aNewStruct->treeItem = confItem; privateCallList_item[confItem] = aNewStruct; privateCallList_call[newConf] = aNewStruct; @@ -431,7 +431,7 @@ Call* CallModel::addConference(const QString & confID) setCurrentItem(confItem); foreach (QString callId, callList) { - insertItem(extractItem(privateCallList_callId[callId]->currentItem),confItem); + insertItem(extractItem(privateCallList_callId[callId]->treeItem),confItem); } return newConf; } @@ -487,7 +487,7 @@ void CallModel::conferenceChanged(const QString &confId, const QString &state) return; } - if (!privateCallList_callId[confId]->currentItem) { + if (!privateCallList_callId[confId]->treeItem) { qDebug() << "The conference item does not exist"; return; } @@ -495,32 +495,32 @@ void CallModel::conferenceChanged(const QString &confId, const QString &state) QList<QTreeWidgetItem*> buffer; foreach (QString callId, callList) { if (privateCallList_callId[callId]) { - QTreeWidgetItem* item3 = extractItem(privateCallList_callId[callId]->currentItem); - insertItem(item3, privateCallList_callId[confId]->currentItem); - buffer << privateCallList_callId[callId]->currentItem; + QTreeWidgetItem* item3 = extractItem(privateCallList_callId[callId]->treeItem); + insertItem(item3, privateCallList_callId[confId]->treeItem); + buffer << privateCallList_callId[callId]->treeItem; } else qDebug() << "Call " << callId << " does not exist"; } - for (int j =0; j < privateCallList_callId[confId]->currentItem->childCount();j++) { - if (buffer.indexOf(privateCallList_callId[confId]->currentItem->child(j)) == -1) - insertItem(extractItem(privateCallList_callId[confId]->currentItem->child(j))); + for (int j =0; j < privateCallList_callId[confId]->treeItem->childCount();j++) { + if (buffer.indexOf(privateCallList_callId[confId]->treeItem->child(j)) == -1) + insertItem(extractItem(privateCallList_callId[confId]->treeItem->child(j))); } } ///Remove a conference from the model and the TreeView void CallModel::conferenceRemoved(const QString &confId) { - qDebug() << "Ending conversation containing " << privateCallList_callId[confId]->currentItem->childCount() << " participants"; - for (int j =0; j < privateCallList_callId[confId]->currentItem->childCount();j++) { - insertItem(extractItem(privateCallList_callId[confId]->currentItem->child(j))); + qDebug() << "Ending conversation containing " << privateCallList_callId[confId]->treeItem->childCount() << " participants"; + for (int j =0; j < privateCallList_callId[confId]->treeItem->childCount();j++) { + insertItem(extractItem(privateCallList_callId[confId]->treeItem->child(j))); } privateCallList_call.remove(privateCallList_callId[confId]->call_real); privateCallList_widget.remove(privateCallList_callId[confId]->call); - privateCallList_item.remove(privateCallList_callId[confId]->currentItem); - takeTopLevelItem(indexOfTopLevelItem(privateCallList_callId[confId]->currentItem)); - delete privateCallList_callId[confId]->currentItem; + privateCallList_item.remove(privateCallList_callId[confId]->treeItem); + takeTopLevelItem(indexOfTopLevelItem(privateCallList_callId[confId]->treeItem)); + delete privateCallList_callId[confId]->treeItem; privateCallList_callId.remove(confId); } @@ -546,4 +546,4 @@ MapStringString CallModel::getHistoryMap() void CallModel::clearHistory() { historyCalls.clear(); -} \ No newline at end of file +} diff --git a/sflphone-client-kde/src/CallModel.h b/sflphone-client-kde/src/CallModel.h index d95f1c29e0..07e9882e42 100644 --- a/sflphone-client-kde/src/CallModel.h +++ b/sflphone-client-kde/src/CallModel.h @@ -25,10 +25,12 @@ #include <QHash> #include <QTreeWidgetItem> #include <QVector> +#include <QTreeWidget> +#include <QItemDelegate> +#include <QDragEnterEvent> #include "CallTreeItem.h" #include "Call.h" -#include "CallTreeWidget.h" #include "dbus/metatypes.h" /** Note from the author: It was previously done by a QAbstractModel + QTreeView, but the sip-call use case is incompatible @@ -44,7 +46,7 @@ struct InternalCallModelStruct { InternalCallModelStruct* parent; CallTreeItem* call; Call* call_real; - QTreeWidgetItem* currentItem; + QTreeWidgetItem* treeItem; QList<InternalCallModelStruct*> children; bool conference; }; @@ -66,7 +68,8 @@ class CallModel : private QTreeWidget { public: enum ModelType { ActiveCall, - History + History, + Address }; CallModel(ModelType type, QWidget* parent =0); @@ -120,4 +123,4 @@ class CallModel : private QTreeWidget { public slots: void clearHistory(); }; -#endif \ No newline at end of file +#endif diff --git a/sflphone-client-kde/src/CallTreeItem.cpp b/sflphone-client-kde/src/CallTreeItem.cpp index c810b3cd97..dc2b15d935 100644 --- a/sflphone-client-kde/src/CallTreeItem.cpp +++ b/sflphone-client-kde/src/CallTreeItem.cpp @@ -72,19 +72,21 @@ void CallTreeItem::setCall(Call *call) labelCallNumber2 = new QLabel(itemCall->getPeerPhoneNumber()); labelTransferPrefix = new QLabel(i18n("Transfer to : ")); labelTransferNumber = new QLabel(); - QSpacerItem * verticalSpacer = new QSpacerItem(16777215, 20, QSizePolicy::Expanding, QSizePolicy::Expanding); + QSpacerItem* verticalSpacer = new QSpacerItem(16777215, 20, QSizePolicy::Expanding, QSizePolicy::Expanding); - QHBoxLayout * mainLayout = new QHBoxLayout(); + QHBoxLayout* mainLayout = new QHBoxLayout(); mainLayout->setContentsMargins ( 3, 1, 2, 1); labelCodec = new QLabel(this); - labelCodec->setText("Codec: "+itemCall->getCurrentCodecName()); + //labelCodec->setText("Codec: "+itemCall->getCurrentCodecName()); + + labelSecure = new QLabel(this); mainLayout->setSpacing(4); - QVBoxLayout * descr = new QVBoxLayout(); + QVBoxLayout* descr = new QVBoxLayout(); descr->setMargin(1); descr->setSpacing(1); - QHBoxLayout * transfer = new QHBoxLayout(); + QHBoxLayout* transfer = new QHBoxLayout(); transfer->setMargin(0); transfer->setSpacing(0); mainLayout->addWidget(labelIcon); @@ -95,6 +97,7 @@ void CallTreeItem::setCall(Call *call) } descr->addWidget(labelCallNumber2); + descr->addWidget(labelSecure); descr->addWidget(labelCodec); transfer->addWidget(labelTransferPrefix); transfer->addWidget(labelTransferNumber); @@ -136,6 +139,11 @@ void CallTreeItem::updated() if(state == CALL_STATE_DIALING) { labelCallNumber2->setText(itemCall->getCallNumber()); } + else { + labelCodec->setText("Codec: "+itemCall->getCurrentCodecName()); + if (itemCall->isSecure()) + labelSecure->setText("⚷"); + } } else { qDebug() << "Updating item of call of state OVER. Doing nothing."; @@ -153,4 +161,4 @@ void CallTreeItem::setConference(bool value) { bool CallTreeItem::isConference() { return conference; } - \ No newline at end of file + diff --git a/sflphone-client-kde/src/CallTreeItem.h b/sflphone-client-kde/src/CallTreeItem.h index 6874046600..ff76000a33 100644 --- a/sflphone-client-kde/src/CallTreeItem.h +++ b/sflphone-client-kde/src/CallTreeItem.h @@ -63,6 +63,7 @@ class CallTreeItem : public QWidget QLabel* labelTransferPrefix; QLabel* labelTransferNumber; QLabel* labelCodec; + QLabel* labelSecure; QWidget* historyItemWidget; QLabel* labelHistoryIcon; diff --git a/sflphone-client-kde/src/SFLPhone.h b/sflphone-client-kde/src/SFLPhone.h index 0a73c42425..f3d381db21 100644 --- a/sflphone-client-kde/src/SFLPhone.h +++ b/sflphone-client-kde/src/SFLPhone.h @@ -35,7 +35,7 @@ #include <QActionGroup> // #include "ui_SFLPhoneView_base.h" -#include "CallList.h" +//#include "CallList.h" #include "AccountWizard.h" #include "Contact.h" #include "SFLPhoneView.h" diff --git a/sflphone-client-kde/src/SFLPhoneView.cpp b/sflphone-client-kde/src/SFLPhoneView.cpp index e1adf3a07d..843410a294 100644 --- a/sflphone-client-kde/src/SFLPhoneView.cpp +++ b/sflphone-client-kde/src/SFLPhoneView.cpp @@ -41,7 +41,6 @@ #include "sflphone_const.h" #include "conf/ConfigurationSkeleton.h" #include "configurationmanager_interface_singleton.h" -#include "calllist_interface_singleton.h" #include "callmanager_interface_singleton.h" #include "instance_interface_singleton.h" #include "ActionSetAccountFirst.h" @@ -49,7 +48,6 @@ #include "SFLPhone.h" #include "typedefs.h" #include "Dialpad.h" -#include "CallTreeView.h" #include "CallTreeItem.h" @@ -62,7 +60,8 @@ QString SFLPhoneView::priorAccountId; SFLPhoneView::SFLPhoneView(QWidget *parent) : QWidget(parent), callTreeModel(CallModel::ActiveCall), - historyTreeModel(CallModel::History) + historyTreeModel(CallModel::History), + addressBookTree(CallModel::Address) { setupUi(this); @@ -308,7 +307,8 @@ void SFLPhoneView::backspace() else { call->backspaceItemText(); if(call->getState() == CALL_STATE_OVER) { - callTreeModel.removeItem(callTreeModel.getCurrentItem()); + if (callTreeModel.getCurrentItem()) + callTreeModel.removeItem(callTreeModel.getCurrentItem()); if(call->getHistoryState() != NONE) { //historyTree->insert(call); diff --git a/sflphone-client-kde/src/SFLPhoneView.h b/sflphone-client-kde/src/SFLPhoneView.h index bde00f1e74..9b6d07af15 100644 --- a/sflphone-client-kde/src/SFLPhoneView.h +++ b/sflphone-client-kde/src/SFLPhoneView.h @@ -32,10 +32,10 @@ #include "ui_SFLPhoneView_base.h" #include "conf/ConfigurationDialog.h" -#include "CallList.h" +//#include "CallList.h" #include "CallTreeItem.h" -#include "CallTreeView.h" -#include "CallTreeWidget.h" +//#include "CallTreeView.h" +//#include "CallTreeWidget.h" #include "AccountWizard.h" #include "Contact.h" #include "AccountList.h" @@ -67,7 +67,7 @@ private: AccountWizard * wizard; //List of calls in the window, and past ones. //Handles both current calls (dialing, ringing...) and history. - CallList * callList; + //CallList * callList; QErrorMessage * errorWindow; //Account used prioritary if defined and registered. If not, the first registered account in accountList is used. static QString priorAccountId; @@ -144,7 +144,7 @@ public: //CallTreeView *addressBookTree; //CallTreeWidget *callTree; //CallTreeWidget *historyTree; - CallTreeWidget *addressBookTree; + CallModel addressBookTree; CallModel callTreeModel; CallModel historyTreeModel; -- GitLab