Commit 6f1a61e2 authored by Alexandre Savard's avatar Alexandre Savard
parents e6b846ed 670e2a2f
......@@ -102,7 +102,7 @@ void Account::setActiveCodecs(const std::vector<std::string> &list)
}
// update the codec string according to new codec selection
codecStr_ = ManagerImpl::serialize(list);
codecStr_ = ManagerImpl::join_string(list);
}
std::string Account::mapStateNumberToString(RegistrationState state)
......
......@@ -93,7 +93,7 @@ void IAXAccount::unserialize(const Conf::MappingNode &map)
map.getValue(CODECS_KEY, &codecStr_);
// Update codec list which one is used for SDP offer
setActiveCodecs(ManagerImpl::unserialize(codecStr_));
setActiveCodecs(ManagerImpl::split_string(codecStr_));
map.getValue(DISPLAY_NAME_KEY, &displayName_);
}
......
......@@ -1802,7 +1802,7 @@ std::string ManagerImpl::createConfigFile() const
return configdir + DIR_SEPARATOR_STR + PROGNAME + ".yml";
}
std::vector<std::string> ManagerImpl::unserialize(std::string s)
std::vector<std::string> ManagerImpl::split_string(std::string s)
{
std::vector<std::string> list;
std::string temp;
......@@ -1817,7 +1817,7 @@ std::vector<std::string> ManagerImpl::unserialize(std::string s)
return list;
}
std::string ManagerImpl::serialize(const std::vector<std::string> &v)
std::string ManagerImpl::join_string(const std::vector<std::string> &v)
{
std::ostringstream os;
std::copy(v.begin(), v.end(), std::ostream_iterator<std::string>(os, "/"));
......@@ -2531,7 +2531,7 @@ std::string ManagerImpl::getNewCallID()
std::vector<std::string> ManagerImpl::loadAccountOrder() const
{
return unserialize(preferences.getAccountOrder());
return split_string(preferences.getAccountOrder());
}
void ManagerImpl::loadDefaultAccountMap()
......@@ -2611,9 +2611,8 @@ void ManagerImpl::loadAccountMap(Conf::YamlParser &parser)
Sequence::const_iterator ip2ip = std::find_if(seq->begin(), seq->end(), isIP2IP);
if (ip2ip != seq->end()) {
MappingNode *node = dynamic_cast<MappingNode*>(*ip2ip);
if (node) {
if (node)
accountMap_[SIPAccount::IP2IP_PROFILE]->unserialize(*node);
}
}
// Initialize default UDP transport according to
......@@ -2734,13 +2733,13 @@ void ManagerImpl::setAddressbookSettings(const std::map<std::string, int32_t>& s
void ManagerImpl::setAddressbookList(const std::vector<std::string>& list)
{
addressbookPreference.setList(ManagerImpl::serialize(list));
addressbookPreference.setList(ManagerImpl::join_string(list));
saveConfig();
}
std::vector<std::string> ManagerImpl::getAddressbookList() const
{
return unserialize(addressbookPreference.getList());
return split_string(addressbookPreference.getList());
}
void ManagerImpl::setIPToIPForCall(const std::string& callID, bool IPToIP)
......
......@@ -571,9 +571,9 @@ class ManagerImpl {
* Required format: payloads separated with one slash.
* @return std::string The serializabled string
*/
static std::string serialize(const std::vector<std::string> &v);
static std::string join_string(const std::vector<std::string> &v);
static std::vector<std::string> unserialize(std::string v);
static std::vector<std::string> split_string(std::string v);
/**
* Ringtone option.
......
......@@ -268,7 +268,7 @@ void SIPAccount::unserialize(const Conf::MappingNode &map)
map.getValue(MAILBOX_KEY, &mailBox_);
map.getValue(CODECS_KEY, &codecStr_);
// Update codec list which one is used for SDP offer
setActiveCodecs(ManagerImpl::unserialize(codecStr_));
setActiveCodecs(ManagerImpl::split_string(codecStr_));
map.getValue(RINGTONE_PATH_KEY, &ringtonePath_);
map.getValue(RINGTONE_ENABLED_KEY, &ringtoneEnabled_);
......
......@@ -29,11 +29,16 @@
*/
#include <iostream>
#include <iterator>
#include <algorithm>
#include <math.h>
#include "resamplertest.h"
ResamplerTest::ResamplerTest() :
CppUnit::TestCase("Resampler module test"), inputBuffer(), outputBuffer()
{}
void ResamplerTest::setUp()
{
......@@ -44,6 +49,16 @@ void ResamplerTest::tearDown()
}
namespace {
template <typename T>
void print_buffer(T &buffer)
{
std::copy(buffer.begin(), buffer.end(),
std::ostream_iterator<SFLDataFormat>(std::cout, ", "));
std::cout << std::endl;
}
}
void ResamplerTest::testUpsamplingRamp()
{
// generate input samples and store them in inputBuffer
......@@ -59,15 +74,11 @@ void ResamplerTest::testUpsamplingRamp()
std::copy(inputBuffer.begin(), inputBuffer.begin() + tmpInputBuffer.size(), tmpInputBuffer.begin());
std::cout << "Input Buffer" << std::endl;
for(int i = 0; i < tmpInputBuffer.size(); i++)
std::cout << tmpInputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpInputBuffer);
std::copy(outputBuffer.begin(), outputBuffer.begin() + tmpOutputBuffer.size(), tmpOutputBuffer.begin());
std::cout << "Output Buffer" << std::endl;
for(int i = 0; i < tmpOutputBuffer.size(); i++)
std::cout << tmpOutputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpOutputBuffer);
}
void ResamplerTest::testDownsamplingRamp()
......@@ -84,15 +95,11 @@ void ResamplerTest::testDownsamplingRamp()
std::copy(inputBuffer.begin(), inputBuffer.begin() + tmpInputBuffer.size(), tmpInputBuffer.begin());
std::cout << "Input Buffer" << std::endl;
for(int i = 0; i < tmpInputBuffer.size(); i++)
std::cout << tmpInputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpInputBuffer);
std::copy(outputBuffer.begin(), outputBuffer.begin() + tmpOutputBuffer.size(), tmpOutputBuffer.begin());
std::cout << "Output Buffer" << std::endl;
for(int i = 0; i < tmpOutputBuffer.size(); i++)
std::cout << tmpOutputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpOutputBuffer);
}
void ResamplerTest::testUpsamplingTriangle()
......@@ -109,15 +116,11 @@ void ResamplerTest::testUpsamplingTriangle()
std::copy(inputBuffer.begin(), inputBuffer.begin() + tmpInputBuffer.size(), tmpInputBuffer.begin());
std::cout << "Input Buffer" << std::endl;
for(int i = 0; i < tmpInputBuffer.size(); i++)
std::cout << tmpInputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpInputBuffer);
std::copy(outputBuffer.begin(), outputBuffer.begin() + tmpOutputBuffer.size(), tmpOutputBuffer.begin());
std::cout << "Output Buffer" << std::endl;
for(int i = 0; i < tmpOutputBuffer.size(); i++)
std::cout << tmpOutputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpOutputBuffer);
}
void ResamplerTest::testDownsamplingTriangle()
......@@ -134,15 +137,11 @@ void ResamplerTest::testDownsamplingTriangle()
std::copy(inputBuffer.begin(), inputBuffer.begin() + tmpInputBuffer.size(), tmpInputBuffer.begin());
std::cout << "Input Buffer" << std::endl;
for(int i = 0; i < tmpInputBuffer.size(); i++)
std::cout << tmpInputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpInputBuffer);
std::copy(outputBuffer.begin(), outputBuffer.begin() + tmpOutputBuffer.size(), tmpOutputBuffer.begin());
std::cout << "Output Buffer" << std::endl;
for(int i = 0; i < tmpOutputBuffer.size(); i++)
std::cout << tmpOutputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpOutputBuffer);
}
void ResamplerTest::testUpsamplingSine()
{
......@@ -159,15 +158,11 @@ void ResamplerTest::testUpsamplingSine()
std::copy(inputBuffer.begin(), inputBuffer.begin() + tmpInputBuffer.size(), tmpInputBuffer.begin());
std::cout << "Input Buffer" << std::endl;
for(int i = 0; i < tmpInputBuffer.size(); i++)
std::cout << tmpInputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpInputBuffer);
std::copy(outputBuffer.begin(), outputBuffer.begin() + tmpOutputBuffer.size(), tmpOutputBuffer.begin());
std::cout << "Output Buffer" << std::endl;
for(int i = 0; i < tmpOutputBuffer.size(); i++)
std::cout << tmpOutputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpOutputBuffer);
}
void ResamplerTest::testDownsamplingSine()
......@@ -185,36 +180,29 @@ void ResamplerTest::testDownsamplingSine()
std::copy(inputBuffer.begin(), inputBuffer.begin() + tmpInputBuffer.size(), tmpInputBuffer.begin());
std::cout << "Input Buffer" << std::endl;
for(int i = 0; i < tmpInputBuffer.size(); i++)
std::cout << tmpInputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpInputBuffer);
std::copy(outputBuffer.begin(), outputBuffer.begin() + tmpOutputBuffer.size(), tmpOutputBuffer.begin());
std::cout << "Output Buffer" << std::endl;
for(int i = 0; i < tmpOutputBuffer.size(); i++)
std::cout << tmpOutputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpOutputBuffer);
}
void ResamplerTest::generateRamp()
{
for(int i = 0; i < inputBuffer.size(); i++) {
inputBuffer[i] = (SFLDataFormat)i;
}
for (size_t i = 0; i < inputBuffer.size(); ++i)
inputBuffer[i] = i;
}
void ResamplerTest::generateTriangularSignal()
{
for(int i = 0; i < inputBuffer.size(); i++) {
inputBuffer[i] = (SFLDataFormat)(i*10);
}
for (size_t i = 0; i < inputBuffer.size(); ++i)
inputBuffer[i] = i * 10;
}
void ResamplerTest::generateSineSignal()
{
for(int i = 0; i < inputBuffer.size(); i++) {
inputBuffer[i] = (SFLDataFormat)(1000.0 * sin((double)i));
}
for (size_t i = 0; i < inputBuffer.size(); ++i)
inputBuffer[i] = (SFLDataFormat) (1000.0 * sin(i));
}
void ResamplerTest::performUpsampling(SamplerateConverter &converter)
......@@ -222,8 +210,7 @@ void ResamplerTest::performUpsampling(SamplerateConverter &converter)
LowSmplrBuffer tmpInputBuffer;
HighSmplrBuffer tmpOutputBuffer;
int i, j;
for(i = 0, j = 0; i < (inputBuffer.size() / 2); i += tmpInputBuffer.size(), j += tmpOutputBuffer.size()) {
for (size_t i = 0, j = 0; i < (inputBuffer.size() / 2); i += tmpInputBuffer.size(), j += tmpOutputBuffer.size()) {
std::copy(inputBuffer.begin() + i, inputBuffer.begin() + tmpInputBuffer.size() + i, tmpInputBuffer.begin());
converter.resample(tmpInputBuffer.data(), tmpOutputBuffer.data(), tmpOutputBuffer.size(), 8000, 16000, tmpInputBuffer.size());
std::copy(tmpOutputBuffer.begin(), tmpOutputBuffer.end(), outputBuffer.begin() + j);
......@@ -235,8 +222,7 @@ void ResamplerTest::performDownsampling(SamplerateConverter &converter)
HighSmplrBuffer tmpInputBuffer;
LowSmplrBuffer tmpOutputBuffer;
int i, j;
for(i = 0, j = 0; i < inputBuffer.size(); i += tmpInputBuffer.size(), j += tmpOutputBuffer.size()) {
for (size_t i = 0, j = 0; i < inputBuffer.size(); i += tmpInputBuffer.size(), j += tmpOutputBuffer.size()) {
std::copy(inputBuffer.begin() + i, inputBuffer.begin() + tmpInputBuffer.size() + i, tmpInputBuffer.begin());
converter.resample(tmpInputBuffer.data(), tmpOutputBuffer.data(), tmpOutputBuffer.size(), 16000, 8000, tmpInputBuffer.size());
std::copy(tmpOutputBuffer.begin(), tmpOutputBuffer.end(), outputBuffer.begin() + j);
......
......@@ -39,6 +39,7 @@
#include <tr1/array>
#include "audio/samplerateconverter.h"
#include "noncopyable.h"
#define MAX_BUFFER_LENGTH 40000
#define TMP_LOWSMPLR_BUFFER_LENGTH 160
......@@ -62,7 +63,7 @@ class ResamplerTest : public CppUnit::TestCase {
CPPUNIT_TEST_SUITE_END();
public:
ResamplerTest() : CppUnit::TestCase("Resampler module test") {}
ResamplerTest();
/*
* Code factoring - Common resources can be initialized here.
......@@ -107,6 +108,7 @@ class ResamplerTest : public CppUnit::TestCase {
void testDownsamplingSine();
private:
NON_COPYABLE(ResamplerTest);
/*
* Generate a ramp to be stored in inputBuffer
......@@ -142,12 +144,6 @@ private:
* Used to receive output samples
*/
std::tr1::array<SFLDataFormat, MAX_BUFFER_LENGTH> outputBuffer;
/**
* Pointer to samplerate converter, may be reinitialized during tests
* don't keep a statically declared instance.
*/
SamplerateConverter *converter;
};
/* Register the test module */
......
......@@ -53,7 +53,7 @@ void
calltab_select_call(calltab_t* tab, callable_obj_t * c)
{
g_assert(tab);
DEBUG("CallTab: Select call %s", c ? c->_callID : "");
DEBUG("Select call %s", c ? c->_callID : "");
tab->selectedType = A_CALL;
tab->selectedCall = c;
......@@ -65,7 +65,7 @@ void
calltab_select_conf(calltab_t *tab, conference_obj_t * c)
{
g_assert(tab);
DEBUG("CallTab: Selected conf %s", c ? c->_confID : "");
DEBUG("Selected conf %s", c ? c->_confID : "");
tab->selectedType = A_CONFERENCE;
tab->selectedConf = c;
......
......@@ -44,7 +44,7 @@ static gint is_confID_confstruct(gconstpointer a, gconstpointer b)
void conferencelist_init(calltab_t *tab)
{
if (tab == NULL) {
ERROR("ConferenceList: Error: Call tab is NULL");
ERROR("Call tab is NULL");
return;
}
......@@ -55,7 +55,7 @@ void conferencelist_init(calltab_t *tab)
void conferencelist_clean(calltab_t *tab)
{
if (tab == NULL) {
ERROR("ConferenceList: Error: Calltab tab is NULL");
ERROR("Calltab tab is NULL");
return;
}
......@@ -65,7 +65,7 @@ void conferencelist_clean(calltab_t *tab)
void conferencelist_reset(calltab_t *tab)
{
if (tab == NULL) {
ERROR("ConferenceList: Error: Calltab tab is NULL");
ERROR("Calltab tab is NULL");
return;
}
......@@ -77,12 +77,12 @@ void conferencelist_reset(calltab_t *tab)
void conferencelist_add(calltab_t *tab, const conference_obj_t* conf)
{
if (conf == NULL) {
ERROR("ConferenceList: Error: Conference is NULL");
ERROR("Conference is NULL");
return;
}
if (tab == NULL) {
ERROR("ConferenceList: Error: Tab is NULL");
ERROR("Tab is NULL");
return;
}
......@@ -96,15 +96,15 @@ void conferencelist_add(calltab_t *tab, const conference_obj_t* conf)
void conferencelist_remove(calltab_t *tab, const gchar* const conf_id)
{
DEBUG("ConferenceList: Remove conference %s", conf_id);
DEBUG("Remove conference %s", conf_id);
if (conf_id == NULL) {
ERROR("ConferenceList: Error: Conf id is NULL");
ERROR("Conf id is NULL");
return;
}
if (tab == NULL) {
ERROR("ConferenceList: Error: Calltab is NULL");
ERROR("Calltab is NULL");
return;
}
......@@ -118,10 +118,10 @@ void conferencelist_remove(calltab_t *tab, const gchar* const conf_id)
conference_obj_t* conferencelist_get(calltab_t *tab, const gchar* const conf_id)
{
DEBUG("ConferenceList: Conference list get %s", conf_id);
DEBUG("Conference list get %s", conf_id);
if (tab == NULL) {
ERROR("ConferenceList: Error: Calltab is NULL");
ERROR("Calltab is NULL");
return NULL;
}
......@@ -136,14 +136,14 @@ conference_obj_t* conferencelist_get(calltab_t *tab, const gchar* const conf_id)
conference_obj_t* conferencelist_get_nth(calltab_t *tab, guint n)
{
if (tab == NULL) {
ERROR("ConferenceList: Error: Calltab is NULL");
ERROR("Calltab is NULL");
return NULL;
}
conference_obj_t *c = g_queue_peek_nth(tab->conferenceQueue, n);
if (c == NULL) {
ERROR("ConferenceList: Error: Could not fetch conference %d", n);
ERROR("Could not fetch conference %d", n);
return NULL;
}
......@@ -153,7 +153,7 @@ conference_obj_t* conferencelist_get_nth(calltab_t *tab, guint n)
conference_obj_t *conferencelist_pop_head(calltab_t *tab)
{
if (tab == NULL) {
ERROR("ConferenceList: Error: Tab is NULL");
ERROR("Tab is NULL");
return NULL;
}
......@@ -163,7 +163,7 @@ conference_obj_t *conferencelist_pop_head(calltab_t *tab)
guint conferencelist_get_size(calltab_t *tab)
{
if (tab == NULL) {
ERROR("ConferenceList: Error: Calltab is NULL");
ERROR("Calltab is NULL");
return 0;
}
......
......@@ -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()