1007 Commits

Author SHA1 Message Date
Lukas Fleischer
c7b56ca556 Add a copy file routine
Add io_file_cp() which can be used to copy an existing source file to
another location. We will need this for our new hash-based note file
names.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-05 12:25:47 +02:00
Lukas Fleischer
9dcb377a64 Add a SHA1 implementation
Add an implementation of the SHA1 hash algorithm based on a public
domain project by Steve Reid <sreid@sea-to-sky.net>. You can get the
original sources from:

    ftp://ftp.funet.fi/pub/crypt/hash/sha/sha1.c

We will need this for several things. File names of note files will be
generated based on a hash their content instead of using a random name.
Items can be uniquely identified using a hash.

In addition to the regular sha1_init(), sha1_update() and sha1_final()
operations, our implementation also contains wrappers for hashing a
string or a stream.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-05 12:25:46 +02:00
Lukas Fleischer
51c6386a05 doc/: Add "submitting-patches.txt"
This short paper contains information on how to create and submit
patches to calcurse. This used to be on our website - "doc/" seems to be
a better place for this, though.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-05 12:20:41 +02:00
Lukas Fleischer
3aefd00f6a Cleanup joinable threads on termination
Always invoke pthread_join() when we blow up a thread via
pthread_cancel() (avoid zombie threads).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-04 12:26:42 +02:00
Lukas Fleischer
4cd62fb0fb src/io.c: Update todo item count on iCal import
Update the number of todo items when importing an iCal file to prevent
some items from being inaccessible.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-04 11:07:33 +02:00
Lukas Fleischer
c41eda256d Do not hardcode paths to the default editor/pager
Use "vi" instead of "/usr/bin/vi" and "less" instead of "/usr/bin/less".
Hardcoding absolute paths is a bad idea:

    $ uname -rsv
    Linux 3.0-ARCH #1 SMP PREEMPT Tue Aug 30 07:32:23 UTC 2011
    $ which less
    /bin/less

The "$PATH" environment variable will almost always have a better idea
of where these binaries are located.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-04 11:05:43 +02:00
Lukas Fleischer
78b663d073 Merge branch 'maint'
Conflicts:
	src/io.c
2011-09-06 14:56:17 +02:00
Lukas Fleischer
9f1fed3ed1 Release 2.9.2
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-09-06 14:55:30 +02:00
Lukas Fleischer
2d298dcd5f Update translations
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-09-06 14:37:56 +02:00
Lukas Fleischer
ac50b5a111 Add a configure setting to skip "doc/"
This should fix all remaining build issues with documentation
generation. Finally.

The new "--disable-docs" option should be used to skip documentation
completely, whereas "--without-asciidoc" can be used if both manual and
man page should not be rebuilt. As a consequence, "--without-asciidoc"
can only be combined with "--enable-docs" if ready-made documentation
already exists in "doc/". This is true for release tarballs (where we
include prebuilt documentation for the sake of portability and
simplicity), as well as for Git checkouts where the documentation has
already been built earlier.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-09-03 02:19:32 +02:00
Lukas Fleischer
33450f9ba9 Merge branch 'maint' 2011-09-02 12:03:43 +02:00
Lukas Fleischer
b59070a49e Rework indentation code in print_notefile()
Do not use snprintf() here as printf() behaviour is undefined if the
destination pointer is used as a parameter.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-08-26 12:14:03 +02:00
Lukas Fleischer
806a13ed8a src/io.c: iCal content line folding correctness
This is a rather invasive change that introduces correct line folding to
our iCal parser.

From now on, ical_readline() should be used instead of fgets() to read
lines from an iCal file as it unfolds lines automatically. We also need
to use shared buffers as each ical_readline() invocation eats up the
first part of the next line and stores it in the "lstore" buffer.
Subsequent ical_readline() invocations copy the contents of this buffer
and append continuation lines. We currently use a single buffer pair
that is allocated in io_import_data() and pass it to all subroutines.

