aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/datetime/appointment.h8
-rw-r--r--src/appointment.cpp18
-rw-r--r--tests/manual-test-snap.cpp2
-rw-r--r--tests/notification-fixture.h4
-rw-r--r--tests/test-alarm-queue.cpp4
-rw-r--r--tests/test-eds-ics-missing-trigger.cpp1
-rw-r--r--tests/test-eds-ics-nonrepeating-events.cpp4
-rw-r--r--tests/test-eds-ics-repeating-events.cpp18
-rw-r--r--tests/test-eds-ics-repeating-valarms.cpp16
-rw-r--r--tests/test-eds-ics-tzids-2.cpp2
10 files changed, 39 insertions, 38 deletions
diff --git a/include/datetime/appointment.h b/include/datetime/appointment.h
index 2c225fc..ae9e8ff 100644
--- a/include/datetime/appointment.h
+++ b/include/datetime/appointment.h
@@ -35,21 +35,21 @@ namespace datetime {
struct Alarm
{
enum Type {
+ None = 0,
EMAIL = 0x001,
SOUND = 0x010,
TEXT = 0x100
};
+ int type;
std::string text;
std::string audio_url;
DateTime time;
- int type : SOUND;
bool operator== (const Alarm& that) const;
- bool has_sound() const;
- bool has_text() const;
+ Alarm();
+ Alarm(int type_, const std::string &text_, const std::string& audio_url_, const DateTime &time_);
};
-
/**
* \brief An instance of an appointment; e.g. a calendar event or clock-app alarm
*
diff --git a/src/appointment.cpp b/src/appointment.cpp
index a6800dd..e014a85 100644
--- a/src/appointment.cpp
+++ b/src/appointment.cpp
@@ -27,22 +27,22 @@ namespace datetime {
*****
****/
-bool Alarm::operator==(const Alarm& that) const
+Alarm::Alarm()
+ : type(Alarm::None)
{
- return (type==that.type)
- && (text==that.text)
- && (audio_url==that.audio_url)
- && (this->time==that.time);
}
-bool Alarm::has_sound() const
+Alarm::Alarm(int type_, const std::string &text_, const std::string& audio_url_, const DateTime &time_)
+ : type(type_), text(text_), audio_url(audio_url_), time(time_)
{
- return !audio_url.empty();
}
-bool Alarm::has_text() const
+bool Alarm::operator==(const Alarm& that) const
{
- return !text.empty();
+ return (type==that.type)
+ && (text==that.text)
+ && (audio_url==that.audio_url)
+ && (this->time==that.time);
}
bool Appointment::operator==(const Appointment& that) const
diff --git a/tests/manual-test-snap.cpp b/tests/manual-test-snap.cpp
index 5aa49a7..1479ef9 100644
--- a/tests/manual-test-snap.cpp
+++ b/tests/manual-test-snap.cpp
@@ -71,7 +71,7 @@ int main(int argc, const char* argv[])
a.type = Appointment::UBUNTU_ALARM;
a.begin = DateTime::Local(2014, 12, 25, 0, 0, 0);
a.end = a.begin.end_of_day();
- a.alarms.push_back(Alarm{"Alarm Text", "", a.begin, Alarm::SOUND});
+ a.alarms.push_back(Alarm{Alarm::SOUND, "Alarm Text", "", a.begin});
auto loop = g_main_loop_new(nullptr, false);
auto on_snooze = [loop](const Appointment& appt, const Alarm&){
diff --git a/tests/notification-fixture.h b/tests/notification-fixture.h
index a2f1179..40f7cee 100644
--- a/tests/notification-fixture.h
+++ b/tests/notification-fixture.h
@@ -111,7 +111,7 @@ protected:
const auto christmas = ayatana::indicator::datetime::DateTime::Local(2015,12,25,0,0,0);
appt.begin = christmas.start_of_day();
appt.end = christmas.end_of_day();
- appt.alarms.push_back(ayatana::indicator::datetime::Alarm{"Ho Ho Ho!", "", appt.begin, ayatana::indicator::datetime::Alarm::SOUND });
+ appt.alarms.push_back(ayatana::indicator::datetime::Alarm{ayatana::indicator::datetime::Alarm::SOUND, "Ho Ho Ho!", "", appt.begin });
// init a Lomiri Alarm
ualarm.color = "red";
@@ -121,7 +121,7 @@ protected:
const auto tomorrow = ayatana::indicator::datetime::DateTime::NowLocal().add_days(1);
ualarm.begin = tomorrow;
ualarm.end = tomorrow;
- ualarm.alarms.push_back(ayatana::indicator::datetime::Alarm{"It's Tomorrow!", "", appt.begin});
+ ualarm.alarms.push_back(ayatana::indicator::datetime::Alarm{ayatana::indicator::datetime::Alarm::SOUND, "It's Tomorrow!", "", appt.begin});
///
/// Add the AccountsService mock
diff --git a/tests/test-alarm-queue.cpp b/tests/test-alarm-queue.cpp
index c1f7929..49bd933 100644
--- a/tests/test-alarm-queue.cpp
+++ b/tests/test-alarm-queue.cpp
@@ -79,7 +79,7 @@ protected:
a1.type = Appointment::UBUNTU_ALARM;
a1.begin = tomorrow_begin;
a1.end = tomorrow_end;
- a1.alarms.push_back(Alarm{"Alarm Text", "", a1.begin, (int) Alarm::SOUND});
+ a1.alarms.push_back(Alarm{Alarm::SOUND, "Alarm Text", "", a1.begin});
const auto ubermorgen_begin = now.add_days(2).start_of_day();
const auto ubermorgen_end = ubermorgen_begin.end_of_day();
@@ -92,7 +92,7 @@ protected:
a2.type = Appointment::EVENT;
a2.begin = ubermorgen_begin;
a2.end = ubermorgen_end;
- a2.alarms.push_back(Alarm{"Alarm Text", "", a2.begin});
+ a2.alarms.push_back(Alarm{Alarm::SOUND, "Alarm Text", "", a2.begin});
return std::vector<Appointment>({a1, a2});
}
diff --git a/tests/test-eds-ics-missing-trigger.cpp b/tests/test-eds-ics-missing-trigger.cpp
index 0aa00c6..3894569 100644
--- a/tests/test-eds-ics-missing-trigger.cpp
+++ b/tests/test-eds-ics-missing-trigger.cpp
@@ -91,6 +91,7 @@ TEST_F(VAlarmFixture, MissingTriggers)
a.alarms[0].audio_url = "file://" ALARM_DEFAULT_SOUND;
a.alarms[0].time = a.begin;
a.alarms[0].text = a.summary;
+ a.alarms[0].type = Alarm::SOUND | Alarm::TEXT;
expected.push_back(a);
// build expected: recurring alarm
diff --git a/tests/test-eds-ics-nonrepeating-events.cpp b/tests/test-eds-ics-nonrepeating-events.cpp
index e79ab1a..fe0d851 100644
--- a/tests/test-eds-ics-nonrepeating-events.cpp
+++ b/tests/test-eds-ics-nonrepeating-events.cpp
@@ -80,11 +80,11 @@ TEST_F(VAlarmFixture, MultipleAppointments)
// what we expect to get...
Appointment expected_appt;
- expected_appt.uid = "20150520T000726Z-3878-32011-1770-81@ubuntu-phablet";
+ expected_appt.uid = "20150520T000726Z-3878-32011-1770-81@lomiri-phablet";
expected_appt.color = "#becedd";
expected_appt.summary = "Alarm";
std::array<Alarm,1> expected_alarms = {
- Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,5,20,20,00,0)})
+ Alarm({Alarm::SOUND | Alarm::TEXT, "Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,5,20,20,00,0)})
};
// compare it to what we actually loaded...
diff --git a/tests/test-eds-ics-repeating-events.cpp b/tests/test-eds-ics-repeating-events.cpp
index d4f0026..cdc0bbc 100644
--- a/tests/test-eds-ics-repeating-events.cpp
+++ b/tests/test-eds-ics-repeating-events.cpp
@@ -80,18 +80,18 @@ TEST_F(VAlarmFixture, MultipleAppointments)
// what we expect to get...
Appointment expected_appt;
- expected_appt.uid = "20150507T211449Z-4262-32011-1418-1@ubuntu-phablet";
+ expected_appt.uid = "20150507T211449Z-4262-32011-1418-1@lomiri-phablet";
expected_appt.color = "#becedd";
expected_appt.summary = "Alarm";
std::array<Alarm,8> expected_alarms = {
- Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,5, 8,16,40,0)}),
- Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,5,15,16,40,0)}),
- Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,5,22,16,40,0)}),
- Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,5,29,16,40,0)}),
- Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,6, 5,16,40,0)}),
- Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,6,12,16,40,0)}),
- Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,6,19,16,40,0)}),
- Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,6,26,16,40,0)})
+ Alarm({Alarm::SOUND | Alarm::TEXT, "Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,5, 8,16,40,0)}),
+ Alarm({Alarm::SOUND | Alarm::TEXT, "Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,5,15,16,40,0)}),
+ Alarm({Alarm::SOUND | Alarm::TEXT, "Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,5,22,16,40,0)}),
+ Alarm({Alarm::SOUND | Alarm::TEXT, "Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,5,29,16,40,0)}),
+ Alarm({Alarm::SOUND | Alarm::TEXT, "Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,6, 5,16,40,0)}),
+ Alarm({Alarm::SOUND | Alarm::TEXT, "Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,6,12,16,40,0)}),
+ Alarm({Alarm::SOUND | Alarm::TEXT, "Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,6,19,16,40,0)}),
+ Alarm({Alarm::SOUND | Alarm::TEXT, "Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,6,26,16,40,0)})
};
// compare it to what we actually loaded...
diff --git a/tests/test-eds-ics-repeating-valarms.cpp b/tests/test-eds-ics-repeating-valarms.cpp
index 2132b71..49ec41b 100644
--- a/tests/test-eds-ics-repeating-valarms.cpp
+++ b/tests/test-eds-ics-repeating-valarms.cpp
@@ -83,14 +83,14 @@ TEST_F(VAlarmFixture, MultipleAppointments)
ASSERT_EQ(1, appts.size());
const auto& appt = appts.front();
ASSERT_EQ(8, appt.alarms.size());
- EXPECT_EQ(Alarm({"Time to pack!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,23,13,35,0)}), appt.alarms[0]);
- EXPECT_EQ(Alarm({"Time to pack!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,23,13,37,0)}), appt.alarms[1]);
- EXPECT_EQ(Alarm({"Time to pack!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,23,13,39,0)}), appt.alarms[2]);
- EXPECT_EQ(Alarm({"Time to pack!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,23,13,41,0)}), appt.alarms[3]);
- EXPECT_EQ(Alarm({"Go to the airport!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,24,10,35,0)}), appt.alarms[4]);
- EXPECT_EQ(Alarm({"Go to the airport!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,24,10,37,0)}), appt.alarms[5]);
- EXPECT_EQ(Alarm({"Go to the airport!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,24,10,39,0)}), appt.alarms[6]);
- EXPECT_EQ(Alarm({"Go to the airport!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,24,10,41,0)}), appt.alarms[7]);
+ EXPECT_EQ(Alarm({Alarm::SOUND | Alarm::TEXT, "Time to pack!", "", DateTime(gtz,2015,4,23,13,35,0)}), appt.alarms[0]);
+ EXPECT_EQ(Alarm({Alarm::SOUND | Alarm::TEXT, "Time to pack!", "", DateTime(gtz,2015,4,23,13,37,0)}), appt.alarms[1]);
+ EXPECT_EQ(Alarm({Alarm::SOUND | Alarm::TEXT, "Time to pack!", "", DateTime(gtz,2015,4,23,13,39,0)}), appt.alarms[2]);
+ EXPECT_EQ(Alarm({Alarm::SOUND | Alarm::TEXT, "Time to pack!", "", DateTime(gtz,2015,4,23,13,41,0)}), appt.alarms[3]);
+ EXPECT_EQ(Alarm({Alarm::SOUND | Alarm::TEXT, "Go to the airport!", "", DateTime(gtz,2015,4,24,10,35,0)}), appt.alarms[4]);
+ EXPECT_EQ(Alarm({Alarm::SOUND | Alarm::TEXT, "Go to the airport!", "", DateTime(gtz,2015,4,24,10,37,0)}), appt.alarms[5]);
+ EXPECT_EQ(Alarm({Alarm::SOUND | Alarm::TEXT, "Go to the airport!", "", DateTime(gtz,2015,4,24,10,39,0)}), appt.alarms[6]);
+ EXPECT_EQ(Alarm({Alarm::SOUND | Alarm::TEXT, "Go to the airport!", "", DateTime(gtz,2015,4,24,10,41,0)}), appt.alarms[7]);
// now let's try this out with AlarmQueue...
// hook the planner up to a SimpleAlarmQueue and confirm that it triggers for each of the reminders
diff --git a/tests/test-eds-ics-tzids-2.cpp b/tests/test-eds-ics-tzids-2.cpp
index c8b0370..b1a344a 100644
--- a/tests/test-eds-ics-tzids-2.cpp
+++ b/tests/test-eds-ics-tzids-2.cpp
@@ -86,7 +86,7 @@ TEST_F(VAlarmFixture, MultipleAppointments)
appt->summary = "National Incubator Initiative for Clean Energy (NIICE) FOA: Pre-Concept Paper Informational Webinar";
appt->begin = DateTime{gtz,2014,1,21,11,0,0};
appt->end = DateTime{gtz,2014,1,21,13,0,0};
- appt->alarms = std::vector<Alarm>{ Alarm({"Reminder", "", DateTime(gtz,2014,1,21,10,45,0)}) };
+ appt->alarms = std::vector<Alarm>{ Alarm({Alarm::TEXT, "Reminder", "", DateTime(gtz,2014,1,21,10,45,0)}) };
// compare it to what we actually loaded...
const auto appts = planner->appointments().get();