Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Commit

Permalink
Remove debug logs and reword an initialization log
Browse files Browse the repository at this point in the history
  • Loading branch information
jezek committed Apr 25, 2021
1 parent 188581a commit a4fcb8c
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 42 deletions.
16 changes: 1 addition & 15 deletions cmd/nuntium/mediator.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ func (mediator *Mediator) handlePushAgentNotification(pushMsg *ofono.PushPDU, mo
if uuid, ok := mediator.unrespondedTransactions[mNotificationInd.TransactionId]; ok {
log.Printf("Pushed transaction ID (%s) is in undownloaded pointing to UUID: %s", mNotificationInd.TransactionId, uuid)
if st, err := storage.GetMMSState(uuid); err == nil {
log.Printf("jezek - mmsState: %v", st)
if st.MNotificationInd != nil {
log.Printf("Changing recieved date to the first push date: %v", st.MNotificationInd.Received)
mNotificationInd.Received = st.MNotificationInd.Received
Expand Down Expand Up @@ -190,14 +189,12 @@ func (mediator *Mediator) handleDeferredDownload(mNotificationInd *mms.MNotifica
}

func (mediator *Mediator) activateMMSContext() (mmsContext ofono.OfonoContext, deactivationFunc func(), err error) {
log.Printf("jezek - mediator.activateMMSContext start")
preferredContext, _ := mediator.telepathyService.GetPreferredContext()
mmsContext, err = mediator.modem.ActivateMMSContext(preferredContext)
if err != nil {
return
}
deactivationFunc = func() {
log.Printf("jezek - mediator.deactivationFunc start")
if err := mediator.modem.DeactivateMMSContext(mmsContext); err != nil {
log.Println("Issues while deactivating context:", err)
}
Expand Down Expand Up @@ -662,14 +659,11 @@ func mmsEnabled() bool {
}

func (mediator *Mediator) initializeMessages(modemId string) {
log.Printf("jezek - Mediator.initializeMessages(%s): start", modemId)
defer log.Printf("jezek - Mediator.initializeMessages(%s): end", modemId)
historyService := mediator.telepathyService.HistoryService()
handledTransactions := map[string]string{}
uuids := storage.GetStoredUUIDs()
log.Printf("Found %d messages in storage", len(uuids))
log.Printf("Initializing %d messages from storage", len(uuids))
for _, uuid := range uuids {
log.Printf("jezek - checking uuid: %s", uuid)
mmsState, err := storage.GetMMSState(uuid)
if err != nil {
log.Printf("Error checking state of message stored under UUID: %s : %v", uuid, err)
Expand All @@ -678,7 +672,6 @@ func (mediator *Mediator) initializeMessages(modemId string) {
}
continue
}
log.Printf("jezek - %#v", mmsState)

if !mmsState.IsIncoming() {
log.Printf("Message %s is not an incoming message. State: %s", uuid, mmsState.State)
Expand All @@ -695,7 +688,6 @@ func (mediator *Mediator) initializeMessages(modemId string) {
}

if modemId != mmsState.ModemId {
log.Printf("jezek - message modem id (%s) doesn't match added modem (%s)", mmsState.ModemId, modemId)
continue
}
// Just log any irregularities here.
Expand Down Expand Up @@ -723,15 +715,13 @@ func (mediator *Mediator) initializeMessages(modemId string) {
handledTransactions[mmsState.MNotificationInd.TransactionId] = uuid
// Add to unresponded, to not communicate possible error to telepathy again, on possible message notification from MMS center.
mediator.unrespondedTransactions[mmsState.MNotificationInd.TransactionId] = uuid
log.Printf("jezek - added message to unresponded")
}

checkExpiredAndHandle := func() bool {
if !mmsState.MNotificationInd.Expired() {
return false
}

log.Printf("jezek - mNotificationInd is expired")
// MNotificationInd is expired, destroy in storage & notify telepathy service.
if err := storage.Destroy(uuid); err != nil {
log.Printf("Error destroying expired message: %v", err)
Expand Down Expand Up @@ -760,7 +750,6 @@ func (mediator *Mediator) initializeMessages(modemId string) {
// Message is expired (and was deleted from storage), don't continue.
// Remove from unrespondedTransactions.
delete(mediator.unrespondedTransactions, mmsState.MNotificationInd.TransactionId)
log.Printf("jezek - remove message from unresponded")
break
}

Expand Down Expand Up @@ -828,7 +817,6 @@ func (mediator *Mediator) initializeMessages(modemId string) {

// Remove from unrespondedTransactions.
delete(mediator.unrespondedTransactions, mmsState.MNotificationInd.TransactionId)
log.Printf("jezek - remove message from unresponded")

if checkInHistoryService {
// Get message from history service and if read or not exist, delete and don't spawn handlers.
Expand All @@ -837,8 +825,6 @@ func (mediator *Mediator) initializeMessages(modemId string) {
if err != nil {
log.Printf("Error getting message %s from HistoryService: %v", eventId, err)
} else {
log.Printf("jezek - hsMessage: %v", hsMessage)

// If message is doesn't exist, break (don't spawn handlers).
if !hsMessage.Exists() {
log.Printf("Message %s doesn't exist in HistoryService, no need to store, deleting.", uuid)
Expand Down
2 changes: 0 additions & 2 deletions storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ func CreateResponseFile(uuid string) (*os.File, error) {
// Returns the stored message state and a nil error on success.
// If message not in storage or other fail it returns empty or previous state and a non nil error.
func UpdateMNotificationInd(mNotificationInd *mms.MNotificationInd) (MMSState, error) {
log.Printf("jezek - UpdateMNotificationInd(%v)", mNotificationInd)
oldState, err := GetMMSState(mNotificationInd.UUID)
if err != nil {
return oldState, fmt.Errorf("error retrieving message state: %w", err)
Expand All @@ -140,7 +139,6 @@ func UpdateMNotificationInd(mNotificationInd *mms.MNotificationInd) (MMSState, e
// If message not in storage or other error occurs, it returns empty or previous state and a non nil error.
// Note: Can return a forced debug error if MNotificationInd has the right ContentLocation parameters.
func UpdateDownloaded(uuid, filePath string) (MMSState, error) {
log.Printf("jezek - UpdateDownloaded(%s, %s)", uuid, filePath)
oldState, err := GetMMSState(uuid)
if err != nil {
return oldState, fmt.Errorf("error retrieving message state: %w", err)
Expand Down
1 change: 0 additions & 1 deletion telepathy/history/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ var ErrorNilHistoryService = fmt.Errorf("nil HistoryService pointer")

// Returns first message identified by eventId from HistoryService.
func (service *HistoryService) GetMessage(eventId string) (Message, error) {
log.Printf("jezek - GetMessage(%s) - start", eventId)
if service == nil {
return nil, ErrorNilHistoryService
}
Expand Down
3 changes: 0 additions & 3 deletions telepathy/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,9 @@ func (msgInterface *MessageInterface) Close() {
}

func (msgInterface *MessageInterface) watchDBusMethodCalls() {
log.Printf("jezek - msgInterface %v: watchDBusMethodCalls(): start", msgInterface.objectPath)
defer log.Printf("jezek - msgInterface %v: watchDBusMethodCalls(): end", msgInterface.objectPath)
var reply *dbus.Message

for msg := range msgInterface.msgChan {
log.Printf("jezek - msgInterface %v: Received message: %v", msgInterface.objectPath, msg)
if msg.Interface != MMS_MESSAGE_DBUS_IFACE {
log.Println("Received unknown interface call on", msg.Interface, msg.Member)
reply = dbus.NewErrorMessage(
Expand Down
21 changes: 0 additions & 21 deletions telepathy/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,11 @@ func (*MMSService) getMMSState(objectPath dbus.ObjectPath) (storage.MMSState, er

func (service *MMSService) watchMessageDeleteCalls() {
for msgObjectPath := range service.msgDeleteChan {
log.Printf("jezek - MMS delete call: %v", msgObjectPath)

if mmsState, err := service.getMMSState(msgObjectPath); err == nil {
if mmsState.State != storage.RESPONDED && mmsState.MNotificationInd != nil && !mmsState.MNotificationInd.Expired() {
log.Printf("Message %s is not responded and not expired, not deleting.", string(msgObjectPath))
continue
}
} else {
log.Printf("jezek - error retrieving message state: %v", err)
}

if err := service.MessageRemoved(msgObjectPath); err != nil {
Expand All @@ -136,8 +132,6 @@ func (service *MMSService) watchMessageDeleteCalls() {

func (service *MMSService) watchMessageRedownloadCalls() {
for msgObjectPath := range service.msgRedownloadChan {
log.Printf("jezek - MMS redownload call: %v", msgObjectPath)

mmsState, err := service.getMMSState(msgObjectPath)
if err != nil {
log.Printf("Redownload of %s error: retrieving message state error: %v", string(msgObjectPath), err)
Expand All @@ -151,7 +145,6 @@ func (service *MMSService) watchMessageRedownloadCalls() {
log.Printf("Redownload of %s error: no mNotificationInd found", string(msgObjectPath))
continue
}
log.Printf("jezek - mNotificationInd old: %#v", mmsState.MNotificationInd)

// Stop previous message handling, remove and notify.
if err := service.MessageRemoved(msgObjectPath); err != nil {
Expand All @@ -163,16 +156,12 @@ func (service *MMSService) watchMessageRedownloadCalls() {
newMNotificationInd.RedownloadOfUUID = mmsState.MNotificationInd.UUID
newMNotificationInd.UUID = mms.GenUUID()
storage.Create(mmsState.ModemId, newMNotificationInd)
log.Printf("jezek - mNotificationInd new: %#v", newMNotificationInd)
service.mNotificationIndChan <- newMNotificationInd
}
}

func (service *MMSService) watchDBusMethodCalls() {
log.Printf("jezek - MMS %v: watchDBusMethodCalls(): start", service.identity)
defer log.Printf("jezek - MMS %v: watchDBusMethodCalls(): end", service.identity)
for msg := range service.msgChan {
log.Printf("jezek - MMS %v: dbus message: %s - %v", service.identity, msg.Member, msg)
var reply *dbus.Message
if msg.Interface != MMS_SERVICE_DBUS_IFACE {
log.Println("Received unknown interface call on", msg.Interface, msg.Member)
Expand Down Expand Up @@ -360,13 +349,11 @@ func (service *MMSService) IncomingMessageFailAdded(mNotificationInd *mms.MNotif

errorCode := "x-ubports-nuntium-mms-error-unknown"
if eci, ok := downloadError.(interface{ Code() string }); ok {
log.Printf("jezek - downloadError has Code() function returning: %v", eci.Code())
errorCode = eci.Code()
}

allowRedownload := false
if ari, ok := downloadError.(interface{ AllowRedownload() bool }); ok {
log.Printf("jezek - downloadError has AllowRedownload() function returning: %v", ari.AllowRedownload())
allowRedownload = ari.AllowRedownload()
}

Expand All @@ -379,7 +366,6 @@ func (service *MMSService) IncomingMessageFailAdded(mNotificationInd *mms.MNotif

var mobileData *bool
if enabled, err := service.MobileDataEnabled(); err == nil {
log.Printf("jezek - MobileDataEnabled(): %v", enabled)
mobileData = &enabled
} else {
log.Printf("Error detecting if mobile data is enabled: %v", err)
Expand Down Expand Up @@ -447,7 +433,6 @@ func (service *MMSService) IncomingMessageAdded(mRetConf *mms.MRetrieveConf, mNo
}

func (service *MMSService) InitializationMessageAdded(mRetConf *mms.MRetrieveConf, mNotificationInd *mms.MNotificationInd) error {
log.Printf("jezek - InitializationMessageAdded(%v, %v)", mRetConf, mNotificationInd)
if service == nil {
return ErrorNilMMSService
}
Expand All @@ -474,13 +459,9 @@ func (service *MMSService) InitializationMessageAdded(mRetConf *mms.MRetrieveCon
if pl, err := service.parseMessage(mRetConf); err == nil {
if _, ok := pl.Properties["Sender"]; !ok {
payload.Properties["Sender"] = pl.Properties["Sender"]
} else {
log.Printf("jezek - No \"Sender\" property in mRetConf for initialization message %s", path)
}
if _, ok := pl.Properties["Recipients"]; !ok {
payload.Properties["Recipients"] = pl.Properties["Recipients"]
} else {
log.Printf("jezek - No \"Recipients\" property in mRetConf for initialization message %s", path)
}
} else {
log.Printf("Error parsing mRetConf for initialization message %s: %v", path, err)
Expand All @@ -494,7 +475,6 @@ func (service *MMSService) InitializationMessageAdded(mRetConf *mms.MRetrieveCon
//MessageAdded emits a MessageAdded with the path to the added message which
//is taken as a parameter
func (service *MMSService) MessageAdded(msgPayload *Payload) error {
log.Printf("jezek - service %v: MessageAdded(): payload: %v", service.identity, msgPayload)
signal := dbus.NewSignalMessage(service.payload.Path, MMS_SERVICE_DBUS_IFACE, messageAddedSignal)
if err := signal.AppendArgs(msgPayload.Path, msgPayload.Properties); err != nil {
return err
Expand Down Expand Up @@ -575,7 +555,6 @@ func (service *MMSService) MessageDestroy(uuid string) error {
if msgInterface, ok := service.messageHandlers[msgObjectPath]; ok {
msgInterface.Close()
delete(service.messageHandlers, msgObjectPath)
log.Printf("jezek - MessageDestroyed/unhandled(%v)", uuid)
return nil
}
return fmt.Errorf("no message interface handler for object path %s", msgObjectPath)
Expand Down

0 comments on commit a4fcb8c

Please sign in to comment.