Skip to content
Snippets Groups Projects
Commit 670e2a2f authored by Tristan Matthews's avatar Tristan Matthews
Browse files
parents 99e6a3b6 008c8846
No related branches found
No related tags found
No related merge requests found
...@@ -145,10 +145,10 @@ void SFLPhoneView::typeString(QString str) ...@@ -145,10 +145,10 @@ void SFLPhoneView::typeString(QString str)
} }
foreach (Call* call2, SFLPhone::model()->getCallList()) { foreach (Call* call2, SFLPhone::model()->getCallList()) {
if(currentCall != call2 && call2->getState() == CALL_STATE_CURRENT) { if(dynamic_cast<Call*>(call2) && currentCall != call2 && call2->getState() == CALL_STATE_CURRENT) {
action(call2, CALL_ACTION_HOLD); action(call2, CALL_ACTION_HOLD);
} }
else if(call2->getState() == CALL_STATE_DIALING) { else if(dynamic_cast<Call*>(call2) && call2->getState() == CALL_STATE_DIALING) {
candidate = call2; candidate = call2;
} }
} }
......
...@@ -10,7 +10,18 @@ ...@@ -10,7 +10,18 @@
ContactHash HelperFunctions::toHash(QList<Contact*> contacts) { ContactHash HelperFunctions::toHash(QList<Contact*> contacts) {
QHash<QString,QHash<QString,QVariant> > hash; QHash<QString,QHash<QString,QVariant> > hash;
for (int i=0;i<contacts.size();i++) { for (int i=0;i<contacts.size();i++) {
hash[contacts[i]->getUid()] = contacts[i]->toHash(); Contact* cont = contacts[i];
QHash<QString,QVariant> conth = cont->toHash();
conth["phoneCount"] = cont->getPhoneNumbers().size();
if (cont->getPhoneNumbers().size() == 1) {
conth["phoneNumber"] = cont->getPhoneNumbers()[0]->getNumber();
conth["phoneType" ] = cont->getPhoneNumbers()[0]->getType();
}
else {
conth["phoneNumber"] = QString::number(cont->getPhoneNumbers().size())+" numbers";
conth["phoneType" ] = "";
}
hash[contacts[i]->getUid()] = conth;
} }
return hash; return hash;
} }
\ No newline at end of file
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "../../lib/Call.h" #include "../../lib/Call.h"
#include "../../lib/Account.h" #include "../../lib/Account.h"
#include "../../lib/AccountList.h" #include "../../lib/AccountList.h"
#include "../../lib/Contact.h"
#include "../../lib/dbus/metatypes.h" #include "../../lib/dbus/metatypes.h"
#include "../../lib/instance_interface_singleton.h" #include "../../lib/instance_interface_singleton.h"
#include "../../lib/configurationmanager_interface_singleton.h" #include "../../lib/configurationmanager_interface_singleton.h"
...@@ -29,6 +30,8 @@ SFLPhoneEngine::SFLPhoneEngine(QObject* parent, const QVariantList& args) ...@@ -29,6 +30,8 @@ SFLPhoneEngine::SFLPhoneEngine(QObject* parent, const QVariantList& args)
//CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); //CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance();
connect(m_pModel , SIGNAL( callStateChanged(Call*)) , this , SLOT(callStateChangedSignal(Call*) ));
connect(m_pModel , SIGNAL( callAdded(Call*)) , this , SLOT(callStateChangedSignal(Call*) ));
connect(m_pModel , SIGNAL( callStateChanged(Call*)) , this , SLOT(callStateChangedSignal(Call*) )); connect(m_pModel , SIGNAL( callStateChanged(Call*)) , this , SLOT(callStateChangedSignal(Call*) ));
//connect(&callManager , SIGNAL( incomingCall(Call*)) , this , SLOT(incomingCallSignal(Call*) )); //connect(&callManager , SIGNAL( incomingCall(Call*)) , this , SLOT(incomingCallSignal(Call*) ));
//connect(&callManager , SIGNAL( conferenceCreated(Call*)) , this , SLOT(conferenceCreatedSignal(Call*) )); //connect(&callManager , SIGNAL( conferenceCreated(Call*)) , this , SLOT(conferenceCreatedSignal(Call*) ));
...@@ -60,6 +63,9 @@ bool SFLPhoneEngine::sourceRequestEvent(const QString &name) ...@@ -60,6 +63,9 @@ bool SFLPhoneEngine::sourceRequestEvent(const QString &name)
else if ( name == "bookmark" ) { else if ( name == "bookmark" ) {
updateBookmarkList(); updateBookmarkList();
} }
else if ( name.left(7) == "Number:" ) {
generateNumberList(name);
}
return true;//updateSourceEvent(name); return true;//updateSourceEvent(name);
} }
...@@ -124,6 +130,7 @@ void SFLPhoneEngine::updateHistory() ...@@ -124,6 +130,7 @@ void SFLPhoneEngine::updateHistory()
historyCall[oldCall->getCallId()][ "peerNumber" ] = oldCall->getPeerPhoneNumber(); historyCall[oldCall->getCallId()][ "peerNumber" ] = oldCall->getPeerPhoneNumber();
historyCall[oldCall->getCallId()][ "length" ] = oldCall->getStopTimeStamp().toInt() - oldCall->getStartTimeStamp().toInt(); historyCall[oldCall->getCallId()][ "length" ] = oldCall->getStopTimeStamp().toInt() - oldCall->getStartTimeStamp().toInt();
historyCall[oldCall->getCallId()][ "date" ] = oldCall->getStopTimeStamp(); historyCall[oldCall->getCallId()][ "date" ] = oldCall->getStopTimeStamp();
historyCall[oldCall->getCallId()][ "id" ] = oldCall->getCallId();
if (oldCall->property("section").isValid()) if (oldCall->property("section").isValid())
historyCall[oldCall->getCallId()][ "section" ] = oldCall->property("section"); historyCall[oldCall->getCallId()][ "section" ] = oldCall->property("section");
setData("history", oldCall->getCallId() , historyCall[oldCall->getCallId()]); setData("history", oldCall->getCallId() , historyCall[oldCall->getCallId()]);
...@@ -132,12 +139,14 @@ void SFLPhoneEngine::updateHistory() ...@@ -132,12 +139,14 @@ void SFLPhoneEngine::updateHistory()
void SFLPhoneEngine::updateCallList() void SFLPhoneEngine::updateCallList()
{ {
removeAllData("calls");
foreach (Call* call, m_pModel->getCalls()) { foreach (Call* call, m_pModel->getCalls()) {
if ((!m_pModel->isConference(call)) && (call->getState() != CALL_STATE_OVER)) { if ((!m_pModel->isConference(call)) && (call->getState() != CALL_STATE_OVER)) {
currentCall[call->getCallId()][ "peerName" ] = call->getPeerName(); currentCall[call->getCallId()][ "peerName" ] = call->getPeerName();
currentCall[call->getCallId()][ "peerNumber" ] = call->getPeerPhoneNumber(); currentCall[call->getCallId()][ "peerNumber" ] = call->getPeerPhoneNumber();
currentCall[call->getCallId()][ "stateName" ] = getCallStateName(call->getState()); currentCall[call->getCallId()][ "stateName" ] = getCallStateName(call->getState());
currentCall[call->getCallId()][ "state" ] = call->getState(); currentCall[call->getCallId()][ "state" ] = call->getState();
currentCall[call->getCallId()][ "id" ] = call->getCallId();
setData("calls", call->getCallId(), currentCall[call->getCallId()]); setData("calls", call->getCallId(), currentCall[call->getCallId()]);
} }
} }
...@@ -160,6 +169,7 @@ void SFLPhoneEngine::updateBookmarkList() ...@@ -160,6 +169,7 @@ void SFLPhoneEngine::updateBookmarkList()
pop["peerNumber" ] = cl[i] ; pop["peerNumber" ] = cl[i] ;
pop["section" ] = "Popular" ; pop["section" ] = "Popular" ;
pop["listPriority" ] = 1000 ; pop["listPriority" ] = 1000 ;
pop["id" ] = i ;
setData("bookmark", QString::number(i), pop); setData("bookmark", QString::number(i), pop);
} }
...@@ -171,6 +181,7 @@ void SFLPhoneEngine::updateBookmarkList() ...@@ -171,6 +181,7 @@ void SFLPhoneEngine::updateBookmarkList()
pop["peerNumber" ] = nb ; pop["peerNumber" ] = nb ;
pop["section" ] = "1" ; pop["section" ] = "1" ;
pop["listPriority" ] = 0 ; pop["listPriority" ] = 0 ;
pop["id" ] = i ;
setData("bookmark", QString::number(i), pop); setData("bookmark", QString::number(i), pop);
} }
} }
...@@ -237,8 +248,26 @@ void SFLPhoneEngine::updateAccounts() ...@@ -237,8 +248,26 @@ void SFLPhoneEngine::updateAccounts()
foreach(Account* a,list) { foreach(Account* a,list) {
QHash<QString,QVariant> acc; QHash<QString,QVariant> acc;
acc["id"] = a->getAccountId(); acc["id"] = a->getAccountId();
acc["alias"] = a->getAccountDetail(ACCOUNT_ALIAS) acc["alias"] = a->getAccountDetail(ACCOUNT_ALIAS);
setData("accounts", QString::number(rand()) , a->getAccountId()); setData("accounts", QString::number(rand()) , acc);
}
}
void SFLPhoneEngine::generateNumberList(QString name)
{
QString contactUid = name.right(name.size()-7);
qDebug() << "LOOKING FOR " << contactUid;
Contact* cont = AkonadiBackend::getInstance()->getContactByUid(contactUid);
if (cont) {
foreach(Contact::PhoneNumber* num,cont->getPhoneNumbers()) {
QHash<QString,QVariant> hash;
hash[ "number" ] = num->getNumber();
hash[ "type" ] = num->getType();
setData(name, QString::number(rand()) , hash);
}
}
else {
kDebug() << "Contact not found";
} }
} }
......
...@@ -63,6 +63,8 @@ class SFLPhoneEngine : public Plasma::DataEngine,public SortableDockCommon<> ...@@ -63,6 +63,8 @@ class SFLPhoneEngine : public Plasma::DataEngine,public SortableDockCommon<>
void updateContacts (); void updateContacts ();
void updateBookmarkList (); void updateBookmarkList ();
void updateInfo(); void updateInfo();
void generateNumberList(QString name);
private slots: private slots:
void updateCollection(); void updateCollection();
void callStateChangedSignal (Call* call); void callStateChangedSignal (Call* call);
......
...@@ -10,4 +10,27 @@ ...@@ -10,4 +10,27 @@
<label>Number to call</label> <label>Number to call</label>
</entry> </entry>
</group> </group>
<group name="DMTF">
<entry name="str" type="String">
<label>Right sound for a key</label>
</entry>
</group>
<group name="Transfer">
<entry name="callid" type="String">
<label>A valid call identifier number</label>
</entry>
<entry name="transfernumber" type="String">
<label>Number to transfer too</label>
</entry>
</group>
<group name="Hangup">
<entry name="callid" type="String">
<label>A valid call identifier number</label>
</entry>
</group>
<group name="Hold">
<entry name="callid" type="String">
<label>A valid call identifier number</label>
</entry>
</group>
</kcfg> </kcfg>
...@@ -18,6 +18,18 @@ ServiceJob *SFLPhoneService::createJob(const QString &operation, QMap<QString, Q ...@@ -18,6 +18,18 @@ ServiceJob *SFLPhoneService::createJob(const QString &operation, QMap<QString, Q
if (operation == "Call") { if (operation == "Call") {
return new CallJob(this, operation,parameters); return new CallJob(this, operation,parameters);
} }
else if (operation == "DMTF") {
return new DTMFJob(this, operation,parameters);
}
else if (operation == "Transfer") {
return new TransferJob(this, operation,parameters);
}
else if (operation == "Hangup") {
return new HangUpJob(this, operation,parameters);
}
else if (operation == "Hold") {
return new HoldJob(this, operation,parameters);
}
m_engine->setData(operation, parameters["query"]); m_engine->setData(operation, parameters["query"]);
return 0; return 0;
} }
\ No newline at end of file
...@@ -36,7 +36,7 @@ public: ...@@ -36,7 +36,7 @@ public:
void start() void start()
{ {
Call* call = SFLPhoneEngine::getModel()->addDialingCall("112",m_AccountId); Call* call = SFLPhoneEngine::getModel()->addDialingCall(m_Number,m_AccountId);
call->setCallNumber(m_Number); call->setCallNumber(m_Number);
call->actionPerformed(CALL_ACTION_ACCEPT); call->actionPerformed(CALL_ACTION_ACCEPT);
} }
...@@ -46,4 +46,83 @@ private: ...@@ -46,4 +46,83 @@ private:
QString m_Number; QString m_Number;
}; };
class DTMFJob : public Plasma::ServiceJob
{
Q_OBJECT
public:
DTMFJob(QObject* parent, const QString& operation, const QVariantMap& parameters = QVariantMap())
: Plasma::ServiceJob("", operation, parameters, parent)
, m_mStr( parameters[ "str" ].toString() )
{}
void start()
{
CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance();
callManager.playDTMF(m_mStr);
}
private:
QString m_mStr;
};
class HangUpJob : public Plasma::ServiceJob
{
Q_OBJECT
public:
HangUpJob(QObject* parent, const QString& operation, const QVariantMap& parameters = QVariantMap())
: Plasma::ServiceJob("", operation, parameters, parent)
, m_CallId( parameters[ "callid" ].toString() )
{}
void start()
{
Call* call = SFLPhoneEngine::getModel()->getCall(m_CallId);
call->actionPerformed(CALL_ACTION_REFUSE);
call->changeCurrentState(CALL_STATE_OVER);
}
private:
QString m_CallId;
};
class TransferJob : public Plasma::ServiceJob
{
Q_OBJECT
public:
TransferJob(QObject* parent, const QString& operation, const QVariantMap& parameters = QVariantMap())
: Plasma::ServiceJob("", operation, parameters, parent)
, m_CallId ( parameters[ "callid" ].toString() )
, m_transferNumber ( parameters[ "transfernumber" ].toString() )
{}
void start()
{
Call* call = SFLPhoneEngine::getModel()->getCall(m_CallId);
call->setTransferNumber(m_transferNumber);
call->changeCurrentState(CALL_STATE_TRANSFER);
call->actionPerformed(CALL_ACTION_ACCEPT);
call->changeCurrentState(CALL_STATE_OVER);
}
private:
QString m_CallId;
QString m_transferNumber;
};
class HoldJob : public Plasma::ServiceJob
{
Q_OBJECT
public:
HoldJob(QObject* parent, const QString& operation, const QVariantMap& parameters = QVariantMap())
: Plasma::ServiceJob("", operation, parameters, parent)
, m_CallId ( parameters[ "callid" ].toString() )
{}
void start()
{
Call* call = SFLPhoneEngine::getModel()->getCall(m_CallId);
call->actionPerformed(CALL_ACTION_HOLD);
}
private:
QString m_CallId;
};
#endif //SFLPHONE_SERVICE_H #endif //SFLPHONE_SERVICE_H
...@@ -199,9 +199,9 @@ QHash<QString,QVariant> Contact::toHash() ...@@ -199,9 +199,9 @@ QHash<QString,QVariant> Contact::toHash()
aContact[ "secondName" ] = getSecondName(); aContact[ "secondName" ] = getSecondName();
aContact[ "formattedName" ] = getFormattedName(); aContact[ "formattedName" ] = getFormattedName();
aContact[ "organization" ] = getOrganization(); aContact[ "organization" ] = getOrganization();
aContact[ "Uid" ] = getUid(); aContact[ "uid" ] = getUid();
aContact[ "preferredEmail" ] = getPreferredEmail(); aContact[ "preferredEmail" ] = getPreferredEmail();
//aContact["Photo"] = getPhoto( const; //aContact[ "Photo" ] = QVariant(*getPhoto());
aContact[ "type" ] = getType(); aContact[ "type" ] = getType();
aContact[ "group" ] = getGroup(); aContact[ "group" ] = getGroup();
aContact[ "department" ] = getDepartment(); aContact[ "department" ] = getDepartment();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment