aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Safety exit and read-only modeLars Henriksen2019-01-071-18/+35
| | | | | | | | | | | | | | | | | | | The key_generic_command() function provides a "safety exit" in case of online changes that should be dropped at exit when auto_save is on, or (NEW) should be saved at exit when in read-only mode. A check for unsaved changes has been added. The command prompt has been extended with minimal help information. After commit 05e0fd0 "Quit, autosave and interactive save" you could not leave calcurse in read-only mode with the quit command because the key_generic_quit() function interpreted IO_SAVE_CANCEL as a decision (by the user) to cancel a save-conflict and cancelled the quit as well. Now the function will quit unconditionally in read-only mode (as stated in the man page). In normal mode a check for unsaved changes has been added in case auto-save is off. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* CLI: tests alignedLars Henriksen2019-01-073-3/+3
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Update man pageLars Henriksen2019-01-071-362/+576
| | | | | | | Rework man page. Add invert filter and purge option. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix print_date()Lars Henriksen2019-01-071-5/+8
| | | | | | | | In print_date(date, day, ...) it is silently assumed that day is midnight (beginning) of the day to be printed. Assume only that it belongs to the day. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* CLI: do not start daemon if calcurse is runningLars Henriksen2019-01-071-1/+3
| | | | | Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* CLI: filter options have no effect for dates before the epochLars Henriksen2019-01-073-16/+16
| | | | | | | | | | | | | | | | With the exception of filter.type_mask, a filter is only applied if set explicitly on the command line with a filter option. Whether that is the case, is determined by comparison with the initialization value. For date related filters (start_from/to, end_from/to) that is -1, hence the criterion is != -1, not >= 0. In generel, a filter initialization value should be invalid (i.e. one that cannot be set explicitly). As times before the epoch (1 January 1970 00:00:00 UTC) are negative, -1 is a valid Unix time. However, as it cannot be set from the command line, it is probably no problem? Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* CLI: time assignments for filter optionsLars Henriksen2019-01-071-4/+21
| | | | | | | | | | | | | | | | | | | | | Explanation. There is an important difference between "to <date>" (e.g. to 15/11/2018) and "to <date time>" (e.g. to "15/11/2018 13:30"): <date> is a time span (of 24 hours), while <date time> is a point in time. "To <date>" really means "to the end of <date>", while "before <date>" means "before the beginning of <date>". There are 24 hours between the two, whereas there is only one second between "before <date time>" and "to <date time>". Similar for from/after. An earlier commit introduced parse_datearg() that only accepts a date without a time. Hence, a date should be treated as a time span from midnight to one second before next midnight. The commit also fixes an error detection bug (filter.start_from/to and filter.end_from/to were updated too early). Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* CLI: long options to override configuration file settingsLars Henriksen2019-01-071-3/+29
| | | | | | | | | | The input and output date formats may be set from the command line. Intended for scripts that must be independent of the local user configuration. Cannot be used in interactive mode. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* CLI: take input date format from configuration file, do not accept timeLars Henriksen2019-01-072-73/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this patch the input date parsing accepts three formats: yyyy/mm/dd, mm/dd/yyyy, yyyy-mm-dd. They are tried in sequence. It also accepts an additional time (hh:mm), or a time without a date. There are several issues with this: - it is not documented - the date format dd/mm/yyyy is not accepted - print_date() and filter option settings (in parse_args()) can only handle midnight times (which are the result of a date without time) - it is highly uncertain what happens if a time (without a date) is given; at least the -d option treats a time without colon (1215 for 12:15) as a number It seems that acceptance of time input is a by-product and not needed. For these reasons the input date parsing has been changed: - the format is taken from the configuration file (as is the case for the output date format) - only a date, and no time, is accepted Because the input date format is used during parsing of the command line, the configuration file must be loaded first, i.e. the options -D or -C must be parsed before the remaining ones. Loading the configuration file may result in errors (e.g. caused by changes between versions). For this reason config_load() has been made more tolerant and issues warnings instead of exiting. A followup patch will introduce two options to allow the configuration file settings to be overridden for input and output date formats. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Command line options: -P, option check, usage, helpLars Henriksen2019-01-071-25/+69
| | | | | | | | | | Option -F/--filter renamed to -P/--purge; -F retained as deprecated. Check for non-option arguments and for filter, format and query-range options only. Update of help and usage messages. Fixed --status output when calcurse is not running. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix day range for queriesLars Henriksen2019-01-071-8/+6
| | | | | | | | | | | | | | | | In "--from a --to z", a is included in the range, z not. This is non-intuitive and disagrees with the semantics of "to" in filter options like --filter-start-to, where "to" (and "from") are used inclusively (as opposed to "before" and "after"). It also has the effect that "--from today --to tomorrow" has a range of 1 day, "--to z" a range of 0 days (otherwise not allowed), and "--to today --days -1" is allowed and displays yesterday! The implementation has been fixed to agree with "inclusive" semantics. Options --from and -days with negative range are allowed, while --to and --days are disallowed also when the range is negative. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Rewrite of io_init()Lars Henriksen2018-12-144-97/+60
| | | | | | | | | | | | | | The introduction of the "-C <confdir>" option is an opportunity to review the initialization of data paths. It lead to a rewrite. Two "root" directories are used (data and configuration files); by default they are identical. The statically allocated path buffers are turned into dynamically allocated buffers. Missing files/directories now include hooks. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* calcurse-caldav: fix authentication in debug modeBram2018-12-051-1/+1
| | | | | | | Objects are reference in python, ".pop" was modifying the original dictionary and thus breaking authentication by removing auth headers. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix priority parsing in iCal importsdott2018-11-244-4/+4
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix default paths for configuration filesLukas Fleischer2018-11-101-3/+3
| | | | | | | Addresses a copy-paste typo introduced in commit 65064ce (Check if the configuration folder exists, 2018-08-25). Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* DST fix: daylength v. DAYINSECLars Henriksen2018-11-104-3/+9
| | | | | | | | | | | | | | | The number of seconds in a day and daylength in seconds differ when Daylight Saving Time is in effect on two days of the year. The day when DST takes effect is 23 hours long, and the day when DST ends is 25 hours long. In the latter case the date changing thread wóuld enter a loop in the last hour before midnight (in the former it would set the date an hour too late). The next midnight is calculated through mktime(), invoked by date2sec(). Wrong daylength prevented appointments from being stored in the day vector and caused them to be displayed wrongly in the appts panel. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* DST fix: adjusting time in appointmentsLars Henriksen2018-11-104-13/+39
| | | | | | | | | | | | | | | | | | | | | | | | | Calcurse saves time and date information on disk as local time in readable text file format. When loaded from disk or when entered by the user, local time is converted to Unix time (seconds since 00:00:00, 1 January 1970). When displayed, and later when saved to disk, the Unix time is converted back to readable local time. Both conversions depend on DST. Hence, if midnight for a day with DST in effect (i.e. local time) is converted, increased with an amount and converted back, the amount has changed if DST is _not_ in effect for the resulting time. In general, calculations on Unix time variables should be used with caution because of the DST-dependent conversions. Instead, the calculations should be performed on local time data with the help of mktime(). The commit fixes start time for pasted appointments (ordinary and recurrent) and the 'until'-date of recurrent appointments, pasted as well as new and edited. The latter problem is slightly different in that the adjustment is a number of days, as it is for exception dates. Update of the date in parse_datetime() has been corrected to be similar to update of the time, although no problem has been identified. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* DST fix: adding appointments on the day when DST starts or stopsLars Henriksen2018-11-101-11/+7
| | | | | | | | | | A new apppoint inserted on the day when the clock is adjusted backward by an hour got a wrong start time (an hour late). Reason: mktime() must not use the Daylight Saving Time information returned by localtime_r(). Also editorial simplifications. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Ignore resize and error keys in getstring()Lukas Fleischer2018-10-211-0/+3
| | | | | | | Partly addresses GitHub issue #145. Suggested-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Check if the configuration folder existsQuentin Hibon2018-10-213-10/+20
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* po/: queue.c addedLars Henriksen2018-10-211-0/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Mutex for the system message queueLars Henriksen2018-10-211-3/+9
| | | | | | | The main thread only reads and removes events from the queue. All other threads only insert events in the queue. Hence, only insertion and removal need protection. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Configuration variable for system eventsLars Henriksen2018-10-215-2/+18
| | | | | | | | After user acknowledgement a system event is deleted from the event queue. The configuration variable determines whether it is turned into an appointment (for later inspection) or not. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Periodic save: report cancelled saveLars Henriksen2018-10-211-1/+3
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* System message queueLars Henriksen2018-10-214-0/+112
| | | | | | | | | | | | | | | The screen and user interaction is managed by the main thread. Other parts of calcurse (threads) wishing to use the screen or communicate with the user, must do it via the main thread. For this purpose the main input loop is extended with a message queue. A thread may insert a message in the queue. The main thread tests for messages before listening for user commands. If a message is present, it is displayed (in a popup window) for the user to acknowledge. Depending on the message other actions may be performed, e.g. the message could be turned into a "system appointment/event" and inserted among the usual appointments. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Quit, autosave and interactive saveLars Henriksen2018-10-211-2/+11
| | | | | | | | Quitting calcurse with auto_save on may lead to an interactive conflict resolution for the save operation. When the result is a cancellation of the save, the quit command is also cancelled. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Remove the configuraton variable conf.progress_barLars Henriksen2018-10-214-15/+6
| | | | | | | | When loading/saving the configuration file the entry is silently ignored (which means it is removed by the first save). Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Error return code for io_reload_data()Lars Henriksen2018-10-213-10/+23
| | | | | | | | The return code from new_data() and io_load_data() is explicitly defined as a bit mask. A file access error is recognised and reported back to the user. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* New save/load mutex strategyLars Henriksen2018-10-211-39/+28
| | | | | | | | | | | | | | | | | | | | | | | A complete save or reload operation is made up of several cooperating lower level function calls. In stead of protecting the lower level read or write calls on the data files, the entire save or load operation is protected in order to ensure its integrity. Thus mutex protection has been moved from the level: io_load_data(), io_merge_data(), new_data(), to two functions at the higher level: io_save_cal(), io_reload_data(). The protection includes pre- and post-hooks. The function io_load_data() needs no protection when calcurse starts up (threads not yet started) or runs in non-interactive mode (no threads involved). Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Periodic save mutexLars Henriksen2018-10-211-2/+6
| | | | | | | To protect the periodic save from being cancelled during a save operation. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Distinguish between interactive and periodic saveLars Henriksen2018-10-213-9/+17
| | | | | | | | | | A new argument to io_save_cal() makes it possible for the periodic save thread to avoid 1) user interaction and 2) overwriting new data. At the moment the thread has no way to report on the result of the save. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Data save and removal of the progress barLars Henriksen2018-10-213-128/+27
| | | | | | | | | | | | | | | | | The function io_save_cal() saves apts, todos, configuration data and key bindings. The configuration and key files do not belong with the two data files, but the progress bar function assumes that all four files are saved in a fixed sequence. Since it is used nowhere else and contains unused parts, the function has been removed. A return code for file access error is introduced, and the EXIT macro moved to the command level in calcurse.c. Save of configuration and key data were already moved to the configuration menu in commit 0124618, A save refinement: no action if everything is unchanged. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Move user information after save/reload to the command levelLars Henriksen2018-10-213-38/+80
| | | | | | | | | | | | | | | | | | | | | Moving user information to calcurse.c makes it easier to perform the actual save/reload operatons in io.c, e.g. it is possible to load instead of reload after a merge in conflict resolving. The save/reload operations are of such importance that the user should always be informed of the result (it's a bit disquieting when there is no reaction to a save or reload command). Hence, the save/reload status messages are no longer conditioned by show_dialogs(). No confirmation is asked for, so a message stays until the status bar is updated by another action. Care is taken to inform about save/reload actions that result in no change. Texts are kept concise because of the limited message area. When conflicts are present, whether saving or reloading, the "continue/merge/cancel" pattern seems easier to grasp. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* A save refinement: no action if everything is unchangedLars Henriksen2018-10-212-2/+10
| | | | | | | | | | | | | A reload action will do nothing if in-memory data as well as data files are unchanged. This commit accomplishes the equivalent for a save action. Because saving of configuration data and key bindings are mixed up with saving of data files, any changes in those will only be saved if data files also have changed. Hence, configuration data and key bindings are also saved upon exit from the configuration menu. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Only reload if data files were changed (replacement)Lars Henriksen2018-10-214-57/+68
| | | | | | | | | | | | | | This is a replacement for commits 57dd3d6 and 912124b. The idea is to move the check for modified files and the list initialization into io_load_data(), and let io_load_data() decide what to load. A new argument is used to force a load. The return code from new_data() (the renamed version of io_check_data_files_modified()) tells which files have changed. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Reload data after resolving save conflict (improved)Lars Henriksen2018-10-213-31/+51
| | | | | | | | | | | | | | | After resolving a save conflict with the merge tool, a save operation has, in effect, occurred, and data files must be reloaded to import the result of the conflict resolution. This is a replacement for commit 2fe9c7e. The operations concerned with the user interface are kept out the io-operations (as in all other cases) and take place at the command-level in calcurse.c. and not at the io-level (io.c). Shorter, more concise prompt texts. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Handling of modified flagLars Henriksen2018-10-212-3/+2
| | | | | | | | | | The flag modified (io.c) keeps track of the memory state of data: modified == 0: unchanged since load or last save modified == 1: changed since load or last save It is now unset in io_load_data() and io_save_cal() only. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Update windows at the right levelLars Henriksen2018-10-211-1/+1
| | | | | | | | The wins_update() call is the responsibility of the caller of io_resolve_save_conflict(). Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Stop/start the notify main thread at the right levelLars Henriksen2018-10-211-7/+0
| | | | | | | | | | | | | | | | | | | The thread is stopped/started in wins_prepare/unprepare_external() when hooks are run. There is no need to do it in io_reload_data(). In fact, because of the nested calls notify_stop_main_thread() <--- io_reload_data() ... notify_stop_main_thread() <--- hook/wins_prepare_external() ... notify_start_main_thread() <--- hook/wins_unprepare_external() ... notify_start_main_thread() <--- io_reload_data() the thread has been running after the first hook anyway. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix window update after hook executionLars Henriksen2018-10-213-14/+4
| | | | | | | | | | | | | | | | | | | | The introduction of hooks raised a problem with window updates. The diagnosis in commit feb059e8 (Fix segmentation fault on reload with pre-load hook) was right, the cure was wrong. The problem is wins_update(), not the listbox contents. The wins_update() call does not belong in wins_unprepare_external() (or in io_reload_data()), but at a higher level. It should be called _after_ reload, as indeed it is in key_generic_reload() when the listbox contents have been updated (todo as well as appointments). The call was introduced in commit 8ae75f3 without comment. The todo updates in io_reload_data() also belong in key_generic_reload() where they were before commit 7f06c252. When saving data, all panels must be updated in case a hook was executed. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* contrib/caldav/Makefile.am: add config.sampleLukas Fleischer2018-10-211-1/+2
| | | | | | Fixes GitHub issue #144. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* calcurse-caldav: fix auth method checkLukas Fleischer2018-09-271-5/+3
| | | | | | | | | Fixes a regression introduced in 6a6c711 (calcurse-caldav: fix basic authentication, 2018-07-20). Addresses GitHub issue #149. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* README.md: add demoLukas Fleischer2018-08-301-0/+5
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Update README.mdLukas Fleischer2018-08-302-32/+36
| | | | | | | | * Add more details on the project directory structure. * Add information on contributions and donations. * Move contributors to the manual but keep a reference. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix memory leak in run_hook()Lukas Fleischer2018-08-251-2/+4
| | | | | | Fixes GitHub issue #139. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Minor merge adjustmentsLars Henriksen2018-08-251-36/+43
| | | | | | | | Comments inserted. Slightly different implementations of parse_time() and parse_datetime(). Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix memory leak in update_duration()Lars Henriksen2018-08-251-1/+4
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix seg fault in update_rept()Lars Henriksen2018-08-251-5/+7
| | | | | | | Memory pointers must be initialized at the start in case memory is freed (cleanup) before it is allocated. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Buffer mixupLars Henriksen2018-08-251-4/+3
| | | | | | Use one (small) buffer long enough to hold a date. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Major overhaul of appointment/event input routines.Lars Henriksen2018-08-251-194/+241
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When setting start time for a new appointment, a date is disallowed (in all other cases both time and date are still allowed). Both date and time are displayed for the user to correct when an appointment is changed or moved. Built-in help in the status bar for display of input formats. Several bug fixes that resulted in data inconsistencies (end time before start time). The routines use the enhanced parsing funtions to validate input: ui_day_item_add(void) parse_datetime() parse_duration() parse_datetime() ui_day_item_repeat(void) parse_date_duration() parse_date() ui_day_item_edit(void) update_start_time() day_edit_time() parse_datetime() update_duration() parse_duration() parse_datetime() update_rept() parse_date_duration() parse_date() Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>