@@ -246,6 +246,7 @@ public class Services.CalDAV : GLib.Object {
246
246
< d: sync- level> 1 < / d: sync- level>
247
247
< d: prop>
248
248
< d: getetag/ >
249
+ < d: getcontenttype/ >
249
250
< / d: prop>
250
251
< / d: sync- collection>
251
252
" " " ;
@@ -610,7 +611,6 @@ public class Services.CalDAV : GLib.Object {
610
611
var username = Services . Settings . get_default (). settings. get_string (" caldav-username" );
611
612
612
613
var url = " %s /remote.php/dav/calendars/%s /%s " . printf (server_url, username, project. id);
613
- print (" URL: %s\n " . printf (url));
614
614
var message = new Soup .Message (" REPORT" , url);
615
615
yield set_credential (message);
616
616
message. set_request_body_from_bytes (" application/xml" , new Bytes ((SYNC_TOKEN_REQUEST . printf (project. sync_id)). data));
@@ -628,53 +628,57 @@ public class Services.CalDAV : GLib.Object {
628
628
foreach (GXml . DomElement element in response) {
629
629
GXml . DomHTMLCollection status = element. get_elements_by_tag_name (" d:status" );
630
630
string ics = get_task_ics_from_url (element);
631
-
632
- if (status. length > 0 && status. get_element (0 ). text_content == " HTTP/1.1 404 Not Found" ) {
633
- Objects . Item ? item = Services . Database . get_default (). get_item_by_ics (ics);
634
- if (item != null ) {
635
- Services . Database . get_default (). delete_item (item);
636
- }
637
- } else {
638
- string vtodo = yield get_vtodo_by_url (project. id, ics);
639
-
640
- ICal . Component ical = new ICal .Component .from_string (vtodo);
641
- Objects . Item ? item = Services . Database . get_default (). get_item (ical. get_uid ());
642
-
643
- if (item != null ) {
644
- string old_project_id = item. project_id;
645
- string old_parent_id = item. parent_id;
646
-
647
- item. update_from_vtodo (vtodo, ics);
648
- item. project_id = project. id;
649
- Services . Database . get_default (). update_item (item);
650
-
651
- if (old_project_id != item. project_id || old_parent_id != item. parent_id) {
652
- Services . EventBus . get_default (). item_moved (item, old_project_id, " " , old_parent_id);
653
- }
654
-
655
- bool old_checked = item. checked;
656
- if (old_checked != item. checked) {
657
- Services . Database . get_default (). checked_toggled (item, old_checked);
631
+ bool is_vtodo = is_vtodo (element);
632
+ print (" is_vtodo: %s\n " . printf (is_vtodo. to_string ()));
633
+
634
+ if (is_vtodo) {
635
+ if (status. length > 0 && status. get_element (0 ). text_content == " HTTP/1.1 404 Not Found" ) {
636
+ Objects . Item ? item = Services . Database . get_default (). get_item_by_ics (ics);
637
+ if (item != null ) {
638
+ Services . Database . get_default (). delete_item (item);
658
639
}
659
640
} else {
660
- string parent_id = Util . find_string_value (" RELATED-TO" , vtodo);
661
- if (parent_id != " " ) {
662
- Objects . Item ? parent_item = Services . Database . get_default (). get_item (parent_id);
663
- if (parent_item != null ) {
664
- var new_item = new Objects .Item .from_vtodo (vtodo, ics);
665
- new_item. project_id = project. id;
666
- parent_item. add_item_if_not_exists (new_item);
641
+ string vtodo = yield get_vtodo_by_url (project. id, ics);
642
+
643
+ ICal . Component ical = new ICal .Component .from_string (vtodo);
644
+ Objects . Item ? item = Services . Database . get_default (). get_item (ical. get_uid ());
645
+
646
+ if (item != null ) {
647
+ string old_project_id = item. project_id;
648
+ string old_parent_id = item. parent_id;
649
+
650
+ item. update_from_vtodo (vtodo, ics);
651
+ item. project_id = project. id;
652
+ Services . Database . get_default (). update_item (item);
653
+
654
+ if (old_project_id != item. project_id || old_parent_id != item. parent_id) {
655
+ Services . EventBus . get_default (). item_moved (item, old_project_id, " " , old_parent_id);
656
+ }
657
+
658
+ bool old_checked = item. checked;
659
+ if (old_checked != item. checked) {
660
+ Services . Database . get_default (). checked_toggled (item, old_checked);
661
+ }
662
+ } else {
663
+ string parent_id = Util . find_string_value (" RELATED-TO" , vtodo);
664
+ if (parent_id != " " ) {
665
+ Objects . Item ? parent_item = Services . Database . get_default (). get_item (parent_id);
666
+ if (parent_item != null ) {
667
+ var new_item = new Objects .Item .from_vtodo (vtodo, ics);
668
+ new_item. project_id = project. id;
669
+ parent_item. add_item_if_not_exists (new_item);
670
+ } else {
671
+ var new_item = new Objects .Item .from_vtodo (vtodo, ics);
672
+ new_item. project_id = project. id;
673
+ project. add_item_if_not_exists (new_item);
674
+ }
667
675
} else {
668
676
var new_item = new Objects .Item .from_vtodo (vtodo, ics);
669
677
new_item. project_id = project. id;
670
678
project. add_item_if_not_exists (new_item);
671
679
}
672
- } else {
673
- var new_item = new Objects .Item .from_vtodo (vtodo, ics);
674
- new_item. project_id = project. id;
675
- project. add_item_if_not_exists (new_item);
676
- }
677
- }
680
+ }
681
+ }
678
682
}
679
683
}
680
684
@@ -740,6 +744,19 @@ public class Services.CalDAV : GLib.Object {
740
744
return parts[parts. length - 1 ];
741
745
}
742
746
747
+ public bool is_vtodo (GXml . DomElement element) {
748
+ bool return_value = false ;
749
+ GXml . DomElement propstat = element. get_elements_by_tag_name (" d:propstat" ). get_element (0 );
750
+ GXml . DomElement prop = propstat. get_elements_by_tag_name (" d:prop" ). get_element (0 );
751
+ GXml . DomElement getcontenttype = prop. get_elements_by_tag_name (" d:getcontenttype" ). get_element (0 );
752
+
753
+ if (getcontenttype. text_content. index_of (" vtodo" ) > - 1 ) {
754
+ return_value = true ;
755
+ }
756
+
757
+ return return_value;
758
+ }
759
+
743
760
/*
744
761
* Tasklist
745
762
*/
0 commit comments