From f1d1eda2e46bcf655b5dfe4ad028194a46e95661 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sun, 13 Mar 2016 21:58:23 +0000 Subject: [PATCH] Create the Profile object --- .gitignore | 1 + src/Makefile.am | 1 + src/matrix-profile.vala | 65 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 src/matrix-profile.vala diff --git a/.gitignore b/.gitignore index 570a7db..b7753d5 100644 --- a/.gitignore +++ b/.gitignore @@ -91,3 +91,4 @@ Makefile.in /src/matrix-message-audio.c /src/matrix-message-video.c /src/matrix-message-location.c +/src/matrix-profile.c diff --git a/src/Makefile.am b/src/Makefile.am index 4c84a36..b00190a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -59,6 +59,7 @@ libmatrix_glib_0_0_la_VALA_SOURCES = \ matrix-message-audio.vala \ matrix-message-video.vala \ matrix-message-location.vala \ + matrix-profile.vala \ $(NULL) AM_CPPFLAGS += \ diff --git a/src/matrix-profile.vala b/src/matrix-profile.vala new file mode 100644 index 0000000..ad5957d --- /dev/null +++ b/src/matrix-profile.vala @@ -0,0 +1,65 @@ +/* + * This file is part of matrix-glib-sdk + * + * matrix-glib-sdk is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * matrix-glib-sdk is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with matrix-glib-sdk. If not, see + * . + */ + +/** + * Object to hold a user's profile + * + * This object is used for both global and room specific profiles. + */ +public class Matrix.Profile : Object { + public TimeSpan age { + get { + return new DateTime.now_utc().difference(_last_update); + } + } + + /** + * The human readable name of the user. + */ + public string? display_name { + get { + return _display_name; + } + + set { + _display_name = value; + _last_update = new DateTime.now_utc(); + } + + default = null; + } + + /** + * The URL of the user's avatar. + */ + public string? avatar_url { + get { + return _avatar_url; + } + set { + _avatar_url = value; + _last_update = new DateTime.now_utc(); + } + + default = null; + } + + private DateTime _last_update; + private string? _display_name = null; + private string? _avatar_url = null; +}