void update_finalize(pixel *vid_buf) { if (!update_flag) return; info_box(vid_buf, "Finalizing update..."); if (last_major>SAVE_VERSION || (last_major==SAVE_VERSION && last_minor>=MINOR_VERSION)) { update_cleanup(); error_ui(vid_buf, 0, "Update failed - try downloading a new version."); } else { if (update_finish()) error_ui(vid_buf, 0, "Update failed - try downloading a new version."); else info_ui(vid_buf, "Update success", "You have successfully updated the Powder Toy!"); } update_flag = 0; }
int event_dnssec(conf_t *conf, zone_t *zone) { assert(zone); changeset_t ch; int ret = changeset_init(&ch, zone->name); if (ret != KNOT_EOK) { goto done; } uint32_t refresh_at = time(NULL); int sign_flags = 0; if (zone->flags & ZONE_FORCE_RESIGN) { log_zone_info(zone->name, "DNSSEC, dropping previous " "signatures, resigning zone"); zone->flags &= ~ZONE_FORCE_RESIGN; sign_flags = ZONE_SIGN_DROP_SIGNATURES; } else { log_zone_info(zone->name, "DNSSEC, signing zone"); sign_flags = 0; } ret = knot_dnssec_zone_sign(zone->contents, &ch, sign_flags, &refresh_at); if (ret != KNOT_EOK) { goto done; } bool zone_changed = !changeset_empty(&ch); if (zone_changed) { /* Apply change. */ apply_ctx_t a_ctx = { { 0 } }; apply_init_ctx(&a_ctx); zone_contents_t *new_contents = NULL; int ret = apply_changeset(&a_ctx, zone, &ch, &new_contents); if (ret != KNOT_EOK) { log_zone_error(zone->name, "DNSSEC, failed to sign zone (%s)", knot_strerror(ret)); goto done; } /* Write change to journal. */ ret = zone_change_store(conf, zone, &ch); if (ret != KNOT_EOK) { log_zone_error(zone->name, "DNSSEC, failed to sign zone (%s)", knot_strerror(ret)); update_rollback(&a_ctx); update_free_zone(&new_contents); goto done; } /* Switch zone contents. */ zone_contents_t *old_contents = zone_switch_contents(zone, new_contents); zone->flags &= ~ZONE_EXPIRED; synchronize_rcu(); update_free_zone(&old_contents); update_cleanup(&a_ctx); } // Schedule dependent events. schedule_dnssec(zone, refresh_at); if (zone_changed) { zone_events_schedule(zone, ZONE_EVENT_NOTIFY, ZONE_EVENT_NOW); conf_val_t val = conf_zone_get(conf, C_ZONEFILE_SYNC, zone->name); if (conf_int(&val) == 0) { zone_events_schedule(zone, ZONE_EVENT_FLUSH, ZONE_EVENT_NOW); } } done: changeset_clear(&ch); return ret; }
void update_notify_ui_process(pixel *vid_buf, int mb, int mbq, int mx, int my) { if (version_check==1 && !version_check_http) version_check_http = http_async_req_start(NULL, "http://" SERVER "/Update.api?Action=CheckVersion", NULL, 0, 0); if (version_check_http) { if (!version_check_http_counter && http_async_req_status(version_check_http)) { int http_ret; char *ver_data; ver_data = http_async_req_stop(version_check_http, &http_ret, NULL); if (http_ret==200 && ver_data) { #ifdef BETA if (sscanf(ver_data, "%d.%d.%d", &version_check_major, &version_check_minor, &version_check_isbeta)==3) if (version_check_major>SAVE_VERSION || (version_check_major==SAVE_VERSION && version_check_minor>MINOR_VERSION) || (version_check_major==SAVE_VERSION && version_check_isbeta == 0)) version_check = 2; #else if (sscanf(ver_data, "%d.%d", &version_check_major, &version_check_minor)==2) if (version_check_major>SAVE_VERSION || (version_check_major==SAVE_VERSION && version_check_minor>MINOR_VERSION)) version_check = 2; #endif #ifdef BETA if (version_check_isbeta) old_ver_len = textwidth(old_ver_msg_beta); else old_ver_len = textwidth(old_ver_msg); #else old_ver_len = textwidth(old_ver_msg); #endif } if (ver_data) free(ver_data); version_check_http = NULL; } version_check_http_counter = (version_check_http_counter+1) & 15; } if (mb && !mbq && mx>=(XRES-19-old_ver_len) && mx<=(XRES-14) && my>=(YRES-22) && my<=(YRES-9) && version_check==2) { char *tmp = malloc(64); #ifdef BETA if (version_check_isbeta) { sprintf(tmp, "Your version: %d (Beta %d), new version: %d (Beta %d).", SAVE_VERSION, MINOR_VERSION, version_check_major, version_check_minor); } else { sprintf(tmp, "Your version: %d (Beta %d), new version: %d.%d.", SAVE_VERSION, MINOR_VERSION, version_check_major, version_check_minor); } #else sprintf(tmp, "Your version: %d.%d, new version: %d.%d.", SAVE_VERSION, MINOR_VERSION, version_check_major, version_check_minor); #endif if (confirm_ui(vid_buf, "Do you want to update The Powder Toy?", tmp, "Update")) { int i; free(tmp); tmp = download_ui(vid_buf, update_uri, &i); if (tmp) { save_presets(1); if (update_start(tmp, i)) { update_cleanup(); save_presets(0); error_ui(vid_buf, 0, "Update failed - try downloading a new version."); } else exit(0); } } else free(tmp); } }