[evolution-mapi] Bug #622567 - Do not search meeting invites in user's calendar
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-mapi] Bug #622567 - Do not search meeting invites in user's calendar
- Date: Thu, 24 Jun 2010 12:26:39 +0000 (UTC)
commit 0c34750f05e37a34e7f75702ee6dd0b4b59bf5a4
Author: Milan Crha <mcrha redhat com>
Date: Thu Jun 24 14:25:52 2010 +0200
Bug #622567 - Do not search meeting invites in user's calendar
src/libexchangemapi/exchange-mapi-cal-utils.c | 350 +-----------------------
src/libexchangemapi/exchange-mapi-connection.c | 5 -
2 files changed, 3 insertions(+), 352 deletions(-)
---
diff --git a/src/libexchangemapi/exchange-mapi-cal-utils.c b/src/libexchangemapi/exchange-mapi-cal-utils.c
index 9ee292c..8db5d49 100644
--- a/src/libexchangemapi/exchange-mapi-cal-utils.c
+++ b/src/libexchangemapi/exchange-mapi-cal-utils.c
@@ -959,317 +959,6 @@ exchange_mapi_cal_util_mapi_props_to_comp (ExchangeMapiConnection *conn, icalcom
#define TEMP_ATTACH_STORE ".evolution/cache/tmp"
-static void
-change_partstat (ECalComponent *comp, const gchar *att, const gchar *sentby, icalparameter_partstat partstat)
-{
- icalcomponent *icalcomp = e_cal_component_get_icalcomponent (comp);
- icalproperty *attendee;
- gboolean found = FALSE;
-
- attendee = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
- while (attendee) {
- const gchar *value = icalproperty_get_attendee (attendee);
- if (!g_ascii_strcasecmp (value, att)) {
- icalparameter *param = icalparameter_new_partstat (partstat);
- icalproperty_set_parameter (attendee, param);
- if (g_ascii_strcasecmp(att, sentby)) {
- icalparameter *sentby_param = icalparameter_new_sentby (sentby);
- icalproperty_set_parameter (attendee, sentby_param);
- }
- found = TRUE;
- break;
- }
- attendee = icalcomponent_get_next_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
- }
-
- if (found) {
- icalproperty *prop = icalproperty_new_x ("1");
- icalproperty_set_x_name (prop, "X-EVOLUTION-IS-REPLY");
- icalcomponent_add_property (icalcomp, prop);
- }
-
- e_cal_component_set_icalcomponent (comp, icalcomp);
-}
-
-static void
-remove_other_attendees (ECalComponent *comp, const gchar *att)
-{
- icalcomponent *icalcomp = e_cal_component_get_icalcomponent (comp);
- icalproperty *attendee;
-
- attendee = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
- while (attendee) {
- const gchar *value = icalproperty_get_attendee (attendee);
- if (g_ascii_strcasecmp (value, att))
- icalcomponent_remove_property (icalcomp, attendee);
-
- attendee = icalcomponent_get_next_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
- }
-
- e_cal_component_set_icalcomponent (comp, icalcomp);
-}
-
-static gboolean
-fetch_server_data_cb (FetchItemsCallbackData *item_data, gpointer data)
-{
- struct mapi_SPropValue_array *properties = item_data->properties;
- const mapi_id_t mid = item_data->mid;
- GSList *streams = item_data->streams;
- GSList *recipients = item_data->recipients;
- GSList *attachments = item_data->attachments;
-
- icalcomponent_kind kind = ICAL_VEVENT_COMPONENT;
- gchar *filename = g_build_filename (g_get_home_dir (), TEMP_ATTACH_STORE, NULL);
- gchar *fileuri = g_filename_to_uri (filename, NULL, NULL);
- gchar *smid = exchange_mapi_util_mapi_id_to_string (mid);
- ECalComponent *comp = exchange_mapi_cal_util_mapi_props_to_comp (item_data->conn, kind, smid, properties, streams, recipients, attachments, fileuri, NULL);
- struct cal_cbdata *cbdata = (struct cal_cbdata *)(data);
- const uint32_t *ui32;
-
- ui32 = (const uint32_t *)find_mapi_SPropValue_data(properties, PR_OWNER_APPT_ID);
- cbdata->appt_id = ui32 ? *ui32 : 0;
- ui32 = (const uint32_t *)find_mapi_SPropValue_data(properties, PROP_TAG(PT_LONG, 0x8201));
- cbdata->appt_seq = ui32 ? *ui32 : 0;
- cbdata->username = exchange_mapi_util_find_array_propval (properties, PR_SENT_REPRESENTING_NAME_UNICODE);
- cbdata->useridtype = exchange_mapi_util_find_array_propval (properties, PR_SENT_REPRESENTING_ADDRTYPE_UNICODE);
- cbdata->userid = exchange_mapi_util_find_array_propval (properties, PR_SENT_REPRESENTING_EMAIL_ADDRESS_UNICODE);
- cbdata->ownername = exchange_mapi_util_find_array_propval (properties, PR_SENDER_NAME_UNICODE);
- cbdata->owneridtype = exchange_mapi_util_find_array_propval (properties, PR_SENDER_ADDRTYPE_UNICODE);
- cbdata->ownerid = exchange_mapi_util_find_array_propval (properties, PR_SENDER_EMAIL_ADDRESS_UNICODE);
-
- cbdata->comp = comp;
-
- exchange_mapi_util_free_recipient_list (&recipients);
-
- g_free (smid);
- g_free (fileuri);
- g_free (filename);
-
- return TRUE;
-}
-
-static void
-fetch_server_data (ExchangeMapiConnection *conn, mapi_id_t mid, struct cal_cbdata *cbd)
-{
- icalcomponent_kind kind = ICAL_VEVENT_COMPONENT;
- mapi_id_t fid;
-
- fid = exchange_mapi_connection_get_default_folder_id (conn, olFolderCalendar);
-
- exchange_mapi_connection_fetch_item (conn, fid, mid,
- exchange_mapi_cal_utils_get_props_cb, GINT_TO_POINTER (kind),
- fetch_server_data_cb, cbd,
- MAPI_OPTIONS_FETCH_RECIPIENTS | MAPI_OPTIONS_FETCH_GENERIC_STREAMS);
-
-}
-
-static ECalComponent *
-update_attendee_status (ExchangeMapiConnection *conn, struct mapi_SPropValue_array *properties, mapi_id_t mid)
-{
- const gchar *att, *att_sentby, *addrtype;
- icalparameter_partstat partstat = ICAL_PARTSTAT_NONE;
- const gchar *state = (const gchar *) exchange_mapi_util_find_array_propval (properties, PR_MESSAGE_CLASS);
- struct cal_cbdata cbdata = { 0 };
- gchar *matt, *matt_sentby;
- uint32_t cur_seq;
- const uint32_t *ui32;
-
- if (!(state && *state))
- return NULL;
-
- if (!g_ascii_strcasecmp (state, IPM_SCHEDULE_MEETING_RESP_POS))
- partstat = ICAL_PARTSTAT_ACCEPTED;
- else if (!g_ascii_strcasecmp (state, IPM_SCHEDULE_MEETING_RESP_TENT))
- partstat = ICAL_PARTSTAT_TENTATIVE;
- else if (!g_ascii_strcasecmp (state, IPM_SCHEDULE_MEETING_RESP_NEG))
- partstat = ICAL_PARTSTAT_DECLINED;
- else
- return NULL;
-
- fetch_server_data (conn, mid, &cbdata);
-
- att = exchange_mapi_util_find_array_propval (properties, PR_SENT_REPRESENTING_EMAIL_ADDRESS_UNICODE);
- addrtype = exchange_mapi_util_find_array_propval (properties, PR_SENT_REPRESENTING_ADDRTYPE_UNICODE);
- if (addrtype && !g_ascii_strcasecmp (addrtype, "EX"))
- att = exchange_mapi_connection_ex_to_smtp (conn, att);
-
- att_sentby = exchange_mapi_util_find_array_propval (properties, PR_SENDER_EMAIL_ADDRESS_UNICODE);
- addrtype = exchange_mapi_util_find_array_propval (properties, PR_SENDER_ADDRTYPE_UNICODE);
- if (addrtype && !g_ascii_strcasecmp (addrtype, "EX"))
- att_sentby = exchange_mapi_connection_ex_to_smtp (conn, att_sentby);
-
- matt = g_strdup_printf ("MAILTO:%s", att);
- matt_sentby = g_strdup_printf ("MAILTO:%s", att_sentby);
-
- change_partstat (cbdata.comp, matt, matt_sentby, partstat);
-
- ui32 = (const uint32_t *) find_mapi_SPropValue_data(properties, PROP_TAG(PT_LONG, 0x8201));
- cur_seq = ui32 ? *ui32 : 0;
-
- if (cbdata.appt_seq == cur_seq) {
-
-/*
- * The itip-formatter provides an option to update the attendee's status.
- * Hence, we need not update the server straight away.
- */
-#if 0
- gchar *filename = g_build_filename (g_get_home_dir (), TEMP_ATTACH_STORE, NULL);
- gchar *fileuri = g_filename_to_uri (filename, NULL, NULL);
- GSList *attachments = NULL, *recipients = NULL, *streams = NULL;
-
- if (e_cal_component_has_attachments (cbdata.comp))
- exchange_mapi_cal_util_fetch_attachments (cbdata.comp, &attachments, fileuri);
-
- if (e_cal_component_has_attendees (cbdata.comp))
- exchange_mapi_cal_util_fetch_recipients (cbdata.comp, &recipients);
-
- cbdata.kind = kind;
- cbdata.meeting_type = (recipients != NULL) ? MEETING_OBJECT : NOT_A_MEETING;
- cbdata.resp = (recipients != NULL) ? olResponseOrganized : olResponseNone;
- cbdata.msgflags = MSGFLAG_READ;
- cbdata.is_modify = TRUE;
- cbdata.cleanglobalid = (const struct SBinary *)find_mapi_SPropValue_data(properties, PROP_TAG(PT_BINARY, 0x0023));
- cbdata.globalid = (const struct SBinary *)find_mapi_SPropValue_data(properties, PROP_TAG(PT_BINARY, 0x0003));
- cbdata.get_timezone = NULL;
- cbdata.get_tz_data = NULL;
-
- status = exchange_mapi_modify_item (conn, olFolderCalendar, fid, mid,
- exchange_mapi_cal_utils_write_props_cb, &cbdata,
- recipients, attachments, streams, MAPI_OPTIONS_DONT_SUBMIT);
- g_free (cbdata.props);
-
- exchange_mapi_util_free_recipient_list (&recipients);
- exchange_mapi_util_free_attachment_list (&attachments);
- g_free (fileuri);
- g_free (filename);
-#endif
-
- /* remove the other attendees so not to confuse itip-formatter */
- remove_other_attendees (cbdata.comp, matt);
- } else {
- g_free (cbdata.props);
- g_object_unref (cbdata.comp);
- cbdata.comp = NULL;
- }
-
- g_free (matt);
- g_free (matt_sentby);
-
- return cbdata.comp;
-}
-
-static void
-update_server_object (ExchangeMapiConnection *conn, struct mapi_SPropValue_array *properties, GSList *attachments, ECalComponent *comp, mapi_id_t *mid)
-{
- const uint32_t *ui32 = NULL;
- uint32_t cur_seq;
- mapi_id_t fid;
- gboolean create_new = TRUE;
-
- fid = exchange_mapi_connection_get_default_folder_id (conn, olFolderCalendar);
-
- ui32 = (const uint32_t *) find_mapi_SPropValue_data(properties, PROP_TAG(PT_LONG, 0x8201));
- cur_seq = ui32 ? *ui32 : 0;
-
- if (*mid) {
- struct cal_cbdata server_cbd = {0};
- fetch_server_data (conn, *mid, &server_cbd);
-
- if (cur_seq > server_cbd.appt_seq) {
- struct id_list idlist;
- GSList *ids = NULL;
-
- idlist.id = *mid;
- ids = g_slist_append (ids, &idlist);
-
- exchange_mapi_connection_remove_items (conn, olFolderCalendar, fid, 0, ids);
- g_slist_free (ids);
- } else
- create_new = FALSE;
-
- if (server_cbd.comp)
- g_object_unref (server_cbd.comp);
- g_free (server_cbd.props);
- }
-
- if (create_new) {
- struct cal_cbdata cbdata = { 0 };
- GSList *myrecipients = NULL;
- GSList *myattachments = NULL;
- icalcomponent_kind kind = icalcomponent_isa (e_cal_component_get_icalcomponent(comp));
-
- cbdata.kind = kind;
- cbdata.comp = comp;
- cbdata.username = (const gchar *) exchange_mapi_util_find_array_propval (properties, PR_SENDER_NAME_UNICODE);
- cbdata.useridtype = (const gchar *) exchange_mapi_util_find_array_propval (properties, PR_SENDER_ADDRTYPE_UNICODE);
- cbdata.userid = (const gchar *) exchange_mapi_util_find_array_propval (properties, PR_SENDER_EMAIL_ADDRESS_UNICODE);
- cbdata.ownername = (const gchar *) exchange_mapi_util_find_array_propval (properties, PR_SENT_REPRESENTING_NAME_UNICODE);
- cbdata.owneridtype = (const gchar *) exchange_mapi_util_find_array_propval (properties, PR_SENT_REPRESENTING_ADDRTYPE_UNICODE);
- cbdata.ownerid = (const gchar *) exchange_mapi_util_find_array_propval (properties, PR_SENT_REPRESENTING_EMAIL_ADDRESS_UNICODE);
- cbdata.is_modify = FALSE;
- cbdata.msgflags = MSGFLAG_READ;
- cbdata.meeting_type = MEETING_REQUEST_RCVD;
- cbdata.resp = olResponseNone;
- ui32 = find_mapi_SPropValue_data (properties, PROP_TAG (PT_LONG, 0x8201));
- cbdata.appt_seq = ui32 ? *ui32 : 0;
- ui32 = find_mapi_SPropValue_data (properties, PR_OWNER_APPT_ID);
- cbdata.appt_id = ui32 ? *ui32 : 0;
- cbdata.globalid = (const struct Binary_r *)find_mapi_SPropValue_data(properties, PROP_TAG(PT_BINARY, 0x0003));
- cbdata.cleanglobalid = (const struct Binary_r *)find_mapi_SPropValue_data(properties, PROP_TAG(PT_BINARY, 0x0023));
- cbdata.get_timezone = NULL;
- cbdata.get_tz_data = NULL;
-
- exchange_mapi_cal_util_fetch_recipients (comp, &myrecipients);
- myattachments = attachments;
- *mid = exchange_mapi_connection_create_item (conn, olFolderCalendar, 0,
- exchange_mapi_cal_utils_write_props_cb, &cbdata,
- myrecipients, myattachments, NULL, MAPI_OPTIONS_DONT_SUBMIT);
- g_free (cbdata.props);
- exchange_mapi_util_free_recipient_list (&myrecipients);
- }
-}
-
-static void
-check_server_for_object (ExchangeMapiConnection *conn, struct mapi_SPropValue_array *properties, mapi_id_t *mid)
-{
- struct mapi_SRestriction res;
- struct SPropValue sprop;
- const struct SBinary *sb;
- uint32_t proptag = 0x0;
- GSList *ids = NULL, *l;
- mapi_id_t fid;
-
- *mid = 0;
-
- fid = exchange_mapi_connection_get_default_folder_id (conn, olFolderCalendar);
-
- proptag = exchange_mapi_connection_resolve_named_prop (conn, fid, PidLidCleanGlobalObjectId);
-
- res.rt = RES_PROPERTY;
- res.res.resProperty.relop = RELOP_EQ;
- res.res.resProperty.ulPropTag = proptag;
-
- sb = (const struct SBinary *)find_mapi_SPropValue_data(properties, proptag);
- if (!sb)
- sb = find_mapi_SPropValue_data(properties, PidLidCleanGlobalObjectId);
-
- set_SPropValue_proptag (&sprop, proptag, (gconstpointer ) sb);
- cast_mapi_SPropValue (&(res.res.resProperty.lpProp), &sprop);
-
- ids = exchange_mapi_connection_check_restriction (conn, fid, 0, &res);
-
- if (ids && g_slist_length(ids) == 1) {
- struct id_list *idlist = (struct id_list *)(ids->data);
- *mid = idlist->id;
- } else {
- /* FIXME: what to do here? */
- }
-
- for (l = ids; l; l = l->next)
- g_free(l->data);
- g_slist_free(l);
-}
-
struct fetch_camel_cal_data {
icalcomponent_kind kind;
icalproperty_method method;
@@ -1283,7 +972,7 @@ fetch_camel_cal_comp_cb (FetchItemsCallbackData *item_data, gpointer data)
ECalComponent *comp = NULL;
mapi_id_t mid = 0;
icalcomponent *icalcomp = NULL;
- gchar *str = NULL, *smid = NULL, *tmp, *filename, *fileuri;
+ gchar *str = NULL, *smid = NULL, *filename, *fileuri;
g_return_val_if_fail (item_data != NULL, FALSE);
g_return_val_if_fail (fccd != NULL, FALSE);
@@ -1291,45 +980,12 @@ fetch_camel_cal_comp_cb (FetchItemsCallbackData *item_data, gpointer data)
filename = g_build_filename (g_get_home_dir (), TEMP_ATTACH_STORE, NULL);
fileuri = g_filename_to_uri (filename, NULL, NULL);
- check_server_for_object (item_data->conn, item_data->properties, &mid);
-
- if (fccd->method == ICAL_METHOD_REPLY) {
- if (mid) {
- comp = update_attendee_status (item_data->conn, item_data->properties, mid);
- set_attachments_to_cal_component (comp, item_data->attachments, fileuri);
- }
- } else if (fccd->method == ICAL_METHOD_CANCEL) {
- if (mid) {
- struct cal_cbdata server_cbd = { 0 };
- fetch_server_data (item_data->conn, mid, &server_cbd);
- comp = server_cbd.comp;
- set_attachments_to_cal_component (comp, item_data->attachments, fileuri);
-
- g_free (server_cbd.props);
- }
- } else if (fccd->method == ICAL_METHOD_REQUEST) {
- if (mid)
- smid = exchange_mapi_util_mapi_id_to_string (mid);
- else
- smid = e_cal_component_gen_uid();
-
- comp = exchange_mapi_cal_util_mapi_props_to_comp (item_data->conn, fccd->kind, smid,
- item_data->properties, item_data->streams, item_data->recipients,
- NULL, NULL, NULL);
- set_attachments_to_cal_component (comp, item_data->attachments, fileuri);
-
- update_server_object (item_data->conn, item_data->properties, item_data->attachments, comp, &mid);
-
- tmp = exchange_mapi_util_mapi_id_to_string (mid);
- e_cal_component_set_uid (comp, tmp);
- g_free (tmp);
- g_free (smid);
- }
-
if (!comp) {
/* read component from a mail, if not found in the calendar */
if (mid)
smid = exchange_mapi_util_mapi_id_to_string (mid);
+ else if (item_data->mid)
+ smid = exchange_mapi_util_mapi_id_to_string (item_data->mid);
else
smid = e_cal_component_gen_uid();
comp = exchange_mapi_cal_util_mapi_props_to_comp (item_data->conn, fccd->kind, smid,
diff --git a/src/libexchangemapi/exchange-mapi-connection.c b/src/libexchangemapi/exchange-mapi-connection.c
index 688f65b..1bc0d66 100644
--- a/src/libexchangemapi/exchange-mapi-connection.c
+++ b/src/libexchangemapi/exchange-mapi-connection.c
@@ -1147,11 +1147,6 @@ exchange_mapi_util_get_recipients (mapi_object_t *obj_message, GSList **recip_li
if (addrtype && !g_ascii_strcasecmp(addrtype, "SMTP"))
recipient->email_id = talloc_steal (recipient->mem_ctx, (const gchar *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_EMAIL_ADDRESS_UNICODE));
}
- /* fail */
- if (!recipient->email_id) {
- g_debug ("%s: %s() - object has a recipient without a PR_SMTP_ADDRESS ", G_STRLOC, G_STRFUNC);
- mapidump_SRow (&(rows_recip.aRow[i_row_recip]), " ");
- }
recipient->out_SRow.ulAdrEntryPad = rows_recip.aRow[i_row_recip].ulAdrEntryPad;
recipient->out_SRow.cValues = rows_recip.aRow[i_row_recip].cValues;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]