Commit 83a874ae authored by Jérémy Quentin's avatar Jérémy Quentin
Browse files

[#1689] getCallList at start

[#1690] getHistory at start
parent ea672d1e
......@@ -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;
......
......@@ -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);
......
......@@ -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();
......
......@@ -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()
......
......@@ -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"
......
......@@ -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) + ")") ;
}
}
......
......@@ -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;
......
......@@ -145,7 +145,7 @@ class Call{
*/
CallState getState();
std::string getStateStr (CallState state);
std::string getStateStr ();
void setCallConfiguration (Call::CallConfiguration callConfig) { _callConfig = callConfig; }
......
......@@ -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
......
Supports Markdown
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