ical_readline_init() needs to be called once for every buffer pair. It
reads the first part of the current line and writes to "lstore",
clearing the target buffer at the same time.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-08-26 11:57:30 +02:00
Lukas Fleischer
45417bc6f0 Add configuration option to notify all appointments
If "notify-all" is enabled, all non-flagged appointments will be
notified (instead of flagged ones). This is useful for users that want
to be notified of everything.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-31 03:23:32 +02:00
Lukas Fleischer
de85010edc Release 2.9.1
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-31 02:55:56 +02:00
Lukas Fleischer
2336066855 Update translations files
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-31 02:55:56 +02:00
Lukas Fleischer
0884d62b22 Merge branch 'maint' 2011-07-30 22:56:22 +02:00
Lukas Fleischer
13a41f8e0a Fix sort order in app_arg()
We used to iterate over the list of regular appointments and the list of
recurrent appointments in separate loops, thus leading to recurrent
appointments being printed first and regular appointments being printed
afterwards, regardless of their start and end times. Merge these loops
to coerce precedence of the start time.

There's still a fair bit of hackery in here - we will fix that later.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-30 21:10:53 +02:00
Lukas Fleischer
6256183e1e Fix configuration file backward compatibility
We kinda broke this in 6377582841118688aee13aff98c9216403582e45.

All hail strsep()!

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-29 23:35:17 +02:00
Lukas Fleischer
709525cf8d Fix apoint_get() call in apoint_switch_notify()
We passed the function arguments the wrong way round. This regression
was introduced in commit 77ef3fe76e4ce4c9a990e8a5904ad2d83420ca02.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-29 20:38:59 +02:00
Lukas Fleischer
1a849cfb8e Fix notify_check_repeated()
Remove the "current_time" check from the first if condition. As "greater
than" relations (">") have higher precedence than assignments ("=") in
C, this caused "real_app_time" to always be one or zero which definitely
isn't what we want here. Reading further down, it turns out that we
don't even need this comparison here, so we should be fine removing it.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-29 20:38:59 +02:00
Lukas Fleischer
1da88589b2 Fix recurrent appointment notification
We probably broke this in 9fab24818a119aef08b9726f6c1cd31d5434ce34.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-29 20:38:59 +02:00
Lukas Fleischer
0126cbd1b3 Update the notification item in *_paste_item()
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-29 20:38:59 +02:00
Lukas Fleischer
cce0acbe00 Update the notification item in day_edit_item()
Ensure the start time as well as the description of the notification
appointment are synced after editing it.

We use notify_check_next_app()'s force parameter to ensure that the
notification item is updated even if only the description was modified.

Reported-by: Andraž 'ruskie' Levstik <ruskie@codemages.net>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-29 20:38:43 +02:00
Lukas Fleischer
5a5c6d2604 Add "force" parameter to notify_check_next_app()
This allows to force notify_check_next_app() to update the notification
appointment, even if start times are equal (e.g. if the item description
was changed).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-29 20:28:30 +02:00
Lukas Fleischer
53b041facf src/calcurse.h: Whitespace cleanup
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-28 14:46:00 +02:00
Lukas Fleischer
f2ddce23d4 src/args.c: Mark various constant strings const
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-28 13:42:44 +02:00
Lukas Fleischer
7b0d017b5d Remove superfluous buffer variable from version_arg()
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-28 13:42:44 +02:00
Lukas Fleischer
5637e973bf Remove superfluous buffer variable from help_arg()
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-28 13:42:44 +02:00
Lukas Fleischer
5b75566ce9 TODO: Remove reference to the bugs mailing list
Feature requests should go to the misc mailing list, no need to mention
the bugs mailing list here.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-28 13:42:44 +02:00
Lukas Fleischer
54813eef19 Merge branch 'maint' 2011-07-28 13:38:12 +02:00
Lukas Fleischer
8681af3c6d io.c: Accept resource parameters in iCal import
Remove colons from the "SUMMARY:" and "DURATION:" search patterns in
ical_read_event() to allow for additional parameters (such as language
parameters, cf. RFC 5545).

Reported-by: Andraž 'ruskie' Levstik <ruskie@codemages.net>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-28 13:37:16 +02:00
Lukas Fleischer
0c4e9d3f00 Invoke vars_init() before importing data with "-i"
We forgot to call vars_init() when importing an item using the "-i"
command line argument, which led to the pager configuration variable
being unset and hence the pager invocation (triggered to show the log in
case there are any errors during import) failing.

