Lines 1535-1540
Link Here
|
1535 |
g_object_unref (message); |
1535 |
g_object_unref (message); |
1536 |
} |
1536 |
} |
1537 |
|
1537 |
|
|
|
1538 |
static gchar * |
1539 |
caldav_gen_file_from_uid_cal (ECalBackendCalDAV *cbdav, |
1540 |
icalcomponent *icalcomp) |
1541 |
{ |
1542 |
icalcomponent_kind my_kind; |
1543 |
const gchar *uid = NULL; |
1544 |
gchar *filename, *res; |
1545 |
|
1546 |
g_return_val_if_fail (cbdav != NULL, NULL); |
1547 |
g_return_val_if_fail (icalcomp != NULL, NULL); |
1548 |
|
1549 |
my_kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbdav)); |
1550 |
if (icalcomponent_isa (icalcomp) == ICAL_VCALENDAR_COMPONENT) { |
1551 |
icalcomponent *subcomp; |
1552 |
|
1553 |
for (subcomp = icalcomponent_get_first_component (icalcomp, my_kind); |
1554 |
subcomp; |
1555 |
subcomp = icalcomponent_get_next_component (icalcomp, my_kind)) { |
1556 |
uid = icalcomponent_get_uid (subcomp); |
1557 |
break; |
1558 |
} |
1559 |
} else if (icalcomponent_isa (icalcomp) == my_kind) { |
1560 |
uid = icalcomponent_get_uid (icalcomp); |
1561 |
} |
1562 |
|
1563 |
if (!uid) |
1564 |
return NULL; |
1565 |
|
1566 |
filename = g_strconcat (uid, ".ics", NULL); |
1567 |
res = soup_uri_encode (filename, NULL); |
1568 |
g_free (filename); |
1569 |
|
1570 |
return res; |
1571 |
} |
1572 |
|
1538 |
static gboolean |
1573 |
static gboolean |
1539 |
caldav_server_put_object (ECalBackendCalDAV *cbdav, |
1574 |
caldav_server_put_object (ECalBackendCalDAV *cbdav, |
1540 |
CalDAVObject *object, |
1575 |
CalDAVObject *object, |
Lines 1601-1607
Link Here
|
1601 |
} |
1636 |
} |
1602 |
|
1637 |
|
1603 |
if (status_code_to_result (message, priv, perror)) { |
1638 |
if (status_code_to_result (message, priv, perror)) { |
1604 |
gboolean was_get = FALSE; |
1639 |
GError *local_error = NULL; |
1605 |
|
1640 |
|
1606 |
hdr = soup_message_headers_get (message->response_headers, "ETag"); |
1641 |
hdr = soup_message_headers_get (message->response_headers, "ETag"); |
1607 |
if (hdr != NULL) { |
1642 |
if (hdr != NULL) { |
Lines 1627-1638
Link Here
|
1627 |
} |
1662 |
} |
1628 |
} |
1663 |
} |
1629 |
|
1664 |
|
1630 |
was_get = TRUE; |
1665 |
if (!caldav_server_get_object (cbdav, object, &local_error)) { |
1631 |
|
1666 |
if (g_error_matches (local_error, E_DATA_CAL_ERROR, NoSuchCal)) { |
1632 |
if (caldav_server_get_object (cbdav, object, perror)) { |
1667 |
gchar *file; |
|
|
1668 |
|
1669 |
/* OK, the event was properly created, but cannot be found on the place |
1670 |
where it was PUT - why didn't server tell us where it saved it? */ |
1671 |
g_clear_error (&local_error); |
1672 |
|
1673 |
/* try whether it's saved as its UID.ics file */ |
1674 |
file = caldav_gen_file_from_uid_cal (cbdav, icalcomp); |
1675 |
if (file) { |
1676 |
g_free (object->href); |
1677 |
object->href = file; |
1678 |
|
1679 |
if (!caldav_server_get_object (cbdav, object, &local_error)) { |
1680 |
if (g_error_matches (local_error, E_DATA_CAL_ERROR, NoSuchCal)) { |
1681 |
g_clear_error (&local_error); |
1682 |
|
1683 |
/* not sure what can happen, but do not need to guess for ever, |
1684 |
thus report success and update the calendar to get fresh info */ |
1685 |
cbdav->priv->slave_cmd = SLAVE_SHOULD_WORK; |
1686 |
g_cond_signal (cbdav->priv->cond); |
1687 |
} |
1688 |
} |
1689 |
} |
1690 |
} |
1691 |
} |
1692 |
|
1693 |
if (!local_error) { |
1633 |
icalcomponent *use_comp = NULL; |
1694 |
icalcomponent *use_comp = NULL; |
1634 |
|
1695 |
|
1635 |
if (object->cdata && was_get) { |
1696 |
if (object->cdata) { |
1636 |
/* maybe server also modified component, thus rather store the server's */ |
1697 |
/* maybe server also modified component, thus rather store the server's */ |
1637 |
use_comp = icalparser_parse_string (object->cdata); |
1698 |
use_comp = icalparser_parse_string (object->cdata); |
1638 |
} |
1699 |
} |
Lines 1644-1649
Link Here
|
1644 |
|
1705 |
|
1645 |
if (use_comp != icalcomp) |
1706 |
if (use_comp != icalcomp) |
1646 |
icalcomponent_free (use_comp); |
1707 |
icalcomponent_free (use_comp); |
|
|
1708 |
} else { |
1709 |
g_propagate_error (perror, local_error); |
1647 |
} |
1710 |
} |
1648 |
} else if (message->status_code == 401) { |
1711 |
} else if (message->status_code == 401) { |
1649 |
caldav_notify_auth_required (cbdav); |
1712 |
caldav_notify_auth_required (cbdav); |