Beispiel #1
0
/**
 * Convert a duration to a time.
 *
 */
time_t
duration2time(duration_type* duration)
{
    time_t period = 0;
    if (duration) {
        period += (duration->seconds);
        period += (duration->minutes)*60;
        period += (duration->hours)*3600;
        period += (duration->days)*86400;
        period += (duration->weeks)*86400*7;
        period += (duration->months)*86400*31;
        period += (duration->years)*86400*365;
        if (duration->months || duration->years) {
            /* [TODO] calculate correct number of days in this month/year */
            region_type* tmpregion = region_create();
            char* dstr = duration2str(tmpregion, duration);
            ods_log_warning("[%s] converting duration %s to approximate value",
                logstr, dstr?dstr:"(null)");
            region_cleanup(tmpregion);
        }
    }
    return period;
}
Beispiel #2
0
void HistoryForm::showCallDetails(const QModelIndex &index)
{
	cdrTextEdit->clear();

	if (!index.isValid()) return;
	
    int x = m_model->data(index, Qt::UserRole).toInt();
    const t_call_record& cr = m_history[x];
	
	t_user *user_config = phone->ref_user_profile(cr.user_profile);
	// If the user profile is not active, then use the
	// first user profile for formatting	
	if (!user_config) {
		user_config = phone->ref_users().front();
	}
	
	QString s = "<table>";
	
	// Left column: header names
	s += "<tr><td><b>";
	s += tr("Call start:") + "<br>";
	s += tr("Call answer:") + "<br>";
	s += tr("Call end:") + "<br>";
	s += tr("Call duration:") + "<br>";
	s += tr("Direction:") + "<br>";
	s += tr("From:") + "<br>";
	s += tr("To:") + "<br>";
	if (cr.reply_to_uri.is_valid()) s += tr("Reply to:") + "<br>";
	if (cr.referred_by_uri.is_valid()) s += tr("Referred by:") + "<br>";
	s += tr("Subject:") + "<br>";
	s += tr("Released by:") + "<br>";
	s += tr("Status:") + "<br>";
	if (!cr.far_end_device.empty()) s += tr("Far end device:") + "<br>";
	s += tr("User profile:");
	s += "</b></td>";
	
	// Right column: values
	s += "<td>";
	s += time2str(cr.time_start, "%d %b %Y %H:%M:%S").c_str();
	s += "<br>";
	if (cr.time_answer != 0) {
		s += time2str(cr.time_answer,  "%d %b %Y %H:%M:%S").c_str();
	}
	s += "<br>";
	s += time2str(cr.time_end, "%d %b %Y %H:%M:%S").c_str();
	s += "<br>";
	
	s += duration2str((unsigned long)(cr.time_end - cr.time_start)).c_str();
	if (cr.time_answer != 0) {
		s += " (";
		s += tr("conversation");
		s += ": ";
		s += duration2str((unsigned long)(cr.time_end - cr.time_answer)).c_str();
		s += ")";
	}
	s += "<br>";
	
	s += cr.get_direction().c_str();
	s += "<br>";
	s += str2html(ui->format_sip_address(user_config, cr.from_display, cr.from_uri).c_str());
	if (cr.from_organization != "") {
		s += ", ";
		s += str2html(cr.from_organization.c_str());
	}
	s += "<br>";
	s +=  str2html(ui->format_sip_address(user_config, cr.to_display, cr.to_uri).c_str());
	if (cr.to_organization != "") {
		s += ", ";
		s +=  str2html(cr.to_organization.c_str());
	}
	s += "<br>";
	if (cr.reply_to_uri.is_valid()) {
		s +=  str2html(ui->format_sip_address(user_config,
					cr.reply_to_display, cr.reply_to_uri).c_str());
		s += "<br>";
	}
	if (cr.referred_by_uri.is_valid()) {
		s +=  str2html(ui->format_sip_address(user_config,
				cr.referred_by_display, cr.referred_by_uri).c_str());
		s += "<br>";
	}
	s +=  str2html(cr.subject.c_str());
	s += "<br>";
	s += cr.get_rel_cause().c_str();
	s += "<br>";
	s += int2str(cr.invite_resp_code).c_str();
	s += ' ';
	s +=  str2html(cr.invite_resp_reason.c_str());
	s += "<br>";
	if (!cr.far_end_device.empty()) {
		s += str2html(cr.far_end_device.c_str());
		s += "<br>";
	}
	s +=  str2html(cr.user_profile.c_str());
	s += "</td></tr>";
	
	s += "</table>";
	
	cdrTextEdit->setText(s);
}
Beispiel #3
0
void HistoryForm::loadHistory()
{
	// Create list of all active profile names
	QStringList profile_name_list;
	list<t_user *>user_list = phone->ref_users();
	for (list<t_user *>::iterator i = user_list.begin(); i != user_list.end(); i++) {
		profile_name_list.append((*i)->get_profile_name().c_str());
	}
	
	// Fill the history table
	unsigned long numberOfCalls = 0;
	unsigned long totalCallDuration = 0;
	unsigned long totalConversationDuration = 0;

	m_model->setRowCount(0);

    std::list<t_call_record> history;

    call_history->get_history(history);
    m_history = QList<t_call_record>::fromStdList(history);

    for (int x = 0; x < m_history.size(); x++) {
        const t_call_record* cr = &m_history[x];

        if (cr->direction == t_call_record::DIR_IN && !inCheckBox->isChecked()) {
			continue;
		}
        if (cr->direction == t_call_record::DIR_OUT && !outCheckBox->isChecked()) {
			continue;
		}
        if (cr->invite_resp_code < 300 && !successCheckBox->isChecked()) {
			continue;
		}
        if (cr->invite_resp_code >= 300 && !missedCheckBox->isChecked()) {
			continue;
		}
        if (!profile_name_list.contains(cr->user_profile.c_str()) &&
		    profileCheckBox->isChecked())
		{
			continue;
		}
		
		numberOfCalls++;
		
		// Calculate total duration
        totalCallDuration += cr->time_end - cr->time_start;
        if (cr->time_answer != 0) {
            totalConversationDuration += cr->time_end - cr->time_answer;
		}
		
        t_user *user_config = phone->ref_user_profile(cr->user_profile);
		
		// If the user profile is not active, then use the
		// first user profile for formatting	
		if (!user_config) {
			user_config = phone->ref_users().front();
		}
		
        m_model->setRowCount(numberOfCalls);

        for (int j = 0; j < 5; j++)
        {
            QModelIndex index = m_model->index(m_model->rowCount()-1, j);

            m_model->setData(index, QVariant(x), Qt::UserRole);
            switch (j)
            {
                case HISTCOL_TIMESTAMP:
                {
                    m_model->setData(index, QDateTime::fromTime_t(cr->time_start));
                    break;
                }
                case HISTCOL_DIRECTION:
                {
                    m_model->setData(index, QString::fromStdString(cr->get_direction()));

                    m_model->setData(index, (cr->direction == t_call_record::DIR_IN ?
                                    m_pixmapIn : m_pixmapOut), Qt::DecorationRole);

                    break;
                }
                case HISTCOL_FROMTO:
                {
                    std::string address;

                    address = (cr->direction == t_call_record::DIR_IN ?
                         ui->format_sip_address(user_config,
                          cr->from_display, cr->from_uri) :
                         ui->format_sip_address(user_config,
                          cr->to_display, cr->to_uri));

                    m_model->setData(index, QString::fromStdString(address));

                    m_model->setData(index, (cr->invite_resp_code < 300 ?
                                    m_pixmapOk : m_pixmapCancel), Qt::DecorationRole);
                    break;
                }
                case HISTCOL_SUBJECT:
                {
                    m_model->setData(index, QString::fromStdString(cr->subject));
                    break;
                }
                case HISTCOL_STATUS:
                {
                    m_model->setData(index, QString::fromStdString(cr->invite_resp_reason));
                    break;
                }
            }
        }
	}
	
	numberCallsValueTextLabel->setText(QString().setNum(numberOfCalls));
	
	// Total call duration formatting
	QString durationText = duration2str(totalCallDuration).c_str();
	durationText += " (";
	durationText += tr("conversation");
	durationText += ": ";
	durationText += duration2str(totalConversationDuration).c_str();
	durationText += ")";
	totalDurationValueTextLabel->setText(durationText);
	
	// Sort entries using currently selected sort column and order.
	historyListView->sortByColumn(historyListView->horizontalHeader()->sortIndicatorSection(), historyListView->horizontalHeader()->sortIndicatorOrder());
	// Make the first entry the selected entry.
	if (numberOfCalls) historyListView->selectRow(0);
}