aboutsummaryrefslogtreecommitdiff
path: root/contact.cpp
blob: f51a6665dcade140219389bb011a452e5daca589 (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
#include "contact.h"

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

DcContact::DcContact(dc_contact_t *contact)
    : QObject{nullptr}
    , m_contact{contact}
{
}

DcContact::~DcContact()
{
    dc_contact_unref(m_contact);
}

uint32_t
DcContact::getId()
{
    return dc_contact_get_id(m_contact);
}

QString
DcContact::getAddr()
{
    char *addr = dc_contact_get_addr(m_contact);
    QString result{addr};
    dc_str_unref(addr);
    return result;
}

QString
DcContact::getName()
{
    char *name = dc_contact_get_name(m_contact);
    QString result{name};
    dc_str_unref(name);
    return result;
}

QString
DcContact::getDisplayName()
{
    char *display_name = dc_contact_get_display_name(m_contact);
    QString result{display_name};
    dc_str_unref(display_name);
    return result;
}

QString
DcContact::getProfileImage()
{
    char *profileImage = dc_contact_get_profile_image(m_contact);
    QString result{profileImage};
    dc_str_unref(profileImage);
    return result;
}

QColor
DcContact::getColor()
{
    uint32_t color = dc_contact_get_color(m_contact);
    return QColor{int(color >> 16) & 0xff, int(color >> 8) & 0xff, int(color) & 0xff};
}