static gboolean matches_status (ECalComponent *comp ,const gchar *str) { icalproperty_status status; if (!*str) return FALSE; e_cal_component_get_status (comp, &status); if (g_str_equal (str, "NOT STARTED") && status == ICAL_STATUS_NONE) return TRUE; else if (g_str_equal (str, "COMPLETED") && status == ICAL_STATUS_COMPLETED) return TRUE; else if (g_str_equal (str, "CANCELLED") && status == ICAL_STATUS_CANCELLED) return TRUE; else if (g_str_equal (str, "IN PROGRESS") && status == ICAL_STATUS_INPROCESS) return TRUE; else if (g_str_equal (str, "NEEDS ACTION") && status == ICAL_STATUS_NEEDSACTION) return TRUE; else if (g_str_equal (str, "TENTATIVE") && status == ICAL_STATUS_TENTATIVE) return TRUE; else if (g_str_equal (str, "CONFIRMED") && status == ICAL_STATUS_CONFIRMED) return TRUE; else if (g_str_equal (str, "DRAFT") && status == ICAL_STATUS_DRAFT) return TRUE; else if (g_str_equal (str, "FINAL") && status == ICAL_STATUS_FINAL) return TRUE; return FALSE; }
icalproperty_status evo_cal_component_get_status(ECalComponent *obj) { icalproperty_status status; e_cal_component_get_status(obj, &status); return status; }
static gboolean task_get_completed (JanaTask *self) { ECalComponent *comp; icalproperty_status status; g_object_get (self, "ecalcomp", &comp, NULL); e_cal_component_get_status (comp, &status); g_object_unref (comp); return (status == ICAL_STATUS_COMPLETED); }
static void cal_component_preview_write_html (ECalComponentPreview *preview, GString *buffer) { ECalClient *client; ECalComponent *comp; icaltimezone *default_zone; ECalComponentText text; ECalComponentDateTime dt; gchar *str; GString *string; GSList *list, *iter; icalcomponent *icalcomp; icalproperty *icalprop; icalproperty_status status; const gchar *location; gint *priority_value; client = preview->priv->client; comp = preview->priv->comp; default_zone = preview->priv->timezone; /* write document header */ e_cal_component_get_summary (comp, &text); g_string_append (buffer, HTML_HEADER); g_string_append (buffer, "<body class=\"-e-web-view-background-color -e-web-view-text-color\">"); if (text.value) g_string_append_printf (buffer, "<h2>%s</h2>", text.value); else g_string_append_printf (buffer, "<h2><i>%s</i></h2>",_("Untitled")); g_string_append (buffer, "<table border=\"0\" cellspacing=\"5\">"); /* write icons for the categories */ string = g_string_new (NULL); e_cal_component_get_categories_list (comp, &list); if (list != NULL) g_string_append_printf (buffer, "<tr><th>%s</th><td>", _("Categories:")); for (iter = list; iter != NULL; iter = iter->next) { const gchar *category = iter->data; gchar *icon_file; icon_file = e_categories_dup_icon_file_for (category); if (icon_file && g_file_test (icon_file, G_FILE_TEST_EXISTS)) { gchar *uri; uri = g_filename_to_uri (icon_file, NULL, NULL); g_string_append_printf ( buffer, "<img alt=\"%s\" src=\"evo-%s\">", category, uri); g_free (uri); } else { if (iter != list) g_string_append_len (string, ", ", 2); g_string_append (string, category); } g_free (icon_file); } if (string->len > 0) g_string_append_printf (buffer, "%s", string->str); if (list != NULL) g_string_append (buffer, "</td></tr>"); e_cal_component_free_categories_list (list); g_string_free (string, TRUE); /* write location */ e_cal_component_get_location (comp, &location); if (location) g_string_append_printf ( buffer, "<tr><th>%s</th><td>%s</td></tr>", _("Summary:"), text.value); /* write start date */ e_cal_component_get_dtstart (comp, &dt); if (dt.value != NULL) { str = timet_to_str_with_zone (&dt, client, default_zone); g_string_append_printf ( buffer, "<tr><th>%s</th><td>%s</td></tr>", _("Start Date:"), str); g_free (str); } e_cal_component_free_datetime (&dt); /* write end date */ e_cal_component_get_dtend (comp, &dt); if (dt.value != NULL) { str = timet_to_str_with_zone (&dt, client, default_zone); g_string_append_printf ( buffer,"<tr><th>%s</th><td>%s</td></tr>", _("End Date:"), str); g_free (str); } e_cal_component_free_datetime (&dt); /* write Due Date */ e_cal_component_get_due (comp, &dt); if (dt.value != NULL) { str = timet_to_str_with_zone (&dt, client, default_zone); g_string_append_printf ( buffer, "<tr><th>%s</th><td>%s</td></tr>", _("Due Date:"), str); g_free (str); } e_cal_component_free_datetime (&dt); /* write status */ icalcomp = e_cal_component_get_icalcomponent (comp); icalprop = icalcomponent_get_first_property ( icalcomp, ICAL_STATUS_PROPERTY); if (icalprop != NULL) { g_string_append_printf ( buffer, "<tr><th>%s</th>", _("Status:")); e_cal_component_get_status (comp, &status); switch (status) { case ICAL_STATUS_INPROCESS : str = g_strdup (_("In Progress")); break; case ICAL_STATUS_COMPLETED : str = g_strdup (_("Completed")); break; case ICAL_STATUS_CANCELLED : str = g_strdup (_("Cancelled")); break; case ICAL_STATUS_NONE : default : str = g_strdup (_("Not Started")); break; } g_string_append_printf (buffer, "<td>%s</td></tr>", str); g_free (str); } /* write priority */ e_cal_component_get_priority (comp, &priority_value); if (priority_value && *priority_value != 0) { g_string_append_printf ( buffer, "<tr><th>%s</th>", _("Priority:")); if (*priority_value <= 4) str = g_strdup (_("High")); else if (*priority_value == 5) str = g_strdup (_("Normal")); else str = g_strdup (_("Low")); g_string_append_printf (buffer, "<td>%s</td></tr>", str); g_free (str); } if (priority_value) e_cal_component_free_priority (priority_value); /* write description and URL */ g_string_append (buffer, "<tr><td colspan=\"2\"><hr></td></tr>"); e_cal_component_get_description_list (comp, &list); if (list) { GSList *node; g_string_append_printf ( buffer, "<tr><th>%s</th>", _("Description:")); g_string_append (buffer, "<td class=\"description\">"); for (node = list; node != NULL; node = node->next) { gchar *html; text = * (ECalComponentText *) node->data; html = camel_text_to_html ( text.value ? text.value : "", CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES | CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES, 0); if (html) g_string_append_printf (buffer, "%s", html); g_free (html); } g_string_append (buffer, "</td></tr>"); e_cal_component_free_text_list (list); } /* URL */ e_cal_component_get_url (comp, (const gchar **) &str); if (str) { g_string_append_printf ( buffer, "<tr><th>%s</th><td><a href=\"%s\">%s</a></td></tr>", _("Web Page:"), str, str); } g_string_append (buffer, "</table>"); /* close document */ g_string_append (buffer, "</body></html>"); }