static void update_sidebar (GcalYearView *year_view) { GcalYearViewPrivate *priv = year_view->priv; GtkWidget *child_widget; GList *events, *l; GList **days_widgets_array; gint i, days_span; update_selected_dates_from_button_data (year_view); gtk_container_foreach (GTK_CONTAINER (priv->events_sidebar), (GtkCallback) gtk_widget_destroy, NULL); days_span = icaltime_day_of_year(*(priv->end_selected_date)) - icaltime_day_of_year(*(priv->start_selected_date)) + 1; days_widgets_array = g_new0 (GList*, days_span); events = gcal_manager_get_events (priv->manager, priv->start_selected_date, priv->end_selected_date); if (events == NULL) { days_span = 0; update_no_events_page (year_view); gtk_stack_set_visible_child_name (GTK_STACK (priv->navigator_stack), "no-events"); } else { gtk_stack_set_visible_child_name (GTK_STACK (priv->navigator_stack), "events-list"); } for (l = events; l != NULL; l = g_list_next (l)) add_event_to_day_array (year_view, l->data, days_widgets_array, days_span); for (i = 0; i < days_span; i++) { GList *current_day = days_widgets_array[i]; for (l = current_day; l != NULL; l = g_list_next (l)) { child_widget = l->data; gtk_widget_show (child_widget); g_signal_connect (child_widget, "activate", G_CALLBACK (event_activated), year_view); g_object_set_data (G_OBJECT (child_widget), "shift", GINT_TO_POINTER (i)); gtk_container_add (GTK_CONTAINER (priv->events_sidebar), child_widget); } g_list_free (current_day); } g_free (days_widgets_array); g_list_free_full (events, g_free); }
void calDateTime::FromIcalTime(icaltimetype const* icalt, calITimezone * tz) { icaltimetype t = *icalt; mIsValid = (icaltime_is_null_time(t) || icaltime_is_valid_time(t) ? true : false); mIsDate = t.is_date ? true : false; if (mIsDate) { t.hour = 0; t.minute = 0; t.second = 0; } if (mIsValid) { t = icaltime_normalize(t); } mYear = static_cast<int16_t>(t.year); mMonth = static_cast<int16_t>(t.month - 1); mDay = static_cast<int16_t>(t.day); mHour = static_cast<int16_t>(t.hour); mMinute = static_cast<int16_t>(t.minute); mSecond = static_cast<int16_t>(t.second); if (tz) { mTimezone = tz; } else { mTimezone = cal::detectTimezone(t, nullptr); } #if defined(DEBUG) if (mTimezone) { if (t.is_utc) { nsCOMPtr<calITimezone> ctz = cal::UTC(); NS_ASSERTION(SameCOMIdentity(mTimezone, ctz), "UTC mismatch!"); } else if (!t.zone) { nsAutoCString tzid; mTimezone->GetTzid(tzid); if (tzid.EqualsLiteral("floating")) { nsCOMPtr<calITimezone> ctz = cal::floating(); NS_ASSERTION(SameCOMIdentity(mTimezone, ctz), "floating mismatch!"); } } else { nsAutoCString tzid; mTimezone->GetTzid(tzid); NS_ASSERTION(tzid.Equals(icaltimezone_get_tzid(const_cast<icaltimezone *>(t.zone))), "tzid mismatch!"); } } #endif mWeekday = static_cast<int16_t>(icaltime_day_of_week(t) - 1); mYearday = static_cast<int16_t>(icaltime_day_of_year(t)); // mNativeTime: not moving the existing date to UTC, // but merely representing it a UTC-based way. t.is_date = 0; mNativeTime = IcaltimeToPRTime(&t, icaltimezone_get_utc_timezone()); }
static void gcal_year_view_component_added (ECalDataModelSubscriber *subscriber, ECalClient *client, ECalComponent *comp) { GcalYearViewPrivate *priv; GcalYearView *year_view = GCAL_YEAR_VIEW (subscriber); GcalEventData *data; GList **days_widgets_array; GList *l; gint i, days_span; ECalComponentDateTime date; time_t event_start, event_end, range_start, range_end; icaltimezone *zone; priv = year_view->priv; update_selected_dates_from_button_data (year_view); days_span = icaltime_day_of_year(*(priv->end_selected_date)) - icaltime_day_of_year(*(priv->start_selected_date)) + 1; days_widgets_array = g_new0 (GList*, days_span); data = g_new0 (GcalEventData, 1); data->source = e_client_get_source (E_CLIENT (client)); data->event_component = e_cal_component_clone (comp); /* check if event belongs to range */ zone = gcal_manager_get_system_timezone (priv->manager); range_start = icaltime_as_timet_with_zone (*(priv->start_selected_date), zone); range_end = icaltime_as_timet_with_zone (*(priv->end_selected_date), zone); e_cal_component_get_dtstart (comp, &date); event_start = icaltime_as_timet_with_zone (*(date.value), date.value->zone != NULL ? date.value->zone : zone); e_cal_component_free_datetime (&date); e_cal_component_get_dtend (comp, &date); if (date.value != NULL) event_end = icaltime_as_timet_with_zone (*(date.value), date.value->zone != NULL ? date.value->zone : zone); else event_end = event_start; e_cal_component_free_datetime (&date); if (!((event_start <= range_start && event_end >= range_end) || (event_start >= range_start && event_end <= range_end) || (event_start >= range_start && event_start <= range_end) || (event_end >= range_start && event_end <= range_end))) { g_object_unref (data->event_component); goto out; } add_event_to_day_array (year_view, data, days_widgets_array, days_span); gtk_stack_set_visible_child_name (GTK_STACK (priv->navigator_stack), "events-list"); for (i = 0; i < days_span; i++) { GList *current_day = days_widgets_array[i]; for (l = current_day; l != NULL; l = g_list_next (l)) { GtkWidget *child_widget = l->data; gtk_widget_show (child_widget); g_signal_connect (child_widget, "activate", G_CALLBACK (event_activated), year_view); g_object_set_data (G_OBJECT (child_widget), "shift", GINT_TO_POINTER (i)); gtk_container_add (GTK_CONTAINER (priv->events_sidebar), child_widget); } g_list_free (current_day); } out: g_free (data); g_free (days_widgets_array); }
void calDateTime::FromIcalTime(icaltimetype const* icalt, calITimezone * tz) { icaltimetype t = *icalt; mIsValid = (icaltime_is_null_time(t) || icaltime_is_valid_time(t) ? PR_TRUE : PR_FALSE); mIsDate = t.is_date ? PR_TRUE : PR_FALSE; if (mIsDate) { t.hour = 0; t.minute = 0; t.second = 0; } if (mIsValid) { t = icaltime_normalize(t); } mYear = static_cast<PRInt16>(t.year); mMonth = static_cast<PRInt16>(t.month - 1); mDay = static_cast<PRInt16>(t.day); mHour = static_cast<PRInt16>(t.hour); mMinute = static_cast<PRInt16>(t.minute); mSecond = static_cast<PRInt16>(t.second); if (tz) { mTimezone = tz; } else { mTimezone = cal::detectTimezone(t, nsnull); } #if defined(DEBUG) if (mTimezone) { if (t.is_utc) { #if 1 nsCOMPtr<calITimezone> utc_tz; nsCOMPtr<calITimezoneService> tzSvc = do_GetService(CAL_TIMEZONESERVICE_CONTRACTID); tzSvc->GetUTC(getter_AddRefs(utc_tz)); NS_ASSERTION(SameCOMIdentity(mTimezone, utc_tz), "UTC mismatch!"); #else NS_ASSERTION(SameCOMIdentity(mTimezone, cal::UTC()), "UTC mismatch!"); #endif } else if (!t.zone) { #if 1 nsCOMPtr<calITimezone> float_tz; nsCOMPtr<calITimezoneService> tzSvc = do_GetService(CAL_TIMEZONESERVICE_CONTRACTID); tzSvc->GetFloating(getter_AddRefs(float_tz)); NS_ASSERTION(SameCOMIdentity(mTimezone, float_tz), "floating mismatch!"); #else NS_ASSERTION(SameCOMIdentity(mTimezone, cal::floating()), "floating mismatch!"); #endif } else { nsCAutoString tzid; mTimezone->GetTzid(tzid); NS_ASSERTION(tzid.Equals(icaltimezone_get_tzid(const_cast<icaltimezone *>(t.zone))), "tzid mismatch!"); } } #endif mWeekday = static_cast<PRInt16>(icaltime_day_of_week(t) - 1); mYearday = static_cast<PRInt16>(icaltime_day_of_year(t)); // mNativeTime: not moving the existing date to UTC, // but merely representing it a UTC-based way. t.is_date = 0; mNativeTime = IcaltimeToPRTime(&t, icaltimezone_get_utc_timezone()); }