-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnotifydesktop.cpp
More file actions
67 lines (58 loc) · 2.35 KB
/
notifydesktop.cpp
File metadata and controls
67 lines (58 loc) · 2.35 KB
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
/**
*************************************************************
* @file notifycli.cpp
* @brief Breve descripción
* Pequeña documentación del archivo
*
*
*
*
*
* @author Gaspar Fernández <blakeyed@totaki.com>
* @version
* @date 15 dic 2015
* Changelog:
*
*
*
*
*
*
*************************************************************/
#include "notifydesktop.hpp"
#include <iostream>
#include "lib/timeutils.hpp"
#include <libnotify/notify.h>
NotifyDesktop::NotifyDesktop(std :: string id):Notify(id, "desktop")
{
}
NotifyDesktop::~NotifyDesktop()
{
}
void NotifyDesktop::_newFail(const std :: string & serviceName, std :: chrono :: system_clock :: time_point outageStart, int code, const std :: string &message)
{
notify_init("Service error");
std::string title = "Service "+serviceName+" failed!";
std::string body = "Service "+serviceName+" got "+message+ "("+std::to_string(code)+") at "+ timeformat(outageStart);
NotifyNotification *failNotification = notify_notification_new(title.c_str(), body.c_str(), "dialog-error");
notify_notification_show(failNotification, NULL);
g_object_unref(G_OBJECT(failNotification));
notify_uninit();
}
void NotifyDesktop::_newBounce(const std::string& serviceName, uint64_t bounces, std::chrono::system_clock::time_point outageStart, std::chrono::system_clock::time_point outageElapsed, int code, const std::string& message)
{
}
void NotifyDesktop::_newRecovery(const std :: string & serviceName, std :: chrono :: system_clock :: time_point outageStart, std :: chrono :: system_clock :: time_point outageEnd, int code, const std :: string &message)
{
auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(outageEnd - outageStart).count();
notify_init("Service recovered");
std::string title = "Service "+serviceName+" recovered!";
std::string body = "Service "+serviceName+" is back to life from error "+message+ "("+std::to_string(code)+")\nHas been down for "+itemized_to_str(get_itemized(std::chrono::seconds(elapsed)));
NotifyNotification *failNotification = notify_notification_new(title.c_str(), body.c_str(), "dialog-information");
notify_notification_show(failNotification, NULL);
g_object_unref(G_OBJECT(failNotification));
notify_uninit();
}
void NotifyDesktop::_newMessage(const std::string& type, const std::string& serviceName, std::chrono::system_clock::time_point outageStart, const std::string& message)
{
}