wsjtx: base logged contacts on the contest template

This is the same thing as what the UI does.  In general, the value from the
template is used but wsjtx packet values override whatever may be in the
template.

It is therefore important for wsjxt to *not* include values that are not
meant to override the template.  For example, wsjtx should *not* provide an
operator callsign as that will override the callsign from the template.

Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
3 files changed, 13 insertions(+), 3 deletions(-)

M hlog/contest.c
M hlog/contest/wsjtx.c
M hlog/contest/wsjtx.h
M hlog/contest.c +1 -1
@@ 388,7 388,7 @@ int main(int argc, char **argv)
 		 *  1. ncurses ui
 		 *  2. wsjtx udp listener
 		 */
-		ret = wsjtx_start(lua);
+		ret = wsjtx_start(lua, &contest_params);
 		if (ret)
 			goto err_script;
 

          
M hlog/contest/wsjtx.c +10 -1
@@ 34,6 34,7 @@ 
 #include "wsjtx.h"
 
 static struct udpsvc *svc;
+static const struct contest_params *contest_params;
 
 #define WSJTX_HOST NULL
 #define WSJTX_PORT 2237

          
@@ 233,6 234,12 @@ static int log_qso(struct xlua_state *lu
 	if (IS_ERR(qso))
 		return PTR_ERR(qso);
 
+	qso_copy(qso, contest_params->template);
+
+	/* generate a new uuid - it's ugly that we have to reach in like this */
+	xuuid_generate(&qso->uuid);
+	xuuid_unparse(&qso->uuid, qso->uuid_str);
+
 	/* QSO */
 	qso->start = msg->t5.timeon;
 	qso->end = msg->t5.timeoff;

          
@@ 410,10 417,12 @@ static void wsjtx_process(const union xs
 	}
 }
 
-int wsjtx_start(struct xlua_state *lua)
+int wsjtx_start(struct xlua_state *lua, const struct contest_params *params)
 {
 	struct udpsvc *svc;
 
+	contest_params = params;
+
 	svc = udpsvc(WSJTX_HOST, WSJTX_PORT, false, "wsjtx", wsjtx_process,
 		     lua);
 	if (IS_ERR(svc)) {

          
M hlog/contest/wsjtx.h +2 -1
@@ 25,7 25,8 @@ 
 
 #include <hlog-lua/xlua.h>
 
-extern int wsjtx_start(struct xlua_state *lua);
+extern int wsjtx_start(struct xlua_state *lua,
+		       const struct contest_params *parms);
 extern void wsjtx_stop(void);
 
 #endif