Chandra
view release on metacpan or search on metacpan
/* Poll sub-modules */
{
SV **hr_svp = hv_fetchs(hv, "_hot_reload", 0);
if (hr_svp && SvOK(*hr_svp)) {
dSP;
ENTER; SAVETMPS;
PUSHMARK(SP);
XPUSHs(*hr_svp);
PUTBACK;
call_method("poll", G_DISCARD);
FREETMPS; LEAVE;
}
}
{
SV **hub_svp = hv_fetchs(hv, "_hub", 0);
if (hub_svp && SvOK(*hub_svp)) {
dSP;
ENTER; SAVETMPS;
PUSHMARK(SP);
XPUSHs(*hub_svp);
PUTBACK;
call_method("poll", G_DISCARD);
FREETMPS; LEAVE;
}
}
{
SV **cl_svp = hv_fetchs(hv, "_client", 0);
if (cl_svp && SvOK(*cl_svp)) {
dSP;
ENTER; SAVETMPS;
PUSHMARK(SP);
XPUSHs(*cl_svp);
PUTBACK;
call_method("poll", G_DISCARD);
FREETMPS; LEAVE;
}
}
/* Sleep 10ms for non-blocking mode */
if (!blocking) {
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 10000;
select(0, NULL, NULL, NULL, &tv);
}
}
/* Exit */
{
dSP;
ENTER; SAVETMPS;
PUSHMARK(SP);
XPUSHs(*wv_svp);
PUTBACK;
call_method("exit", G_DISCARD);
FREETMPS; LEAVE;
}
(void)hv_stores(hv, "_started", newSViv(0));
}
# ---- notify(%args) - send a desktop notification ----
int
notify(self, ...)
SV *self
CODE:
{
ChandraNotification notif;
I32 i;
memset(¬if, 0, sizeof(notif));
/* Parse key-value pairs from args */
for (i = 1; i + 1 < items; i += 2) {
const char *key = SvPV_nolen(ST(i));
SV *val = ST(i + 1);
if (strcmp(key, "title") == 0 && SvOK(val)) {
notif.title = SvPV_nolen(val);
} else if (strcmp(key, "body") == 0 && SvOK(val)) {
notif.body = SvPV_nolen(val);
} else if (strcmp(key, "icon") == 0 && SvOK(val)) {
notif.icon = SvPV_nolen(val);
} else if (strcmp(key, "sound") == 0 && SvOK(val)) {
notif.sound = SvIV(val);
} else if (strcmp(key, "timeout") == 0 && SvOK(val)) {
notif.timeout_ms = SvIV(val);
}
}
if (!notif.title) {
warn("Chandra::App::notify: title is required");
RETVAL = 0;
} else {
RETVAL = chandra_notify_send(aTHX_ ¬if);
}
}
OUTPUT:
RETVAL
# ---- shortcuts() - lazy accessor for Chandra::Shortcut instance ----
SV *
shortcuts(self)
SV *self
CODE:
{
HV *hv = (HV *)SvRV(self);
SV **svp = hv_fetchs(hv, "_shortcut", 0);
if (svp && SvOK(*svp)) {
RETVAL = SvREFCNT_inc(*svp);
} else {
SV *sc;
dSP;
int count;
load_module(PERL_LOADMOD_NOIMPORT,
newSVpvs("Chandra::Shortcut"), NULL);
ENTER; SAVETMPS;
PUSHMARK(SP);
XPUSHs(sv_2mortal(newSVpvs("Chandra::Shortcut")));
XPUSHs(sv_2mortal(newSVpvs("app")));
( run in 0.640 second using v1.01-cache-2.11-cpan-df04353d9ac )