Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Fixed cleaning of old object files
[xestiaab/.git] / source / carddav / carddav-processdata.cpp
index 76b41d8..1e5a603 100644 (file)
@@ -30,6 +30,8 @@
 
 void CardDAV::ProcessDataThread(){
 
+       // Process the data (threaded).
+       
        PageData.Clear();
        PageHeader.Clear();
 
@@ -42,10 +44,16 @@ void CardDAV::ProcessDataThread(){
        wxString ServerAddressURL;
        wxString ServerAuth;
        wxString ServerAddressSSL;
-       wxString ServerAddressNormal;   
-
+       wxString ServerAddressNormal;
+        
         conn = curl_easy_init();
        
+#if defined(__APPLE__)
+       
+        SetConnectionObject(conn);
+
+#endif
+       
        struct CardDAVCURLPasser {
        
                CardDAV *Data;
@@ -66,31 +74,11 @@ void CardDAV::ProcessDataThread(){
        wxString ETagOriginal;
        wxString ETagServer;
                
-       ServerAddressURL = ServerAddress + wxT(":") + wxString::Format(wxT("%i"), ServerPort) + wxT("/") + ServerPrefix + ServerFilenameLocation;
+       ServerAddressURL = ServerAddress + wxT(":") + wxString::Format(wxT("%i"), ServerPort) + ServerPrefix + ServerFilenameLocation;
        ServerAddressSSL = wxT("https://") + ServerAddressURL;
        ServerAddressNormal = wxT("http://") + ServerAddressURL;
        
        ServerAuth = ServerUser + wxT(":") + ServerPass;
-       
-       // Try SSL first.
-
-
-       /*
-       char *ServerAdrSSLChar = new char[(ServerAddressSSL.Length() - 1)];
-       //memset(ServerAdrSSLChar, 0, ServerAddressSSL.Length());
-       strncpy(ServerAdrSSLChar, (const char*)ServerAddressSSL.mb_str(wxConvUTF8), (ServerAddressSSL.Length() - 1));
-       
-       char *ServerAdrNorChar = new char[(ServerAddressNormal.Length() - 1)];
-       //memset(ServerAdrNorChar, 0, ServerAddressSSL.Length());       
-       strncpy(ServerAdrNorChar, (const char*)ServerAddressNormal.mb_str(wxConvUTF8), (ServerAddressNormal.Length() - 1));
-
-       char *ServerAuthChar = new char[(ServerAuth.Length() - 1)];
-       //memset(ServerAuthChar, 0, ServerAddressSSL.Length()); 
-       strncpy(ServerAuthChar, (const char*)ServerAuth.mb_str(wxConvUTF8), (ServerAuth.Length() - 1));
-       
-       */
-
-       //std::string WriteDataString = std::string(ServerUploadData.mb_str());
 
        std::map<int,int>::iterator ActIter;
        struct UploadDataStruc UploadData;
@@ -109,6 +97,8 @@ void CardDAV::ProcessDataThread(){
                curl_easy_setopt(conn, CURLOPT_CUSTOMREQUEST, (const char*)ServerMethod.mb_str(wxConvUTF8));
 
        }
+       
+       // Try SSL first.
 
        if (ServerSSL){
 
@@ -139,6 +129,10 @@ void CardDAV::ProcessDataThread(){
                
                }
 
+#if defined(__APPLE__) || defined(__WIN32__)
+               
+#else
+               
                ServerCertFilename = GetAccountDir(ServerAccount, TRUE);
 
                if (wxFile::Exists(ServerCertFilename) == TRUE){
@@ -148,14 +142,8 @@ void CardDAV::ProcessDataThread(){
                        curl_easy_setopt(conn, CURLOPT_CAINFO, (const char*)ServerCertFilename.mb_str(wxConvUTF8));
                
                }
-
-               //UploadData.readptr = &CardDAVDataQuery;
-               //UploadData.sizeleft = CardDAVDataQuery.Len();
-               //curl_easy_setopt(conn, CURLOPT_UPLOAD, 1);
-               //curl_easy_setopt(conn, CURLOPT_READDATA, &UploadData);
-               //curl_easy_setopt(conn, CURLOPT_READFUNCTION, UploadReadFunc);
-               
-               //curl_easy_setopt(conn, CURLOPT_WRITEFUNCTION, writefunc);
+       
+#endif
                
                claconncode = (curl_easy_perform(conn));
 
@@ -209,17 +197,16 @@ void CardDAV::ProcessDataThread(){
                // Check if it fails with a CURLE_SSL_CACERT then compare
                // the certificates as PEM files.
                
-               if (claconncode == CURLE_SSL_CACERT && wxFile::Exists(ServerCertFilename) == TRUE){
+#if defined(__APPLE__)
+               
+#else
                
-                       //curl_easy_cleanup(conn);
-                       //conn = curl_easy_init();
+               if (claconncode == CURLE_SSL_CACERT && wxFile::Exists(ServerCertFilename) == TRUE){
 
                        CURL *sslerrconn;
                        sslerrconn = curl_easy_init();
                        CURLcode sslerrconncode;
 
-                       //claconncode = (curl_easy_perform(conn));
-
                        wxString ServerAddressOnly = wxT("https://") + ServerAddress + wxT(":") + wxString::Format(wxT("%i"), ServerPort) + wxT("/");
 
                        curl_easy_setopt(sslerrconn, CURLOPT_URL, (const char*)ServerAddressOnly.mb_str(wxConvUTF8));
@@ -239,9 +226,9 @@ void CardDAV::ProcessDataThread(){
                
                        wxString SSLLocalData;
                        wxString SSLServerData;
-               
-                       sslerrconncode = (curl_easy_perform(sslerrconn));
-               
+                        
+                        sslerrconncode = (curl_easy_perform(sslerrconn));
+                       
                        SSLCertCol = BuildSSLCollection(sslerrconn);
                        std::map<int, SSLCertData>::iterator SSLCDIter = SSLCertCol.SSLCollection.find(0);
                        std::multimap<wxString,wxString>::iterator SSLDataIter = SSLCDIter->second.CertData.find(wxT("Cert"));
@@ -322,6 +309,8 @@ void CardDAV::ProcessDataThread(){
                        curl_easy_cleanup(sslerrconn);
                
                }
+               
+#endif
 
                // Sort out SSL error.
                
@@ -356,17 +345,29 @@ void CardDAV::ProcessDataThread(){
                        curl_easy_setopt(sslerrconn, CURLOPT_NOSIGNAL, 1);
                        curl_easy_setopt(sslerrconn, CURLOPT_SSL_VERIFYPEER, 0);
                        curl_easy_setopt(sslerrconn, CURLOPT_CERTINFO, 1);
-               
+       
+#if defined(__APPLE__)
+                       
+                       SetConnectionObject(sslerrconn);
+                       
+#endif
+                       
                        sslerrconncode = (curl_easy_perform(sslerrconn));
 
+#if defined(__APPLE__)
+                       
+#else
+                       
                        SSLCertCol = BuildSSLCollection(sslerrconn);
                        SSLCertCol.SuccessCode = 1;
 
+#endif
+                       
                        return;
                
                } else if (claconncode == CURLE_HTTP_RETURNED_ERROR){
                
-                       fprintf(stderr, "curl_easy_perform() failed: %s\n",
+                       fprintf(stderr, "ProcessDataThrad(): curl_easy_perform() failed: %s\n",
                                        curl_easy_strerror(claconncode));
                        int http_code = 0;
                        curl_easy_getinfo(conn, CURLINFO_RESPONSE_CODE, &http_code);
@@ -506,7 +507,6 @@ void CardDAV::ProcessDataThread(){
        
        // Catch all.
        
-       //ActIter->second = 1;
        *ServerResult = TRUE;
        return;
 
@@ -514,6 +514,8 @@ void CardDAV::ProcessDataThread(){
 
 void CardDAV::ProcessData(){
 
+       // Process the data.
+       
        std::thread ConnectThread(&CardDAV::ProcessDataThread, this);
        ConnectThread.detach();
 
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy