コード例 #1
0
void QtHistory::replayItem(int id) {
	if (id != 0){
	HistoryMementoCollection * collection = _cHistory.getHistory().getHistoryMementoCollection();
	HistoryMemento* memento = collection->getMemento(id);
	QString data = QString::fromStdString(memento->getData());

	QtWengoPhone * qtWengoPhone = (QtWengoPhone *) _cHistory.getCWengoPhone().getPresentation();
	//VOXOX - CJC - 2009.06.10 
	QtVoxMessageBox box(_historyWidget->getWidget());
	box.setWindowTitle("VoxOx - Call History");
	box.setText(tr("Do you want to call %1?").arg(formatName(memento->getPeer(), _isWengoAccountConnected)));
	box.setStandardButtons(QMessageBox::Yes | QMessageBox::No );


	/*QMessageBox mb(tr("@product@ - Call History"),
		tr("Do you want to call %1?").arg(formatName(memento->getPeer(), _isWengoAccountConnected)),
		QMessageBox::Question,
		QMessageBox::Yes | QMessageBox::Default,
		QMessageBox::No | QMessageBox::Escape,
		QMessageBox::NoButton, _historyWidget->getWidget());*/

	switch (memento->getState()) {
	case HistoryMemento::OutgoingSmsOk:
	case HistoryMemento::OutgoingSmsNok: {
		//Retrieve info & configure the Sms widget
		std::string data = _cHistory.getMementoData(id);
		QString text = QString::fromUtf8(data.c_str(), data.size());
		QString phoneNumber = QString::fromStdString(_cHistory.getMementoPeer(id));

		//Test existance of Sms (available only if a WengoAccount has been created)
		QtSms * sms = qtWengoPhone->getQtSms();
		if (sms) {
			sms->setText(text);
			sms->setPhoneNumber(phoneNumber);
			sms->getWidget()->show();
		}
		break;
	}

	case HistoryMemento::OutgoingCall:
	case HistoryMemento::IncomingCall:
	case HistoryMemento::MissedCall:
	case HistoryMemento::RejectedCall:
		if (box.exec() == QMessageBox::Yes) {
			_cHistory.replay(id);
		}
		break;

	case HistoryMemento::ChatSession:
		_chatLogViewer = new QtChatLogViewer(NULL, *qtWengoPhone, data );
		_chatLogViewer->restartChat();
		break;

	default:
		break;
		}
	}
}
コード例 #2
0
void QtVoxOxCallBarFrame::fillComboBox() {
	QStringList tobeinserted = QStringList();
	clearComboBox();

	//CUserProfile * cUserProfile =
	//	_qtWengoPhone->getCWengoPhone().getCUserProfileHandler().getCUserProfile();
	if (!_cUserProfile) {
		return;
	}

	//completion of history
	//if _qtHistoryWidget is set it means that History has been created
	
	bool isWengoAccountConnected = _cUserProfile->getUserProfile().hasWengoAccount();
	
	CHistory* chistory = _cUserProfile->getCHistory();
	if (chistory) {
		HistoryMementoCollection * mementos = chistory->getMementos(HistoryMemento::OutgoingCall, 10);
		Config & config = ConfigManager::getInstance().getCurrentConfig();
		QString wengoSuffix = "@" + QString::fromStdString( config.getWengoRealm() );
		for (HistoryMap::iterator it = mementos->begin(); it != mementos->end(); it++) {
			HistoryMemento * memento = (*it).second;
			SipAddress sipAddress(memento->getPeer());
			
			QString username(sipAddress.getSipAddress().c_str());
			if (isWengoAccountConnected) {
				username.remove(wengoSuffix);
			}
			username.remove("sip:");	

			if( !username.isEmpty() && (memento->getState()==HistoryMemento::OutgoingCall) && !tobeinserted.contains(username) ) {
				tobeinserted << username;
			}
		}
		OWSAFE_DELETE(mementos);
	}
	////

	tobeinserted.sort();

	QStringList::const_iterator constIterator;
	for (constIterator = tobeinserted.constBegin(); constIterator != tobeinserted.constEnd();++constIterator){		
		
		addComboBoxItem(*constIterator);

	}

	if(tobeinserted.count() > 0){
		if(_ui->callBarComboBox->findText(CLEAR_RECENT_CALLS_MESSAGE) == -1){
			_ui->callBarComboBox->insertItem (_ui->callBarComboBox->count(), CLEAR_RECENT_CALLS_MESSAGE );
		}
	}

	clearComboBoxEditText();
}
コード例 #3
0
QVariant QtHistory::data(const QModelIndex& index, int role) const {
	if (index.row() < 0 || index.row() >= _mementoIdList.size()) {
		return QVariant();
	}
	int id = _mementoIdList[index.row()];
	HistoryMementoCollection * collection = _cHistory.getHistory().getHistoryMementoCollection();
	HistoryMemento* memento = collection->getMemento(id);
	if (!memento) {
		LOG_ERROR("Couldn't get memento for id " + String::fromNumber(id));
		return QVariant();
	}

	if (role == Qt::DisplayRole) {
		switch (index.column()) {
		case 0:
			return textForMementoState(memento->getState());

		case 1:
			return QVariant(formatName(memento->getPeer(), _isWengoAccountConnected));

		case 2:
			return QVariant(formatDate(qDateTimeForMemento(memento)));
		case 3:
			//VOXOX - CJC - 2009.05.31 Only show duration for calls
			if(memento->getState() == HistoryMemento::OutgoingCall || memento->getState()== HistoryMemento::IncomingCall
				||memento->getState() == HistoryMemento::MissedCall || memento->getState() == HistoryMemento::RejectedCall){
					return QVariant(formatDuration(qTimeForDuration(memento->getDuration())));
				}else{
					return QVariant("");
			}

		default:
			return QVariant();
		}
	} else if (role == Qt::DecorationRole) {
		if (index.column() == 0) {
			return QVariant(iconForMementoState(memento->getState()));
		} else {
			return QVariant();
		}
	} else if (role == Qt::UserRole) {
		return QVariant(id);
	}
	return QVariant();
}