diff --git a/SoObjects/Appointments/MSExchangeFreeBusy.m b/SoObjects/Appointments/MSExchangeFreeBusy.m index 05be8c37c..0aa0f8b19 100644 --- a/SoObjects/Appointments/MSExchangeFreeBusy.m +++ b/SoObjects/Appointments/MSExchangeFreeBusy.m @@ -41,7 +41,7 @@ #import "MSExchangeFreeBusySOAPRequest.h" #import "MSExchangeFreeBusy.h" -size_t curlBodyFunction(void *ptr, size_t size, size_t nmemb, void *inSelf) +size_t curl_body_function_freebusy(void *ptr, size_t size, size_t nmemb, void *inSelf) { return [(MSExchangeFreeBusy *)inSelf curlWritePtr:ptr size:size number:nmemb]; } @@ -139,7 +139,7 @@ size_t curlBodyFunction(void *ptr, size_t size, size_t nmemb, void *inSelf) //curl_easy_setopt(curl, CURLOPT_HEADER, 1); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curlBodyFunction); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_body_function_freebusy); curl_easy_setopt(curl, CURLOPT_WRITEDATA, self); curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error); diff --git a/SoObjects/Appointments/SOGoWebAppointmentFolder.h b/SoObjects/Appointments/SOGoWebAppointmentFolder.h index 1b8ac33b2..c47098d5a 100644 --- a/SoObjects/Appointments/SOGoWebAppointmentFolder.h +++ b/SoObjects/Appointments/SOGoWebAppointmentFolder.h @@ -1,8 +1,9 @@ /* SOGoWebAppointmentFolder.h - this file is part of SOGo * - * Copyright (C) 2009 Inverse inc. + * Copyright (C) 2009-2012 Inverse inc. * * Author: Cyril Robert + * Ludovic Marcotte * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,6 +27,10 @@ #import "SOGoAppointmentFolder.h" @interface SOGoWebAppointmentFolder : SOGoAppointmentFolder +{ + @public + NSMutableData *buffer; +} - (void) setUsername: (NSString *) username andPassword: (NSString *) password; diff --git a/SoObjects/Appointments/SOGoWebAppointmentFolder.m b/SoObjects/Appointments/SOGoWebAppointmentFolder.m index 76c5f21ab..edb6fc887 100644 --- a/SoObjects/Appointments/SOGoWebAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoWebAppointmentFolder.m @@ -46,6 +46,16 @@ @class WOHTTPURLHandle; +size_t curl_body_function(void *ptr, size_t size, size_t nmemb, void *inSelf) +{ + size_t total; + + total = size * nmemb; + [((SOGoWebAppointmentFolder *)inSelf)->buffer appendBytes: ptr length: total]; + + return total; +} + @implementation SOGoWebAppointmentFolder - (void) deleteAllContent @@ -107,7 +117,6 @@ { NSString *location, *httpauth; NSDictionary *authInfos; - NSMutableData *bodyData; NSURL *url; CURL *curl; CURLcode rc; @@ -142,17 +151,11 @@ curl_easy_setopt (curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); } - bodyData = [NSMutableData data]; - size_t curlBodyFunction (void *ptr, size_t size, size_t nmemb, void *inSelf) - { - size_t total; + /* buffering ivar, no need to retain/release */ + buffer = [NSMutableData data]; - total = size * nmemb; - [bodyData appendBytes: ptr length: total]; - - return total; - } - curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, curlBodyFunction); + curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, curl_body_function); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, self); error[0] = 0; curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, &error); @@ -167,10 +170,10 @@ if (status == 200) { - content = [[NSString alloc] initWithData: bodyData + content = [[NSString alloc] initWithData: buffer encoding: NSUTF8StringEncoding]; if (!content) - content = [[NSString alloc] initWithData: bodyData + content = [[NSString alloc] initWithData: buffer encoding: NSISOLatin1StringEncoding]; [content autorelease]; calendar = [iCalCalendar parseSingleFromSource: content];