--bugs
authorBernhard Tittelbach <xro@realraum.at>
Sat, 5 Oct 2013 14:01:24 +0000 (14:01 +0000)
committerBernhard Tittelbach <xro@realraum.at>
Sat, 5 Oct 2013 14:01:24 +0000 (14:01 +0000)
go/r3-eventbroker_zmq/logging.go
go/r3-netstatus/logging.go
go/r3-netstatus/main.go
go/r3-netstatus/make_deploy.zsh
go/r3-netstatus/r3xmppbot/logging.go
go/r3-netstatus/r3xmppbot/r3xmppbot.go
go/r3events/marshal_events.go

index 0c0cd40..bdd2855 100644 (file)
@@ -26,5 +26,5 @@ func LogEnableSyslog() {
 }
 
 func LogEnableDebuglog() {
-    Debug_ = log.New(os.Stderr, "DEBUG", log.LstdFlags)
+    Debug_ = log.New(os.Stderr, "DEBUG ", log.LstdFlags)
 }
\ No newline at end of file
index b805aba..b3473ed 100644 (file)
@@ -27,5 +27,5 @@ func LogEnableSyslog() {
 
 func LogEnableDebuglog() {
     Syslog_ = log.New(os.Stdout, "", log.LstdFlags)
-    Debug_ = log.New(os.Stderr, "DEBUG", log.LstdFlags)
+    Debug_ = log.New(os.Stderr, "DEBUG ", log.LstdFlags)
 }
\ No newline at end of file
index 0af7ef8..d5b3e2f 100644 (file)
@@ -81,7 +81,7 @@ func EventToXMPP(ps *pubsub.PubSub, xmpp_presence_events_chan_ chan <- interface
     xmpp_presence_events_chan_ <- r3xmppbot.XMPPStatusEvent{r3xmppbot.ShowNotAvailabe, "Nobody is here"}
 
     for eventinterface := range(events) {
-        Debug_.Println("event2xmpp", eventinterface)
+        Debug_.Printf("event2xmpp: %T %+v", eventinterface, eventinterface)
         switch event := eventinterface.(type) {
             case r3events.PresenceUpdate:
                 present = event.Present
@@ -119,6 +119,7 @@ func EventToXMPP(ps *pubsub.PubSub, xmpp_presence_events_chan_ chan <- interface
 
 func ParseZMQr3Event(lines [][]byte, ps *pubsub.PubSub) {
     evnt, pubsubcat, err := r3events.UnmarshalByteByte2Event(lines)
+    Debug_.Printf("ParseZMQr3Event: %s %s %s", evnt, pubsubcat, err)
     if err != nil { return }
     ps.Pub(evnt, pubsubcat)
 }
index 24be54e..f43a274 100644 (file)
@@ -1,6 +1,7 @@
 #!/bin/zsh
 export GO386=387
+export CGO_ENABLED=1
 go-linux-386 clean
 #go-linux-386 build
 #strip ${PWD:t}
-go-linux-386 build -ldflags "-s" && rsync --progress -v ${PWD:t} wuzzler.realraum.at:/flash/tuer/
+go-linux-386 build -ldflags "-s" && rsync -v --progress ${PWD:t} wuzzler.realraum.at:/flash/tuer/
index 83a7dad..d8ae7f6 100644 (file)
@@ -27,5 +27,5 @@ func LogEnableSyslog() {
 
 func LogEnableDebuglog() {
     Syslog_ = log.New(os.Stdout, "", log.LstdFlags)
-    Debug_ = log.New(os.Stderr, "DEBUG", log.LstdFlags)
+    Debug_ = log.New(os.Stderr, "DEBUG ", log.LstdFlags)
 }
\ No newline at end of file
index 7863b70..141e541 100644 (file)
@@ -191,6 +191,7 @@ func (botdata *XmppBot) handleEventsforXMPP(xmppout chan <- xmpp.Stanza, presenc
        for {
                select {
                case pe := <-presence_events:
+            Debug_.Printf("handleEventsforXMPP<-presence_events: %T %+v", pe, pe)
             switch pec := pe.(type) {
                 case xmpp.Stanza:
                     xmppout <- pec
@@ -219,10 +220,18 @@ func (botdata *XmppBot) handleEventsforXMPP(xmppout chan <- xmpp.Stanza, presenc
                 }
 
                case je := <-jabber_events:
+            Debug_.Printf("handleEventsforXMPP<-jabber_events: %T %+v", je, je)
             simple_jid := removeJIDResource(je.JID)
             jid_data, jid_in_map := botdata.realraum_jids_[simple_jid]
+            
+            //send status if requested, even if user never changed any settings and thus is not in map
+            if last_status_msg != nil && je.StatusNow {
+                xmppout <-  botdata.makeXMPPMessage(je.JID, last_status_msg, nil)
+            }
+            
             if jid_in_map {
-                if last_status_msg != nil && (je.StatusNow || (! jid_data.Online && je.Online && jid_data.Wants == R3OnlineOnlyWithRecapInfo) ) {
+                //if R3OnlineOnlyWithRecapInfo, we want a status update when coming online
+                if last_status_msg != nil && ! jid_data.Online && je.Online && jid_data.Wants == R3OnlineOnlyWithRecapInfo {
                     xmppout <-  botdata.makeXMPPMessage(je.JID, last_status_msg, nil)
                 }
                 jid_data.Online = je.Online
@@ -388,6 +397,7 @@ func NewStartedBot(loginjid, loginpwd, password, state_save_dir string, insecure
 
     roster := xmpp.Roster(botdata.xmppclient_)
     for _, entry := range roster {
+        Debug_.Print(entry)
         if entry.Subscription == "from" {
             botdata.xmppclient_.Out <- botdata.makeXMPPPresence(entry.Jid, "subscribe", "","")
         }
index 041452c..212f9b1 100644 (file)
@@ -32,69 +32,85 @@ func UnmarshalByteByte2Event(data [][]byte) (event interface{}, category string,
     }
     switch string(data[0]) {
         case "DoorLockUpdate":
-            event = DoorLockUpdate{}
-            err = json.Unmarshal(data[1],&event)
+            newevent := new(DoorLockUpdate)
+            err = json.Unmarshal(data[1],newevent)
             category = "door"
+            event = *newevent
         case "DoorAjarUpdate":
-            event := DoorAjarUpdate{}
-            err = json.Unmarshal(data[1], &event)
+            newevent := new(DoorAjarUpdate)
+            err = json.Unmarshal(data[1], newevent)
             category = "door"
+            event = *newevent
         case "BackdoorAjarUpdate":
-            event := DoorAjarUpdate{}
-            err = json.Unmarshal(data[1], &event)
+            newevent := new(BackdoorAjarUpdate)
+            err = json.Unmarshal(data[1], newevent)
             category = "door"
+            event = *newevent
         case "DoorCommandEvent":
-            event := DoorCommandEvent{}
-            err = json.Unmarshal(data[1], &event)
+            newevent := new(DoorCommandEvent)
+            err = json.Unmarshal(data[1], newevent)
             category = "door"
+            event = *newevent
         case "DoorProblemEvent":
-            event := DoorProblemEvent{}
-            err = json.Unmarshal(data[1], &event)
+            newevent := new(DoorProblemEvent)
+            err = json.Unmarshal(data[1], newevent)
             category = "door"
+            event = *newevent
         case "BoreDoomButtonPressEvent":
-            event := BoreDoomButtonPressEvent{}
-            err = json.Unmarshal(data[1], &event)
+            newevent := new(BoreDoomButtonPressEvent)
+            err = json.Unmarshal(data[1], newevent)
             category = "buttons"
+            event = *newevent
         case "TempSensorUpdate":
-            event := TempSensorUpdate{}
-            err = json.Unmarshal(data[1], &event)
+            newevent := new(TempSensorUpdate)
+            err = json.Unmarshal(data[1], newevent)
             category = "sensors"
+            event = *newevent
         case "IlluminationSensorUpdate":
-            event := IlluminationSensorUpdate{}
-            err = json.Unmarshal(data[1], &event)
+            newevent := new(IlluminationSensorUpdate)
+            err = json.Unmarshal(data[1], newevent)
             category = "sensors"
+            event = *newevent
         case "DustSensorUpdate":
-            event := DustSensorUpdate{}
-            err = json.Unmarshal(data[1], &event)
+            newevent := new(DustSensorUpdate)
+            err = json.Unmarshal(data[1], newevent)
             category = "sensors"
+            event = *newevent
         case "RelativeHumiditySensorUpdate":
-            event := RelativeHumiditySensorUpdate{}
-            err = json.Unmarshal(data[1], &event)
+            newevent := new(RelativeHumiditySensorUpdate)
+            err = json.Unmarshal(data[1], newevent)
             category = "sensors"
+            event = *newevent
         case "TimeTick":
-            event := TimeTick{}
-            err = json.Unmarshal(data[1], &event)
+            newevent := new(TimeTick)
+            err = json.Unmarshal(data[1], newevent)
             category = "time"
+            event = *newevent
         case "MovementSensorUpdate":
-            event := MovementSensorUpdate{}
-            err = json.Unmarshal(data[1], &event)
+            newevent := new(MovementSensorUpdate)
+            err = json.Unmarshal(data[1], newevent)
             category = "movement"
+            event = *newevent
         case "PresenceUpdate":
-            event := PresenceUpdate{}
-            err = json.Unmarshal(data[1], &event)
+            newevent := new(PresenceUpdate)
+            err = json.Unmarshal(data[1], newevent)
             category = "presence"
+            event = *newevent
         case "SomethingReallyIsMoving":
-            event := SomethingReallyIsMoving{}
-            err = json.Unmarshal(data[1], &event)
+            newevent := new(SomethingReallyIsMoving)
+            err = json.Unmarshal(data[1], newevent)
             category = "movement"
+            event = *newevent
         case "NetDHCPACK":
-            event := NetDHCPACK{}
-            err = json.Unmarshal(data[1], &event)
+            newevent := new(NetDHCPACK)
+            err = json.Unmarshal(data[1], newevent)
             category = "network"
+            event = *newevent
         case "NetGWStatUpdate":
-            event := NetGWStatUpdate{}
-            err = json.Unmarshal(data[1], &event)
+            newevent := new(NetGWStatUpdate)
+            err = json.Unmarshal(data[1], newevent)
             category = "network"
+            event = *newevent
         default:
             event = nil
             err = errors.New("cannot unmarshal unknown type")