* *** HUGE CHANGES *** *** WARNING: NOT FULLY FUNCTIONAL ***
[citadel.git] / webcit / calendar_view.c
1 /*
2  * $Id$
3  *
4  *
5  */
6
7 #include <ctype.h>
8 #include <stdlib.h>
9 #include <unistd.h>
10 #include <stdio.h>
11 #include <fcntl.h>
12 #include <signal.h>
13 #include <sys/types.h>
14 #include <sys/wait.h>
15 #include <sys/socket.h>
16 #include <limits.h>
17 #include <netinet/in.h>
18 #include <netdb.h>
19 #include <string.h>
20 #include <pwd.h>
21 #include <errno.h>
22 #include <stdarg.h>
23 #include <pthread.h>
24 #include <signal.h>
25 #include <time.h>
26 #include "webcit.h"
27 #include "webserver.h"
28
29 #ifndef WEBCIT_WITH_CALENDAR_SERVICE
30
31 void do_calendar_view(void) {   /* stub for non-libical builds */
32         wprintf("<CENTER><I>Calendar view not available</I></CENTER><br />\n");
33 }
34
35 void do_tasks_view(void) {      /* stub for non-libical builds */
36         wprintf("<CENTER><I>Tasks view not available</I></CENTER><br />\n");
37 }
38
39 #else   /* WEBCIT_WITH_CALENDAR_SERVICE */
40
41 /****************************************************************************/
42
43
44 void calendar_month_view_display_events(time_t thetime) {
45         int i;
46         time_t event_tt;
47         struct tm event_tm;
48         struct tm today_tm;
49         icalproperty *p;
50         struct icaltimetype t;
51         int month, day, year;
52         int all_day_event = 0;
53
54         if (WC->num_cal == 0) {
55                 wprintf("<br /><br /><br />\n");
56                 return;
57         }
58
59         localtime_r(&thetime, &today_tm);
60         month = today_tm.tm_mon + 1;
61         day = today_tm.tm_mday;
62         year = today_tm.tm_year + 1900;
63
64         for (i=0; i<(WC->num_cal); ++i) {
65                 p = icalcomponent_get_first_property(WC->disp_cal[i].cal,
66                                                 ICAL_DTSTART_PROPERTY);
67                 if (p != NULL) {
68                         t = icalproperty_get_dtstart(p);
69                         event_tt = icaltime_as_timet(t);
70
71                         if (t.is_date) all_day_event = 1;
72                         else all_day_event = 0;
73
74                         if (all_day_event) {
75                                 gmtime_r(&event_tt, &event_tm);
76                         }
77                         else {
78                                 localtime_r(&event_tt, &event_tm);
79                         }
80
81 lprintf(9, "Event: %04d/%02d/%02d, Now: %04d/%02d/%02d\n",
82         event_tm.tm_year,
83         event_tm.tm_mon,
84         event_tm.tm_mday,
85         today_tm.tm_year,
86         today_tm.tm_mon,
87         today_tm.tm_mday);
88
89
90                         if ((event_tm.tm_year == today_tm.tm_year)
91                            && (event_tm.tm_mon == today_tm.tm_mon)
92                            && (event_tm.tm_mday == today_tm.tm_mday)) {
93
94                                 p = icalcomponent_get_first_property(
95                                                         WC->disp_cal[i].cal,
96                                                         ICAL_SUMMARY_PROPERTY);
97                                 if (p != NULL) {
98
99                                         if (all_day_event) {
100                                                 wprintf("<TABLE border=0 cellpadding=2><TR>"
101                                                         "<TD BGCOLOR=\"#CCCCDD\">"
102                                                 );
103                                         }
104
105                                         wprintf("<FONT SIZE=-1>"
106                                                 "<A HREF=\"/display_edit_event?msgnum=%ld&calview=%s&year=%s&month=%s&day=%s\">",
107                                                 WC->disp_cal[i].cal_msgnum,
108                                                 bstr("calview"),
109                                                 bstr("year"),
110                                                 bstr("month"),
111                                                 bstr("day")
112                                         );
113                                         escputs((char *)
114                                                 icalproperty_get_comment(p));
115                                         wprintf("</A></FONT><br />\n");
116
117                                         if (all_day_event) {
118                                                 wprintf("</TD></TR></TABLE>");
119                                         }
120
121                                 }
122
123                         }
124
125
126                 }
127         }
128 }
129
130
131
132 void calendar_month_view(int year, int month, int day) {
133         struct tm starting_tm;
134         struct tm tm;
135         time_t thetime;
136         int i;
137         time_t previous_month;
138         time_t next_month;
139
140         /* Determine what day to start.
141          * First, back up to the 1st of the month...
142          */
143         memset(&starting_tm, 0, sizeof(struct tm));
144         starting_tm.tm_year = year - 1900;
145         starting_tm.tm_mon = month - 1;
146         starting_tm.tm_mday = day;
147         thetime = mktime(&starting_tm);
148
149         memcpy(&tm, &starting_tm, sizeof(struct tm));
150         while (tm.tm_mday != 1) {
151                 thetime = thetime - (time_t)86400;      /* go back 24 hours */
152                 localtime_r(&thetime, &tm);
153         }
154
155         /* Determine previous and next months ... for links */
156         previous_month = thetime - (time_t)864000L;     /* back 10 days */
157         next_month = thetime + (time_t)(31L * 86400L);  /* ahead 31 days */
158
159         /* Now back up until we're on a Sunday */
160         localtime_r(&thetime, &tm);
161         while (tm.tm_wday != 0) {
162                 thetime = thetime - (time_t)86400;      /* go back 24 hours */
163                 localtime_r(&thetime, &tm);
164         }
165
166         /* Outer table (to get the background color) */
167         wprintf("<TABLE width=100%% border=0 cellpadding=0 cellspacing=0 "
168                 "bgcolor=#204B78><TR><TD>\n");
169
170         wprintf("<TABLE width=100%% border=0 cellpadding=0 cellspacing=0>"
171                 "<TR><TD align=left><font color=#FFFFFF>"
172                 "&nbsp;<A HREF=\"/display_edit_event?msgnum=0"
173                 "&year=%d&month=%d&day=%d\">"
174                 "Add new calendar event</A>"
175                 "</font></TD>\n",
176                 year, month, day
177         );
178
179         wprintf("<TD ALIGN=CENTER>");
180
181         localtime_r(&previous_month, &tm);
182         wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
183                 (int)(tm.tm_year)+1900, tm.tm_mon + 1);
184         wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/back.gif\" BORDER=0></A>\n");
185
186         wprintf("&nbsp;&nbsp;"
187                 "<FONT SIZE=+1 COLOR=\"#FFFFFF\">"
188                 "%s %d"
189                 "</FONT>"
190                 "&nbsp;&nbsp;", months[month-1], year);
191
192         localtime_r(&next_month, &tm);
193         wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
194                 (int)(tm.tm_year)+1900, tm.tm_mon + 1);
195         wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/forward.gif\" BORDER=0></A>\n");
196
197         wprintf("</TD><TD align=right><font color=#FFFFFF size=-2>"
198                 "Click on any date for day view&nbsp;"
199                 "</FONT></TD></TR></TABLE>\n");
200
201         /* Inner table (the real one) */
202         wprintf("<TABLE width=100%% border=0 cellpadding=1 cellspacing=1 "
203                 "bgcolor=#204B78><TR>");
204         for (i=0; i<7; ++i) {
205                 wprintf("<TD ALIGN=CENTER WIDTH=14%%>"
206                         "<FONT COLOR=\"#FFFFFF\">%s</FONT></TH>", days[i]);
207         }
208         wprintf("</TR>\n");
209
210         /* Now do 35 days */
211         for (i = 0; i < 35; ++i) {
212                 localtime_r(&thetime, &tm);
213
214                 /* Before displaying Sunday, start a new row */
215                 if ((i % 7) == 0) {
216                         wprintf("<TR>");
217                 }
218
219                 wprintf("<TD BGCOLOR=\"#%s\" WIDTH=14%% HEIGHT=60 VALIGN=TOP><B>",
220                         ((tm.tm_mon != month-1) ? "DDDDDD" :
221                         ((tm.tm_wday==0 || tm.tm_wday==6) ? "EEEECC" :
222                         "FFFFFF"))
223                 );
224                 if ((i==0) || (tm.tm_mday == 1)) {
225                         wprintf("%s ", months[tm.tm_mon]);
226                 }
227                 wprintf("<A HREF=\"readfwd?calview=day&year=%d&month=%d&day=%d\">"
228                         "%d</A></B><br />",
229                         tm.tm_year + 1900,
230                         tm.tm_mon + 1,
231                         tm.tm_mday,
232                         tm.tm_mday);
233
234                 /* put the data here, stupid */
235                 calendar_month_view_display_events(thetime);
236
237                 wprintf("</TD>");
238
239                 /* After displaying Saturday, end the row */
240                 if ((i % 7) == 6) {
241                         wprintf("</TR>\n");
242                 }
243
244                 thetime += (time_t)86400;               /* ahead 24 hours */
245         }
246
247         wprintf("</TABLE>"                      /* end of inner table */
248                 "</TD></TR></TABLE>"            /* end of outer table */
249                 "</CENTER>\n");
250 }
251
252
253 void calendar_week_view(int year, int month, int day) {
254         wprintf("<CENTER><I>week view FIXME</I></CENTER><br />\n");
255 }
256
257
258 /*
259  * Display events for a particular hour of a particular day.
260  * (Specify hour < 0 to show "all day" events)
261  */
262 void calendar_day_view_display_events(int year, int month,
263                                         int day, int hour) {
264         int i;
265         icalproperty *p;
266         struct icaltimetype t;
267         time_t event_tt;
268         struct tm *event_tm;
269         int all_day_event = 0;
270
271         if (WC->num_cal == 0) {
272                 wprintf("<br /><br /><br />\n");
273                 return;
274         }
275
276         for (i=0; i<(WC->num_cal); ++i) {
277                 p = icalcomponent_get_first_property(WC->disp_cal[i].cal,
278                                                 ICAL_DTSTART_PROPERTY);
279                 if (p != NULL) {
280                         t = icalproperty_get_dtstart(p);
281                         event_tt = icaltime_as_timet(t);
282                         if (t.is_date) all_day_event = 1;
283
284                         if (all_day_event) {
285                                 event_tm = gmtime(&event_tt);
286                         }
287                         else {
288                                 event_tm = localtime(&event_tt);
289                         }
290
291                         if ((event_tm->tm_year == (year-1900))
292                            && (event_tm->tm_mon == (month-1))
293                            && (event_tm->tm_mday == day)
294                            && ( ((event_tm->tm_hour == hour)&&(!t.is_date)) || ((hour<0)&&(t.is_date)) )
295                            ) {
296
297
298                                 p = icalcomponent_get_first_property(
299                                                         WC->disp_cal[i].cal,
300                                                         ICAL_SUMMARY_PROPERTY);
301                                 if (p != NULL) {
302
303                                         if (all_day_event) {
304                                                 wprintf("<TABLE border=1 cellpadding=2><TR>"
305                                                         "<TD BGCOLOR=\"#CCCCCC\">"
306                                                 );
307                                         }
308
309                                         wprintf("<FONT SIZE=-1>"
310                                                 "<A HREF=\"/display_edit_event?msgnum=%ld&calview=day&year=%d&month=%d&day=%d\">",
311                                                 WC->disp_cal[i].cal_msgnum,
312                                                 year, month, day
313                                         );
314                                         escputs((char *)
315                                                 icalproperty_get_comment(p));
316                                         wprintf("</A></FONT><br />\n");
317
318                                         if (all_day_event) {
319                                                 wprintf("</TD></TR></TABLE>");
320                                         }
321                                 }
322
323                         }
324
325
326                 }
327         }
328 }
329
330
331
332 void calendar_day_view(int year, int month, int day) {
333         int hour;
334         struct icaltimetype today, yesterday, tomorrow;
335
336
337         /* Figure out the dates for "yesterday" and "tomorrow" links */
338
339         memset(&today, 0, sizeof(struct icaltimetype));
340         today.year = year;
341         today.month = month;
342         today.day = day;
343         today.is_date = 1;
344
345         memcpy(&yesterday, &today, sizeof(struct icaltimetype));
346         --yesterday.day;
347         yesterday = icaltime_normalize(yesterday);
348
349         memcpy(&tomorrow, &today, sizeof(struct icaltimetype));
350         ++tomorrow.day;
351         tomorrow = icaltime_normalize(tomorrow);
352
353
354         /* Outer table (to get the background color) */
355         wprintf("<TABLE width=100%% border=0 cellpadding=0 cellspacing=0 "
356                 "bgcolor=#204B78><TR><TD>\n");
357
358         /* Inner table (the real one) */
359         wprintf("<TABLE width=100%% border=0 cellpadding=1 cellspacing=1 "
360                 "bgcolor=#204B78><TR>\n");
361
362         /* Innermost table (contains hours etc.) */
363         wprintf("<TD WIDTH=80%%>"
364                 "<TABLE width=100%% border=0 cellpadding=1 cellspacing=1 "
365                 "bgcolor=#204B78>\n");
366
367         /* Display events before 8:00 (hour=-1 is all-day events) */
368         wprintf("<TR>"
369                 "<TD BGCOLOR=\"#CCCCDD\" VALIGN=MIDDLE WIDTH=10%%></TD>"
370                 "<TD BGCOLOR=\"#FFFFFF\" VALIGN=TOP>");
371         for (hour = (-1); hour <= 7; ++hour) {
372                 calendar_day_view_display_events(year, month, day, hour);
373         }
374         wprintf("</TD></TR>\n");
375
376         /* Now the middle of the day... */      
377         for (hour = 8; hour <= 17; ++hour) {    /* could do HEIGHT=xx */
378                 wprintf("<TR HEIGHT=30><TD BGCOLOR=\"#CCCCDD\" ALIGN=MIDDLE "
379                         "VALIGN=MIDDLE WIDTH=10%%>");
380                 wprintf("<A HREF=\"/display_edit_event?msgnum=0"
381                         "&year=%d&month=%d&day=%d&hour=%d&minute=0\">",
382                         year, month, day, hour
383                 );
384                 wprintf("%d:00%s</A> ",
385                         (hour <= 12 ? hour : hour-12),
386                         (hour < 12 ? "am" : "pm")
387                 );
388                 wprintf("</TD><TD BGCOLOR=\"#FFFFFF\" VALIGN=TOP>");
389
390                 /* put the data here, stupid */
391                 calendar_day_view_display_events(year, month, day, hour);
392
393                 wprintf("</TD></TR>\n");
394         }
395
396         /* Display events after 5:00... */
397         wprintf("<TR>"
398                 "<TD BGCOLOR=\"#CCCCDD\" VALIGN=MIDDLE WIDTH=10%%></TD>"
399                 "<TD BGCOLOR=\"#FFFFFF\" VALIGN=TOP>");
400         for (hour = 18; hour <= 23; ++hour) {
401                 calendar_day_view_display_events(year, month, day, hour);
402         }
403         wprintf("</TD></TR>\n");
404
405
406         wprintf("</TABLE>"                      /* end of innermost table */
407                 "</TD>"
408         );
409
410         wprintf("<TD WIDTH=20%% VALIGN=top>");  /* begin stuff-on-the-right */
411
412
413         /* Begin todays-date-with-left-and-right-arrows */
414         wprintf("<TABLE BORDER=0 WIDTH=100%% "
415                 "CELLSPACING=0 CELLPADDING=0 BGCOLOR=\"#FFFFFF\">\n");
416         wprintf("<TR>");
417
418         /* Left arrow */        
419         wprintf("<TD ALIGN=CENTER>");
420         wprintf("<A HREF=\"readfwd?calview=day&year=%d&month=%d&day=%d\">",
421                 yesterday.year, yesterday.month, yesterday.day);
422         wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/back.gif\" BORDER=0></A>");
423         wprintf("</TD>");
424
425         /* Today's date */
426         wprintf("<TD ALIGN=CENTER>");
427         wprintf("<FONT SIZE=+2>%s</FONT><br />"
428                 "<FONT SIZE=+3>%d</FONT><br />"
429                 "<FONT SIZE=+2>%d</FONT><br />",
430                 months[month-1], day, year);
431         wprintf("</TD>");
432
433         /* Right arrow */
434         wprintf("<TD ALIGN=CENTER>");
435         wprintf("<A HREF=\"readfwd?calview=day&year=%d&month=%d&day=%d\">",
436                 tomorrow.year, tomorrow.month, tomorrow.day);
437         wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/forward.gif\""
438                 " BORDER=0></A>\n");
439         wprintf("</TD>");
440
441         wprintf("</TR></TABLE>\n");
442         /* End todays-date-with-left-and-right-arrows */
443
444         wprintf("<br /><br /><CENTER><font color=#FFFFFF>"
445                 "&nbsp;<A HREF=\"/display_edit_event?msgnum=0"
446                 "&year=%d&month=%d&day=%d\">"
447                 "Add new calendar event</A>"
448                 "<br /><br />\n",
449                 year, month, day
450         );
451
452         wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">"
453                 "Back to month view</A>\n", year, month);
454
455         wprintf("</FONT></CENTER>\n");
456
457         wprintf("</TD>");                       /* end stuff-on-the-right */
458
459
460
461         wprintf("</TR></TABLE>"                 /* end of inner table */
462                 "</TD></TR></TABLE>"            /* end of outer table */
463         );
464
465
466
467 }
468
469 /*
470  * Display today's events.
471  */
472 void calendar_summary_view(void) {
473         int i;
474         icalproperty *p;
475         struct icaltimetype t;
476         time_t event_tt;
477         struct tm event_tm;
478         struct tm today_tm;
479         time_t now;
480         int all_day_event = 0;
481         char timestring[SIZ];
482
483         if (WC->num_cal == 0) {
484                 return;
485         }
486
487         now = time(NULL);
488         localtime_r(&now, &today_tm);
489
490         for (i=0; i<(WC->num_cal); ++i) {
491                 p = icalcomponent_get_first_property(WC->disp_cal[i].cal,
492                                                 ICAL_DTSTART_PROPERTY);
493                 if (p != NULL) {
494                         t = icalproperty_get_dtstart(p);
495                         event_tt = icaltime_as_timet(t);
496                         if (t.is_date) all_day_event = 1;
497                         fmt_time(timestring, event_tt);
498
499                         if (all_day_event) {
500                                 gmtime_r(&event_tt, &event_tm);
501                         }
502                         else {
503                                 localtime_r(&event_tt, &event_tm);
504                         }
505
506                         if ( (event_tm.tm_year == today_tm.tm_year)
507                            && (event_tm.tm_mon == today_tm.tm_mon)
508                            && (event_tm.tm_mday == today_tm.tm_mday)
509                            ) {
510
511
512                                 p = icalcomponent_get_first_property(
513                                                         WC->disp_cal[i].cal,
514                                                         ICAL_SUMMARY_PROPERTY);
515                                 if (p != NULL) {
516                                         escputs((char *)
517                                                 icalproperty_get_comment(p));
518                                         wprintf(" (%s)<br />\n", timestring);
519                                 }
520                         }
521                 }
522         }
523         free_calendar_buffer();
524 }
525
526
527
528 void free_calendar_buffer(void) {
529         int i;
530         if (WC->num_cal) for (i=0; i<(WC->num_cal); ++i) {
531                 icalcomponent_free(WC->disp_cal[i].cal);
532         }
533         WC->num_cal = 0;
534         free(WC->disp_cal);
535         WC->disp_cal = NULL;
536 }
537
538
539
540
541 void do_calendar_view(void) {
542         time_t now;
543         struct tm tm;
544         int year, month, day;
545         char calview[SIZ];
546
547         /* In case no date was specified, go with today */
548         now = time(NULL);
549         localtime_r(&now, &tm);
550         year = tm.tm_year + 1900;
551         month = tm.tm_mon + 1;
552         day = tm.tm_mday;
553
554         /* Now see if a date was specified */
555         if (strlen(bstr("year")) > 0) year = atoi(bstr("year"));
556         if (strlen(bstr("month")) > 0) month = atoi(bstr("month"));
557         if (strlen(bstr("day")) > 0) day = atoi(bstr("day"));
558
559         /* How would you like that cooked? */
560         if (strlen(bstr("calview")) > 0) {
561                 strcpy(calview, bstr("calview"));
562         }
563         else {
564                 strcpy(calview, "month");
565         }
566
567         /* Display the selected view */
568         if (!strcasecmp(calview, "day")) {
569                 calendar_day_view(year, month, day);
570         }
571         else if (!strcasecmp(calview, "week")) {
572                 calendar_week_view(year, month, day);
573         }
574         else {
575                 calendar_month_view(year, month, day);
576         }
577
578         /* Free the calendar stuff */
579         free_calendar_buffer();
580
581 }
582
583
584 /*
585  * Helper function for do_tasks_view().  Returns the date/time due.
586  */
587 time_t get_task_due_date(icalcomponent *vtodo) {
588         icalproperty *p;
589
590         if (vtodo == NULL) {
591                 return(0L);
592         }
593
594         /* If we're looking at a fully encapsulated VCALENDAR
595          * rather than a VTODO component, recurse into the data
596          * structure until we get a VTODO.
597          */
598         if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
599                 return get_task_due_date(
600                         icalcomponent_get_first_component(
601                                 vtodo, ICAL_VTODO_COMPONENT
602                         )
603                 );
604         }
605
606         p = icalcomponent_get_first_property(vtodo, ICAL_DUE_PROPERTY);
607         if (p != NULL) {
608                 return(icaltime_as_timet(icalproperty_get_due(p)));
609         }
610         else {
611                 return(0L);
612         }
613 }
614
615
616 /*
617  * Compare the due dates of two tasks (this is for sorting)
618  */
619 int task_due_cmp(const void *task1, const void *task2) {
620         time_t t1;
621         time_t t2;
622
623         t1 =  get_task_due_date(((struct disp_cal *)task1)->cal);
624         t2 =  get_task_due_date(((struct disp_cal *)task2)->cal);
625
626         if (t1 < t2) return(-1);
627         if (t1 > t2) return(1);
628         return(0);
629 }
630
631
632
633
634
635 void do_tasks_view(void) {
636         int i;
637         time_t due;
638         int bg = 0;
639         char buf[SIZ];
640         icalproperty *p;
641
642         do_template("beginbox_nt");
643
644         wprintf("<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%%>\n<TR>\n"
645                 "<TH>Name of task</TH>\n"
646                 "<TH>Date due</TH></TR>\n"
647         );
648
649         /* Sort them if necessary */
650         if (WC->num_cal > 1) {
651                 qsort(WC->disp_cal,
652                         WC->num_cal,
653                         sizeof(struct disp_cal),
654                         task_due_cmp
655                 );
656         }
657
658         if (WC->num_cal) for (i=0; i<(WC->num_cal); ++i) {
659
660                 bg = 1 - bg;
661                 wprintf("<TR BGCOLOR=\"#%s\"><TD>",
662                         (bg ? "DDDDDD" : "FFFFFF")
663                 );
664
665                 p = icalcomponent_get_first_property(WC->disp_cal[i].cal,
666                                                         ICAL_SUMMARY_PROPERTY);
667                 wprintf("<A HREF=\"/display_edit_task?msgnum=%ld&taskrm=",
668                         WC->disp_cal[i].cal_msgnum );
669                 urlescputs(WC->wc_roomname);
670                 wprintf("\">");
671                 if (p != NULL) {
672                         escputs((char *)icalproperty_get_comment(p));
673                 }
674                 wprintf("</A>\n");
675                 wprintf("</TD>\n");
676
677                 due = get_task_due_date(WC->disp_cal[i].cal);
678                 fmt_date(buf, due);
679                 wprintf("<TD><FONT");
680                 if (due < time(NULL)) {
681                         wprintf(" COLOR=\"#FF0000\"");
682                 }
683                 wprintf(">%s</FONT></TD></TR>\n", buf);
684         }
685
686         wprintf("</TABLE>\n");
687
688         wprintf("<hr /><A HREF=\"/display_edit_task?msgnum=0\">"
689                 "Add new task</A>\n"
690         );
691
692         do_template("endbox");
693
694
695         /* Free the list */
696         free_calendar_buffer();
697
698 }
699
700 #endif  /* WEBCIT_WITH_CALENDAR_SERVICE */