From 71d48d47febcbbf5a98a6fbe3a8b43df76a8b5af Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage <emmanuel.lepage@savoirfairelinux.com> Date: Thu, 14 Jun 2012 14:38:14 -0400 Subject: [PATCH] [ #12352 ] Use object instead of QString id for 'addDialingCall' --- kde/src/CallView.cpp | 7 ++--- kde/src/SFLPhoneView.cpp | 4 +-- kde/src/klib/dataengine/sflphoneService.cpp | 7 ++--- kde/src/klib/dataengine/sflphoneService.h | 6 +++-- kde/src/lib/CallModel.cpp | 22 +++++++-------- kde/src/lib/CallModel.h | 30 ++++++++++----------- kde/src/lib/CallModel.hpp | 9 +++---- kde/src/widgets/ContactItemWidget.cpp | 2 +- kde/src/widgets/HistoryDock.cpp | 2 +- kde/src/widgets/HistoryTreeItem.cpp | 2 +- 10 files changed, 44 insertions(+), 47 deletions(-) diff --git a/kde/src/CallView.cpp b/kde/src/CallView.cpp index 03f6842a7f..1310ca2538 100644 --- a/kde/src/CallView.cpp +++ b/kde/src/CallView.cpp @@ -272,11 +272,8 @@ bool CallView::phoneNumberToCall(QTreeWidgetItem *parent, int index, const QMime if (!QString(encodedPhoneNumber).isEmpty()) { Contact* contact = AkonadiBackend::getInstance()->getContactByPhone(encodedPhoneNumber); QString name; - if (contact) - name = contact->getFormattedName(); - else - name = i18n("Unknown"); - Call* call2 = SFLPhone::model()->addDialingCall(name, SFLPhone::model()->getCurrentAccountId()); + name = (contact)?contact->getFormattedName():i18n("Unknown"); + Call* call2 = SFLPhone::model()->addDialingCall(name, SFLPhone::model()->getCurrentAccount()); call2->appendText(QString(encodedPhoneNumber)); if (!parent) { //Dropped on free space diff --git a/kde/src/SFLPhoneView.cpp b/kde/src/SFLPhoneView.cpp index cda5c0d4af..a826334eb2 100755 --- a/kde/src/SFLPhoneView.cpp +++ b/kde/src/SFLPhoneView.cpp @@ -278,7 +278,7 @@ void SFLPhoneView::action(Call* call, call_action action) bool SFLPhoneView::selectCallPhoneNumber(Call* call2,Contact* contact) { if (contact->getPhoneNumbers().count() == 1) { - call2 = SFLPhone::model()->addDialingCall(contact->getFormattedName(), SFLPhone::model()->getCurrentAccountId()); + call2 = SFLPhone::model()->addDialingCall(contact->getFormattedName(), SFLPhone::model()->getCurrentAccount()); call2->appendText(contact->getPhoneNumbers()[0]->getNumber()); } else if (contact->getPhoneNumbers().count() > 1) { @@ -291,7 +291,7 @@ bool SFLPhoneView::selectCallPhoneNumber(Call* call2,Contact* contact) } QString result = QInputDialog::getItem (this, i18n("Select phone number"), i18n("This contact have many phone number, please select the one you wish to call"), list, 0, false, &ok); if (ok) { - call2 = SFLPhone::model()->addDialingCall(contact->getFormattedName(), SFLPhone::model()->getCurrentAccountId()); + call2 = SFLPhone::model()->addDialingCall(contact->getFormattedName(), SFLPhone::model()->getCurrentAccount()); call2->appendText(map[result]); } else { diff --git a/kde/src/klib/dataengine/sflphoneService.cpp b/kde/src/klib/dataengine/sflphoneService.cpp index 952dd4905f..0cd5d591b0 100644 --- a/kde/src/klib/dataengine/sflphoneService.cpp +++ b/kde/src/klib/dataengine/sflphoneService.cpp @@ -21,6 +21,7 @@ #include "sflphoneService.h" #include "../../lib/Call.h" +#include "../../lib/Account.h" /***************************************************************************** * * @@ -31,8 +32,8 @@ ///Constructor CallJob::CallJob(QObject* parent, const QString& operation, const QVariantMap& parameters) : Plasma::ServiceJob("", operation, parameters, parent) - , m_AccountId ( parameters[ "AccountId" ].toString() ) - , m_Number ( parameters[ "Number" ].toString() ) + , m_pAccount ( Account::buildExistingAccountFromId(parameters[ "AccountId" ].toString() )) + , m_Number ( parameters[ "Number" ].toString() ) { } @@ -40,7 +41,7 @@ CallJob::CallJob(QObject* parent, const QString& operation, const QVariantMap& p ///Make a call void CallJob::start() { - Call* call = SFLPhoneEngine::getModel()->addDialingCall(m_Number,m_AccountId); + Call* call = SFLPhoneEngine::getModel()->addDialingCall(m_Number,m_pAccount); call->setCallNumber(m_Number); call->actionPerformed(CALL_ACTION_ACCEPT); } diff --git a/kde/src/klib/dataengine/sflphoneService.h b/kde/src/klib/dataengine/sflphoneService.h index b73d5078cf..b5004f863d 100644 --- a/kde/src/klib/dataengine/sflphoneService.h +++ b/kde/src/klib/dataengine/sflphoneService.h @@ -31,6 +31,8 @@ using namespace Plasma; +class Account; + ///@class SFLPhoneService RPC between the plasmoid and the library class SFLPhoneService : public Plasma::Service { @@ -54,8 +56,8 @@ public: void start(); private: - QString m_AccountId; - QString m_Number ; + Account* m_pAccount; + QString m_Number ; }; ///@class DTMFJob Play a sound when called diff --git a/kde/src/lib/CallModel.cpp b/kde/src/lib/CallModel.cpp index 93afb27574..e5184f86fb 100644 --- a/kde/src/lib/CallModel.cpp +++ b/kde/src/lib/CallModel.cpp @@ -34,13 +34,13 @@ CallModelBase::CallModelBase(QObject* parent) : QObject(parent) //SLOTS // SENDER SIGNAL RECEIVER SLOT / - /**/connect(&callManager, SIGNAL( callStateChanged (const QString &, const QString & ) ), this , SLOT( callStateChanged ( const QString &, const QString & ) ) ); - /**/connect(&callManager, SIGNAL( incomingCall (const QString &, const QString &, const QString & ) ), this , SLOT( incomingCall ( const QString &, const QString & ) ) ); - /**/connect(&callManager, SIGNAL( conferenceCreated (const QString & ) ), this , SLOT( incomingConference( const QString & ) ) ); - /**/connect(&callManager, SIGNAL( conferenceChanged (const QString &, const QString & ) ), this , SLOT( changingConference( const QString &, const QString & ) ) ); - /**/connect(&callManager, SIGNAL( conferenceRemoved (const QString & ) ), this , SLOT( conferenceRemoved ( const QString & ) ) ); - /**/connect(&callManager, SIGNAL( voiceMailNotify (const QString &, int ) ), this , SLOT( voiceMailNotify ( const QString &, int ) ) ); - /**/connect(&callManager, SIGNAL( volumeChanged (const QString &, double ) ), this , SLOT( volumeChanged ( const QString &, double ) ) ); + /**/connect(&callManager, SIGNAL( callStateChanged (const QString &, const QString & ) ), this , SLOT( callStateChanged ( const QString &, const QString & ) ) ); + /**/connect(&callManager, SIGNAL( incomingCall (const QString &, const QString &, const QString & ) ), this , SLOT( incomingCall ( const QString &, const QString & ) ) ); + /**/connect(&callManager, SIGNAL( conferenceCreated (const QString & ) ), this , SLOT( incomingConference ( const QString & ) ) ); + /**/connect(&callManager, SIGNAL( conferenceChanged (const QString &, const QString & ) ), this , SLOT( changingConference ( const QString &, const QString & ) ) ); + /**/connect(&callManager, SIGNAL( conferenceRemoved (const QString & ) ), this , SLOT( conferenceRemovedSlot ( const QString & ) ) ); + /**/connect(&callManager, SIGNAL( voiceMailNotify (const QString &, int ) ), this , SLOT( voiceMailNotifySlot ( const QString &, int ) ) ); + /**/connect(&callManager, SIGNAL( volumeChanged (const QString &, double ) ), this , SLOT( volumeChangedSlot ( const QString &, double ) ) ); /* */ connect(HistoryModel::self(),SIGNAL(newHistoryCall(Call*)),this,SLOT(addPrivateCall(Call*))); @@ -111,7 +111,7 @@ void CallModelBase::incomingCall(const QString & accountID, const QString & call void CallModelBase::incomingConference(const QString &confID) { Call* conf = addConference(confID); - qDebug() << "---------------Adding conference" << conf << confID << "---------------"; + qDebug() << "Adding conference" << conf << confID; emit conferenceCreated(conf); } @@ -131,7 +131,7 @@ void CallModelBase::changingConference(const QString &confID, const QString &sta } ///When a conference is removed -void CallModelBase::conferenceRemoved(const QString &confId) +void CallModelBase::conferenceRemovedSlot(const QString &confId) { Call* conf = getCall(confId); emit aboutToRemoveConference(conf); @@ -140,14 +140,14 @@ void CallModelBase::conferenceRemoved(const QString &confId) } ///When a new voice mail is available -void CallModelBase::voiceMailNotify(const QString &accountID, int count) +void CallModelBase::voiceMailNotifySlot(const QString &accountID, int count) { qDebug() << "Signal : VoiceMail Notify ! " << count << " new voice mails for account " << accountID; emit voiceMailNotify(accountID,count); } ///When the daemon change the volume -void CallModelBase::volumeChanged(const QString & device, double value) +void CallModelBase::volumeChangedSlot(const QString & device, double value) { emit volumeChanged(device,value); } diff --git a/kde/src/lib/CallModel.h b/kde/src/lib/CallModel.h index d6c67d9870..06fcf3b7ba 100644 --- a/kde/src/lib/CallModel.h +++ b/kde/src/lib/CallModel.h @@ -65,13 +65,13 @@ public: static AccountList* getAccountList ( ); public slots: - void callStateChanged ( const QString& callID , const QString &state ); - void incomingCall ( const QString& accountID , const QString & callID ); - void incomingConference ( const QString& confID ); - void changingConference ( const QString& confID , const QString &state ); - void conferenceRemoved ( const QString& confId ); - void voiceMailNotify ( const QString& accountID , int count ); - void volumeChanged ( const QString& device , double value ); + void callStateChanged ( const QString& callID , const QString &state ); + void incomingCall ( const QString& accountID , const QString & callID ); + void incomingConference ( const QString& confID ); + void changingConference ( const QString& confID , const QString &state ); + void conferenceRemovedSlot ( const QString& confId ); + void voiceMailNotifySlot ( const QString& accountID , int count ); + void volumeChangedSlot ( const QString& device , double value ); protected: static CallMap m_sActiveCalls; @@ -119,14 +119,14 @@ class LIB_EXPORT CallModel : public CallModelBase { static void destroy ( ); //Call related - virtual Call* addCall ( Call* call , Call* parent =0 ); - Call* addDialingCall ( const QString& peerName="", QString account="" ); - Call* addIncomingCall ( const QString& callId ); - Call* addRingingCall ( const QString& callId ); - static QString generateCallId ( ); - void removeCall ( Call* call ); - void attendedTransfer ( Call* toTransfer , Call* target ); - void transfer ( Call* toTransfer , QString target ); + virtual Call* addCall ( Call* call , Call* parent =0 ); + Call* addDialingCall ( const QString& peerName="", Account* account=nullptr ); + Call* addIncomingCall ( const QString& callId ); + Call* addRingingCall ( const QString& callId ); + static QString generateCallId ( ); + void removeCall ( Call* call ); + void attendedTransfer ( Call* toTransfer , Call* target ); + void transfer ( Call* toTransfer , QString target ); virtual bool selectItem(Call* item) { Q_UNUSED(item); return false;} diff --git a/kde/src/lib/CallModel.hpp b/kde/src/lib/CallModel.hpp index 6d2daa8f3e..fb0f342d54 100644 --- a/kde/src/lib/CallModel.hpp +++ b/kde/src/lib/CallModel.hpp @@ -210,14 +210,11 @@ CALLMODEL_TEMPLATE Call* CALLMODEL_T::addCallCommon(Call* call) } //addCallCommon ///Create a new dialing call from peer name and the account ID -CALLMODEL_TEMPLATE Call* CALLMODEL_T::addDialingCall(const QString& peerName, QString account) +CALLMODEL_TEMPLATE Call* CALLMODEL_T::addDialingCall(const QString& peerName, Account* account) { - QString account2 = account; - if (account2.isEmpty()) { - account2 = getCurrentAccountId(); - } + Account* acc = (account)?account:getCurrentAccount(); - Call* call = Call::buildDialingCall(generateCallId(), peerName, account2); + Call* call = Call::buildDialingCall(generateCallId(), peerName, acc->getAccountId()); return addCallCommon(call); } //addDialingCall diff --git a/kde/src/widgets/ContactItemWidget.cpp b/kde/src/widgets/ContactItemWidget.cpp index 1cade1ef2c..d3f2cf0c08 100644 --- a/kde/src/widgets/ContactItemWidget.cpp +++ b/kde/src/widgets/ContactItemWidget.cpp @@ -336,7 +336,7 @@ void ContactItemWidget::callAgain() bool ok; QString number = showNumberSelector(ok); if (ok) { - Call* call = SFLPhone::model()->addDialingCall(m_pContactKA->getFormattedName(), SFLPhone::app()->model()->getCurrentAccountId()); + Call* call = SFLPhone::model()->addDialingCall(m_pContactKA->getFormattedName(), SFLPhone::app()->model()->getCurrentAccount()); call->setCallNumber(number); call->setPeerName(m_pContactKA->getFormattedName()); call->actionPerformed(CALL_ACTION_ACCEPT); diff --git a/kde/src/widgets/HistoryDock.cpp b/kde/src/widgets/HistoryDock.cpp index d11cb8f110..c6e989f976 100644 --- a/kde/src/widgets/HistoryDock.cpp +++ b/kde/src/widgets/HistoryDock.cpp @@ -429,7 +429,7 @@ void HistoryDock::keyPressEvent(QKeyEvent* event) { if (m_pItemView->selectedItems()[0] && m_pItemView->itemWidget(m_pItemView->selectedItems()[0],0)) { QNumericTreeWidgetItem* item = dynamic_cast<QNumericTreeWidgetItem*>(m_pItemView->selectedItems()[0]); if (item) { - SFLPhone::model()->addDialingCall(item->widget->getName(), SFLPhone::app()->model()->getCurrentAccountId())->setCallNumber(item->widget->getPhoneNumber()); + SFLPhone::model()->addDialingCall(item->widget->getName(), SFLPhone::app()->model()->getCurrentAccount())->setCallNumber(item->widget->getPhoneNumber()); } } } diff --git a/kde/src/widgets/HistoryTreeItem.cpp b/kde/src/widgets/HistoryTreeItem.cpp index d4510e180c..a0471e4415 100644 --- a/kde/src/widgets/HistoryTreeItem.cpp +++ b/kde/src/widgets/HistoryTreeItem.cpp @@ -248,7 +248,7 @@ void HistoryTreeItem::callAgain() if (m_pItemCall) { kDebug() << "Calling "<< m_pItemCall->getPeerPhoneNumber(); } - Call* call = SFLPhone::model()->addDialingCall(getName(), SFLPhone::app()->model()->getCurrentAccountId()); + Call* call = SFLPhone::model()->addDialingCall(getName(), SFLPhone::app()->model()->getCurrentAccount()); call->setCallNumber(m_PhoneNumber); call->setPeerName(m_pPeerNameL->text()); call->actionPerformed(CALL_ACTION_ACCEPT); -- GitLab