aboutsummaryrefslogtreecommitdiff
path: root/contact.cpp
diff options
context:
space:
mode:
authorlink2xt <link2xt@testrun.org>2020-09-12 14:10:13 +0300
committerlink2xt <link2xt@testrun.org>2020-10-03 00:20:03 +0300
commitb8762ddb38dd975b0acb217b793594dfed83a824 (patch)
tree23ccefbba703fed6c07acce82ff72e32ba77c9ba /contact.cpp
downloadkdeltachat-b8762ddb38dd975b0acb217b793594dfed83a824.tar.gz
kdeltachat-b8762ddb38dd975b0acb217b793594dfed83a824.zip
Initial commit
Diffstat (limited to 'contact.cpp')
-rw-r--r--contact.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/contact.cpp b/contact.cpp
new file mode 100644
index 0000000..db6a887
--- /dev/null
+++ b/contact.cpp
@@ -0,0 +1,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};
+}