aboutsummaryrefslogtreecommitdiff
path: root/contact.cpp
blob: db6a887a80ae846df52bd720bc9f8905d3955fcf (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
#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;
}

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};
}