File indexing completed on 2024-04-21 15:42:59

0001 /*
0002  * This file is part of TelepathyLoggerQt
0003  *
0004  * Copyright (C) 2011 Collabora Ltd. <http://www.collabora.co.uk/>
0005  *
0006  * This library is free software; you can redistribute it and/or modify
0007  * it under the terms of the GNU Lesser General Public License as published
0008  * by the Free Software Foundation; either version 2.1 of the License, or
0009  * (at your option) any later version.
0010  *
0011  * This program is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  * GNU General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public License
0017  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018  */
0019 
0020 #include "call-event.h"
0021 #include "entity.h"
0022 
0023 #include <telepathy-logger/call-event.h>
0024 #include <telepathy-logger/entity.h>
0025 
0026 using namespace Tpl;
0027 
0028 QTime CallEvent::duration() const
0029 {
0030     GTimeSpan timeSpan = tpl_call_event_get_duration(object<TplCallEvent>());
0031     int hh = timeSpan / 3600;
0032     timeSpan = timeSpan % 3600;
0033     int mm = timeSpan / 60;
0034     int ss = timeSpan % 60;
0035     int ms = 0;
0036     // FIXME there is no timespan type in Qt yet, use QTime in the meanwhile
0037     QTime ret(hh,mm,ss,ms);
0038     return ret;
0039 }
0040 
0041 EntityPtr CallEvent::endActor() const
0042 {
0043     TplEntity * entity = tpl_call_event_get_end_actor(object<TplCallEvent>());
0044     return TPLoggerQtWrapper::wrap<TplEntity, Entity>(entity, true);
0045 }
0046 
0047 Tp::CallStateChangeReason CallEvent::endReason() const
0048 {
0049     Tp::CallStateChangeReason er = (Tp::CallStateChangeReason) tpl_call_event_get_end_reason(object<TplCallEvent>());
0050     return er;
0051 }
0052 
0053 QString CallEvent::detailedEndReason() const
0054 {
0055     const gchar *s = tpl_call_event_get_detailed_end_reason(object<TplCallEvent>());
0056     QString str = QString::fromUtf8(s);
0057     return str;
0058 }