summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/scanner-session/scannersession-interface.vala9
-rw-r--r--src/scanner-session/scannersession.vala22
2 files changed, 31 insertions, 0 deletions
diff --git a/src/scanner-session/scannersession-interface.vala b/src/scanner-session/scannersession-interface.vala
index 89498df..9f989e7 100644
--- a/src/scanner-session/scannersession-interface.vala
+++ b/src/scanner-session/scannersession-interface.vala
@@ -24,3 +24,12 @@ public enum MessageType {
WARNING,
ERROR
}
+
+public enum ScannerSessionCodeType {
+ USER,
+ GUEST,
+ UNDO,
+ LOGOUT,
+ EAN,
+ UNKNOWN
+}
diff --git a/src/scanner-session/scannersession.vala b/src/scanner-session/scannersession.vala
index eeb02e3..23db939 100644
--- a/src/scanner-session/scannersession.vala
+++ b/src/scanner-session/scannersession.vala
@@ -78,6 +78,28 @@ public class ScannerSessionImplementation {
return true;
}
+ private ScannerSessionCodeType getCodeType(string scannerdata){
+ if(scannerdata.has_prefix("USER ")){
+ return ScannerSessionCodeType.USER;
+ } else if(scannerdata == "GUEST") {
+ return ScannerSessionCodeType.GUEST;
+ } else if(scannerdata == "UNDO") {
+ return ScannerSessionCodeType.UNDO;
+ } else if(scannerdata == "LOGOUT") {
+ return ScannerSessionCodeType.LOGOUT;
+ } else {
+ //Handle EAN Code
+ uint64 id = 0;
+ scannerdata.scanf("%llu", out id);
+
+ /* check if scannerdata has valid format */
+ if(scannerdata != "%llu".printf(id) && scannerdata != "%08llu".printf(id) && scannerdata != "%013llu".printf(id)) {
+ return ScannerSessionCodeType.UNKNOWN;
+ }
+ return ScannerSessionCodeType.EAN;
+ }
+ }
+
private void play_audio(AudioType audioType){
switch (audioType) {
case AudioType.ERROR: