conversation.cpp 2.05 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
    Copyright (C) 2011  Lasath Fernando <kde@lasath.org>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/


#include "conversation.h"
21
#include "messages-model.h"
22

David Edmundson's avatar
David Edmundson committed
23
#include <TelepathyQt/TextChannel>
Lasath Fernando's avatar
Lasath Fernando committed
24
#include <KDebug>
25
#include "conversation-target.h"
26

Lasath Fernando's avatar
Lasath Fernando committed
27 28
class Conversation::ConversationPrivate
{
29
public:
30 31
    MessagesModel* model;
    ConversationTarget* target;
32
//     Tp::AccountPtr account;
33 34
};

35 36
Conversation::Conversation(Tp::TextChannelPtr channel, Tp::AccountPtr account) :
        d (new ConversationPrivate)
37
{
Lasath Fernando's avatar
Lasath Fernando committed
38 39
    kDebug();

40 41
    d->model = new MessagesModel();
    d->model->setTextChannel(channel);
42

43
    d->target = new ConversationTarget(channel->targetContact());
44

45
//     connect(model(), SIGNAL(unreadCountChanged(int)), SLOT(onUnreadMessagesChanged()));
46
//     d->account = account;
Lasath Fernando's avatar
Lasath Fernando committed
47 48
}

49
Conversation::Conversation(QObject* parent) : QObject(parent)
Lasath Fernando's avatar
Lasath Fernando committed
50
{
51
    kError() << "Conversation should not be created directly. Use ConversationWatcher instead.";
52
    Q_ASSERT(false);
53 54
}

55
MessagesModel* Conversation::model() const
56
{
Lasath Fernando's avatar
Lasath Fernando committed
57
    return d->model;
58 59
}

60
ConversationTarget* Conversation::target() const
61
{
62
    return d->target;
63 64
}

65 66 67 68 69 70 71 72 73
// void Conversation::onUnreadMessagesChanged()
// {
//     enqueSelf();
// }
// 
// void Conversation::selfDequed()
// {
//     Q_EMIT popoutRequested();
// }
74

75 76
Conversation::~Conversation()
{
Lasath Fernando's avatar
Lasath Fernando committed
77
    kDebug();
Lasath Fernando's avatar
Lasath Fernando committed
78
    delete d->model;
79 80
    delete d->target;
    delete d;
81
}