📄 phonelinemanagerimpl.cpp
字号:
this, SIGNAL(actionSet(QString))); QObject::disconnect(mCurrentLine, SIGNAL(bufferStatusChanged(QString)), this, SIGNAL(bufferStatusSet(QString))); QObject::disconnect(mCurrentLine, SIGNAL(talkingStarted(QTime)), this, SIGNAL(talkingStarted(QTime))); QObject::disconnect(mCurrentLine, SIGNAL(talkingStopped()), this, SIGNAL(talkingStopped())); QObject::disconnect(mCurrentLine, SIGNAL(transfered()), this, SLOT(unselect())); QObject::connect(mCurrentLine, SIGNAL(lineStatusChanged(QString)), this, SIGNAL(unselectedLineStatusSet(QString))); if(mCurrentLine->isAvailable()) { mSession->stopTone(); } mCurrentLine->unselect(); mCurrentLine = NULL; emit lineStatusSet(""); emit actionSet(""); emit bufferStatusSet(""); emit talkingStopped(); }}PhoneLine *PhoneLineManagerImpl::selectNextAvailableLine(){ isInitialized(); PhoneLine *selectedLine = getNextAvailableLine(); // If we found one available line. if(selectedLine) { unselect(); select(selectedLine); } return selectedLine;}PhoneLine *PhoneLineManagerImpl::getPhoneLine(unsigned int line){ isInitialized(); if(mPhoneLines.size() <= line) { throw std::runtime_error("Trying to get an invalid Line"); } return mPhoneLines[line];}PhoneLine *PhoneLineManagerImpl::getPhoneLine(const QString &callId){ isInitialized(); PhoneLine *selectedLine = NULL; unsigned int i = 0; while(i < mPhoneLines.size() && !selectedLine) { if(mPhoneLines[i]->getCallId() == callId) { selectedLine = mPhoneLines[i]; } else { i++; } } return selectedLine;}voidPhoneLineManagerImpl::sendKey(Qt::Key c){ isInitialized(); PhoneLine *selectedLine = getCurrentLine(); // Only digits that select a line if there's // no current line. switch(c) { case Qt::Key_F1: case Qt::Key_F2: case Qt::Key_F3: case Qt::Key_F4: case Qt::Key_F5: case Qt::Key_F6: selectLine(c - Qt::Key_F1); break; case Qt::Key_Escape: if (selectedLine) { selectedLine->hangup(true); } default: if (!selectedLine) { selectedLine = selectNextAvailableLine(); } if(selectedLine) { if (c == Qt::Key_Enter || c == Qt::Key_Return) { mLastNumber = selectedLine->getBuffer(); } selectedLine->sendKey(c); } }}void PhoneLineManagerImpl::selectLine(const QString &callId, bool hardselect){ isInitialized(); PhoneLine *selectedLine = NULL; unsigned int line = 0; while(!selectedLine && line < mPhoneLines.size()) { if(mPhoneLines[line]->getCallId() == callId) { selectedLine = mPhoneLines[line]; } else { line++; } } if(selectedLine) { selectLine(line, hardselect); } else { DebugOutput::instance() << QObject::tr("PhoneLineManager: Tried to selected line with call ID (%1), " "which appears to be invalid.\n").arg(callId); }}voidPhoneLineManagerImpl::unselectLine(unsigned int line){ isInitialized(); PhoneLine *selectedLine = NULL; // getting the wanted line; { if(mPhoneLines.size() > line) { selectedLine = mPhoneLines[line]; } } if(selectedLine == mCurrentLine) { unselect(); }}/** * Warning: This function might 'cause a problem if * we select 2 line in a very short time. */voidPhoneLineManagerImpl::selectLine(unsigned int line, bool hardselect){ isInitialized(); PhoneLine *selectedLine = NULL; // getting the wanted line; { if(mPhoneLines.size() > line) { selectedLine = mPhoneLines[line]; } } if(selectedLine != NULL) { PhoneLine *oldLine = mCurrentLine; if(oldLine != selectedLine) { select(selectedLine, hardselect); } } else { DebugOutput::instance() << QObject::tr("PhoneLineManager: Tried to selected line %1, " "which appears to be invalid.\n").arg(line); }}voidPhoneLineManagerImpl::call(const QString &to){ PhoneLine *current = getCurrentLine(); if(current) { current->call(to); mLastNumber = to; }}voidPhoneLineManagerImpl::call(){ PhoneLine *current = getCurrentLine(); if(current) { mLastNumber = current->getBuffer(); current->call(); }}voidPhoneLineManagerImpl::makeNewCall(const QString& to) { selectNextAvailableLine(); call(to);}voidPhoneLineManagerImpl::transfer() { if(mCurrentLine) { mCurrentLine->transfer(); }}voidPhoneLineManagerImpl::hold(){ PhoneLine *selectedLine = mCurrentLine; mCurrentLine = NULL; if(selectedLine) { if(selectedLine->isAvailable()) { mSession->stopTone(); } selectedLine->hold(); }}voidPhoneLineManagerImpl::redial(){ PhoneLine *phoneLine = selectNextAvailableLine(); if(phoneLine && !mLastNumber.isEmpty()) { phoneLine->call(mLastNumber); }}voidPhoneLineManagerImpl::hangup(bool sendrequest){ PhoneLine *selectedLine = mCurrentLine; mCurrentLine = NULL; if(selectedLine) { if(selectedLine->isAvailable()) { mSession->stopTone(); } selectedLine->hangup(sendrequest); lineStatusSet(""); }}voidPhoneLineManagerImpl::mute(bool muting){ if(muting) { mute(); } else { unmute(); }}voidPhoneLineManagerImpl::mute(){ isInitialized(); mSession->mute();}voidPhoneLineManagerImpl::setup(){ isInitialized(); mSession->configGetAll();}voidPhoneLineManagerImpl::unmute(){ isInitialized(); mSession->unmute();}voidPhoneLineManagerImpl::hangup(const QString &callId, bool sendrequest){ PhoneLine *selectedLine = getPhoneLine(callId); hangup(selectedLine, sendrequest);} voidPhoneLineManagerImpl::hangup(unsigned int line, bool sendrequest){ PhoneLine *selectedLine = getPhoneLine(line); hangup(selectedLine, sendrequest);} void PhoneLineManagerImpl::hangup(PhoneLine *line, bool sendrequest){ if(line) { line->hangup(sendrequest); if(mCurrentLine == line) { unselect(); } }}voidPhoneLineManagerImpl::clear(){ PhoneLine *selectedLine = mCurrentLine; if(selectedLine) { selectedLine->clear(); }}void PhoneLineManagerImpl::incomming(const QString &accountId, const QString &callId, const QString &peer){ Call call(mSession->id(), accountId, callId, peer, true); PhoneLine *line = addCall(call, QObject::tr("Incomming")); if(line) { line->setLineStatus(QObject::tr("Ringing (%1)...").arg(peer)); }}PhoneLine *PhoneLineManagerImpl::addCall(const QString &accountId, const QString &callId, const QString &peer, const QString &state){ return addCall(Call(mSession->id(), accountId, callId, peer), state);}PhoneLine *PhoneLineManagerImpl::addCall(Call call, const QString &state){ PhoneLine *selectedLine = getNextAvailableLine(); if(selectedLine) { selectedLine->incomming(call); selectedLine->setLineStatus(state); } else { DebugOutput::instance() << QObject::tr("PhoneLineManager: There's no available lines" "here for the incomming call ID: %1.\n") .arg(call.id()); call.notAvailable(); } return selectedLine;}voidPhoneLineManagerImpl::updateVolume(int volume){ mVolume = volume; emit volumeUpdated((unsigned int)volume);}voidPhoneLineManagerImpl::updateMicVolume(int volume){ mMicVolume = volume; emit micVolumeUpdated((unsigned int)volume);}void PhoneLineManagerImpl::setVolume(int volume){ if(mVolume != volume) { mSession->volume(volume); updateVolume(volume); }}void PhoneLineManagerImpl::setMicVolume(int volume){ if(mMicVolume != volume) { mSession->micVolume(volume); updateMicVolume(volume); } }voidPhoneLineManagerImpl::incomingMessageText(const QString& message) { QMessageBox messageBox; messageBox.setText(message); messageBox.exec();}voidPhoneLineManagerImpl::addAccount(const QString& name, bool isEnabled, const QString& alias) { if (mSession!=0) { mSession->addAccount(name, isEnabled, alias); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -