97 Commits

Author SHA1 Message Date
Lukas Fleischer
9ed7494f5e Move interaction functions to a separate file
This is a first step to clean up several compilation units and separate
the front end from back-end operations. All functions that require user
interaction are moved to a new compilation unit "interaction.c". Also,
following things are adjusted to the new layout:

* Make day_item_get_*() and a few other functions public, so that it can
  be accessed from the new compilation unit.

* Use apoint_hilt(), todo_hilt(), etc. instead of directly accessing
  static variables.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:35 +02:00
Lukas Fleischer
ba28426fc0 Remove unused functions
Remove apoint_get(), event_get(), recur_get_apoint() and
recur_get_event(), since they are no longer used.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:35 +02:00
Lukas Fleischer
80e24954c2 Simplify recur_apoint_switch_notify()
Pass the recurrent appointment itself instead of passing a date and an
item number. This is quite simple as we can just pass the pointer that
is contained in the generic item structure and don't have to
LLIST_TS_FIND_*() the item first any more.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:33 +02:00
Lukas Fleischer
52bfc54333 Rework generic item container
Instead of copying all members of the individual item structures to a
generic structure containing all fields, create compulsory fields only
and set up a pointer to the actual item. This results in lower memory
footprint and lets us clean up some code.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:33 +02:00
Baptiste Jonglez
b5a911421f Fix incorrect i18n usage for some strings
Some strings are initialized without wrapping them in _(); instead,
_() is applied on the variable when it is used.

This is incorrect, since these strings don't get added to the catalog.
Fix that by applying _() only once, when the string is declared.

Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-25 13:28:26 +02:00
Lukas Fleischer
cfd8ede2b3 Switch to Linux kernel coding style
Convert our code base to adhere to Linux kernel coding style using
Lindent, with the following exceptions:

* Use spaces, instead of tabs, for indentation.
* Use 2-character indentations (instead of 8 characters).

Rationale: We currently have too much levels of indentation. Using
8-character tabs would make huge code parts unreadable. These need to be
cleaned up before we can switch to 8 characters.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-21 10:13:05 +02:00
Baptiste Jonglez
7d4ef08345 Use status_ask_choice() on more difficult cases
These cases are also candidates for the factorisation process, but
they are somewhat more tricky to get right.

Since we use a completely different approach, the result (from a user
perspective) looks different.

Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-14 19:31:13 +02:00
Lukas Fleischer
1c442e6aef Miscellaneous small code cleanups
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-06 23:23:58 +02:00
Lukas Fleischer
80f7e8ead5 Mark localized string literals constant
Translated strings returned by gettext() are statically allocated and
shouldn't be modified.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-05 22:18:46 +02:00
Lukas Fleischer
c9aff6d213 Update copyright ranges
Add 2012 to the copyright range for all source and documentation files.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-03-26 14:38:16 +02:00
Lukas Fleischer
2c9499bf27 Use strcmp() instead of strncmp()
strncmp() isn't intended to be a secure strcmp() replacement, it is
designed to be used if you want to compare the first n characters of two
strings. Since we always compare character pointers with string
literals, switch to using strcmp() everywhere.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-03-12 20:36:22 +01:00
Lukas Fleischer
2bc4deacdc Fix up fscanf() format strings
All members of the tm structure are signed integers. Stick to using the
correct fscanf() format specifiers for these.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-02-19 03:14:31 +01:00
Lukas Fleischer
894ac2d70d Trap fgets() failure in *_scan()
Ensure we don't read arbitrary data when fgets() returns a NULL string
(meaning that either the EOF is encountered or an error occurred). This
also fixes a couple of compiler warnings seen with "-Wunused-result".

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-02-18 13:04:21 +01:00
Lukas Fleischer
41c33eeb44 Use a global configuration variable
This is one of the few valid use cases for a global variable. No need to
make it pseudo-local and pass it from one function to another.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-11-14 11:08:14 +01:00
Lukas Fleischer
6f01c7af97 Remove parentheses from return statements
No reason to use "return (x);" here. Refer to the GNU coding guidelines
for details. Created using following semantic patch:

    @@
    expression expr;
    @@

    - return (expr);
    + return expr;

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-11-02 19:38:38 +01:00
Lukas Fleischer
7cc6305588 Do not cast unused return values to void
A small style fix that removes all remaining "(void)" casts. Using these
isn't encouraged in GNU coding guidelines and doesn't serve a certain
purpose, except for satisfying a few static code analysis tools. We
already nuked some of these in previous patches, but this semantic patch
should fix what's left:

    @@
    identifier func;
    @@

    - (void)func (
    + func (
    ...);

Long lines were re-formatted manually.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-11-02 18:32:17 +01:00
Lukas Fleischer
44bc9605d6 Avoid use of printf()/fprintf()
Use one of the following functions where appropriate:

* puts() (whenever we print hard coded strings to stdout)
* fputs() (whenever we print hard coded strings to a stream)
* putchar() (whenever we print a single character to stdout)
* fputc() (whenever we print a single character to a stream)
* strncpy() (whenever we copy hard coded strings to a buffer)

This removes the overhead introduced by the format string parser and
reduces the number of false positive C-format strings spotted by
xgettext(1)'s heuristics.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-11-02 18:31:10 +01:00
Lukas Fleischer
9aa9fde504 src/recur.c: Speed up recur_item_find_occurrence()
Bail out early if we check for a date beyond the item's repetition end
date.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-11-02 18:31:10 +01:00
Lukas Fleischer
2bf0249338 Avoid unnecessary start time calculations
Rename recur_*_inday() to recur_*_find_occurrence() and use the new
functions whenever we actually care about the start time of an
occurrence.

Reintroduce recur_*_inday() as wrappers to recur_*_find_occurrence() and
pass NULL as start time buffer (which means "skip start time
calculation"). Keep using these when we only want to know if a recurrent
item belongs to a specific day but do not care about the actual start
time.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-21 08:58:54 +02:00
Lukas Fleischer
1fb897feae src/recur.c: Remove diff_weeks()
After our recur_item_inday() rewrite, this function is no longer used.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-21 08:58:53 +02:00
Lukas Fleischer
0d51e61f3d src/recur.c: Support recurrent multi-day appointments
Completely rewrite our inday algorithm in recur_item_inday() and be more
fine-grained. This version can deal with recurrent multi-day
appointments unless they overlap.

In case of overlapping appointments, only the last appointment that
starts before the current day is shown. We will need to rewrite the
whole recur_item_inday() interface in order to fix this - this
relatively trivial patch is only the first step.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-21 08:58:53 +02:00
Lukas Fleischer
b0a6e1d448 Pass item durations to recur_item_inday()
Having item's durations eventually allows for better parsing of
recurrent appointments as we might be interested in how many days are
covered by a multi-day appointment.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-21 08:58:53 +02:00
Lukas Fleischer
3e84074ae5 Make events start on 00:00 (12:00 a.m.)
There is absolutely no reason to make events start on noon, 12:00.
Switching to 00:00 seems totally reasonable here, and makes event
handling a bit easier, also.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-21 08:58:53 +02:00
Lukas Fleischer
6c7edfbb86 Do not unlink() note files on note removal
Now that we use hash-based note file names, note files should never be
unlinked as a note file might be shared.

Also, remove the ERASE_FORCE_KEEP_NOTE flag that no longer makes any
sense.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-05 12:25:47 +02:00
Lukas Fleischer
0884d62b22 Merge branch 'maint' 2011-07-30 22:56:22 +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
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
003431880e Make recur_*_write() public
This allows one to serialize and send recurrent items to arbitrary
output streams.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-02 10:15:35 +02:00
Lukas Fleischer
b2645847a0 Fix whitespace issues
Strip trailing whitespaces in all source files.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-06-09 21:37:22 +02:00
Lukas Fleischer
38865b8e48 Update copyright notices in source files, documentation and "COPYING".
* Update copyright dates (use 2004-2011 as date range everywhere).

* Change copyright holder from "Frederic Culot" to "calcurse Development
  Team".

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-04-22 07:26:05 +02:00
Lukas Fleischer
fb5f9d0155 Use generic lists for recurring item exceptions.
Rename "days" structure to "excp" which seems to be a better name here.
Use generic linked lists of excp structures instead of using the "days"
structure which again contains a linked list implementation. Do some
cleanups and invocation fixes.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-04-22 02:47:36 +02:00
Lukas Fleischer
9fab24818a Use generic lists for recurring apointments and events.
Use them instead of "recur_apoint_list" and "next" pointers in
"recur_event" type variables. Includes some code simplifications and
cleanups.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-04-19 11:42:35 +02:00
Lukas Fleischer
2438470fd3 Add recur_apoint_inday() and recur_event_inday().
To be used with llist_fn_match_t callbacks later.

I feel a bit ill adding those functions. This definitely is a hack.
Ultimately, there should be some generic recur_item_inday() function
that accepts both recurring apointments and events (or some wrapper
structure) instead of parameter galeere. This is not the right place to
fix that tho.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-04-19 11:42:35 +02:00
Lukas Fleischer
6fb0f6f4c6 Compare pointers to "NULL" instead of "0".
"bad_zero.cocci" spatch from http://coccinelle.lip6.fr/impact_linux.php.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-04-05 09:27:04 +02:00
Lukas Fleischer
5b12c236cf Remove dead assignments spotted by clang-analyzer.
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-04-03 22:09:00 +02:00
Lukas Fleischer
d6e5347340 Use upper case for macro names.
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-03-15 10:23:41 +01:00
Lukas Fleischer
9c9fd5da15 Overall indentation fixes.
Use spaces instead of tabs for source code indentation only, strip
trailing whitespaces from lines.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-03-14 19:03:53 +01:00
Lukas Fleischer
c22dcaf6be Update website links to match the new URL.
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-03-04 11:07:49 +01:00
Lukas Fleischer
73e9649387 Update mail addresses to match the new mailing lists.
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-03-04 11:07:40 +01:00
Lukas Fleischer
91c9cac898 Remove CVS "$Id" headers.
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-03-03 16:19:45 +01:00
Lukas Fleischer
56b9cbcb84 Fixed file permissions. 2011-03-03 12:21:16 +01:00
Lukas Fleischer
c8af480f52 Make parse_date accept several short forms.
Short forms are only accepted in interactive mode (e.g. when using the
"Go to" function, editing a recurrent item's end date, and so on).

Samples: "1/1/30" for "01/01/2030", "26" for the 26th of the currently
selected month/year or "3/1" for Mar 01 (or Jan 03, depending on the
date format) of the currently selected year.
2011-01-11 22:10:48 +00:00
Frederic Culot
a8cb1c92ef All headers gathered into a single one. Typedefs suppressed. 2010-03-20 10:54:41 +00:00
Frederic Culot
b2321a7567 Patch to correct the wrong calculation of recurrent items' dates after a
turn of year (submitted by Lukas Fleischer, thanks!).
2010-03-08 08:44:28 +00:00
Frederic Culot
5dcc213c16 Make use of erase_note() whenever possible. 2009-07-19 08:19:37 +00:00
Frederic Culot
27b25548a4 Switch to BSD license. 2009-07-05 20:33:13 +00:00
Frederic Culot
3f6aff84e6 The buffer should be allocated dynamically, but I am quite busy right now :'( Anyway, thanks Kamil for feedback 2009-05-22 19:59:17 +00:00
Frederic Culot
936b6fe373 more code cleanup 2009-01-03 21:32:10 +00:00
Frederic Culot
aa7d6c5eb7 various bugfixes 2009-01-02 19:52:32 +00:00