dupondje / PHP-Push-2

Z-Push Fork With CalDAV/LDAP Support
GNU Affero General Public License v3.0
67 stars 24 forks source link

CardDAV.php not working against SabreDAV in owncloud 5.0.7 #80

Open arved opened 11 years ago

arved commented 11 years ago

first of all thanks for this great project. After days of despair while trying to bring the CardDav up an running. I've done some investigation in this. I try to get PHP-Push-2 running on a device with owncloud 5.0.7. CalDAV ist working without problems. But I never got managend to get CardDAV up. After checking the code a litte bit, my /config.php file looks like this and shoud be correct (I hope):

define('CARDDAV_SERVER', 'http://localhost');
define('CARDDAV_PORT', '80');
define('CARDDAV_PATH', '/owncloud/remote.php/carddav/addressbooks/%u/');
define('CARDDAV_PRINCIPAL', 'contacts'); //Personal CardDAV folder

The log-file on debug level shows a lot of thess kind of entries:

30/06/2013 16:24:40 [ 7662] [ INFO] [user1] [SEC169xxxxxxxxxxxxx] BackendCardDAV->Logon(): User 'user1' is authenticated on CardDAV

and from time to time something like this:

30/06/2013 16:24:37 [ 7560] [DEBUG] [user1] [SEC169BACE18BCE5] BackendCardDAV->GetMessageList('contacts','1356531877')

but sync in both ways silently fails. no hint.

CardDAV via Firefox / Andriod CardDAV App ist working without any issues. So I tracked the functions and classes a litte and found, that in the file /include/carddav.php the function public function get_all_vcards($include_vcards = true, $raw = false) with will get all the vCards silently fails.

the line
$result = $this->query($this->url, 'REPORT', $content, $content_type); ($result['http_code']) results in the values 403 or more rare 401. This result is not handled in the code as far as I see. An more worse: I have no Idea how to correct it. Unfortually I am not really good in php.

Another thing was, that the way of CARDDAV_PATH and CARDDAV_PRINCIPAL are merged to an complete url semms to be different in different code parts. But maybe it's beyond my knowledge.

Update (2013-07-01):

After doning some investigations it seems, that the main issue on having CardDAV not working against sabreDAV, it apperars that sabreDAV does not support the "sync-collection" command, used in /include/carddav.php:

public function get_all_vcards($include_vcards = true, $raw = false) ....

$content = '<?xml version="1.0" encoding="utf-8" ?>/D:sync-token/C:address-data/D:prop/D:sync-collection';

After made some minor changes to this file to avoid the access problems (Changing any apperance of CURLAUTH_ANY to CURLAUTH_BASIC, ans adding this

if ($this->auth !== null)
{

    curl_setopt($this->curl, CURLOPT_HTTPAUTH,  CURLAUTH_BASIC);
    curl_setopt($this->curl, CURLOPT_USERPWD, $this->auth);

}

direct before the

$complete_response  = curl_exec($this->curl);

line in the query function

As far as I see the function get_all_vcards exists not in the carddav.php repository, so I assume, that this function ist created in this project.

Maybe it will work, when this CardDAV report body is replaced by something compareable with a PROPFIND or addressbook-query statement?

pulser commented 11 years ago

I am having the same issue.

get_all_vcards is defined in include/carddav.php (https://github.com/fmbiete/PHP-Push-2/blob/master/include/carddav.php#L298).

I am looking at this pull request to Z-Push that looks to be what we want. https://github.com/fmbiete/Z-Push-contrib/pull/1/

arved commented 11 years ago

thanks. I'm new to this and didn't find the reference. I was glad to dig town to this, because i do not have any php / CardDAV skills There are more open Issues on CardDAV. Does it make sense to aggregate these or are there other root causes?

pulser commented 11 years ago

I don't really have much CardDAV knowledge either. I know a little bit of PHP. I'm currently trying to cobble something together that works. There's a number of issues RE cardDAV, but I really don't know what's best - perhaps collating them might help.

Perhaps OwnCloud is unique in using SabreDAV (which appears to miss a few features)? I don't have the experience to say unfortunately.

arved commented 11 years ago

currently I'm working on the fork form ziirish but this either is like an OOBE. I've already integrated the code in the combinedbackend and hav it in a state that Contacts are copied to the phone...

pulser commented 11 years ago

Yeah, I may well give that a shot myself, as it appears PHP-Push is based around Z-Push sufficiently that it should be possible to merge it into the fork of Z-Push.

Let me know if you have any more success in getting it into something usable.

arved commented 11 years ago

It took me some time, but for now there is a working version developed on qnap 4.0.1 / ownCloud 5.0.7 and Galaxy Note 2 here : https://github.com/arved/PHP-Push-2 based on the cardav development by ziirsh. it's in the state : working for me. Due to the special behavior of the samsung devices, I've heard about there might be some changes necesary. I'm new to github ... maybe this is the wrong way to publish the changes, so please correct me :-)

pulser commented 11 years ago

Thanks for this!

Tested nicely with the "vanilla" Android AOSP Exchange client. Contacts working nicely, as are email and calendar!

This is a good way to publish your changes. You could offer them as a pull request to the upstream code if you wished, or let them know of the changes you made to make it functional.

arved commented 11 years ago

I took work from this fork an ziirish in the z-push repo, so who should I let know and in which way ? to be honest: i dont remember what I changed excactly, because of a lot of testing and coding by trail and error :-)