X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcarddav%2Fcarddav.cpp;h=fb07b50f0d403947da7025ba5523ffefcdf98865;hb=26c542881613813bd6a671a56e78f129944f68e6;hp=29f1c70c8b12a1497321137c447203fd71ab9613;hpb=911611528b36f56f7de9b6bf027b4c2a1a54df00;p=xestiaab%2F.git diff --git a/source/carddav/carddav.cpp b/source/carddav/carddav.cpp index 29f1c70..fb07b50 100644 --- a/source/carddav/carddav.cpp +++ b/source/carddav/carddav.cpp @@ -1,3 +1,21 @@ +// carddav.cpp - Main CardDAV Object file. +// +// (c) 2012-2015 Xestia Software Development. +// +// This file is part of Xestia Address Book. +// +// Xestia Address Book is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by the +// Free Software Foundation, version 3 of the license. +// +// Xestia Address Book is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with Xestia Address Book. If not, see + #include "carddav.h" #include "../version.h" #include @@ -12,6 +30,8 @@ size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, wxString *stream){ + // Writeback function for the CardDAV object. + wxString Data; Data = wxString::FromUTF8((char *)ptr); @@ -23,6 +43,8 @@ size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, wxString *stream){ int ProgressFunc(void *clientdata, double TTDown, double NDown, double TTUp, double NUp){ + // Progress function for the CardDAV object. + int ProgressRet; CardDAV *IncCardDAV = static_cast(clientdata); @@ -72,6 +94,9 @@ SSLCertCollection CardDAV::VerifyCertCollection; bool CardDAV::AllowSelfSign; CardDAV::CardDAV(){ + + // Setup the CardDAV object. + ServerPort = 8080; SSLStatus = FALSE; SSLVerified = FALSE; @@ -85,14 +110,20 @@ CardDAV::CardDAV(){ UploadMode = FALSE; EditMode = FALSE; HTTPErrorCode = 0; + } CardDAV::~CardDAV(){ + // Destroy the CardDAV object. + } size_t UploadReadFunc(void *ptr, size_t size, size_t nmemb, void *userdata){ + + // Upload function for the CardDAV object. + struct UploadDataStruc *UploadPtr = (struct UploadDataStruc *)userdata; if (UploadPtr->sizeleft){ @@ -121,6 +152,8 @@ size_t UploadReadFunc(void *ptr, size_t size, size_t nmemb, void *userdata){ bool CardDAV::SetupConnection(wxString SvrAddress, int SvrPort, wxString SvrUser, wxString SvrPass, bool SvrSSL){ + // Setup the CardDAV connection without the prefix/account. + ServerAddress = SvrAddress; ServerPort = SvrPort; ServerUser = SvrUser; @@ -133,6 +166,8 @@ bool CardDAV::SetupConnection(wxString SvrAddress, int SvrPort, wxString SvrUser bool CardDAV::SetupConnection(wxString SvrAddress, int SvrPort, wxString SvrUser, wxString SvrPass, bool SvrSSL, wxString SvrPrefix, wxString SvrAccount){ + // Setup the CardDAV connection with the prefix/account. + ServerAddress = SvrAddress; ServerPort = SvrPort; ServerUser = SvrUser; @@ -147,6 +182,8 @@ bool CardDAV::SetupConnection(wxString SvrAddress, int SvrPort, wxString SvrUser bool CardDAV::SetupResultBools(bool *SvrResult, bool *SvrMonitor){ + // Setup the result booleans. + ServerResult = SvrResult; ServerMonitor = SvrMonitor; @@ -156,59 +193,56 @@ bool CardDAV::SetupResultBools(bool *SvrResult, bool *SvrMonitor){ bool CardDAV::HasValidResponse(){ + // Check that CardDAV server gave a valid response. + return ValidResponse; } bool CardDAV::CanDoCardDAV(){ + // Check that the server has CardDAV support. + return HasCalDAVSupport; } bool CardDAV::CanDoSSL(){ + // Check that the server can do SSL. + return SSLStatus; } bool CardDAV::SSLVerify(){ + // Check that the server can verify SSL. + return SSLVerified; } bool CardDAV::AbleToLogin(){ + // Check that the user is able to login. + return AuthPassed; } bool CardDAV::IsSelfSigned(){ + // Check that self-signed certificates are allowed. + return AllowSelfSign; } -/* - -size_t CardDAV::WritebackFunc(char *ptr, size_t size, size_t nmemb, FILE *stream){ - - wxString Data; - Data = wxString::FromUTF8((char *)ptr); - if ((bool)stream == TRUE){ - PageHeader.Append(Data); - } else { - PageData.Append(Data); - } - return size * nmemb; - -} - -*/ - int CardDAV::ProgressFuncProc(void *clientdata, double TTUp, double NUp, double TTDown, double NDown){ + // Progress function processing. + if (AbortConnection == TRUE){ return -1; @@ -223,26 +257,37 @@ int CardDAV::ProgressFuncProc(void *clientdata, double TTUp, double NUp, double void CardDAV::Abort(){ + // Abort (close) the connection. + AbortConnection = TRUE; } SSLCertCollection CardDAV::GetSSLVerifyResults(){ + + // Get the SSL verification results. + return VerifyCertCollection; + } void CardDAV::AllowSelfSignTest(bool AllowSelfSignIn){ + + // Set the value to enable/disable SSL self-signed certificates. + AllowSelfSign = AllowSelfSignIn; } void CardDAV::GetSSLResults(){ - + // Get the SSL results. } void CardDAV::SetServerFilename(wxString Filename){ + // Set the server filename. + ServerFilenameLocation = Filename; } @@ -250,18 +295,24 @@ void CardDAV::SetServerFilename(wxString Filename){ wxString CardDAV::GetPageData() { + // Get the server page data. + return PageData; } wxString CardDAV::ETagValueResult(){ + // Get the ETag Result value. + return ETagResult; } void CardDAV::SetupData(wxString Method, wxString FilenameLocation, wxString UploadData){ + // Setup the data to use with the CardDAV connection. + ServerMethod = Method; ServerFilenameLocation = FilenameLocation; ServerUploadData = UploadData; @@ -281,6 +332,8 @@ void CardDAV::SetupData(wxString Method, wxString FilenameLocation, wxString Upl void CardDAV::SetupVariables(std::map *actlist, int actindex){ + // Setup the variable pointers. + ActivityListPtr = actlist; ItemIndex = actindex; @@ -288,36 +341,48 @@ void CardDAV::SetupVariables(std::map *actlist, int actindex){ wxString CardDAV::GetETagData(){ + // Get the ETag data. + return ETagData; } void CardDAV::SetUploadMode(bool IncMode){ + // Set the upload mode. + UploadMode = IncMode; } void CardDAV::SetEditMode(bool EditModeInc){ + // Set the edit mode. + EditMode = EditModeInc; } int CardDAV::GetResultCode(){ + // Get the result code. + return (int)claconncode; } int CardDAV::GetHTTPCode(){ + // Get the HTTP error code. + return HTTPErrorCode; } wxString CardDAV::GetErrorBuffer(){ + // Get the error buffer. + wxString ErrorBuffer = wxString::FromUTF8(curlerrbuffer); return ErrorBuffer; @@ -326,6 +391,8 @@ wxString CardDAV::GetErrorBuffer(){ SSLCertCollection CardDAV::BuildSSLCollection(CURL *conn){ + // Build and return the SSL collection. + SSLCertCollection SSLCertInfo; // Grab the certificate data. @@ -387,6 +454,8 @@ SSLCertCollection CardDAV::GetCertificateData(){ wxString CardDAV::GetErrorMessage(){ + // Get the error message. + return ErrorMessage; } \ No newline at end of file