Commit 670e2a2f authored by Tristan Matthews's avatar Tristan Matthews
parents 99e6a3b6 008c8846
......@@ -145,10 +145,10 @@ void SFLPhoneView::typeString(QString str)
}
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);
}
else if(call2->getState() == CALL_STATE_DIALING) {
else if(dynamic_cast<Call*>(call2) && call2->getState() == CALL_STATE_DIALING) {
candidate = call2;
}
}
......
......@@ -10,7 +10,18 @@
ContactHash HelperFunctions::toHash(QList<Contact*> contacts) {
QHash<QString,QHash<QString,QVariant> > hash;
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;
}
\ No newline at end of file
......@@ -5,6 +5,7 @@
#include "../../lib/Call.h"
#include "../../lib/Account.h"
#include "../../lib/AccountList.h"
#include "../../lib/Contact.h"
#include "../../lib/dbus/metatypes.h"
#include "../../lib/instance_interface_singleton.h"
#include "../../lib/configurationmanager_interface_singleton.h"
......@@ -29,6 +30,8 @@ SFLPhoneEngine::SFLPhoneEngine(QObject* parent, const QVariantList& args)
//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(&callManager , SIGNAL( incomingCall(Call*)) , this , SLOT(incomingCallSignal(Call*) ));
//connect(&callManager , SIGNAL( conferenceCreated(Call*)) , this , SLOT(conferenceCreatedSignal(Call*) ));
......@@ -39,27 +42,30 @@ SFLPhoneEngine::SFLPhoneEngine(QObject* parent, const QVariantList& args)
bool SFLPhoneEngine::sourceRequestEvent(const QString &name)
{
if ( name == "history" ) {
if ( name == "history" ) {
updateHistory();
}
else if ( name == "calls" ) {
else if ( name == "calls" ) {
updateCallList();
}
else if ( name == "conferences" ) {
else if ( name == "conferences" ) {
updateConferenceList();
}
else if ( name == "info" ) {
else if ( name == "info" ) {
updateInfo();
}
else if ( name == "accounts" ) {
else if ( name == "accounts" ) {
updateAccounts();
}
else if ( name == "contacts" ) {
else if ( name == "contacts" ) {
updateContacts();
}
else if ( name == "bookmark" ) {
else if ( name == "bookmark" ) {
updateBookmarkList();
}
else if ( name.left(7) == "Number:" ) {
generateNumberList(name);
}
return true;//updateSourceEvent(name);
}
......@@ -124,6 +130,7 @@ void SFLPhoneEngine::updateHistory()
historyCall[oldCall->getCallId()][ "peerNumber" ] = oldCall->getPeerPhoneNumber();
historyCall[oldCall->getCallId()][ "length" ] = oldCall->getStopTimeStamp().toInt() - oldCall->getStartTimeStamp().toInt();
historyCall[oldCall->getCallId()][ "date" ] = oldCall->getStopTimeStamp();
historyCall[oldCall->getCallId()][ "id" ] = oldCall->getCallId();
if (oldCall->property("section").isValid())
historyCall[oldCall->getCallId()][ "section" ] = oldCall->property("section");
setData("history", oldCall->getCallId() , historyCall[oldCall->getCallId()]);
......@@ -132,12 +139,14 @@ void SFLPhoneEngine::updateHistory()
void SFLPhoneEngine::updateCallList()
{
removeAllData("calls");
foreach (Call* call, m_pModel->getCalls()) {
if ((!m_pModel->isConference(call)) && (call->getState() != CALL_STATE_OVER)) {
currentCall[call->getCallId()][ "peerName" ] = call->getPeerName();
currentCall[call->getCallId()][ "peerNumber" ] = call->getPeerPhoneNumber();
currentCall[call->getCallId()][ "stateName" ] = getCallStateName(call->getState());
currentCall[call->getCallId()][ "state" ] = call->getState();
currentCall[call->getCallId()][ "id" ] = call->getCallId();
setData("calls", call->getCallId(), currentCall[call->getCallId()]);
}
}
......@@ -157,9 +166,10 @@ void SFLPhoneEngine::updateBookmarkList()
else {
pop["peerName" ] = cl[i];
}
pop["peerNumber" ] = cl[i];
pop["section" ] = "Popular";
pop["listPriority" ] = 1000;
pop["peerNumber" ] = cl[i] ;
pop["section" ] = "Popular" ;
pop["listPriority" ] = 1000 ;
pop["id" ] = i ;
setData("bookmark", QString::number(i), pop);
}
......@@ -167,10 +177,11 @@ void SFLPhoneEngine::updateBookmarkList()
foreach (QString nb, ConfigurationSkeleton::bookmarkList()) {
i++;
QHash<QString,QVariant> pop;
pop["peerName" ] = "TODO";
pop["peerNumber" ] = nb;
pop["section" ] = "1";
pop["listPriority" ] = 0;
pop["peerName" ] = "TODO" ;
pop["peerNumber" ] = nb ;
pop["section" ] = "1" ;
pop["listPriority" ] = 0 ;
pop["id" ] = i ;
setData("bookmark", QString::number(i), pop);
}
}
......@@ -237,8 +248,26 @@ void SFLPhoneEngine::updateAccounts()
foreach(Account* a,list) {
QHash<QString,QVariant> acc;
acc["id"] = a->getAccountId();
acc["alias"] = a->getAccountDetail(ACCOUNT_ALIAS)
setData("accounts", QString::number(rand()) , a->getAccountId());
acc["alias"] = a->getAccountDetail(ACCOUNT_ALIAS);
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<>
void updateContacts ();
void updateBookmarkList ();
void updateInfo();
void generateNumberList(QString name);
private slots:
void updateCollection();
void callStateChangedSignal (Call* call);
......
......@@ -10,4 +10,27 @@
<label>Number to call</label>
</entry>
</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>
......@@ -15,9 +15,21 @@ ServiceJob *SFLPhoneService::createJob(const QString &operation, QMap<QString, Q
return 0;
}
if (operation == "Call") {
if (operation == "Call") {
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"]);
return 0;
}
\ No newline at end of file
......@@ -36,7 +36,7 @@ public:
void start()
{
Call* call = SFLPhoneEngine::getModel()->addDialingCall("112",m_AccountId);
Call* call = SFLPhoneEngine::getModel()->addDialingCall(m_Number,m_AccountId);
call->setCallNumber(m_Number);
call->actionPerformed(CALL_ACTION_ACCEPT);
}
......@@ -46,4 +46,83 @@ private:
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
......@@ -199,9 +199,9 @@ QHash<QString,QVariant> Contact::toHash()
aContact[ "secondName" ] = getSecondName();
aContact[ "formattedName" ] = getFormattedName();
aContact[ "organization" ] = getOrganization();
aContact[ "Uid" ] = getUid();
aContact[ "uid" ] = getUid();
aContact[ "preferredEmail" ] = getPreferredEmail();
//aContact["Photo"] = getPhoto( const;
//aContact[ "Photo" ] = QVariant(*getPhoto());
aContact[ "type" ] = getType();
aContact[ "group" ] = getGroup();
aContact[ "department" ] = getDepartment();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment