- When taskwarrior is built without GnuTLS, there will be a message to that
  effect.
- Stubbed the TLSClient calling code.  The current Socket code will become
  obsolete soon.
This commit is contained in:
Paul Beckingham 2013-05-11 13:07:14 -04:00
parent 157699cbde
commit a973ccf8f2
7 changed files with 37 additions and 9 deletions

View file

@ -90,7 +90,6 @@ check_function_exists (srandom HAVE_SRANDOM)
check_function_exists (timegm HAVE_TIMEGM)
check_function_exists (get_current_dir_name HAVE_GET_CURRENT_DIR_NAME)
check_struct_has_member ("struct tm" tm_gmtoff time.h HAVE_TM_GMTOFF)
check_struct_has_member ("struct stat" st_birthtime "sys/types.h;sys/stat.h" HAVE_ST_BIRTHTIME)

View file

@ -29,7 +29,11 @@
#include <sstream>
#include <inttypes.h>
#include <Context.h>
#include <Socket.h>
#include <cmake.h>
#include <Socket.h> // TODO Socket is obsolete.
/*
#include <TLSClient.h>
*/
#include <Color.h>
#include <text.h>
#include <i18n.h>
@ -51,6 +55,7 @@ CmdSync::CmdSync ()
int CmdSync::execute (std::string& output)
{
int status = 0;
#ifdef HAVE_LIBGNUTLS
Timer timer_sync;
timer_sync.start ();
@ -110,8 +115,8 @@ int CmdSync::execute (std::string& output)
std::string code = response.get ("code");
if (code == "200")
{
Color colorAdded (context.config.get ("color.sync.added"));
Color colorChanged (context.config.get ("color.sync.changed"));
Color colorAdded (context.config.get ("color.sync.added"));
Color colorChanged (context.config.get ("color.sync.changed"));
int download_count = 0;
payload = response.getPayload ();
@ -244,6 +249,10 @@ int CmdSync::execute (std::string& output)
debug (s.str ());
*/
#else
// Without GnuTLS found at compile time, there is no working sync command.
throw std::string (STRING_CMD_SYNC_NO_TLS);
#endif
return status;
}
@ -253,6 +262,7 @@ bool CmdSync::send (
const Msg& request,
Msg& response)
{
#ifdef HAVE_LIBGNUTLS
std::string::size_type colon = to.rfind (':');
if (colon == std::string::npos)
throw format (STRING_CMD_SYNC_BAD_SERVER, to);
@ -262,6 +272,7 @@ bool CmdSync::send (
try
{
// TODO Socket is obsolete.
Socket s;
s.connect (server, port);
s.write (request.serialize () + "\n");
@ -270,6 +281,21 @@ bool CmdSync::send (
s.read (incoming);
s.close ();
/*
// A very basic TLS client, with X.509 authentication.
TLSClient client;
client.debug (); // TODO if (context.config.get ("debug"))
client.limit (1024); // TODO ???
client.init ("pki/client.cert.pem"); // TODO ???
client.connect (server, port);
client.send (request.serialize () + "\n");
std::string incoming;
client.recv (incoming);
client.bye ();
*/
response.parse (incoming);
return true;
}
@ -280,6 +306,7 @@ bool CmdSync::send (
}
// Indicate message failed.
#endif
return false;
}

View file

@ -416,6 +416,7 @@
#define STRING_CMD_SYNC_FAIL_ERROR "Sync failed. The Task Server returned error: {1} {2}"
#define STRING_CMD_SYNC_FAIL_CONNECT "Sync failed. Could not connect to the Task Server."
#define STRING_CMD_SYNC_BAD_SERVER "Sync failed. Malformed configuration setting '{1}'"
#define STRING_CMD_SYNC_NO_TLS "Taskwarrior was built without GnuTLS support. Sync is not available."
#define STRING_CMD_DIAG_USAGE "Platform, build and environment details"
#define STRING_CMD_DIAG_PLATFORM "Platform"
#define STRING_CMD_DIAG_UNKNOWN "<unknown>"

View file

@ -427,6 +427,7 @@
#define STRING_CMD_SYNC_FAIL_ERROR "Sincronización fallida. El Servidor Task devolvió error: {1} {2}"
#define STRING_CMD_SYNC_FAIL_CONNECT "Sincronización fallida. No se pudo conectar con el Servidor Task."
#define STRING_CMD_SYNC_BAD_SERVER "Sincronización fallida. Ajuste de configuración '{1}' incorrecto"
#define STRING_CMD_SYNC_NO_TLS "Taskwarrior was built without GnuTLS support. Sync is not available."
#define STRING_CMD_DIAG_USAGE "Detalles de plataforma, construcción y entorno"
#define STRING_CMD_DIAG_PLATFORM "Plataforma"

View file

@ -416,6 +416,7 @@
#define STRING_CMD_SYNC_FAIL_ERROR "Sync failed. The Task Server returned error: {1} {2}"
#define STRING_CMD_SYNC_FAIL_CONNECT "Sync failed. Could not connect to the Task Server."
#define STRING_CMD_SYNC_BAD_SERVER "Sync failed. Malformed configuration setting '{1}'"
#define STRING_CMD_SYNC_NO_TLS "Taskwarrior was built without GnuTLS support. Sync is not available."
#define STRING_CMD_DIAG_USAGE "Platform, build and environment details"
#define STRING_CMD_DIAG_PLATFORM "Platform"
#define STRING_CMD_DIAG_UNKNOWN "<unknown>"

View file

@ -417,6 +417,7 @@
#define STRING_CMD_SYNC_FAIL_ERROR "Sincronizzazione fallita. Il Task Server ha ritornato l'errore: {1} {2}"
#define STRING_CMD_SYNC_FAIL_CONNECT "Sincronizzazione fallita. Impossibile connettersi al Task Server."
#define STRING_CMD_SYNC_BAD_SERVER "Sincronizzazione fallita. Impostazione di configurazione '{1}' malformata"
#define STRING_CMD_SYNC_NO_TLS "Taskwarrior was built without GnuTLS support. Sync is not available."
#define STRING_CMD_DIAG_USAGE "Dettagli su piattaforma, build e ambiente"
#define STRING_CMD_DIAG_PLATFORM "Piattaforma"
#define STRING_CMD_DIAG_UNKNOWN "<sconoscito>"

View file

@ -16,21 +16,19 @@ if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
set (TESTBLOB "./*.t")
if (CYGWIN)
set (TESTBLOB "./*.t ./*.t.exe")
set (TESTBLOB "./*.t ./*.t.exe")
endif (CYGWIN)
else (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
set (TESTBLOB "${CMAKE_SOURCE_DIR}/test/*.t ${CMAKE_BINARY_DIR}/test/*.t")
if (CYGWIN)
set (TESTBLOB "${CMAKE_SOURCE_DIR}/test/*.t ${CMAKE_BINARY_DIR}/test/*.t.exe")
set (TESTBLOB "${CMAKE_SOURCE_DIR}/test/*.t ${CMAKE_BINARY_DIR}/test/*.t.exe")
endif (CYGWIN)
endif (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
configure_file (
run_all.in
run_all)
configure_file (run_all.in run_all)
add_custom_target (test ./run_all --verbose
DEPENDS ${test_SRCS} task_executable