⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qtguimainwindow.cpp

📁 IP电话GUI界面设计及源代码,应用参考.
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		return -1;	}}void QtGUIMainWindow::changeLineStatePixmap (int line, line_state state){	// Set free-status for current line    phLines[line]->setState(state);    // Set free-pixmap	if (state == ONHOLD) {		// Because for the state of line pixmap there are just 2 states 		// (FREE and BUSY), so we associate ONHOLD to BUSY		state = BUSY;	}   	phLines[line]->button()->setPixmap(TabLinePixmap[line][state]);}intQtGUIMainWindow::busyLineNumber (void){	int temp = -1;    for (int i = 0; i < NUMBER_OF_LINES; i++) {        if (phLines[i]->isBusy() and i != _currentLine) {            temp = i;        }    }    return temp;}intQtGUIMainWindow::putOnHoldBusyLine (int line){	if (line != -1 and !phLines[line]->getbRinging()) {		if (!getCall(line2id(line))->isRinging()) {			// Occurs when newly off-hook line replaces another one.			_debug("On hold line %d [id=%d]\n", line, line2id(line));			qt_onHoldCall(line2id(line));		} 		changeLineStatePixmap(line, ONHOLD);		return 1;	} 	return 0;}voidQtGUIMainWindow::dialtone (bool var) {    if (_callmanager->error()->getError() == 0) {        if (_dialtone != var) {            _dialtone = var;        }        _callmanager->setTonezone(var);        _callmanager->getTonegenerator()->toneHandle(ZT_TONE_DIALTONE);    } else {        _callmanager->error()->errorName(DEVICE_NOT_OPEN, NULL);    }}////////////////////////////////////////////////////////////////////////////// Public functions////////////////////////////////////////////////////////////////////////////Call* QtGUIMainWindow::getCall (short id){	return _callmanager->getCall(id);}int QtGUIMainWindow::associateCall2Line (short id){	int i;	if (getChooseLine()) {		i = getCurrentLine();		phLines[i]->setState(BUSY);		phLines[i]->setCallId(id);		return i;	} else {		for (i = 0 ; i < NUMBER_OF_LINES; i++) {			if (phLines[i]->isFree()) {				phLines[i]->setState(BUSY);				phLines[i]->setCallId(id);				return i;			}		}		if (i == NUMBER_OF_LINES) {			displayError("All the lines are busy");			return -1;		}		return -1;	}}PhoneLine* QtGUIMainWindow::getPhoneLine (short id){	int i;	for (i = 0; i < NUMBER_OF_LINES; i++) {		if (phLines[i]->getCallId() == id) {			return phLines[i];		} 	}	if (i == NUMBER_OF_LINES) {		_debug("Id is not attributed to a phoneline\n");		return NULL;	}	return NULL;}int QtGUIMainWindow::getCurrentLine (void){	return _currentLine;}void QtGUIMainWindow::setCurrentLine (int current){	_currentLine = current;}int QtGUIMainWindow::getElapse (void){	int line = getCurrentLine();	return (phLines[line]->timer->elapsed() / 1000);}/////////////////////////////////////////////////////////////////////////////// Reimplementation of virtual functions/////////////////////////////////////////////////////////////////////////////int QtGUIMainWindow::incomingCall (short id){	int i;	// Associate call id with a phoneline i.	i = associateCall2Line(id);	if (i >= 0) {		_TabIncomingCalls[i] = id;		_debug("Phoneline %d associated to id %d\n", i, id);		if (getPhoneLine(id) != NULL) {			_lcd->setInFunction(false);			// Set boolean to true to blink pixmap to notify the ringing line 			getPhoneLine(id)->setbRinging(true);			// Set the status to the phoneline			getPhoneLine(id)->setStatus(QString(getCall(id)->getStatus()));		}	}	return i;}	int QtGUIMainWindow::peerAnsweredCall (short id){	getPhoneLine(id)->setStatus(QString(getCall(id)->getStatus()));	// Afficher call-timer	startCallTimer(id);	setChooseLine(false);		return 1;}int QtGUIMainWindow::peerRingingCall (short id){	getPhoneLine(id)->setStatus(QString(getCall(id)->getStatus()));	return 1;}	int QtGUIMainWindow::peerHungupCall (short id){	int line = id2line(id);	if (line == getCurrentLine() or getCurrentLine() == -1) {		stopCallTimer(id);		_callmanager->displayStatus(HUNGUP_STATUS);		setCurrentLine(-1);	} else {		// Stop the call timer when hang up    	if (getPhoneLine(id)->timer != NULL) {        	getPhoneLine(id)->stopTimer();    	}		getPhoneLine(id)->first = true;	}	getPhoneLine(id)->setStatus(QString(getCall(id)->getStatus()));	changeLineStatePixmap(line, FREE);	getPhoneLine(id)->setbRinging(false);	getPhoneLine(id)->setCallId(0);	setChooseLine(false);	_TabIncomingCalls[line] = -1;		return 1;}void QtGUIMainWindow::displayTextMessage (short id, const string& message){	_lcd->clearBuffer();	_lcd->appendText(message);}	void QtGUIMainWindow::displayError (const string& error){	_lcd->clearBuffer();	_lcd->appendText(error);}	void QtGUIMainWindow::displayStatus (const string& status){	if (status.compare(HUNGUP_STATUS) == 0 or 			status.compare(TRANSFER_STATUS) == 0) {		_lcd->clearBuffer();	}	_lcd->setStatus(status);}void QtGUIMainWindow::displayContext (short id){	displayStatus(getCall(id)->getStatus());	if (getCall(id)->isIncomingType()) {		displayTextMessage (id, getCall(id)->getCallerIdName());	} else if (getCall(id)->isOutgoingType()) {		displayTextMessage (id, getCall(id)->getCallerIdNumber());	} else {		_debug("No call with id %d\n", id);	}}void QtGUIMainWindow::setup (void) {	configuration();}intQtGUIMainWindow::selectedCall (void) {	int id = -1;	if (getChooseLine()) {		id = line2id(getChosenLine());	}	return id;}////////////////////////////////////////////////////////////////////////////// IP-phone user actions////////////////////////////////////////////////////////////////////////////int QtGUIMainWindow::qt_outgoingCall (void){	int id, line;	if (_lcd->getTextBuffer() == NULL) {		_callmanager->displayStatus(ENTER_NUMBER_STATUS);		return -1;	}	const string to(_lcd->getTextBuffer().ascii());	if (to.empty()) {		_callmanager->displayStatus(ENTER_NUMBER_STATUS);		return -1;	} 		id = outgoingCall(to);	if (id > 0) {			line = associateCall2Line(id);		_debug("Call %d -> line %d\n", id, line);		setCurrentLine(line);		displayStatus(TRYING_STATUS);		_callmanager->getCall(id)->setCallerIdNumber(to);		changeLineStatePixmap(line, BUSY);	}		return line;}		int QtGUIMainWindow::qt_hangupCall (short id){	int i;	i = hangupCall(id);	stopCallTimer(id);		displayStatus(HUNGUP_STATUS);	setCurrentLine(-1);	return i;}		int QtGUIMainWindow::qt_answerCall (short id){	int i;	i = answerCall(id);	getPhoneLine(id)->setStatus(QString(getCall(id)->getStatus()));	startCallTimer(id);		displayStatus(CONNECTED_STATUS);	getPhoneLine(id)->setbRinging(false);	return i;	}		int QtGUIMainWindow::qt_onHoldCall (short id){	int i;	i = onHoldCall(id);	getPhoneLine(id)->setStatus(QString(getCall(id)->getStatus()));	return i;	}		int QtGUIMainWindow::qt_offHoldCall (short id){	int i;	i = offHoldCall(id);	getPhoneLine(id)->setStatus(QString(getCall(id)->getStatus()));	displayStatus(CONNECTED_STATUS);	return i;	}		int QtGUIMainWindow::qt_transferCall (short id){	int i;	const string to(_lcd->getTextBuffer().ascii());;	_debug("Transfer call %d to %s\n", id, to.data());	i = transferCall(id, to);	getPhoneLine(id)->setStatus(QString(getCall(id)->getStatus()));	return i;	}		void QtGUIMainWindow::qt_muteOn (short id){	int i;	i = muteOn(id);	getPhoneLine(id)->setStatus(QString(getCall(id)->getStatus()));		displayStatus(MUTE_ON_STATUS);}		void QtGUIMainWindow::qt_muteOff (short id){	int i;	i = muteOff(id);	getPhoneLine(id)->setStatus(QString(getCall(id)->getStatus()));	displayStatus(CONNECTED_STATUS);}		int QtGUIMainWindow::qt_refuseCall (short id){	int i;	i = refuseCall(id);//	getPhoneLine(id)->setStatus(QString(getCall(id)->getStatus()));	displayStatus(HUNGUP_STATUS);	getPhoneLine(id)->setbRinging(false);	_TabIncomingCalls[id2line(id)] = -1;	return i;	}		///////////////////////////////////////////////////////////////////////////////// Public Methods implementations                                            /////////////////////////////////////////////////////////////////////////////////	/** * Initializes LCD display, and move it at the configuration file position. */voidQtGUIMainWindow::setMainLCD (void) {	// Screen initialisation	this->_lcd->move (pt->getX(SCREEN), pt->getY(SCREEN));}intQtGUIMainWindow::toggleLine (int line) {	int id;	int busyLine;	Call* call;	if (line == -1) {		return -1;	}		setCurrentLine(line);	busyLine = busyLineNumber();		id = line2id(line);	if (id > 0) {	// If the call-id already exists		call = getCall(id);		if (call == NULL) {		// Check if the call exists			return -1;		} else if (call->isRinging()){			// If call is ringing			_debug("CASE 1: Call %d is ringing\n", id);			changeLineStatePixmap(line, BUSY);			putOnHoldBusyLine(busyLine);			displayContext(id);		} else if (call->isBusy()){			// If call is busy, put this call on hold			_debug("CASE 2 Put Call %d on-hold\n", id);			changeLineStatePixmap(line, ONHOLD);			displayStatus(ONHOLD_STATUS);			qt_onHoldCall(id);		} else if (call->isOnHold()) {			// If call is on hold, put this call on busy state			_debug("CASE 3: Put Call %d off-hold\n", id);			changeLineStatePixmap(line, BUSY);			putOnHoldBusyLine(busyLine);			if (getChooseLine()) {				// If a free line is off-hook, set this line to free state				setChooseLine(false);				changeLineStatePixmap(getChosenLine(), FREE);				dialtone(false);			}					_lcd->setInFunction(true);			qt_offHoldCall(id);			displayContext(id);		} else if (call->isIncomingType()) {		// If incoming call occurs			_debug("CASE 4: Answer call %d\n", id);			changeLineStatePixmap(line, BUSY);			putOnHoldBusyLine(busyLine);			qt_answerCall(id);		} else {			_debug("Others cases to handle\n");			return -1;		}		} else {	// If just click on free line		_debug("CASE 5: New line off-hook\n");		phLines[line]->button()->setPixmap(TabLinePixmap[line][BUSY]);		displayStatus(ENTER_NUMBER_STATUS);		setChooseLine(true);		setChosenLine(line);		putOnHoldBusyLine(busyLine);		if (getPrevLine() != -1 and getPrevLine() != line 				and phLines[getPrevLine()]->isFree()) {			changeLineStatePixmap(getPrevLine(), FREE);		}			setPrevLine(line);					_lcd->setInFunction(false);		_lcd->clearBuffer();		dialtone(true);	}	return 1;}/** * Actions occur when click on hang off button.  * Use to validate incoming and outgoing call, transfer call. */voidQtGUIMainWindow::dial (void) {	short i;	int line = -1;		if ((i = isThereIncomingCall()) > 0) {		// If new incoming call 		line = id2line(i);		_TabIncomingCalls[line] = -1;		toggleLine(line);	} else if (getTransfer()){		// If call transfer		qt_transferCall (line2id(getCurrentLine()));	} else {		// If new outgoing call  		if (getCurrentLine() < 0 or getChooseLine()) {			line = qt_outgoingCall();		}	}		}/** * Hangup the current call. */voidQtGUIMainWindow::hangupLine (void) {  	int i;	int line = getCurrentLine();	int id = phLines[line]->getCallId();	if (_callmanager->getbCongestion()) {		// If congestion tone		changeLineStatePixmap(line, FREE);        _lcd->clear(QString(ENTER_NUMBER_STATUS));		qt_hangupCall(id);		_callmanager->congestion(false);		phLines[line]->setCallId(0);	} else if (line >= 0 and id > 0 and getCall(id)->isProgressing()) {		// If I want to cancel a call before ringing, i have to wait.	} else if (line >= 0 and id > 0) {		// If hangup current line normally		_debug("Hangup line %d\n", line);		qt_hangupCall(id);		changeLineStatePixmap(line, FREE);		phLines[line]->setCallId(0);		setChooseLine(false);	} else if ((i = isThereIncomingCall()) > 0){		// To refuse new incoming call 		_debug("Refuse call %d\n", id);		qt_refuseCall(i);		changeLineStatePixmap(id2line(i), FREE);	} else if (line >= 0) {		_debug("Just load free pixmap for the line %d\n", line);		changeLineStatePixmap(line, FREE);		dialtone(false);		setChooseLine(false);		setCurrentLine(-1);	}}/** * Stop the blinking message slot and load the message-off button pixmap. */voidQtGUIMainWindow::stopTimerMessage (void) {   	_msgVar = false;    phoneKey_msg->setPixmap(TabMsgPixmap[FREE]);}/** * Stop the call timer. *  * @param	line: number of line  */voidQtGUIMainWindow::stopCallTimer (short id) {	// Stop the call timer when hang up    if (getPhoneLine(id)->timer != NULL) {        getPhoneLine(id)->stopTimer();    }    // No display call timer, display current hour	_lcd->setInFunction(false);    getPhoneLine(id)->first = true;}/** * Start the call timer. *  * @param	line: number of line  */voidQtGUIMainWindow::startCallTimer (short id) {	// Call-timer enable    _lcd->setInFunction(true);                                                                                    // To start the timer for display text just one time    if (getPhoneLine(id)->first) {        getPhoneLine(id)->startTimer();        getPhoneLine(id)->first = false;    }} ///////////////////////////////////////////////////////////////////////////////// Public slot implementations                                               /////////////////////////////////////////////////////////////////////////////////voidQtGUIMainWindow::volumeSpkrChanged (int val) {	_callmanager->setSpkrVolume(val);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -