How to set an alarm event on Maemo
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.
The article is believed to be still valid for the original topic scope.
The article is believed to be still valid for the original topic scope.
Overview
This snippet demonstrates how to set an alarm on a Maemo device.
Use case
Set an alarm at 7:30 am, tomorrow.
Source file
//necessary header files
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <alarmd/alarm_event.h>
int main (int argc, char *argv[])
{
time_t currentTime;
struct tm *targetTime;
// Get current time
time (¤tTime);
//Convert time_t to tm as local time
targetTime = localtime (¤tTime);
//set alarm time at 7:30 of tomorrow
targetTime->tm_mday = targetTime->tm_mday + 1;
targetTime->tm_hour = 7;
targetTime->tm_min = 30;
alarm_event_t event;
// initializing event object
memset (&event, 0, sizeof (alarm_event_t));
// set event's alarm from targetTime
event.alarm_time = mktime (targetTime);
//add alarm event
cookie_t coo = alarm_event_add (&event);
if (coo == 0)
{
// Error happens
//do someing....
return 1;
}
else
{
//no error happens
return 0;
}
}
Download the source code file: Media:alarm_maemo.zip


(no comments yet)