Fix this by calling vars_init() before io_import_data().

Reported-by: Andraž 'ruskie' Levstik <ruskie@codemages.net>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-28 13:36:30 +02:00
Lukas Fleischer
a232c9af33 Use gettext plural features
Make use of the plural features of gettext to handle plural forms
correctly instead of using the plural form even if the singular form
should be used.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-24 21:13:14 +02:00
Lukas Fleischer
e121ded3a5 Split stats messages in io_import_data()
Use separate format strings for separate values. This is useful in case
we want to output similar stats somewhere else and is a preparation for
supporting plural forms.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-24 21:00:59 +02:00
Lukas Fleischer
87664095cd Refactor out note functions
* Add new note_edit() and note_view() helper functions. Use these
  instead of copy-pasted code in *_note_edit().

* Move all note-related functions (note_edit(), note_view(),
  note_erase()) to a new source file "note.c".

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 18:13:40 +02:00
Lukas Fleischer
40772daaf4 Add hint to error messages in custom_load_conf()
Include the name of the configuration variable that issued the error in
error messages that are thrown while parsing the configuration file.
This makes it a lot easier to locate syntactic and semantic errors.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 17:58:19 +02:00
Lukas Fleischer
6377582841 Use map for configuration variable names
Use a map instead of dozens of hardcoded conditionals. This makes
configuration variable parsing more dynamic and extensible.

Also, reintroduce formatting error messages that we dropped earlier.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 17:58:04 +02:00
Lukas Fleischer
32f22fdcc5 Return error status in custom_set_conf()
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 17:57:59 +02:00
Lukas Fleischer
8e4238c242 Rename custom_load_color() to conf_parse_color()
Also, temporarily remove all error messages and return an error status
instead.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 17:57:50 +02:00
Lukas Fleischer
1355bad264 Declare foreground and background variables global
Removes the need to pass the terminal's default background color round.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 17:56:39 +02:00
Lukas Fleischer
e5dee68dcf Refactor out integer variable parsing
Introduce conf_parse_unsigned() and conf_parse_int() similar to
conf_parse_bool().

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 17:56:25 +02:00
Lukas Fleischer
7e4f995692 Refactor conf_parse_bool()
* Increase size argument for strncmp() comparisons by one to include the
  terminating null-character (otherwise "yesfoo" would be parsed as
  "yes", "nobar" as "no").

* Pass destination address as an additional argument and return
  success/failure status to allow for better error handling.

* Temporarily remove error handling (will be fixed later).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 17:55:55 +02:00
Lukas Fleischer
c875ab4195 Rename fill_config_var() to conf_parse_bool()
This is a much better name as it implicitly describes that this function
parses boolean configuration values only.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 17:54:59 +02:00
Lukas Fleischer
f69d1a1572 Refactor out configuration variable setting
Move configuration variable assignments to a new function,
custom_set_conf(). This improves code readability and allows for setting
configuration variables outside the configuration file loading function.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 17:53:46 +02:00
Lukas Fleischer
9d41f8e5b3 Use single-line configuration settings by default
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-15 18:47:43 +02:00
Lukas Fleischer
3b4a21e79c Parse single-line configuration variables
Include a fallback branch that accepts multi-line comments as well
(backward compatibility).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-15 18:25:17 +02:00
Lukas Fleischer
1f658881de Be stricter when parsing the configuration file
Throw an error message if there is a line that contains an invalid
configuration line (e.g. a non-empty line that neither contains a key
nor a value).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-15 18:13:47 +02:00
Lukas Fleischer
b362c17daa Skip indentation and comments in io_extract_data()
We actually only use this function to parse configuration data.
Currently, this probably is the best way to do some common
preprocessing.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-15 18:13:45 +02:00
Lukas Fleischer
5f24132d18 Refactor custom_load_conf()
Read key and value of each configuration setting in one loop cycle to
facilitate adjustments of the configuration setting format. Also, this
allows us to get rid of all the redundant variable resetting.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-15 17:47:28 +02:00