aboutsummaryrefslogtreecommitdiff
path: root/chat.cpp
blob: 6b28b9e7fe1eda4913f9fa34669a681e812a90f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "chat.h"

DcChat::DcChat(QObject *parent)
    : QObject{parent}
{
}

DcChat::DcChat(dc_chat_t *chat)
    : QObject{nullptr}
    , m_chat{chat}
{
}

DcChat::~DcChat()
{
    dc_chat_unref(m_chat);
}

uint32_t
DcChat::getId()
{
    return dc_chat_get_id(m_chat);
}

int
DcChat::getType()
{
    return dc_chat_get_type(m_chat);
}

QString
DcChat::getName()
{
    char *name = dc_chat_get_name(m_chat);
    QString result{name};
    dc_str_unref(name);
    return result;
}

QString
DcChat::getProfileImage()
{
    char *profileImage = dc_chat_get_profile_image(m_chat);
    QString result{profileImage};
    dc_str_unref(profileImage);
    return result;
}

QColor
DcChat::getColor()
{
    uint32_t color = dc_chat_get_color(m_chat);
    return QColor{int(color >> 16) & 0xff, int(color >> 8) & 0xff, int(color) & 0xff};
}

bool
DcChat::isContactRequest()
{
    return dc_chat_is_contact_request(m_chat);
}

bool
DcChat::canSend()
{
    return dc_chat_can_send(m_chat);
}

bool
DcChat::isMuted()
{
    return dc_chat_is_muted(m_chat);
}

int
DcChat::getVisibility()
{
    return dc_chat_get_visibility(m_chat);
}

void
DcChat::notifyNewMess()
{
   KNotification *newMess = new KNotification("onIncomingMessage");
   newMess->setPixmap(QPixmap(getProfileImage()));
   newMess->setIconName("chat.delta.KDeltaChat");
   newMess->setComponentName("kdeltachat");
   newMess->setTitle(getName());
   newMess->setText("has sent you a message");
   newMess->sendEvent();
}