gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cash2ecash] branch master updated: debugging


From: gnunet
Subject: [cash2ecash] branch master updated: debugging
Date: Thu, 02 Jan 2025 15:36:34 +0100

This is an automated email from the git hooks/post-receive script.

manuel-geissbuehler pushed a commit to branch master
in repository cash2ecash.

The following commit(s) were added to refs/heads/master by this push:
     new c636b7f  debugging
c636b7f is described below

commit c636b7ff2c53cfdba7e6c50a8861f7177d306b9b
Author: Manuel Geissbühler <manuel@debian>
AuthorDate: Thu Jan 2 15:36:26 2025 +0100

    debugging
---
 src/bank/bankCommunication.hpp   | 12 ++++++------
 src/cash2ecash.cpp               | 29 ++++++++++++++++++++++++-----
 src/gui/screenAcceptCash.hpp     |  2 +-
 src/gui/screenConnection.hpp     |  2 +-
 src/gui/screenIdentification.hpp |  4 ++--
 src/gui/screenWelcomme.hpp       |  2 +-
 src/include/global.hpp           |  2 +-
 7 files changed, 36 insertions(+), 17 deletions(-)

diff --git a/src/bank/bankCommunication.hpp b/src/bank/bankCommunication.hpp
index a539086..896663b 100644
--- a/src/bank/bankCommunication.hpp
+++ b/src/bank/bankCommunication.hpp
@@ -14,24 +14,24 @@ class BankCommunication{
   static const char **status;
 
   static void initCallback(){
-    eventHandler(EVENT_BANK_TOKEN_DONE);
+    event(EVENT_BANK_TOKEN_DONE);
   }
   
   static void withdrawalRequestCallback(){
-    eventHandler(EVENT_BANK_WITHDRAWAL_DONE);
+    event(EVENT_BANK_WITHDRAWAL_DONE);
   }
 
   static void withdrawalConfirmRequestCallback(){
-    eventHandler(EVENT_BANK_W_CONFIRMATION_DONE);
+    event(EVENT_BANK_W_CONFIRMATION_DONE);
   }
 
   static void withdrawalIDInfoRequestCallback(){
     if  (0 == std::strcmp(*status, "pending")){
-      eventHandler(EVENT_BANK_W_STATUS_PENDING);
+      event(EVENT_BANK_W_STATUS_PENDING);
     }else if (0 == std::strcmp(*status, "selected")) {
-      eventHandler(EVENT_BANK_W_STATUS_SELECTED);
+      event(EVENT_BANK_W_STATUS_SELECTED);
     }else if (0 == std::strcmp(*status, "aborted")) {
-      eventHandler(EVENT_BUTTON_ABORT);
+      event(EVENT_BUTTON_ABORT);
     }else{
       std::cerr << "Unexpected Withdrawal Staus: " << *status << std::endl;
       exit(EXIT_FAILURE);
diff --git a/src/cash2ecash.cpp b/src/cash2ecash.cpp
index ae80a61..47f1a72 100644
--- a/src/cash2ecash.cpp
+++ b/src/cash2ecash.cpp
@@ -3,6 +3,7 @@
 #include <iostream>
 #include <ostream>
 #include <vector>
+#include <mutex>
 #include "utils.hpp"
 #include "gui.hpp"
 #include "global.hpp"
@@ -26,6 +27,9 @@ enum state_e state = INIT;
 const char **withdrawal_id;
 const char **taler_withdraw_uri;
 
+std::vector<event_e> eventFIFO;
+std::mutex eventFIFOMutex;
+
 
 char hello[] = "hello";
 char world[] = "wold";
@@ -195,10 +199,24 @@ void initStateEvent(){
 }
 
 
-void eventHandler(event_e event){
-  state_e oldstate = state;
-  state = stateEventTable[state][event].nextState;
-  stateEventTable[oldstate][event].action();
+void event(event_e event){
+  eventFIFOMutex.lock();
+  eventFIFO.push_back(event);
+  eventFIFOMutex.unlock();
+}
+
+void eventHandler(){
+  state_e oldstate;
+  event_e event;
+  eventFIFOMutex.lock();
+  while (0 < eventFIFO.size()) {
+    oldstate = state;
+    event = eventFIFO.front();
+    state = stateEventTable[state][event].nextState;
+    stateEventTable[oldstate][event].action();
+    eventFIFO.erase(eventFIFO.begin());
+  }
+  eventFIFOMutex.unlock();
 }
 
 int main(int argc, char *argv[]){
@@ -212,9 +230,10 @@ int main(int argc, char *argv[]){
   initStateEvent();
   
   //Trigger Initialzation Event
-  eventHandler(EVENT_INITIALIZE);
+  event(EVENT_INITIALIZE);
   
   while (true) {
+    eventHandler();
     guiDriver();
   }
 }
diff --git a/src/gui/screenAcceptCash.hpp b/src/gui/screenAcceptCash.hpp
index d571728..3f9f3b8 100644
--- a/src/gui/screenAcceptCash.hpp
+++ b/src/gui/screenAcceptCash.hpp
@@ -15,7 +15,7 @@ class ScreenAcceptCash : public Screen{
   lv_obj_t *amountLabel;
 
   static void finishedButtonEvent(lv_event_t *e){
-    eventHandler(EVENT_BUTTON_FINISH_CASHIN);
+    event(EVENT_BUTTON_FINISH_CASHIN);
   }
   
   protected:
diff --git a/src/gui/screenConnection.hpp b/src/gui/screenConnection.hpp
index ac87cd9..11adb26 100644
--- a/src/gui/screenConnection.hpp
+++ b/src/gui/screenConnection.hpp
@@ -15,7 +15,7 @@ class ScreenConnection : public Screen{
   lv_obj_t *qrCode;
 
   static void callbackEventAbort(lv_event_t *e){
-    eventHandler(EVENT_BUTTON_ABORT);
+    event(EVENT_BUTTON_ABORT);
   }
   
   protected:
diff --git a/src/gui/screenIdentification.hpp b/src/gui/screenIdentification.hpp
index bdbed73..41d896f 100644
--- a/src/gui/screenIdentification.hpp
+++ b/src/gui/screenIdentification.hpp
@@ -13,11 +13,11 @@ class ScreenIdentification : public Screen {
   lv_obj_t *identButton;
 
   static void abortButtonEvent(lv_event_t *e){
-    eventHandler(EVENT_BUTTON_ABORT);
+    event(EVENT_BUTTON_ABORT);
   }
 
   static void identButtonEvent(lv_event_t *e){
-    eventHandler(EVENT_IDENTIFICATION_SUCCESS);
+    event(EVENT_IDENTIFICATION_SUCCESS);
   }
   
   protected:
diff --git a/src/gui/screenWelcomme.hpp b/src/gui/screenWelcomme.hpp
index 2a6365d..017b849 100644
--- a/src/gui/screenWelcomme.hpp
+++ b/src/gui/screenWelcomme.hpp
@@ -20,7 +20,7 @@ private:
   lv_obj_t *startButton;
 
   static void startButtonEvent(lv_event_t *e){
-    eventHandler(EVENT_BUTTON_START);
+    event(EVENT_BUTTON_START);
   }
   
   public:
diff --git a/src/include/global.hpp b/src/include/global.hpp
index 2f60f02..c2abaa0 100644
--- a/src/include/global.hpp
+++ b/src/include/global.hpp
@@ -19,6 +19,6 @@ enum event_e {
 };
 #define NUMBER_OF_EVENTS 13
 
-void eventHandler(event_e event);
+void event(event_e event);
 
 #endif

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]