aboutsummaryrefslogtreecommitdiff
path: root/message.cpp
blob: ff4bab9eab0f481affd2583016e94042acc823ce (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "message.h"

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

DcMessage::DcMessage(dc_msg_t *message)
    : QObject{nullptr}
    , m_message{message}
{
}

DcMessage::~DcMessage()
{
    dc_msg_unref(m_message);
}

uint32_t
DcMessage::getId()
{
    return dc_msg_get_id(m_message);
}

uint32_t
DcMessage::getFromId()
{
    return dc_msg_get_from_id(m_message);
}

uint32_t
DcMessage::getChatId()
{
    return dc_msg_get_chat_id(m_message);
}

int
DcMessage::getViewtype()
{
    return dc_msg_get_viewtype(m_message);
}

int
DcMessage::getState()
{
    return dc_msg_get_state(m_message);
}

QString
DcMessage::getText()
{
    char *text = dc_msg_get_text(m_message);
    QString result{text};
    dc_str_unref(text);
    return result;
}

QString
DcMessage::getFile()
{
    char *file = dc_msg_get_file(m_message);
    QString result{file};
    dc_str_unref(file);
    return result;
}

QString
DcMessage::getFilename()
{
    char *filename = dc_msg_get_filename(m_message);
    QString result{filename};
    dc_str_unref(filename);
    return result;
}

int
DcMessage::getWidth()
{
    return dc_msg_get_width(m_message);
}

int
DcMessage::getHeight()
{
    return dc_msg_get_height(m_message);
}

QString
DcMessage::getOverrideSenderName()
{
    char *name = dc_msg_get_override_sender_name(m_message);
    QString result{name};
    dc_str_unref(name);
    return result;
}

bool
DcMessage::isInfo()
{
    return dc_msg_is_info(m_message);
}

QString
DcMessage::getQuotedText()
{
    char *text = dc_msg_get_quoted_text(m_message);
    QString result{text};
    dc_str_unref(text);
    return result;
}

DcMessage *
DcMessage::getQuotedMessage()
{
    dc_msg_t *quote = dc_msg_get_quoted_msg(m_message);
    if (quote) {
        return new DcMessage{quote};
    } else {
        return NULL;
    }
}