diff --git a/sflphone-client-kde/src/Account.cpp b/sflphone-client-kde/src/Account.cpp index 6bb541c1271600dbabeb20a1fc915efcdf95999c..927c94fffa851c770cac13c736420608e2580f79 100644 --- a/sflphone-client-kde/src/Account.cpp +++ b/sflphone-client-kde/src/Account.cpp @@ -96,6 +96,7 @@ Account * Account::buildExistingAccountFromId(QString _accountId) ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); Account * a = new Account(); a->accountId = new QString(_accountId); + qDebug() << "getAccountDetails 1 sent"; a->accountDetails = new MapStringString( configurationManager.getAccountDetails(_accountId).value() ); a->initAccountItem(); return a; diff --git a/sflphone-client-kde/src/Call.cpp b/sflphone-client-kde/src/Call.cpp index 38f0e209d9b0391ce68b08957473097c2c743b37..873c4de3f44d100ff4835431d21413d74b13fec1 100644 --- a/sflphone-client-kde/src/Call.cpp +++ b/sflphone-client-kde/src/Call.cpp @@ -164,6 +164,26 @@ Call::Call(call_state startState, QString callId, QString peerName, QString peer this->stopTime = NULL; } +Call::Call(QString callId) +{ + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + MapStringString details = callManager.getCallDetails(callId).value(); + qDebug() << "Constructing existing call with details : " << details; + this->callId = callId; + this->peerPhoneNumber = details[CALL_PEER_NUMBER]; + this->peerName = details[CALL_PEER_NAME]; + initCallItem(); + call_state startState = getStartStateFromDaemonCallState(details[CALL_STATE], details[CALL_TYPE]); + changeCurrentState(startState); + this->historyState = getHistoryStateFromDaemonCallState(details[CALL_STATE], details[CALL_TYPE]); + this->account = details[CALL_ACCOUNTID]; + this->recording = false; + this->startTime = new QDateTime(QDateTime::currentDateTime()); + this->stopTime = NULL; + this->historyItem = NULL; + this->historyItemWidget = NULL; +} + Call::~Call() { delete startTime; @@ -206,6 +226,89 @@ Call * Call::buildRingingCall(const QString & callId) return call; } +Call * Call::buildHistoryCall(const QString & callId, uint startTimeStamp, uint stopTimeStamp, QString account, QString name, QString number, QString type) +{ + if(name == "empty") name = ""; + Call * call = new Call(CALL_STATE_OVER, callId, name, number, account); + call->startTime = new QDateTime(QDateTime::fromTime_t(startTimeStamp)); + call->stopTime = new QDateTime(QDateTime::fromTime_t(stopTimeStamp)); + call->historyState = getHistoryStateFromType(type); + return call; +} + + +history_state Call::getHistoryStateFromType(QString type) +{ + if(type == DAEMON_HISTORY_TYPE_MISSED) + { + return MISSED; + } + else if(type == DAEMON_HISTORY_TYPE_OUTGOING) + { + return OUTGOING; + } + else if(type == DAEMON_HISTORY_TYPE_INCOMING) + { + return INCOMING; + } +} + +call_state Call::getStartStateFromDaemonCallState(QString daemonCallState, QString daemonCallType) +{ + if(daemonCallState == DAEMON_CALL_STATE_INIT_CURRENT) + { + return CALL_STATE_CURRENT; + } + else if(daemonCallState == DAEMON_CALL_STATE_INIT_HOLD) + { + return CALL_STATE_HOLD; + } + else if(daemonCallState == DAEMON_CALL_STATE_INIT_BUSY) + { + return CALL_STATE_BUSY; + } + else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_INCOMING) + { + return CALL_STATE_INCOMING; + } + else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_OUTGOING) + { + return CALL_STATE_RINGING; + } + else + { + return CALL_STATE_FAILURE; + } +} + +history_state Call::getHistoryStateFromDaemonCallState(QString daemonCallState, QString daemonCallType) +{ + if((daemonCallState == DAEMON_CALL_STATE_INIT_CURRENT || daemonCallState == DAEMON_CALL_STATE_INIT_HOLD) && daemonCallType == DAEMON_CALL_TYPE_INCOMING) + { + return INCOMING; + } + else if((daemonCallState == DAEMON_CALL_STATE_INIT_CURRENT || daemonCallState == DAEMON_CALL_STATE_INIT_HOLD) && daemonCallType == DAEMON_CALL_TYPE_OUTGOING) + { + return OUTGOING; + } + else if(daemonCallState == DAEMON_CALL_STATE_INIT_BUSY) + { + return OUTGOING; + } + else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_INCOMING) + { + return INCOMING; + } + else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_OUTGOING) + { + return MISSED; + } + else + { + return NONE; + } +} + daemon_call_state Call::toDaemonCallState(const QString & stateName) { if(stateName == QString(CALL_STATE_CHANGE_HUNG_UP)) @@ -307,7 +410,6 @@ QWidget * Call::getHistoryItemWidget() descr->setMargin(0); descr->setSpacing(1); mainLayout->addWidget(labelHistoryIcon); - qDebug() << "descr->addWidget(labelPeerName);"; if(! peerName.isEmpty()) { labelHistoryPeerName = new QLabel(peerName); diff --git a/sflphone-client-kde/src/Call.h b/sflphone-client-kde/src/Call.h index e9fff3fb2bae151a93765b1043df05b80b95bccb..65f6aec0d950aae92cfb76f541b6d970f11d0232 100644 --- a/sflphone-client-kde/src/Call.h +++ b/sflphone-client-kde/src/Call.h @@ -180,12 +180,16 @@ private: public: //Constructors & Destructors + Call(QString callId); ~Call(); void initCallItem(); static Call * buildDialingCall(QString callId, const QString & peerName, QString account = ""); static Call * buildIncomingCall(const QString & callId/*, const QString & from, const QString & account*/); static Call * buildRingingCall(const QString & callId); - + static Call * buildHistoryCall(const QString & callId, uint startTimeStamp, uint stopTimeStamp, QString account, QString name, QString number, QString type); + static history_state getHistoryStateFromType(QString type); + static call_state getStartStateFromDaemonCallState(QString daemonCallState, QString daemonCallType); + static history_state getHistoryStateFromDaemonCallState(QString daemonCallState, QString daemonCallType); //Getters QListWidgetItem * getItem(); diff --git a/sflphone-client-kde/src/CallList.cpp b/sflphone-client-kde/src/CallList.cpp index e98ab32e39e50cd7f3e86b047e514c1a3a48b583..11a13e37195cc192792a30897bf7d1799a57d82f 100644 --- a/sflphone-client-kde/src/CallList.cpp +++ b/sflphone-client-kde/src/CallList.cpp @@ -21,10 +21,36 @@ #include "CallList.h" + +#include "callmanager_interface_singleton.h" +#include "configurationmanager_interface_singleton.h" + CallList::CallList() { + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + QStringList callList = callManager.getCallList(); + qDebug() << "Call List = " << callList; callIdCpt = 0; calls = new QVector<Call *>(); + for(int i = 0 ; i < callList.size() ; i++) + { + calls->append(new Call(callList[i])); + } + MapStringString historyMap = configurationManager.getHistory().value(); + qDebug() << "Call History = " << historyMap; + QMapIterator<QString, QString> i(historyMap); + while (i.hasNext()) { + i.next(); + uint startTimeStamp = i.key().toUInt(); + QStringList param = i.value().split("|"); + QString type = param[0]; + QString number = param[1]; + QString name = param[2]; + uint stopTimeStamp = param[3].toUInt(); + QString account = param[4]; + calls->append(Call::buildHistoryCall(getAndIncCallId(), startTimeStamp, stopTimeStamp, account, name, number, type)); + } } CallList::~CallList() diff --git a/sflphone-client-kde/src/sflphone_const.h b/sflphone-client-kde/src/sflphone_const.h index 9771be44158dd78337f519f97679c81184c1e9c5..074f06fae906f8b27674e95773c361fd1cccc525 100644 --- a/sflphone-client-kde/src/sflphone_const.h +++ b/sflphone-client-kde/src/sflphone_const.h @@ -150,6 +150,8 @@ #define CALL_PEER_NAME "PEER_NAME" #define CALL_PEER_NUMBER "PEER_NUMBER" #define CALL_ACCOUNTID "ACCOUNTID" +#define CALL_STATE "CALL_STATE" +#define CALL_TYPE "CALL_TYPE" /** Call States */ #define CALL_STATE_CHANGE_HUNG_UP "HUNGUP" @@ -162,6 +164,18 @@ #define CALL_STATE_CHANGE_UNHOLD_RECORD "UNHOLD_RECORD" #define CALL_STATE_CHANGE_UNKNOWN "UNKNOWN" +#define DAEMON_CALL_STATE_INIT_CURRENT "CURRENT" +#define DAEMON_CALL_STATE_INIT_HOLD "HOLD" +#define DAEMON_CALL_STATE_INIT_BUSY "BUSY" +#define DAEMON_CALL_STATE_INIT_INACTIVE "INACTIVE" + +#define DAEMON_CALL_TYPE_INCOMING "0" +#define DAEMON_CALL_TYPE_OUTGOING "1" + +#define DAEMON_HISTORY_TYPE_MISSED "0" +#define DAEMON_HISTORY_TYPE_OUTGOING "1" +#define DAEMON_HISTORY_TYPE_INCOMING "2" + /** Address Book Settings */ #define ADDRESSBOOK_MAX_RESULTS "ADDRESSBOOK_MAX_RESULTS" #define ADDRESSBOOK_DISPLAY_CONTACT_PHOTO "ADDRESSBOOK_DISPLAY_CONTACT_PHOTO" diff --git a/sflphone-client-kde/src/sflphone_kdeview.cpp b/sflphone-client-kde/src/sflphone_kdeview.cpp index 3325a01a72d18717d6edeebbc4ac79be5dabe8b1..3f2ff56fbc9f838f01d503364a1c3bc9f9456b9c 100644 --- a/sflphone-client-kde/src/sflphone_kdeview.cpp +++ b/sflphone-client-kde/src/sflphone_kdeview.cpp @@ -58,6 +58,18 @@ sflphone_kdeView::sflphone_kdeView(QWidget *parent) errorWindow = new QErrorMessage(this); callList = new CallList(); + for(int i = 0 ; i < callList->size() ; i++) + { + Call * call = (*callList)[i]; + if(call->getState() == CALL_STATE_OVER) + { + addCallToCallHistory(call); + } + else + { + addCallToCallList(call); + } + } configDialog = new ConfigurationDialog(this); configDialog->setModal(true); @@ -502,7 +514,6 @@ void sflphone_kdeView::updateWindowCallState() enabledActions[3] = false; break; case CALL_STATE_CURRENT: - qDebug() << "Calling getCallDetails3"; qDebug() << "details = " << CallManagerInterfaceSingleton::getInstance().getCallDetails(call->getCallId()).value(); qDebug() << "Reached CALL_STATE_CURRENT with call " << (*callList)[item]->getCallId() << ". Updating window."; recordEnabled = true; @@ -875,7 +886,14 @@ void sflphone_kdeView::updateStatusMessage() { qDebug() << "updateStatusMessage"; Account * account = firstRegisteredAccount(); - emit statusMessageChanged(tr2i18n("Using account") + " \'" + account->getAlias() + "\' (" + account->getAccountDetail(ACCOUNT_TYPE) + ")") ; + if(account == NULL) + { + emit statusMessageChanged(tr2i18n("No account registered")); + } + else + { + emit statusMessageChanged(tr2i18n("Using account") + " \'" + account->getAlias() + "\' (" + account->getAccountDetail(ACCOUNT_TYPE) + ")") ; + } } diff --git a/sflphone-common/src/call.cpp b/sflphone-common/src/call.cpp index 49fde4fc0c9a6923416c06aef6304ae04a71b70c..60513cf9625cba81c3e5ce730ead8019101ed16d 100644 --- a/sflphone-common/src/call.cpp +++ b/sflphone-common/src/call.cpp @@ -83,8 +83,10 @@ Call::getState() } std::string -Call::getStateStr (CallState state) +Call::getStateStr () { + CallState state = getState(); + _debug("getStateStr , state = %d\n", state); std::string state_str; switch (state) { @@ -97,9 +99,11 @@ Call::getStateStr (CallState state) case Busy: state_str = "BUSY"; break; + case Inactive: + state_str = "INACTIVE"; + break; case Refused: case Error: - case Inactive: default: state_str = "FAILURE"; break; diff --git a/sflphone-common/src/call.h b/sflphone-common/src/call.h index be0298e83a765394c90de75e4c379aab3600dd3f..000f2298930654374b74c21083a7edce9dead880 100644 --- a/sflphone-common/src/call.h +++ b/sflphone-common/src/call.h @@ -145,7 +145,7 @@ class Call{ */ CallState getState(); - std::string getStateStr (CallState state); + std::string getStateStr (); void setCallConfiguration (Call::CallConfiguration callConfig) { _callConfig = callConfig; } diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 681a61aa740568402eb6cd4fb2b7292e9b70c099..27ef3e4e079c7f1d9ac06a6a5c1c8e1d4477eea1 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -1430,7 +1430,7 @@ ManagerImpl::getCurrentCodecName(const CallID& id) ManagerImpl::getInputAudioPluginList(void) { std::vector<std::string> v; - _debug("Get input audio plugin list"); + _debug("Get input audio plugin list\n"); v.push_back("default"); v.push_back("surround40"); @@ -1446,7 +1446,7 @@ ManagerImpl::getInputAudioPluginList(void) ManagerImpl::getOutputAudioPluginList(void) { std::vector<std::string> v; - _debug("Get output audio plugin list"); + _debug("Get output audio plugin list\n"); v.push_back( PCM_DEFAULT ); v.push_back( PCM_DMIX ); @@ -2881,11 +2881,11 @@ std::map< std::string, std::string > ManagerImpl::getCallDetails(const CallID& c } if (call) { - type << call->getCallType () << std::endl; + type << call->getCallType (); call_details.insert (std::pair<std::string, std::string> ("ACCOUNTID", accountid)); call_details.insert (std::pair<std::string, std::string> ("PEER_NUMBER", call->getPeerNumber ())); call_details.insert (std::pair<std::string, std::string> ("PEER_NAME", call->getPeerName ())); - call_details.insert (std::pair<std::string, std::string> ("CALL_STATE", call->getStateStr (call->getState()))); + call_details.insert (std::pair<std::string, std::string> ("CALL_STATE", call->getStateStr ())); call_details.insert (std::pair<std::string, std::string> ("CALL_TYPE", type.str ())); } else