/** * calculate and assign the surface interval between dives */ dif_dive_collection_t *dif_dive_collection_calculate_surface_interval(dif_dive_collection_t *dc) { dc = dif_dive_collection_sort_dives(dc); GList *dives = dc->dives; dif_dive_t *previousDive = NULL; while (dives != NULL) { dif_dive_t *thisDive = dives->data; if (thisDive->duration == 0 && thisDive->samples) { thisDive = dif_dive_sort_samples(thisDive); dif_sample_t *firstSample = g_list_first(thisDive->samples)->data; dif_sample_t *lastSample = g_list_last(thisDive->samples)->data; thisDive->duration = lastSample->timestamp - firstSample->timestamp; } if (previousDive == NULL) { thisDive->surfaceInterval = -1; } else { GDateTime *previousTime = previousDive->datetime; previousTime = g_date_time_add_seconds(previousTime, previousDive->duration); GTimeSpan diff = g_date_time_difference(thisDive->datetime, previousTime); thisDive->surfaceInterval = diff/G_TIME_SPAN_SECOND; if (thisDive->surfaceInterval > SURFACE_INTERVAL_MAX) { thisDive->surfaceInterval = -1; } } previousDive = thisDive; dives = g_list_next(dives); } return dc; }
static gboolean update_clock (gpointer data) { GnomeWallClock *self = data; GDesktopClockFormat clock_format; gboolean show_full_date; gboolean show_weekday; gboolean show_seconds; GSource *source; GDateTime *now; GDateTime *expiry; clock_format = g_settings_get_enum (self->priv->desktop_settings, "clock-format"); show_weekday = !self->priv->time_only && g_settings_get_boolean (self->priv->desktop_settings, "clock-show-weekday"); show_full_date = !self->priv->time_only && g_settings_get_boolean (self->priv->desktop_settings, "clock-show-date"); show_seconds = g_settings_get_boolean (self->priv->desktop_settings, "clock-show-seconds"); now = g_date_time_new_now (self->priv->timezone); if (show_seconds) expiry = g_date_time_add_seconds (now, 1); else expiry = g_date_time_add_seconds (now, 60 - g_date_time_get_second (now)); if (self->priv->clock_update_id) g_source_remove (self->priv->clock_update_id); source = _gnome_datetime_source_new (now, expiry, TRUE); g_source_set_priority (source, G_PRIORITY_HIGH); g_source_set_callback (source, update_clock, self, NULL); self->priv->clock_update_id = g_source_attach (source, NULL); g_source_unref (source); g_free (self->priv->clock_string); self->priv->clock_string = gnome_wall_clock_string_for_datetime (self, now, clock_format, show_weekday, show_full_date, show_seconds); g_date_time_unref (now); g_date_time_unref (expiry); g_object_notify ((GObject*)self, "clock"); return FALSE; }
void dt_image_add_time_offset(const int imgid, const long int offset) { const dt_image_t *cimg = dt_image_cache_read_get(darktable.image_cache, imgid); if (!cimg) return; // get the datetime_taken and calculate the new time gint year; gint month; gint day; gint hour; gint minute; gint seconds; if (sscanf(cimg->exif_datetime_taken, "%d:%d:%d %d:%d:%d", (int*)&year, (int*)&month, (int*)&day, (int*)&hour,(int*)&minute,(int*)&seconds) != 6) { fprintf(stderr,"broken exif time in db, '%s', imgid %d\n", cimg->exif_datetime_taken, imgid); dt_image_cache_read_release(darktable.image_cache, cimg); return; } GTimeZone *tz = g_time_zone_new_utc(); GDateTime *datetime_original = g_date_time_new(tz, year, month, day, hour, minute, seconds); g_time_zone_unref(tz); if(!datetime_original) { dt_image_cache_read_release(darktable.image_cache, cimg); return; } // let's add our offset GDateTime *datetime_new = g_date_time_add_seconds(datetime_original, offset); g_date_time_unref(datetime_original); if(!datetime_new) { dt_image_cache_read_release(darktable.image_cache, cimg); return; } gchar *datetime = g_date_time_format(datetime_new, "%Y:%m:%d %H:%M:%S"); g_date_time_unref(datetime_new); // update exif_datetime_taken in img if(datetime) { dt_image_t *img = dt_image_cache_write_get(darktable.image_cache, cimg); g_strlcpy(img->exif_datetime_taken, datetime, 20); dt_image_cache_write_release(darktable.image_cache, img, DT_IMAGE_CACHE_SAFE); } dt_image_cache_read_release(darktable.image_cache, cimg); g_free(datetime); }
GDateTime* gnc_g_date_time_new_from_timespec_local (Timespec ts) { GDateTime *gdt1 = gnc_g_date_time_new_from_unix_local (ts.tv_sec); double nsecs = ((double)ts.tv_nsec + 0.5)/ 1000000000.0L; GDateTime *gdt2 = g_date_time_add_seconds (gdt1, nsecs); g_date_time_unref (gdt1); g_assert (g_date_time_to_unix (gdt2) == ts.tv_sec + (nsecs >= 1.0 ? (gint64)nsecs : 0)); return gdt2; }
/** * gst_video_time_code_to_date_time: * @tc: #GstVideoTimeCode to convert * * The @tc.config->latest_daily_jam is required to be non-NULL. * * Returns: the #GDateTime representation of @tc. * * Since: 1.10 */ GDateTime * gst_video_time_code_to_date_time (const GstVideoTimeCode * tc) { GDateTime *ret; GDateTime *ret2; gdouble add_us; g_return_val_if_fail (gst_video_time_code_is_valid (tc), NULL); g_return_val_if_fail (tc->config.latest_daily_jam != NULL, NULL); ret = g_date_time_ref (tc->config.latest_daily_jam); if (ret == NULL) { gchar *tc_str = gst_video_time_code_to_string (tc); GST_WARNING ("Asked to convert time code %s to GDateTime, but its latest daily jam is NULL", tc_str); g_free (tc_str); return NULL; } if (tc->config.fps_n == 0 && tc->config.fps_d == 1) { gchar *tc_str = gst_video_time_code_to_string (tc); GST_WARNING ("Asked to convert time code %s to GDateTime, but its framerate is unknown", tc_str); g_free (tc_str); return NULL; } gst_util_fraction_to_double (tc->frames * tc->config.fps_d, tc->config.fps_n, &add_us); if ((tc->config.flags & GST_VIDEO_TIME_CODE_FLAGS_INTERLACED) && tc->field_count == 1) { gdouble sub_us; gst_util_fraction_to_double (tc->config.fps_d, 2 * tc->config.fps_n, &sub_us); add_us -= sub_us; } ret2 = g_date_time_add_seconds (ret, add_us + tc->seconds); g_date_time_unref (ret); ret = g_date_time_add_minutes (ret2, tc->minutes); g_date_time_unref (ret2); ret2 = g_date_time_add_hours (ret, tc->hours); g_date_time_unref (ret); return ret2; }
static void foreach_enum_trackers(gpointer data, gpointer user) { enum_trackers_state_t *state = user; GArray *str = g_array_new (FALSE, FALSE, sizeof (data)); g_array_append_vals(str, data, 5); fitbitd_tracker_t *tracker; GValue *val_serial; GValue *val_state; GValue *val_sync_age; GValue *val_tracker_id; GValue *val_user_id; guint tracker_state; guint sync_age; GDateTime *time_now; val_serial = g_array_index(str, GValue *, 0); val_state = g_array_index(str, GValue *, 1); val_sync_age = g_array_index(str, GValue *, 2); val_tracker_id = g_array_index(str, GValue *, 3); val_user_id = g_array_index(str, GValue *, 4); if (!val_serial || !val_state || !val_sync_age || !val_tracker_id || !val_user_id) { g_printerr("Missing tracker values\n"); return; } tracker = get_tracker(g_value_get_string(val_serial)); if (!tracker) { g_printerr("No tracker record\n"); return; } tracker_state = g_value_get_uint(val_state); tracker->sync_active = !!(tracker_state & (1 << 0)); sync_age = g_value_get_uint(val_sync_age); time_now = g_date_time_new_now_local(); if (tracker->sync_time) g_date_time_unref(tracker->sync_time); tracker->sync_time = g_date_time_add_seconds(time_now, -(gdouble)sync_age); g_date_time_unref(time_now); strncpy(tracker->id, g_value_get_string(val_tracker_id), sizeof(tracker->id)); strncpy(tracker->user_id, g_value_get_string(val_user_id), sizeof(tracker->user_id)); state->callback(tracker, state->user); }
/* When first focussing the grid, or then when pressing right or left, we * record a date (the middle of the focused event) that will then be used * when pressing up/down to focus the relevant tile, the one that contains the * this focused date */ static void update_focused_date (MexEpgGrid *grid, MexEpgTile *tile) { MexEpgGridPrivate *priv = grid->priv; GDateTime *start_date, *middle_date; MexEpgEvent *event; gint duration; if (priv->focused_date) g_date_time_unref (priv->focused_date); event = mex_epg_tile_get_event (tile); start_date = mex_epg_event_get_start_date (event); duration = mex_epg_event_get_duration (event); middle_date = g_date_time_add_seconds (start_date, duration / 2); priv->focused_date = middle_date; }
static gboolean redisplay_clock (gpointer data) { GSource *source; GDateTime *now, *expiry; now = g_date_time_new_now_local (); g_print ("%02d:%02d\n", g_date_time_get_hour (now), g_date_time_get_minute (now)); expiry = g_date_time_add_seconds (now, 60 - g_date_time_get_second (now)); source = g_date_time_source_new (expiry, TRUE); g_source_set_callback (source, redisplay_clock, NULL, NULL); g_source_attach (source, NULL); g_source_unref (source); g_date_time_unref (expiry); g_date_time_unref (now); return FALSE; }
static gboolean update_clock (gpointer data) { GnomeWallClock *self = data; const char *format_string; GSource *source; GDateTime *now; GDateTime *expiry; now = g_date_time_new_now_local (); expiry = g_date_time_add_seconds (now, 60 - g_date_time_get_second (now)); if (self->priv->clock_update_id) g_source_remove (self->priv->clock_update_id); source = _gnome_datetime_source_new (now, expiry, TRUE); g_source_set_priority (source, G_PRIORITY_HIGH); g_source_set_callback (source, update_clock, self, NULL); self->priv->clock_update_id = g_source_attach (source, NULL); g_source_unref (source); format_string = g_strdup_printf ( "<b><span font_desc=\"Ubuntu 64\" foreground=\"#FFFFFF\">%s</span></b>\n<b><span font_desc=\"Ubuntu 24\" foreground=\"#FFFFFF\">%s</span></b>", _("%R"), _("%A, %B %e")); g_free (self->priv->clock_string); self->priv->clock_string = g_date_time_format (now, format_string); g_date_time_unref (now); g_date_time_unref (expiry); g_object_notify ((GObject*)self, "clock"); return FALSE; }
void sv_ev_lastactivity_response(const char *const from, const int seconds, const char *const msg) { Jid *jidp = jid_create(from); if (!jidp) { return; } GDateTime *now = g_date_time_new_now_local(); GDateTime *active = g_date_time_add_seconds(now, 0 - seconds); gchar *date_fmt = NULL; char *time_pref = prefs_get_string(PREF_TIME_LASTACTIVITY); date_fmt = g_date_time_format(active, time_pref); prefs_free_string(time_pref); assert(date_fmt != NULL); // full jid - last activity if (jidp->resourcepart) { if (seconds == 0) { if (msg) { cons_show("%s currently active, status: %s", from, msg); } else { cons_show("%s currently active", from); } } else { if (msg) { cons_show("%s last active %s, status: %s", from, date_fmt, msg); } else { cons_show("%s last active %s", from, date_fmt); } } // barejid - last logged in } else if (jidp->localpart) { if (seconds == 0) { if (msg) { cons_show("%s currently logged in, status: %s", from, msg); } else { cons_show("%s currently logged in", from); } } else { if (msg) { cons_show("%s last logged in %s, status: %s", from, date_fmt, msg); } else { cons_show("%s last logged in %s", from, date_fmt); } } // domain only - uptime } else { int left = seconds; int days = seconds / 86400; left = left - days * 86400; int hours = left / 3600; left = left - hours * 3600; int minutes = left / 60; left = left - minutes * 60; int seconds = left; cons_show("%s up since %s, uptime %d days, %d hrs, %d mins, %d secs", from, date_fmt, days, hours, minutes, seconds); } g_date_time_unref(now); g_date_time_unref(active); g_free(date_fmt); jid_destroy(jidp); }
static void set_time (GstRTSPTime * time, GstRTSPTime2 * time2, GstRTSPRangeUnit unit, GstClockTime clock_time) { memset (time, 0, sizeof (GstRTSPTime)); memset (time2, 0, sizeof (GstRTSPTime2)); if (clock_time == GST_CLOCK_TIME_NONE) { time->type = GST_RTSP_TIME_END; return; } switch (unit) { case GST_RTSP_RANGE_SMPTE: case GST_RTSP_RANGE_SMPTE_30_DROP: { time->seconds = (guint64) (clock_time / GST_SECOND); time2->frames = 30003 * (clock_time % GST_SECOND) / (gdouble) (1001 * GST_SECOND); time->type = GST_RTSP_TIME_FRAMES; g_assert (time2->frames < 30); break; } case GST_RTSP_RANGE_SMPTE_25: { time->seconds = (guint64) (clock_time / GST_SECOND); time2->frames = (25 * (clock_time % GST_SECOND)) / (gdouble) GST_SECOND; time->type = GST_RTSP_TIME_FRAMES; g_assert (time2->frames < 25); break; } case GST_RTSP_RANGE_NPT: { time->seconds = (gdouble) clock_time / (gdouble) GST_SECOND; time->type = GST_RTSP_TIME_SECONDS; break; } case GST_RTSP_RANGE_CLOCK: { GDateTime *bt, *datetime; GstClockTime subsecond = clock_time % GST_SECOND; bt = g_date_time_new_utc (1900, 1, 1, 0, 0, 0.0); datetime = g_date_time_add_seconds (bt, clock_time / GST_SECOND); time2->year = g_date_time_get_year (datetime); time2->month = g_date_time_get_month (datetime); time2->day = g_date_time_get_day_of_month (datetime); time->seconds = g_date_time_get_hour (datetime) * 60 * 60; time->seconds += g_date_time_get_minute (datetime) * 60; time->seconds += g_date_time_get_seconds (datetime); time->seconds += (gdouble) subsecond / (gdouble) GST_SECOND; time->type = GST_RTSP_TIME_UTC; g_date_time_unref (bt); g_date_time_unref (datetime); break; } } if (time->seconds < 0.000000001) time->seconds = 0; if (time2->frames < 0.000000001) time2->frames = 0; }
static int _available_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata) { // handler still fires if error if (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_ERROR) == 0) { return 1; } // handler still fires if other types if ((g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_UNAVAILABLE) == 0) || (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_SUBSCRIBE) == 0) || (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_SUBSCRIBED) == 0) || (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_UNSUBSCRIBED) == 0)) { return 1; } // handler still fires for muc presence if (stanza_is_muc_presence(stanza)) { return 1; } char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); if (from) { log_info("Available presence handler fired for: %s", from); } else { log_info("Available presence handler fired"); } // exit when no from attribute if (!from) { log_warning("No from attribute found."); return 1; } // own jid is invalid const char *my_jid_str = xmpp_conn_get_jid(conn); Jid *my_jid = jid_create(my_jid_str); if (!my_jid) { if (my_jid_str) { log_error("Could not parse account JID: %s", my_jid_str); } else { log_error("Could not parse account JID: NULL"); } return 1; } // contact jid invalud Jid *from_jid = jid_create(from); if (!from_jid) { log_warning("Could not parse contact JID: %s", from); jid_destroy(my_jid); return 1; } // presence properties char *show_str = stanza_get_show(stanza, "online"); char *status_str = stanza_get_status(stanza, NULL); // presence last activity int idle_seconds = stanza_get_idle_time(stanza); GDateTime *last_activity = NULL; if (idle_seconds > 0) { GDateTime *now = g_date_time_new_now_local(); last_activity = g_date_time_add_seconds(now, 0 - idle_seconds); g_date_time_unref(now); } // priority int priority = 0; xmpp_stanza_t *priority_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_PRIORITY); if (priority_stanza != NULL) { char *priority_str = xmpp_stanza_get_text(priority_stanza); if (priority_str != NULL) { priority = atoi(priority_str); } free(priority_str); } // send disco info for capabilities, if not cached if ((g_strcmp0(my_jid->fulljid, from_jid->fulljid) != 0) && (stanza_contains_caps(stanza))) { log_info("Presence contains capabilities."); _handle_caps(stanza); } // create Resource Resource *resource = NULL; resource_presence_t presence = resource_presence_from_string(show_str); if (from_jid->resourcepart == NULL) { // hack for servers that do not send full jid resource = resource_new("__prof_default", presence, status_str, priority); } else { resource = resource_new(from_jid->resourcepart, presence, status_str, priority); } free(status_str); free(show_str); // check for self presence if (g_strcmp0(my_jid->barejid, from_jid->barejid) == 0) { connection_add_available_resource(resource); // contact presence } else { handle_contact_online(from_jid->barejid, resource, last_activity); } if (last_activity != NULL) { g_date_time_unref(last_activity); } jid_destroy(my_jid); jid_destroy(from_jid); return 1; }
static int _available_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata) { // handler still fires if error if (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_ERROR) == 0) { return 1; } // handler still fires if other types if ((g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_UNAVAILABLE) == 0) || (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_SUBSCRIBE) == 0) || (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_SUBSCRIBED) == 0) || (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_UNSUBSCRIBED) == 0)) { return 1; } // handler still fires for muc presence if (stanza_is_muc_presence(stanza)) { return 1; } const char *jid = xmpp_conn_get_jid(conn); char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); log_debug("Available presence handler fired for %s", from); Jid *my_jid = jid_create(jid); Jid *from_jid = jid_create(from); if (my_jid == NULL || from_jid == NULL) { jid_destroy(my_jid); jid_destroy(from_jid); return 1; } char *show_str = stanza_get_show(stanza, "online"); char *status_str = stanza_get_status(stanza, NULL); int idle_seconds = stanza_get_idle_time(stanza); GDateTime *last_activity = NULL; char *caps_key = NULL; if (stanza_contains_caps(stanza)) { caps_key = _get_caps_key(stanza); } if (idle_seconds > 0) { GDateTime *now = g_date_time_new_now_local(); last_activity = g_date_time_add_seconds(now, 0 - idle_seconds); g_date_time_unref(now); } // get priority int priority = 0; xmpp_stanza_t *priority_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_PRIORITY); if (priority_stanza != NULL) { char *priority_str = xmpp_stanza_get_text(priority_stanza); if (priority_str != NULL) { priority = atoi(priority_str); } free(priority_str); } resource_presence_t presence = resource_presence_from_string(show_str); Resource *resource = NULL; // hack for servers that do not send fulljid with initial presence if (from_jid->resourcepart == NULL) { resource = resource_new("__prof_default", presence, status_str, priority, caps_key); } else { resource = resource_new(from_jid->resourcepart, presence, status_str, priority, caps_key); } // self presence if (strcmp(my_jid->barejid, from_jid->barejid) == 0) { connection_add_available_resource(resource); // contact presence } else { handle_contact_online(from_jid->barejid, resource, last_activity); } free(caps_key); free(status_str); free(show_str); jid_destroy(my_jid); jid_destroy(from_jid); if (last_activity != NULL) { g_date_time_unref(last_activity); } return 1; }
static gboolean update_clock (gpointer data) { GnomeWallClock *self = data; CDesktopClockFormat clock_format; const char *format_string; gboolean show_full_date; gboolean show_weekday; gboolean show_seconds; GSource *source; GDateTime *now; GDateTime *expiry; clock_format = g_settings_get_enum (self->priv->desktop_settings, "clock-format"); show_weekday = !self->priv->time_only; show_full_date = show_weekday && g_settings_get_boolean (self->priv->desktop_settings, "clock-show-date"); show_seconds = g_settings_get_boolean (self->priv->desktop_settings, "clock-show-seconds"); now = g_date_time_new_now_local (); if (show_seconds) expiry = g_date_time_add_seconds (now, 1); else expiry = g_date_time_add_seconds (now, 60 - g_date_time_get_second (now)); if (self->priv->clock_update_id) g_source_remove (self->priv->clock_update_id); source = _gnome_datetime_source_new (now, expiry, TRUE); g_source_set_priority (source, G_PRIORITY_HIGH); g_source_set_callback (source, update_clock, self, NULL); self->priv->clock_update_id = g_source_attach (source, NULL); g_source_unref (source); if (clock_format == C_DESKTOP_CLOCK_FORMAT_24H) { if (show_full_date) { /* Translators: This is the time format with full date used in 24-hour mode. */ format_string = show_seconds ? _("%a %b %e, %R:%S") : _("%a %b %e, %R"); } else if (show_weekday) { /* Translators: This is the time format with day used in 24-hour mode. */ format_string = show_seconds ? _("%a %R:%S") : _("%a %R"); } else { /* Translators: This is the time format without date used in 24-hour mode. */ format_string = show_seconds ? _("%R:%S") : _("%R"); } } else { if (show_full_date) { /* Translators: This is a time format with full date used for AM/PM. */ format_string = show_seconds ? _("%a %b %e, %l:%M:%S %p") : _("%a %b %e, %l:%M %p"); } else if (show_weekday) { /* Translators: This is a time format with day used for AM/PM. */ format_string = show_seconds ? _("%a %l:%M:%S %p") : _("%a %l:%M %p"); } else { /* Translators: This is a time format without date used for AM/PM. */ format_string = show_seconds ? _("%l:%M:%S %p") : _("%l:%M %p"); } } g_free (self->priv->clock_string); self->priv->clock_string = g_date_time_format (now, format_string); g_date_time_unref (now); g_date_time_unref (expiry); g_object_notify ((GObject*)self, "clock"); return FALSE; }
static gboolean parse_epg_dat_line (Request *req, gchar *line, GPtrArray *events) { gchar *duration_s, *start_time_s, *end_time_s, *date_s; gboolean start_in_between, end_in_between, englobing; gint year, month, day, hours, minutes, duration; GDateTime *start_date, *end_date; gint n_parsed; duration_s = cut_last_field_out (line); if (duration_s == NULL) goto no_duration; end_time_s = cut_last_field_out (line); if (end_time_s == NULL) goto no_end_time; start_time_s = cut_last_field_out (line); if (start_time_s == NULL) goto no_start_time; date_s = cut_last_field_out (line); if (date_s == NULL) goto no_date; n_parsed = sscanf (date_s, "%d/%d/%d", &day, &month, &year); if (n_parsed != 3) goto scanf_failed; n_parsed = sscanf (start_time_s, "%d:%d", &hours, &minutes); if (n_parsed != 2) goto scanf_failed; duration = atoi (duration_s); if (duration == 0) return TRUE; /* duration is always is seconds in Mex, minutes in the data files */ duration *= 60; start_date = g_date_time_new_local (year, month, day, hours, minutes, 0); end_date = g_date_time_add_seconds (start_date, duration); start_in_between = g_date_time_compare (start_date, req->start_date) >= 0 && g_date_time_compare (start_date, req->end_date) <= 0; end_in_between = g_date_time_compare (end_date, req->start_date) >= 0 && g_date_time_compare (end_date, req->end_date) <= 0; englobing = g_date_time_compare (start_date, req->start_date) <= 0 && g_date_time_compare (end_date, req->end_date) >= 0; if (start_in_between || end_in_between || englobing) { MexEpgEvent *event; MexProgram *program; event = mex_epg_event_new_with_date_time (start_date, duration); program = parse_program (line); if (program == NULL) goto program_failed; /* we add the duration here as parse_program don't do it and that we * need the duration in seconds instead of minutes */ duration_s = g_strdup_printf ("%d", duration); mex_program_set_metadata (program, MEX_CONTENT_METADATA_DURATION, duration_s); g_free (duration_s); mex_epg_event_set_program (event, program); g_object_unref (program); mex_epg_event_set_channel (event, req->channel); g_ptr_array_add (events, event); } return TRUE; program_failed: MEX_WARN (EPG, "could not create the program: %s", line); return FALSE; scanf_failed: MEX_WARN (EPG, "could not parse date or time: %s", line); return FALSE; no_date: MEX_WARN (EPG, "could not find the date: %s", line); return FALSE; no_start_time: MEX_WARN (EPG, "could not find the start time: %s", line); return FALSE; no_end_time: MEX_WARN (EPG, "could not find the end time: %s", line); return FALSE; no_duration: MEX_WARN (EPG, "could not find the duration: %s", line); return FALSE; }