File indexing completed on 2024-03-24 16:27:32

0001 /*
0002  * This file is part of TelepathyLoggerQt
0003  *
0004  * Copyright (C) 2011 Stefano Sanfilippo <stefano.k.sanfilippo@gmail.com>
0005  * Copyright (C) 2011 Collabora Ltd. <http://www.collabora.co.uk/>
0006  *
0007  * This library is free software; you can redistribute it and/or modify
0008  * it under the terms of the GNU Lesser General Public License as published
0009  * by the Free Software Foundation; either version 2.1 of the License, or
0010  * (at your option) any later version.
0011  *
0012  * This program is distributed in the hope that it will be useful,
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0015  * GNU General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU Lesser General Public License
0018  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0019  */
0020 
0021 #include "event.h"
0022 #include "entity.h"
0023 #include "utils.h"
0024 
0025 #include <TelepathyQt/Account>
0026 
0027 #include <telepathy-logger/event.h>
0028 
0029 using namespace Tpl;
0030 
0031 QDateTime Event::timestamp() const
0032 {
0033     // FIXME See http://bugs.freedesktop.org/show_bug.cgi?id=21690
0034     uint seconds = (uint) tpl_event_get_timestamp(object<TplEvent>());
0035     QDateTime dateTime;
0036     dateTime.setTime_t(seconds);
0037     return dateTime;
0038 }
0039 
0040 QString Event::accountPath() const
0041 {
0042     const gchar *s = tpl_event_get_account_path(object<TplEvent>());
0043     QString str = QString::fromUtf8(s);
0044     return str;
0045 }
0046 
0047 Tp::AccountPtr Event::account() const
0048 {
0049     TpAccount *account = tpl_event_get_account(object<TplEvent>());
0050     return Utils::instance()->accountPtr(account);
0051 }
0052 
0053 EntityPtr Event::sender() const
0054 {
0055     TplEntity *entity = tpl_event_get_sender(object<TplEvent>());
0056     return TPLoggerQtWrapper::wrap<TplEntity, Entity>(entity, true);
0057 }
0058 
0059 EntityPtr Event::receiver() const
0060 {
0061     TplEntity *entity = tpl_event_get_receiver(object<TplEvent>());
0062     return TPLoggerQtWrapper::wrap<TplEntity, Entity>(entity, true);
0063 }
0064 
0065 bool Event::equalTo(const EventPtr& rhs) const
0066 {
0067     return tpl_event_equal(object<TplEvent>(), rhs->object<TplEvent>());
0068 }
0069 
0070 bool Event::operator==(const EventPtr& rhs) const
0071 {
0072     return equalTo(rhs);
0073 }
0074