|
|
@ -11,21 +11,26 @@ |
|
|
|
#include <unistd.h>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <sqlite3.h>
|
|
|
|
|
|
|
|
#include <db/db.h>
|
|
|
|
#include <util/notifications.h>
|
|
|
|
#include <util/calendar_parsing.h>
|
|
|
|
|
|
|
|
#include <io/debug.h>
|
|
|
|
const int MINUTE = 1000000; |
|
|
|
|
|
|
|
void update_database() { |
|
|
|
std::vector<ical::ical_object*> objects = util::parse_cal_dir(); |
|
|
|
void init_database(std::string calendar) { |
|
|
|
db::init(calendar + ".db"); |
|
|
|
} |
|
|
|
|
|
|
|
void update_database(std::string directory) { |
|
|
|
std::vector<ical::ical_object*> objects = util::parse_cal_dir(directory); |
|
|
|
} |
|
|
|
|
|
|
|
void do_heartbeat() |
|
|
|
void do_heartbeat(std::string directory) |
|
|
|
{ |
|
|
|
util::notify("Testing", ""); |
|
|
|
update_database(); |
|
|
|
util::notify("Updating files from " + directory, ""); |
|
|
|
update_database(directory); |
|
|
|
} |
|
|
|
|
|
|
|
// For security purposes, we don't allow any arguments to be passed into the daemon
|
|
|
@ -88,11 +93,14 @@ int main(void) |
|
|
|
// Daemon-specific intialization should go here
|
|
|
|
const int SLEEP_INTERVAL = 5 * MINUTE; |
|
|
|
|
|
|
|
std::string calendar = "dummy"; |
|
|
|
std::string directory = "/home/stefan/.local/share/khal/calendars/" + calendar + "/"; |
|
|
|
init_database(calendar); |
|
|
|
// Enter daemon loop
|
|
|
|
while(1) |
|
|
|
{ |
|
|
|
// Execute daemon heartbeat, where your recurring activity occurs
|
|
|
|
do_heartbeat(); |
|
|
|
do_heartbeat(directory); |
|
|
|
exit(0); |
|
|
|
|
|
|
|
// Sleep for a period of time
|
|
|
|