Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/majn/telegram-purple.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormjentsch <mtthsjntsch@gmail.com>2015-03-13 18:57:08 +0300
committermjentsch <mtthsjntsch@gmail.com>2015-03-13 18:57:08 +0300
commit7903ce181126a2c5da2263bca60fa78099be6165 (patch)
treebf95f2febb7455de75c4c31d8717098940af5ac0 /tgp-utils.c
parent05908621519a024d63eeadc9b56b8240fa4c089c (diff)
Fix user online/offline status
Fix bug that prevented users from being displayed as online. Add option to set inactive users offline after a certain amount of days. Clean up user status code.
Diffstat (limited to 'tgp-utils.c')
-rw-r--r--tgp-utils.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tgp-utils.c b/tgp-utils.c
index 6687e75..2d0a74a 100644
--- a/tgp-utils.c
+++ b/tgp-utils.c
@@ -42,6 +42,28 @@ char *format_img_full (int imgstore) {
return g_strdup_printf ("%s<img id=\"%u\">", br, imgstore);
}
+char *tgp_format_user_status (struct tgl_user_status *status) {
+ char *when;
+ switch (status->online) {
+ case -1:
+ when = g_strdup_printf("%s", format_time (status->when));
+ break;
+ case -2:
+ when = g_strdup_printf("recently");
+ break;
+ case -3:
+ when = g_strdup_printf("last week");
+ break;
+ case -4:
+ when = g_strdup_printf("last month");
+ break;
+ default:
+ when = g_strdup ("unknown");
+ break;
+ }
+ return when;
+}
+
int str_not_empty (const char *string) {
return string && string[0] != '\0';
}
@@ -68,6 +90,12 @@ tgl_peer_t *tgp_encr_chat_get_partner (struct tgl_state *TLS, struct tgl_secret_
return tgl_peer_get (TLS, TGL_MK_USER(chat->admin_id == TLS->our_id ? chat->user_id : chat->admin_id));
}
+long tgp_time_n_days_ago (int days) {
+ time_t now;
+ time (&now);
+ return now - 24 * 3600 * (time_t)days;
+};
+
char *tgp_g_format_size (gint64 size) {
char *sizes[] = {
"B",