Add libzlcore-tqt cmake files. Currently, this builds with a dummy TQt3-based GUI

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/1/head
Michele Calgaro 4 months ago
parent 247d5d3bd6
commit bfc2deaeb6
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -23,3 +23,27 @@ tde_setup_largefiles( )
if( WITH_GCC_VISIBILITY )
tde_setup_gcc_visibility( )
endif( WITH_GCC_VISIBILITY )
##### check for zlib
find_package( ZLIB )
if( NOT ZLIB_FOUND )
tde_message_fatal( "zlib is required, but not found on your system" )
endif( )
##### check for bzip2
find_package( BZip2 )
if( NOT BZIP2_FOUND )
tde_message_fatal( "bzip2 is required, but not found on your system" )
endif( )
##### check for expat
find_package( EXPAT )
if( NOT EXPAT_FOUND )
tde_message_fatal( "expat support is required but not found on your system." )
endif()

@ -6,3 +6,7 @@
// Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
// significant byte first (like Motorola and SPARC, unlike Intel).
#cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@
// Zlibrary defines
#define BASEDIR "@SHARE_INSTALL_PREFIX@"
#define IMAGEDIR "@SHARE_INSTALL_PREFIX@/pixmaps"

@ -1 +1 @@
#usr/lib
/usr/lib

@ -2,13 +2,16 @@
##### zlibrary-tqt install path
_tde_internal_setup_path(
ZLIB_SHARE_INSTALL_PREFIX "${CMAKE_ZLIBRARY_INSTALL_PREFIX}/share/zlibrary-tqt"
"Base directory for zlibrary-tqt files which go to share/"
ZL_SHARE_INSTALL_PREFIX "${CMAKE_ZLIBRARY_INSTALL_PREFIX}/share/zlibrary-tqt"
"Base directory for zlibrary-tqt files which go to share"
)
_tde_internal_setup_path(
ZL_LIB_INSTALL_DIR "${CMAKE_ZLIBRARY_INSTALL_PREFIX}/lib${LIB_SUFFIX}"
"Base directory for zlibrary-tqt lib files"
)
##### subfolders
add_subdirectory( core )
#add_subdirectory( text )
#add_subdirectory( ui )

@ -1,24 +1,39 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}
)
##### libzlcore-tqt (shared)
file( GLOB_RECURSE _zlcore_cpp_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
tde_add_library( zlcore-tqt SHARED AUTOMOC
SOURCES ${_zlcore_cpp_files}
LINK ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${EXPAT_LIBRARIES} ${TQT_LIBRARIES}
VERSION 0.99.4
DESTINATION ${ZL_LIB_INSTALL_DIR}
)
##### install data files
install(
FILES data/languagePatterns.zip data/unicode.xml.gz
DESTINATION ${ZLIB_SHARE_INSTALL_PREFIX}
FILES data/languagePatterns.zip data/unicode.xml.gz data/ui/keynames.desktop-tqt.xml
DESTINATION ${ZL_SHARE_INSTALL_PREFIX}
)
install(
FILES data/config.xml
DESTINATION ${ZLIB_SHARE_INSTALL_PREFIX}/default
DESTINATION ${ZL_SHARE_INSTALL_PREFIX}/default
)
file( GLOB _enconding_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/data/encodings/* )
install(
FILES ${_enconding_files}
DESTINATION ${ZLIB_SHARE_INSTALL_PREFIX}/encodings
DESTINATION ${ZL_SHARE_INSTALL_PREFIX}/encodings
)
file( GLOB _resources_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/data/resources/*.xml )
install(
FILES ${_resources_files}
DESTINATION ${ZLIB_SHARE_INSTALL_PREFIX}/resources
DESTINATION ${ZL_SHARE_INSTALL_PREFIX}/resources
)

@ -29,6 +29,8 @@
#include "../options/ZLConfig.h"
#include "../network/ZLNetworkManager.h"
#include "config.h"
bool ZLibrary::ourLocaleIsInitialized = false;
std::string ZLibrary::ourLanguage;
std::string ZLibrary::ourCountry;
@ -103,7 +105,7 @@ std::string ZLibrary::replaceRegExps(const std::string &pattern) {
void ZLibrary::initApplication(const std::string &name) {
ourApplicationName = name;
ourImageDirectory = replaceRegExps(IMAGEDIR);
ourApplicationImageDirectory = replaceRegExps(APPIMAGEDIR);
ourApplicationImageDirectory = replaceRegExps(IMAGEDIR);
ourApplicationDirectory = BaseDirectory + FileNameDelimiter + ourApplicationName;
ourApplicationWritableDirectory =
#ifdef XMLCONFIGHOMEDIR

@ -0,0 +1,47 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
*
* This program 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; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#include <tqapplication.h>
#include <ZLApplication.h>
#include <ZLibrary.h>
#include <ZLLanguageUtil.h>
#include "../../unix/library/ZLibraryImplementation.h"
class ZLTQtLibraryImplementation : public ZLibraryImplementation {
private:
void init(int &argc, char **&argv);
ZLPaintContext *createContext();
void run(ZLApplication *application);
};
void initLibrary() {
}
void ZLTQtLibraryImplementation::init(int &argc, char **&argv) {
}
ZLPaintContext *ZLTQtLibraryImplementation::createContext() {
return 0;
}
void ZLTQtLibraryImplementation::run(ZLApplication *application) {
}

@ -1,313 +0,0 @@
/*
* Copyright (C) 2008-2012 Geometer Plus <contact@geometerplus.com>
*
* This program 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; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#include <map>
#include <set>
#include <curl/curl.h>
#include <ZLStringUtil.h>
#include <ZLNetworkUtil.h>
#include <ZLResource.h>
#include <ZLOutputStream.h>
#include <ZLXMLReader.h>
#include <ZLNetworkRequest.h>
#include "ZLCurlNetworkManager.h"
class PostData : public ZLUserData {
public:
PostData();
~PostData();
bool addItem(const std::string &name, const std::string &content);
const curl_httppost *postItem() const;
private:
curl_httppost *myPostItem;
curl_httppost *myLastItem;
private: // disable copying
PostData(const PostData &);
const PostData &operator = (const PostData &);
};
PostData::PostData() : myPostItem(0), myLastItem(0) {
}
PostData::~PostData() {
if (myPostItem != 0) {
curl_formfree(myPostItem);
}
}
bool PostData::addItem(const std::string &name, const std::string &content) {
// TODO: url-encode content???
return curl_formadd(&myPostItem, &myLastItem,
CURLFORM_COPYNAME, name.c_str(),
CURLFORM_COPYCONTENTS, content.c_str(),
CURLFORM_END) == 0;
}
inline const curl_httppost *PostData::postItem() const {
return myPostItem;
}
static std::size_t handleHeader(void *ptr, std::size_t size, std::size_t nmemb, ZLNetworkRequest *request) {
const std::size_t dataSize = size * nmemb;
return (request->handleHeader(ptr, dataSize)) ? dataSize : 0;
}
static std::size_t handleContent(void *ptr, std::size_t size, std::size_t nmemb, ZLNetworkRequest *request) {
const std::size_t dataSize = size * nmemb;
return (request->handleContent(ptr, dataSize)) ? dataSize : 0;
}
void ZLCurlNetworkManager::createInstance() {
ourInstance = new ZLCurlNetworkManager();
}
void ZLCurlNetworkManager::setStandardOptions(CURL *handle, const std::string &proxy) const {
const std::string &agent = userAgent();
if (!agent.empty()) {
curl_easy_setopt(handle, CURLOPT_USERAGENT, agent.c_str());
}
if (useProxy()) {
curl_easy_setopt(handle, CURLOPT_PROXY, proxy.c_str());
}
curl_easy_setopt(handle, CURLOPT_LOW_SPEED_LIMIT, 1L);
curl_easy_setopt(handle, CURLOPT_LOW_SPEED_TIME, TimeoutOption().value());
curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT, ConnectTimeoutOption().value());
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 1L);
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, 2L);
const std::string cookies = CookiesPath();
curl_easy_setopt(handle, CURLOPT_COOKIEFILE, cookies.c_str());
curl_easy_setopt(handle, CURLOPT_COOKIEJAR, cookies.c_str());
}
std::string ZLCurlNetworkManager::doBeforeRequest(ZLNetworkRequest &request) const {
const ZLResource &errorResource = ZLResource::resource("dialog")["networkError"];
if (!request.doBefore()) {
const std::string &err = request.errorMessage();
if (!err.empty()) {
return err;
}
return ZLStringUtil::printf(errorResource["somethingWrongMessage"].value(), ZLNetworkUtil::hostFromUrl(request.url()));
}
if (request.isInstanceOf(ZLNetworkPostRequest::TYPE_ID)) {
return doBeforePostRequest((ZLNetworkPostRequest &) request);
}
return "";
}
std::string ZLCurlNetworkManager::doBeforePostRequest(ZLNetworkPostRequest &request) const {
shared_ptr<ZLUserData> postDataPtr = new PostData;
PostData &postData = (PostData&)*postDataPtr;
const std::vector<std::pair<std::string, std::string> > &data = request.postParameters();
for (std::size_t i = 0; i < data.size(); ++i) {
if (!postData.addItem(data[i].first, data[i].second)) {
return "Invalid form data for " + ZLNetworkUtil::hostFromUrl(request.url()); // TODO: localize
}
}
request.addUserData("postData", postDataPtr);
return "";
}
void ZLCurlNetworkManager::setRequestOptions(CURL *handle, const ZLNetworkRequest &request) const {
curl_easy_setopt(handle, CURLOPT_URL, request.url().c_str());
if (!request.sslCertificate().Path.empty()) {
curl_easy_setopt(handle, CURLOPT_CAINFO, request.sslCertificate().Path.c_str());
} else if (!request.sslCertificate().DoVerify) {
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0L);
}
curl_easy_setopt(handle, CURLOPT_HEADERFUNCTION, handleHeader);
curl_easy_setopt(handle, CURLOPT_WRITEHEADER, &request);
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, handleContent);
curl_easy_setopt(handle, CURLOPT_WRITEDATA, &request);
switch (request.authenticationMethod()) {
case ZLNetworkRequest::NO_AUTH:
break;
case ZLNetworkRequest::BASIC:
#if LIBCURL_VERSION_NUM >= 0x071301
curl_easy_setopt(handle, CURLOPT_USERNAME, request.userName().c_str());
curl_easy_setopt(handle, CURLOPT_PASSWORD, request.password().c_str());
#else
curl_easy_setopt(
handle, CURLOPT_USERPWD,
(request.userName() + ':' + request.password()).c_str()
);
#endif
curl_easy_setopt(handle, CURLOPT_HTTPAUTH, (long) CURLAUTH_BASIC);
break;
}
curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, request.isRedirectionSupported());
if (request.isInstanceOf(ZLNetworkPostRequest::TYPE_ID)) {
shared_ptr<ZLUserData> postDataPtr = request.getUserData("postData");
PostData &postData = (PostData&)*postDataPtr;
if (postData.postItem() != 0) {
curl_easy_setopt(handle, CURLOPT_HTTPPOST, postData.postItem());
}
}
}
void ZLCurlNetworkManager::clearRequestOptions(ZLNetworkRequest &request) const {
if (request.isInstanceOf(ZLNetworkPostRequest::TYPE_ID)) {
request.removeUserData("postData");
}
}
std::string ZLCurlNetworkManager::perform(const ZLExecutionData::Vector &dataList) const {
const ZLResource &errorResource = ZLResource::resource("dialog")["networkError"];
if (dataList.empty()) {
return errorResource["emptyLibrariesList"].value();
}
std::set<std::string> errors;
const std::string proxy = proxyHost() + ':' + proxyPort();
CURLM *handle = curl_multi_init();
std::map<CURL*,shared_ptr<ZLExecutionData> > handleToRequest;
for (ZLExecutionData::Vector::const_iterator it = dataList.begin(); it != dataList.end(); ++it) {
if (it->isNull() || !(*it)->isInstanceOf(ZLNetworkRequest::TYPE_ID)) {
continue;
}
ZLNetworkRequest &request = (ZLNetworkRequest&)**it;
const std::string err = doBeforeRequest(request);
if (!err.empty()) {
errors.insert(err);
continue;
}
CURL *easyHandle = curl_easy_init();
if (easyHandle != 0) {
handleToRequest[easyHandle] = *it;
setStandardOptions(easyHandle, proxy);
setRequestOptions(easyHandle, request);
curl_multi_add_handle(handle, easyHandle);
}
}
int counter;
CURLMcode res;
do {
res = curl_multi_perform(handle, &counter);
} while ((res == CURLM_CALL_MULTI_PERFORM) || (counter > 0));
CURLMsg *message;
do {
int queueSize;
message = curl_multi_info_read(handle, &queueSize);
if ((message != 0) && (message->msg == CURLMSG_DONE)) {
ZLNetworkRequest &request = (ZLNetworkRequest&)*handleToRequest[message->easy_handle];
const std::string &url = request.url();
CURLcode result = message->data.result;
bool doAfterResult = request.doAfter(result == CURLE_OK);
if (result == CURLE_OK && !doAfterResult) {
result = CURLE_WRITE_ERROR;
}
switch (result) {
case CURLE_OK:
break;
case CURLE_WRITE_ERROR:
if (!request.errorMessage().empty()) {
errors.insert(request.errorMessage());
} else {
errors.insert(ZLStringUtil::printf(errorResource["somethingWrongMessage"].value(), ZLNetworkUtil::hostFromUrl(url)));
}
break;
default:
errors.insert(ZLStringUtil::printf(errorResource["somethingWrongMessage"].value(), ZLNetworkUtil::hostFromUrl(url)));
break;
case CURLE_COULDNT_RESOLVE_PROXY:
errors.insert(ZLStringUtil::printf(errorResource["couldntResolveProxyMessage"].value(), proxyHost()));
break;
case CURLE_COULDNT_RESOLVE_HOST:
errors.insert(ZLStringUtil::printf(errorResource["couldntResolveHostMessage"].value(), ZLNetworkUtil::hostFromUrl(url)));
break;
case CURLE_COULDNT_CONNECT:
errors.insert(ZLStringUtil::printf(errorResource["couldntConnectMessage"].value(), ZLNetworkUtil::hostFromUrl(url)));
break;
case CURLE_OPERATION_TIMEDOUT:
errors.insert(errorResource["operationTimedOutMessage"].value());
break;
case CURLE_SSL_CONNECT_ERROR:
errors.insert(ZLStringUtil::printf(errorResource["sslConnectErrorMessage"].value(), curl_easy_strerror(CURLE_SSL_CONNECT_ERROR)));
break;
case CURLE_PEER_FAILED_VERIFICATION:
errors.insert(ZLStringUtil::printf(errorResource["peerFailedVerificationMessage"].value(), ZLNetworkUtil::hostFromUrl(url)));
break;
case CURLE_SSL_CACERT_BADFILE:
errors.insert(ZLStringUtil::printf(errorResource["sslBadCertificateFileMessage"].value(), request.sslCertificate().Path));
break;
case CURLE_SSL_SHUTDOWN_FAILED:
errors.insert(ZLStringUtil::printf(errorResource["sslShutdownFailedMessage"].value(), ZLNetworkUtil::hostFromUrl(url)));
break;
}
}
} while ((message != 0) && (errors.size() < 3));
for (std::map<CURL*,shared_ptr<ZLExecutionData> >::const_iterator jt = handleToRequest.begin(); jt != handleToRequest.end(); ++jt) {
CURL *easyHandle = jt->first;
curl_multi_remove_handle(handle, easyHandle);
curl_easy_cleanup(easyHandle);
ZLNetworkRequest &request = (ZLNetworkRequest&)*jt->second;
clearRequestOptions(request);
}
handleToRequest.clear();
curl_multi_cleanup(handle);
std::string result;
for (std::set<std::string>::const_iterator et = errors.begin(); et != errors.end(); ++et) {
if (!result.empty()) {
result += '\n';
}
result += *et;
}
return result;
}

@ -1,51 +0,0 @@
/*
* Copyright (C) 2008-2012 Geometer Plus <contact@geometerplus.com>
*
* This program 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; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLCURLNETWORKMANAGER_H__
#define __ZLCURLNETWORKMANAGER_H__
#include <curl/curl.h>
#include "../../network/ZLNetworkManager.h"
class ZLNetworkRequest;
class ZLNetworkGetRequest;
class ZLNetworkPostRequest;
class ZLCurlNetworkManager : public ZLNetworkManager {
public:
static void createInstance();
private:
std::string perform(const ZLExecutionData::Vector &dataList) const;
std::string doBeforeRequest(ZLNetworkRequest &request) const;
std::string doBeforePostRequest(ZLNetworkPostRequest &request) const;
void setStandardOptions(CURL *handle, const std::string &proxy) const;
void setRequestOptions(CURL *handle, const ZLNetworkRequest &request) const;
void clearRequestOptions(ZLNetworkRequest &request) const;
};
#endif /* __ZLCURLNETWORKMANAGER_H__ */

@ -65,65 +65,6 @@ ZLibraryImplementation::~ZLibraryImplementation() {
}
bool ZLibrary::init(int &argc, char **&argv) {
//#ifdef ZLSHARED
// const std::string pluginPath = std::string(LIBDIR) + "/zlibrary/ui";
// void *handle = 0;
// if ((argc > 2) && std::string("-zlui") == argv[1]) {
// std::string pluginName = argv[2];
// if (!ZLStringUtil::stringEndsWith(pluginName, ".so")) {
// pluginName = pluginPath + "/zlui-" + pluginName + ".so";
// }
// handle = loadPlugin(pluginName);
// argc -= 2;
// argv += 2;
// }
// if (handle == 0) {
// DIR *dir = opendir(pluginPath.c_str());
// if (dir == 0) {
// return false;
// }
// std::vector<std::string> names;
// const dirent *file;
// struct stat fileInfo;
// while ((file = readdir(dir)) != 0) {
// const std::string shortName = file->d_name;
// if ((shortName.substr(0, 5) != "zlui-") ||
// !ZLStringUtil::stringEndsWith(shortName, ".so")) {
// continue;
// }
// const std::string fullName = pluginPath + "/" + shortName;
// stat(fullName.c_str(), &fileInfo);
// if (!S_ISREG(fileInfo.st_mode)) {
// continue;
// }
// names.push_back(fullName);
// }
// closedir(dir);
// std::sort(names.begin(), names.end());
// for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); ++it) {
// handle = loadPlugin(*it);
// if (handle != 0) {
// break;
// }
// }
// if (handle == 0) {
// return false;
// }
// }
// void (*initLibrary)();
// *(void**)&initLibrary = dlsym(handle, "initLibrary");
// const char *error = dlerror();
// if (error != 0) {
// ZLLogger::Instance().println(ZLLogger::DEFAULT_CLASS, error);
// return false;
// }
//#endif /* ZLSHARED */
initLibrary();
if (ZLibraryImplementation::Instance == 0) {

@ -1,14 +0,0 @@
/*QLineEdit:focus#search-field {
border-style: solid;
border-width: 2px;
border-radius: 12px;
border-color: #6F9FCF;
}
QLineEdit#search-field {
border-style: solid;
border-width: 1px;
border-radius: 12px;
border-color: #8D8D8D;
}*/
Loading…
Cancel
Save