static gboolean is_meeting_owner (ECalComponent *comp, ECalClient *client) { ECalComponentOrganizer org; gchar *email = NULL; const gchar *strip = NULL; gboolean ret_val = FALSE; if (!(e_cal_component_has_attendees (comp) && e_cal_client_check_save_schedules (client))) return ret_val; e_cal_component_get_organizer (comp, &org); strip = itip_strip_mailto (org.value); if (e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &email, NULL, NULL) && !g_ascii_strcasecmp (email, strip)) { ret_val = TRUE; } if (!ret_val) ret_val = itip_address_is_user (strip); g_free (email); return ret_val; }
static void set_data_and_props (SunOneInvitationList *list, int row) { SunOneInvitationListPrivate *priv = list->priv; BonoboControlFrame *control_frame; Bonobo_PropertyBag prop_bag; ECalComponent *comp; icalcomponent *top_level; char *string; CORBA_Environment ev; if (row == -1) { set_data (BONOBO_WIDGET (priv->control), ""); return; } comp = sunone_invitation_list_model_get_comp (priv->model, row); if (!comp) return; /* Set the from address on the control */ control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (priv->control)); prop_bag = bonobo_control_frame_get_control_property_bag (control_frame, NULL); if (prop_bag != CORBA_OBJECT_NIL){ ECalComponentOrganizer organizer; CORBA_exception_init (&ev); e_cal_component_get_organizer (comp, &organizer); bonobo_property_bag_client_set_value_string (prop_bag, "from_address", organizer.value, &ev); CORBA_exception_init (&ev); bonobo_property_bag_client_set_value_gint (prop_bag, "view_only", 1, &ev); Bonobo_Unknown_unref (prop_bag, &ev); CORBA_exception_free (&ev); } /* Send the icalendar code over */ top_level = toplevel_with_zones (list, comp); string = icalcomponent_as_ical_string_r (top_level); set_data (BONOBO_WIDGET (priv->control), string); g_free (string); icalcomponent_free (top_level); }
static gboolean matches_organizer (ECalComponent *comp, const gchar *str) { ECalComponentOrganizer org; e_cal_component_get_organizer (comp, &org); if (str && !*str) return TRUE; if ((org.value && e_util_strstrcase (org.value, str)) || (org.cn && e_util_strstrcase (org.cn, str))) return TRUE; return FALSE; }
CamelMimeMessage * scalix_appointment_to_mime_message (ScalixObject * object) { CamelMimeMessage *message; CamelMultipart *multipart; CamelMimePart *part; CamelMedium *medium; CamelStream *stream; CamelDataWrapper *wrapper; ECalComponentDateTime dtstart, dtend; ECalComponent *comp; ECalComponentText text; icalcomponent_kind kind; icalcomponent *icalcomp, *toplevel_comp; icaltimezone *zone = NULL; GSList *attachment_list = NULL; GSList *attachment_list_new = NULL; GSList *siter = NULL; GList *part_list = NULL; GList *iter = NULL; char *msgid; char *str, *meeting_status; const char *ouid = NULL; char *file_contents = NULL; char *full_path, *filename, *mime_filename; char *cid; int size; g_object_get (SCALIX_APPOINTMENT (object), "timezone", &zone, NULL); comp = E_CAL_COMPONENT (scalix_object_clone (object)); message = camel_mime_message_new (); medium = CAMEL_MEDIUM (message); camel_medium_add_header (medium, "X-Scalix-Class", "IPM.Appointment"); /* Preserve msg id if there is already one */ if (scalix_appointment_get (SCALIX_APPOINTMENT (comp), X_SCALIX_MSG_ID, &msgid)) { scalix_appointment_unset (SCALIX_APPOINTMENT (comp), X_SCALIX_MSG_ID); } else { msgid = camel_header_msgid_generate (); } camel_mime_message_set_message_id (message, msgid); /* subject */ e_cal_component_get_summary (comp, &text); if (text.value != NULL) { camel_mime_message_set_subject (message, text.value); } /* start day */ e_cal_component_get_dtstart (comp, &dtstart); if (!icaltime_get_timezone (*dtstart.value)) icaltime_set_timezone (dtstart.value, icaltimezone_get_builtin_timezone_from_tzid (dtstart.tzid)); /* end day */ e_cal_component_get_dtend (comp, &dtend); if (!icaltime_get_timezone (*dtend.value)) icaltime_set_timezone (dtend.value, icaltimezone_get_builtin_timezone_from_tzid (dtend.tzid)); /* set From: and Sender: */ if (e_cal_component_has_organizer (comp)) { ECalComponentOrganizer organizer; e_cal_component_get_organizer (comp, &organizer); if (!strncasecmp (organizer.value, "MAILTO:", 7)) { camel_medium_add_header (medium, "Sender", organizer.value + 7); camel_medium_add_header (medium, "From", organizer.value + 7); } } /* set the appropriate recipient headers from the recipient table */ if (e_cal_component_has_attendees (comp) && e_cal_component_has_organizer (comp)) { GSList *iter, *attendees = NULL; CamelInternetAddress *recipients_to = NULL; CamelInternetAddress *recipients_cc = NULL; meeting_status = "1"; e_cal_component_get_attendee_list (comp, &attendees); for (iter = attendees; iter; iter = iter->next) { ECalComponentAttendee *attendee = iter->data; const char *mail = NULL; /* attendee entries must start with MAILTO: */ if (strncasecmp (attendee->value, "MAILTO:", 7)) { continue; } mail = attendee->value + 7; if (attendee->role == ICAL_ROLE_REQPARTICIPANT) { if (recipients_to == NULL) { recipients_to = camel_internet_address_new (); } camel_internet_address_add (recipients_to, attendee->cn, mail); } else if (attendee->role == ICAL_ROLE_OPTPARTICIPANT) { if (recipients_cc == NULL) { recipients_cc = camel_internet_address_new (); } camel_internet_address_add (recipients_cc, attendee->cn, mail); } else { continue; } } if (recipients_to != NULL) { camel_mime_message_set_recipients (message, "To", recipients_to); camel_object_unref (recipients_to); } if (recipients_cc != NULL) { camel_mime_message_set_recipients (message, "Cc", recipients_cc); camel_object_unref (recipients_cc); } } else { meeting_status = "0"; } /* Clear properties */ scalix_appointment_unset (SCALIX_APPOINTMENT (comp), X_SCALIX_IMAP_UID); /* Render the text/calendar */ e_cal_component_commit_sequence (comp); icalcomp = e_cal_component_get_icalcomponent (comp); kind = icalcomponent_isa (icalcomp); if (kind != ICAL_VCALENDAR_COMPONENT) { /* If its not a VCALENDAR, make it one to simplify below */ toplevel_comp = e_cal_util_new_top_level (); icalcomponent_add_component (toplevel_comp, icalcomp); icalcomp = toplevel_comp; } /* set METHOD to PUSBLISH */ icalcomponent_set_method (icalcomp, ICAL_METHOD_PUBLISH); /* Add the VTIMEZONE components for start- and/or end-times */ if (zone) { icalcomponent_add_component (icalcomp, icaltimezone_get_component (zone)); } else if (dtstart.tzid) { icalcomponent_add_component (icalcomp, icaltimezone_get_component (icaltimezone_get_builtin_timezone_from_tzid (dtstart.tzid))); } if (dtstart.tzid && dtend.tzid && strcmp (dtstart.tzid, dtend.tzid) != 0) { icalcomponent_add_component (icalcomp, icaltimezone_get_component (icaltimezone_get_builtin_timezone_from_tzid (dtend.tzid))); } /* FIXME: do we leek icalcomponents here? */ if (e_cal_component_has_attachments (comp)) { multipart = camel_multipart_new (); camel_multipart_set_boundary (multipart, NULL); e_cal_component_get_uid (comp, &ouid); e_cal_component_get_attachment_list (comp, &attachment_list); for (siter = attachment_list; siter; siter = siter->next) { if (siter->data == NULL) continue; if (strstr (siter->data, "file://") != siter->data) continue; full_path = ((char *) siter->data) + strlen ("file://"); filename = g_strrstr (full_path, "/") + 1; mime_filename = filename + strlen (ouid) + 1; size = 0; file_contents = get_file_contents (full_path, &size); if (file_contents == NULL) continue; stream = camel_stream_mem_new_with_buffer (file_contents, size); wrapper = camel_data_wrapper_new (); camel_data_wrapper_construct_from_stream (wrapper, stream); camel_object_unref (stream); part = camel_mime_part_new (); camel_medium_set_content_object (CAMEL_MEDIUM (part), wrapper); camel_mime_part_set_filename (part, mime_filename); camel_mime_part_set_encoding (part, CAMEL_TRANSFER_ENCODING_BASE64); cid = camel_header_msgid_generate (); camel_mime_part_set_content_id (part, cid); camel_mime_part_set_description (part, mime_filename); camel_mime_part_set_disposition (part, "attachment"); part_list = g_list_append (part_list, part); attachment_list_new = g_slist_append (attachment_list_new, g_strdup_printf ("CID:%s", cid)); g_free (cid); } e_cal_component_set_attachment_list (comp, attachment_list_new); str = icalcomponent_as_ical_string (icalcomp); part = camel_mime_part_new (); camel_mime_part_set_content (part, str, strlen (str), "text/calendar; method=PUBLISH; charset=UTF-8"); part_list = g_list_prepend (part_list, part); for (iter = part_list; iter; iter = iter->next) { part = (CamelMimePart *) iter->data; camel_multipart_add_part (multipart, part); camel_object_unref (part); } camel_medium_set_content_object (CAMEL_MEDIUM (message), CAMEL_DATA_WRAPPER (multipart)); camel_object_unref (multipart); g_slist_free (attachment_list); g_slist_free (attachment_list_new); g_list_free (part_list); } else { str = icalcomponent_as_ical_string (icalcomp); camel_mime_part_set_content (CAMEL_MIME_PART (message), str, strlen (str), "text/calendar; method=PUBLISH; charset=UTF-8"); } scalix_appointment_set (SCALIX_APPOINTMENT (object), X_SCALIX_MSG_ID, msgid); return message; }
/** Collect recipients from the iTip (based on the METHOD). * * To exclude username from the list, pass his name using @a sender * parameter. * * @param icomp iCal component. * @param sender Username to exclude from the list. * @param recipients Pointer to the list of recipients' emails. It will be * appended to. */ void icalcomponent_collect_recipients(icalcomponent *icomp, const char *sender, GSList * *recipients) { GSList *to_list = NULL, *attendees = NULL, *iter; ECalComponentOrganizer organizer; icalproperty_method method; icalcomponent *payload; ECalComponent *ecomp = NULL; payload = icalcomponent_get_itip_payload(icomp); method = icalcomponent_get_itip_method(icomp); if (payload == NULL) { goto out; } ecomp = e_cal_component_new(); e_cal_component_set_icalcomponent(ecomp, icalcomponent_new_clone(payload)); e_cal_component_get_attendee_list(ecomp, &attendees); e_cal_component_get_organizer(ecomp, &organizer); if (organizer.value == NULL) { goto out; } switch (method) { case ICAL_METHOD_REQUEST: case ICAL_METHOD_CANCEL: for (iter = attendees; iter; iter = iter->next) { ECalComponentAttendee *att = iter->data; if (!g_ascii_strcasecmp(att->value, organizer.value)) { continue; } else if (att->sentby && !g_ascii_strcasecmp(att->sentby, organizer.sentby)) { continue; } else if (!g_ascii_strcasecmp(strip_mailto(att->value), sender)) { continue; } else if (att->status == ICAL_PARTSTAT_DELEGATED && (att->delto && *att->delto) && !(att->rsvp) && method == ICAL_METHOD_REQUEST) { continue; } to_list = g_slist_append(to_list, g_strdup(strip_mailto(att->value))); } break; case ICAL_METHOD_REPLY: to_list = g_slist_append(to_list, g_strdup(strip_mailto(organizer.value))); break; case ICAL_METHOD_ADD: case ICAL_METHOD_REFRESH: case ICAL_METHOD_COUNTER: case ICAL_METHOD_DECLINECOUNTER: to_list = g_slist_append(to_list, g_strdup(strip_mailto(organizer.value))); // send the status to delegatee to the delegate also is missing break; case ICAL_METHOD_PUBLISH: default: break; } out: e_cal_component_free_attendee_list(attendees); if (ecomp) { g_object_unref(ecomp); } if (recipients) { *recipients = to_list; } }
static void set_itip_view (SunOneInvitationList *list, int row) { SunOneInvitationListPrivate *priv = list->priv; ECalComponent *comp; ECalComponentText text; const char *string; ECalComponentDateTime datetime; GString *gstring = NULL; GSList *description_list, *l; SunOneItipView *itip_view; ECalComponentOrganizer organizer; if (row == -1) { if (GTK_WIDGET_VISIBLE (priv->control)) gtk_widget_hide (priv->control); return; } comp = sunone_invitation_list_model_get_comp (priv->model, row); if (!comp) return; itip_view = (SunOneItipView *)priv->control; sunone_itip_view_set_mode (itip_view, SUNONE_ITIP_VIEW_MODE_REQUEST); sunone_itip_view_set_item_type (itip_view, E_CAL_SOURCE_TYPE_EVENT); e_cal_component_get_organizer (comp, &organizer); sunone_itip_view_set_organizer (itip_view, organizer.cn ? organizer.cn : itip_strip_mailto (organizer.value)); sunone_itip_view_set_sentby (itip_view, organizer.sentby); e_cal_component_get_summary (comp, &text); sunone_itip_view_set_summary (itip_view, text.value ? text.value : _("None")); e_cal_component_get_location (comp, &string); sunone_itip_view_set_location (itip_view, string); e_cal_component_get_description_list (comp, &description_list); for (l = description_list; l; l = l->next) { ECalComponentText *text = l->data; if (!gstring && text->value) gstring = g_string_new (text->value); else if (text->value) g_string_append_printf (gstring, "\n\n%s", text->value); } e_cal_component_free_text_list (description_list); if (gstring) { sunone_itip_view_set_description (itip_view, gstring->str); g_string_free (gstring, TRUE); } else sunone_itip_view_set_description (itip_view, NULL); e_cal_component_get_dtstart (comp, &datetime); if (datetime.value) { struct tm start_tm; start_tm = icaltimetype_to_tm_with_zone (datetime.value, icaltimezone_get_utc_timezone (), priv->model->zone); sunone_itip_view_set_start (itip_view, &start_tm); } e_cal_component_free_datetime (&datetime); e_cal_component_get_dtend (comp, &datetime); if (datetime.value) { struct tm end_tm; end_tm = icaltimetype_to_tm_with_zone (datetime.value, icaltimezone_get_utc_timezone (), priv->model->zone); sunone_itip_view_set_end (itip_view, &end_tm); } e_cal_component_free_datetime (&datetime); /* Recurrence info */ sunone_itip_view_clear_upper_info_items (itip_view); if (e_cal_component_has_recurrences (comp)) { sunone_itip_view_add_upper_info_item (itip_view, SUNONE_ITIP_VIEW_INFO_ITEM_TYPE_INFO, "This meeting recurs"); } sunone_itip_view_set_status (itip_view, NULL); sunone_itip_view_set_comment (itip_view, NULL); sunone_itip_view_set_show_rsvp (itip_view, FALSE); if (!GTK_WIDGET_VISIBLE (priv->control)) gtk_widget_show (priv->control); }
static void preview_comp (EWebViewPreview *preview, ECalComponent *comp) { ECalComponentText text = { 0 }; ECalComponentDateTime dt; ECalComponentClassification classif; const gchar *str; gchar *tmp; gint percent; gboolean have; GHashTable *timezones; icaltimezone *users_zone; GSList *slist, *l; g_return_if_fail (preview != NULL); g_return_if_fail (comp != NULL); timezones = g_object_get_data (G_OBJECT (preview), "iCalImp-timezones"); users_zone = g_object_get_data (G_OBJECT (preview), "iCalImp-userszone"); str = NULL; switch (e_cal_component_get_vtype (comp)) { case E_CAL_COMPONENT_EVENT: str = e_cal_component_has_attendees (comp) ? C_("iCalImp", "Meeting") : C_("iCalImp", "Event"); break; case E_CAL_COMPONENT_TODO: str = C_("iCalImp", "Task"); break; case E_CAL_COMPONENT_JOURNAL: str = C_("iCalImp", "Memo"); break; default: str = "??? Other ???"; break; } have = FALSE; if (e_cal_component_has_recurrences (comp)) { e_web_view_preview_add_section (preview, have ? NULL : str, C_("iCalImp", "has recurrences")); have = TRUE; } if (e_cal_component_is_instance (comp)) { e_web_view_preview_add_section (preview, have ? NULL : str, C_("iCalImp", "is an instance")); have = TRUE; } if (e_cal_component_has_alarms (comp)) { e_web_view_preview_add_section (preview, have ? NULL : str, C_("iCalImp", "has reminders")); have = TRUE; } if (e_cal_component_has_attachments (comp)) { e_web_view_preview_add_section (preview, have ? NULL : str, C_("iCalImp", "has attachments")); have = TRUE; } if (!have) { e_web_view_preview_add_section (preview, str, ""); } str = NULL; classif = E_CAL_COMPONENT_CLASS_NONE; e_cal_component_get_classification (comp, &classif); if (classif == E_CAL_COMPONENT_CLASS_PUBLIC) { /* Translators: Appointment's classification */ str = C_("iCalImp", "Public"); } else if (classif == E_CAL_COMPONENT_CLASS_PRIVATE) { /* Translators: Appointment's classification */ str = C_("iCalImp", "Private"); } else if (classif == E_CAL_COMPONENT_CLASS_CONFIDENTIAL) { /* Translators: Appointment's classification */ str = C_("iCalImp", "Confidential"); } if (str) /* Translators: Appointment's classification section name */ e_web_view_preview_add_section (preview, C_("iCalImp", "Classification"), str); e_cal_component_get_summary (comp, &text); if ((text.value && *text.value) || (text.altrep && *text.altrep)) /* Translators: Appointment's summary */ e_web_view_preview_add_section (preview, C_("iCalImp", "Summary"), (text.value && *text.value) ? text.value : text.altrep); str = NULL; e_cal_component_get_location (comp, &str); if (str && *str) /* Translators: Appointment's location */ e_web_view_preview_add_section (preview, C_("iCalImp", "Location"), str); dt.value = NULL; e_cal_component_get_dtstart (comp, &dt); if (dt.value) { tmp = format_dt (&dt, timezones, users_zone); if (tmp) /* Translators: Appointment's start time */ e_web_view_preview_add_section (preview, C_("iCalImp", "Start"), tmp); g_free (tmp); } e_cal_component_free_datetime (&dt); dt.value = NULL; e_cal_component_get_due (comp, &dt); if (dt.value) { tmp = format_dt (&dt, timezones, users_zone); if (tmp) /* Translators: 'Due' like the time due a task should be finished */ e_web_view_preview_add_section (preview, C_("iCalImp", "Due"), tmp); g_free (tmp); } else { e_cal_component_free_datetime (&dt); dt.value = NULL; e_cal_component_get_dtend (comp, &dt); if (dt.value) { tmp = format_dt (&dt, timezones, users_zone); if (tmp) /* Translators: Appointment's end time */ e_web_view_preview_add_section (preview, C_("iCalImp", "End"), tmp); g_free (tmp); } } e_cal_component_free_datetime (&dt); str = NULL; e_cal_component_get_categories (comp, &str); if (str && *str) /* Translators: Appointment's categories */ e_web_view_preview_add_section (preview, C_("iCalImp", "Categories"), str); percent = e_cal_component_get_percent_as_int (comp); if (percent >= 0) { tmp = NULL; if (percent == 100) { icaltimetype *completed = NULL; e_cal_component_get_completed (comp, &completed); if (completed) { dt.tzid = "UTC"; dt.value = completed; tmp = format_dt (&dt, timezones, users_zone); e_cal_component_free_icaltimetype (completed); } } if (!tmp) tmp = g_strdup_printf ("%d%%", percent); /* Translators: Appointment's complete value (either percentage, or a date/time of a completion) */ e_web_view_preview_add_section (preview, C_("iCalImp", "Completed"), tmp); g_free (tmp); } str = NULL; e_cal_component_get_url (comp, &str); if (str && *str) /* Translators: Appointment's URL */ e_web_view_preview_add_section (preview, C_("iCalImp", "URL"), str); if (e_cal_component_has_organizer (comp)) { ECalComponentOrganizer organizer = { 0 }; e_cal_component_get_organizer (comp, &organizer); if (organizer.value && *organizer.value) { if (organizer.cn && *organizer.cn) { tmp = g_strconcat (organizer.cn, " <", strip_mailto (organizer.value), ">", NULL); /* Translators: Appointment's organizer */ e_web_view_preview_add_section (preview, C_("iCalImp", "Organizer"), tmp); g_free (tmp); } else { e_web_view_preview_add_section (preview, C_("iCalImp", "Organizer"), strip_mailto (organizer.value)); } } } if (e_cal_component_has_attendees (comp)) { GSList *attendees = NULL, *a; have = FALSE; e_cal_component_get_attendee_list (comp, &attendees); for (a = attendees; a; a = a->next) { ECalComponentAttendee *attnd = a->data; if (!attnd || !attnd->value || !*attnd->value) continue; if (attnd->cn && *attnd->cn) { tmp = g_strconcat (attnd->cn, " <", strip_mailto (attnd->value), ">", NULL); /* Translators: Appointment's attendees */ e_web_view_preview_add_section (preview, have ? NULL : C_("iCalImp", "Attendees"), tmp); g_free (tmp); } else { e_web_view_preview_add_section (preview, have ? NULL : C_("iCalImp", "Attendees"), strip_mailto (attnd->value)); } have = TRUE; } e_cal_component_free_attendee_list (attendees); } slist = NULL; e_cal_component_get_description_list (comp, &slist); for (l = slist; l; l = l->next) { ECalComponentText *txt = l->data; e_web_view_preview_add_section (preview, l != slist ? NULL : C_("iCalImp", "Description"), (txt && txt->value) ? txt->value : ""); } e_cal_component_free_text_list (slist); }