Active Topics

 


Reply
Thread Tools
fiferboy's Avatar
Posts: 475 | Thanked: 771 times | Joined on Dec 2007 @ Hamilton, Ontario, Canada
#1
Hi,

I have been looking for an easy way to access all the alarms set in chinook. osso_worldclock has a nifty little dialog for viewing/adding/editing/deleting alarms that would be perfect to add to my statusbar clock except that I cannot find the source for osso_worldclock anywhere.

The alarm statusbar plugin uses the same dialog, but its source is also unavailable. Does anyone know if this dialog can be called using a command or dbus? That would be very helpful.

Also, if I try to check what alarms are set in my program using alarmd commands I get a segfault. The following is the code I was using:

Code:
#include <alarmd/alarm_event.h>
...
cookie_t *list;
list=alarm_event_query(time(NULL),time(NULL)+40,0,0);
...
My program crashes every time at the "list=..." line both in scratchbox (ARMEL and x86) and on the device. The code above is directly taken from the apitest.c included in the alarmd source, so it should be correct. Does anyone have experience using alarmd?

Last edited by fiferboy; 2008-02-28 at 21:03.
 
Posts: 99 | Thanked: 65 times | Joined on Jan 2008 @ Finland
#2
Originally Posted by fiferboy View Post
Also, if I try to check what alarms are set in my program using alarmd commands I get a segfault. -- My program crashes every time at the "list=..."
I've only used alarmd in one application so far, but I haven't really had any problems with it. alarm_event_query() works just fine here, compile with gcc -Wall $(pkg-config --libs --cflags libalarm) file.c:

Code:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <alarmd/alarm_event.h>

int
main(int argc, char **argv)
{
        cookie_t *list, *iter;
        time_t now;

        now = time(NULL);
        list = alarm_event_query(now, now + 60, 0, 0);
        if (list == NULL) {
                fprintf(stderr, "alarm_event_query() failed\n");
                return EXIT_FAILURE;
        }

        if (list[0] == (cookie_t) 0) {
                printf("no alarms set\n");
        } else {
                printf("alarm ids:");
                for (iter = list; *iter != (cookie_t) 0; iter++) {
                        printf(" %u\n", (unsigned int) *iter);
                }
                printf("\n");
        }

        free(list);
        return EXIT_SUCCESS;
}
 

The Following 2 Users Say Thank You to wnd For This Useful Post:
fiferboy's Avatar
Posts: 475 | Thanked: 771 times | Joined on Dec 2007 @ Hamilton, Ontario, Canada
#3
Thank you very much for the reply. I suspect my problem was not compiling with the correct libraries. I will give this another try.

UPDATE: Yes, that was my problem - I wasn't compiling with libalarm CFLAGS and LIBS. Now the program runs with no hitches. So, I can now start the fun task of building an interface similar to that in world clock for managing alarms (since there is no available source for this)

Last edited by fiferboy; 2008-02-20 at 21:21.
 
fiferboy's Avatar
Posts: 475 | Thanked: 771 times | Joined on Dec 2007 @ Hamilton, Ontario, Canada
#4
Okay, while my code now compiles and runs with no problems I cannot for the life of me get alarmd running in scratchbox.

alarmd is installed, and when I have af-sb-init running the following occur:
- running "/etc/init.d/alarmd start" comes back with "Starting OSSO Alarm Daemon: alarmd." but no process gets started.
- running "alarmd -d" executes, but again no process starts.

As I only have one tablet I do not relish doing any testing of alarmd on it, especially to the level I eventually want to get. If anyone has been successful in getting alarmd testing to work in scratchbox, please let me know.

Thanks
 
fiferboy's Avatar
Posts: 475 | Thanked: 771 times | Joined on Dec 2007 @ Hamilton, Ontario, Canada
#5
Just for posterity's sake (in case anyone is searching for how to do this in the future) I will post how to get alarmd to work in scratchbox!

This really is the simplest solution to a frustrating problem I have seen in quite some time.

Code:
run-standalone.sh alarmd
That's all folks! And you thought run-standalone just made your application look pretty! This is really going to help with testing alarms in statusbar-clock.
 

The Following User Says Thank You to fiferboy For This Useful Post:
Posts: 74 | Thanked: 34 times | Joined on Jan 2008
#6
#!/usr/bin/env python
#simple example to issue a command using python and maemo alarmed RTC tool
# look at /var/cache/alarmd/alarm_queue.ini for the full queue
import time,alarm

if __name__ == '__main__':
event = alarm.Event()
event.appid = 'lovelyName'
event.alarm_time = time.time() +10
action = event.add_actions(1)[0]
action.flags |= alarm.ACTION_WHEN_TRIGGERED | alarm.ACTION_TYPE_EXEC
action.command = 'touch /tmp/alarm.txt'
cookie = alarm.add_event(event)
print cookie

Last edited by niv; 2011-04-28 at 14:45.
 

The Following 2 Users Say Thank You to niv For This Useful 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:
Reply


 
Forum Jump


All times are GMT. The time now is 06:50.