Commit aa709ec5 authored by jpbl's avatar jpbl
Browse files

now we have the buffer of the line

parent 5cf8f0c6
......@@ -103,7 +103,6 @@ PhoneLine::unselect(bool hardselect)
emit backgrounded();
}
else {
clear();
emit unselected();
}
}
......@@ -126,6 +125,7 @@ void
PhoneLine::clear()
{
mBuffer.clear();
emit bufferStatusChanged(mBuffer);
}
void
......@@ -147,6 +147,7 @@ PhoneLine::sendKey(Qt::Key c)
if(!mCall) {
mSession.playDtmf(c);
mBuffer += QString(c);
emit bufferStatusChanged(mBuffer);
}
else {
mCall->sendDtmf(c);
......@@ -171,6 +172,7 @@ PhoneLine::call(const QString &to)
setLineStatus("Calling " + to + "...");
mCall = new Call(mSession.createCall());
mCall->call(to);
clear();
}
}
......@@ -216,6 +218,9 @@ PhoneLine::hangup()
delete mCall;
mCall = NULL;
}
else {
clear();
}
//This is a hack for unselect;
mSelected = true;
......
......@@ -56,6 +56,8 @@ public:
void sendKey(Qt::Key c);
QString getLineStatus();
QString getBuffer()
{return mBuffer;}
void setLineStatus(const QString &);
public slots:
......@@ -91,6 +93,7 @@ signals:
void unselected();
void backgrounded();
void lineStatusChanged(const QString &);
void bufferStatusChanged(const QString &);
private:
Session mSession;
......
......@@ -143,6 +143,8 @@ PhoneLineManagerImpl::setNbLines(unsigned int nb)
PhoneLine *p = new PhoneLine(*mSession, i + 1);
QObject::connect(p, SIGNAL(lineStatusChanged(const QString &)),
this, SIGNAL(lineStatusSet(const QString &)));
QObject::connect(p, SIGNAL(bufferStatusChanged(const QString &)),
this, SIGNAL(bufferStatusSet(const QString &)));
mPhoneLines.push_back(p);
}
}
......@@ -198,6 +200,7 @@ PhoneLineManagerImpl::selectNextAvailableLine()
// done at the top.
selectedLine->select();
emit lineStatusSet(selectedLine->getLineStatus());
emit bufferStatusSet(selectedLine->getBuffer());
}
return selectedLine;
......@@ -322,6 +325,7 @@ PhoneLineManagerImpl::selectLine(unsigned int line, bool hardselect)
PhoneLineLocker guard(selectedLine);
selectedLine->select(hardselect);
emit lineStatusSet(selectedLine->getLineStatus());
emit bufferStatusSet(selectedLine->getBuffer());
if(selectedLine->isAvailable()) {
mSession->playTone();
}
......
......@@ -51,6 +51,7 @@ signals:
void readyToHandleEvents();
void gotErrorOnCallStatus();
void globalStatusSet(const QString &);
void bufferStatusSet(const QString &);
void lineStatusSet(const QString &);
public slots:
......
......@@ -16,6 +16,7 @@ SFLLcd::SFLLcd(QWidget *parent, Qt::WFlags flags)
, mOverscreen(JPushButton::transparize(":/sflphone/images/overscreen.png"))
, mGlobalStatusPos(-1)
, mLineStatusPos(-1)
, mBufferStatusPos(-1)
, mIsTimed(false)
, mFont(FONT_FAMILY, FONT_SIZE)
{
......@@ -41,6 +42,10 @@ SFLLcd::updateText()
if(mLineStatusPos >= 0) {
mLineStatusPos++;
}
if(mBufferStatusPos >= 0) {
mBufferStatusPos++;
}
}
void
......@@ -68,11 +73,23 @@ SFLLcd::setGlobalStatus(const QString &global)
mGlobalStatus = global;
}
void
SFLLcd::setBufferStatus(const QString &buffer)
{
if(textIsTooBig(buffer)) {
mBufferStatusPos = 0;
}
else {
mBufferStatusPos = -1;
}
mBufferStatus = buffer;
}
void
SFLLcd::setLineStatus(const QString &line)
{
if(textIsTooBig(line)) {
mGlobalStatusPos = 0;
mLineStatusPos = 0;
}
else {
mLineStatusPos = -1;
......@@ -116,6 +133,8 @@ SFLLcd::paintEvent(QPaintEvent *)
extractVisibleText(mGlobalStatus, mGlobalStatusPos));
p.drawText(QPoint(margin, 2*fm.height()),
extractVisibleText(mLineStatus, mLineStatusPos));
p.drawText(QPoint(margin, 3*fm.height()),
extractVisibleText(mBufferStatus, mBufferStatusPos));
p.drawText(QPoint(margin, mScreen.size().height() - margin), getTimeStatus());
//p.drawPixmap(0,0, mScreen);
......
......@@ -42,6 +42,7 @@ public slots:
void setGlobalStatus(const QString &global);
void setLineStatus(const QString &line);
void setBufferStatus(const QString &line);
void startTiming();
void stopTiming();
......@@ -54,8 +55,10 @@ private:
QString mGlobalStatus;
QString mLineStatus;
QString mBufferStatus;
int mGlobalStatusPos;
int mLineStatusPos;
int mBufferStatusPos;
bool mIsTimed;
QTime mTime;
......
......@@ -70,6 +70,8 @@ SFLPhoneApp::initConnections(SFLPhoneWindow *w)
w->mLcd, SLOT(setLineStatus(const QString &)));
QObject::connect(&PhoneLineManager::instance(), SIGNAL(globalStatusSet(const QString &)),
w->mLcd, SLOT(setGlobalStatus(const QString &)));
QObject::connect(&PhoneLineManager::instance(), SIGNAL(bufferStatusSet(const QString &)),
w->mLcd, SLOT(setBufferStatus(const QString &)));
......
......@@ -86,7 +86,7 @@ TCPSessionIO::send(const QString &request)
{
QTextStream stream(mSocket);
if(mSocket->state() == QAbstractSocket::ConnectedState) {
_debug("Sending request to sflphone: %s",
_debug("TCPSessioIO: Sending request to sflphone: %s",
request.toStdString().c_str());
stream << request;
}
......@@ -103,6 +103,8 @@ TCPSessionIO::receive(QString &answer)
if(mSocket->isReadable()) {
QTextStream stream(mSocket);
answer = stream.readLine();
_debug("TCPSessionIO: Received answer from sflphone: %s",
answer.toStdString().c_str());
}
}
......
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