View Single Post
Posts: 309 | Thanked: 519 times | Joined on Oct 2010
#7
^ Thanks niv, really helped me.

Here's the C++ version:

Code:
#include <alarmd/libalarm.h>
#include <iostream>
#define APPID "example-apps"

cookie_t MyClass::addAlarmdJob(){
    cookie_t cookie = 0;
    alarm_event_t *eve = 0;
    alarm_action_t *act = 0;

    /* Create alarm event structure, set application
       * identifier and dialog message */
    eve = alarm_event_create();
    alarm_event_set_alarm_appid(eve, APPID);

    /* Use absolute time triggering, show dialog
       * ten seconds from now */
    eve->alarm_time = time(0) + 10;

    /* Add command*/
    act = alarm_event_add_actions(eve,1);
    act->flags |= ALARM_ACTION_WHEN_TRIGGERED;
    act->flags |= ALARM_ACTION_TYPE_EXEC;
    act->exec_command = "phone-control --notify Hello!";

    /* Send the alarm to alarmd */
    cookie = alarmd_event_add(eve);

    std::cout << cookie << std::endl;

    /* Free all dynamic memory associated with the*/
    //alarm_event_delete(eve); //<-- Invalid pointer exception
    return cookie;   //Cookie ID of event
}
__________________
PhoneStreamer - VLC/Webcam/Audio streaming to your PC. Also it's a SPYCAM app
WatchDog - Motion Detector and Time Lapser. Securicam!

Last edited by tetris11_; 2012-08-12 at 23:17.
 

The Following User Says Thank You to tetris11_ For This Useful Post: