/****************************************************************************** * DCOP call from the alarm daemon to notify a change. * The daemon notifies calendar statuses when we first register as a GUI, and whenever * a calendar status changes. So we don't need to read its config files. */ void NotificationHandler::alarmDaemonUpdate(int calendarStatus, const QString& calendarURL) { kdDebug(5950) << "NotificationHandler::alarmDaemonUpdate(" << calendarStatus << ")\n"; KAlarmd::CalendarStatus status = KAlarmd::CalendarStatus(calendarStatus); if (expandURL(calendarURL) != AlarmCalendar::activeCalendar()->urlString()) return; // it's not a notification about KAlarm's calendar bool enabled = false; switch (status) { case KAlarmd::CALENDAR_UNAVAILABLE: // Calendar is not available for monitoring kdDebug(5950) << "NotificationHandler::alarmDaemonUpdate(CALENDAR_UNAVAILABLE)\n"; break; case KAlarmd::CALENDAR_DISABLED: // Calendar is available for monitoring but is not currently being monitored kdDebug(5950) << "NotificationHandler::alarmDaemonUpdate(DISABLE_CALENDAR)\n"; break; case KAlarmd::CALENDAR_ENABLED: // Calendar is currently being monitored kdDebug(5950) << "NotificationHandler::alarmDaemonUpdate(ENABLE_CALENDAR)\n"; enabled = true; break; default: return; } Daemon::calendarIsEnabled(enabled); }
/****************************************************************************** * DCOP call to notify the daemon that an event has been handled, and optionally * to tell it to reload the calendar. */ void AlarmDaemon::eventHandled(const QCString &appname, const QString &calendarUrl, const QString &eventID, bool reload) { QString urlString = expandURL(calendarUrl); kdDebug(5900) << "AlarmDaemon::eventHandled(" << urlString << (reload ? "): reload" : ")") << endl; ADCalendar *cal = ADCalendar::getCalendar(urlString); if(!cal || cal->appName() != appname) return; cal->setEventHandled(eventID); if(reload) reloadCal(cal, false); }
int main(int argc, char *argv[]) { int rc, ch; char *argv0 = argv[0]; while ((ch = getopt(argc, argv, "v")) != -1) { switch (ch) { case 'v': Verbose=1; break; default: usage(); } } argc -= optind; argv += optind; if (argc<1) usage(); while(argv[0] != NULL) { char newurl[MaxPathSize]; printf("Expand %s:\n", argv[0]); rc = expandURL(newurl, argv[0]); if (rc==-1) warnx("Cannot expand %s", argv[0]); else printf("Expanded URL: %s\n", newurl); /* test out connection caching */ if (1) { char *s, buf[MaxPathSize]; if ((s=getenv(PKG_FTPIO_CNT)) && atoi(s)>0) { (void) snprintf(buf, sizeof(buf),"%d", atoi(s)-1); setenv(PKG_FTPIO_CNT, buf, 1); printf("%s>>> %s -v %s\n", s, argv0, argv[0]); fexec(argv0, "-v", argv[0], NULL); } } printf("\n\n\n"); argv++; } ftp_stop(); return 0; }
/* * extract the given (expanded) URL "url" to the given directory "dir" * return -1 on error, 0 else; */ int unpackURL(const char *url, const char *dir) { char *pkg; int rc; char base[MaxPathSize]; char pkg_path[MaxPathSize]; { /* Verify if the URL is really ok */ char expnd[MaxPathSize]; rc=expandURL(expnd, url); if (rc == -1) { warnx("unpackURL: verification expandURL failed"); return -1; } if (strcmp(expnd, url) != 0) { warnx("unpackURL: verification expandURL failed, '%s'!='%s'", expnd, url); return -1; } } pkg=strrchr(url, '/'); if (pkg == NULL) { warnx("unpackURL: no '/' in URL %s?!", url); return -1; } (void) snprintf(base, sizeof(base), "%.*s/", (int)(pkg-url), url); (void) snprintf(pkg_path, sizeof(pkg_path), "%.*s", (int)(pkg-url), url); /* no trailing '/' */ pkg++; /* Leave a hint for any depending pkgs that may need it */ if (getenv("PKG_PATH") == NULL) { setenv("PKG_PATH", pkg_path, 1); #if 0 path_create(pkg_path); /* XXX */ #endif if (Verbose) printf("setenv PKG_PATH='%s'\n", pkg_path); } if (strncmp(url, "http://", 7) == 0) return http_fetch(url, dir); rc = ftp_start(base); if (rc == -1) { warnx("ftp_start() failed"); return -1; /* error */ } { char cmd[1024]; const char *decompress_cmd = NULL; const char *suf; if (Verbose) printf("unpackURL '%s' to '%s'\n", url, dir); suf = suffix_of(pkg); if (!strcmp(suf, "tbz") || !strcmp(suf, "bz2")) decompress_cmd = BZIP2_CMD; else if (!strcmp(suf, "tgz") || !strcmp(suf, "gz")) decompress_cmd = GZIP_CMD; else if (!strcmp(suf, "tar")) ; /* do nothing */ else errx(EXIT_FAILURE, "don't know how to decompress %s, sorry", pkg); /* yes, this is gross, but needed for borken ftp(1) */ (void) snprintf(cmd, sizeof(cmd), "get %s \"| ( cd %s; " TAR_CMD " %s %s -vvxp -f - | tee %s )\"\n", pkg, dir, decompress_cmd != NULL ? "--use-compress-program" : "", decompress_cmd != NULL ? decompress_cmd : "", Verbose ? "/dev/stderr" : "/dev/null"); rc = ftp_cmd(cmd, "\n(226|550).*\n"); if (rc != 226) { warnx("Cannot fetch file (%d!=226)!", rc); return -1; } } return 0; }