Skip to content

Commit

Permalink
add missing events
Browse files Browse the repository at this point in the history
  • Loading branch information
adbenitez committed Feb 4, 2024
1 parent 951cc3a commit 8c64ba3
Showing 1 changed file with 75 additions and 34 deletions.
109 changes: 75 additions & 34 deletions deltachat/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,43 @@ package deltachat
type eventType string

const (
eventTypeInfo eventType = "Info"
eventTypeSmtpConnected eventType = "SmtpConnected"
eventTypeImapConnected eventType = "ImapConnected"
eventTypeSmtpMessageSent eventType = "SmtpMessageSent"
eventTypeImapMessageDeleted eventType = "ImapMessageDeleted"
eventTypeImapMessageMoved eventType = "ImapMessageMoved"
eventTypeImapInboxIdle eventType = "ImapInboxIdle"
eventTypeNewBlobFile eventType = "NewBlobFile"
eventTypeDeletedBlobFile eventType = "DeletedBlobFile"
eventTypeWarning eventType = "Warning"
eventTypeError eventType = "Error"
eventTypeErrorSelfNotInGroup eventType = "ErrorSelfNotInGroup"
eventTypeMsgsChanged eventType = "MsgsChanged"
eventTypeReactionsChanged eventType = "ReactionsChanged"
eventTypeIncomingMsg eventType = "IncomingMsg"
eventTypeIncomingMsgBunch eventType = "IncomingMsgBunch"
eventTypeMsgsNoticed eventType = "MsgsNoticed"
eventTypeMsgDelivered eventType = "MsgDelivered"
eventTypeMsgFailed eventType = "MsgFailed"
eventTypeMsgRead eventType = "MsgRead"
eventTypeMsgDeleted eventType = "MsgDeleted"
eventTypeChatModified eventType = "ChatModified"
eventTypeChatEphemeralTimerModified eventType = "ChatEphemeralTimerModified"
eventTypeContactsChanged eventType = "ContactsChanged"
eventTypeLocationChanged eventType = "LocationChanged"
eventTypeConfigureProgress eventType = "ConfigureProgress"
eventTypeImexProgress eventType = "ImexProgress"
eventTypeImexFileWritten eventType = "ImexFileWritten"
eventTypeSecurejoinInviterProgress eventType = "SecurejoinInviterProgress"
eventTypeSecurejoinJoinerProgress eventType = "SecurejoinJoinerProgress"
eventTypeConnectivityChanged eventType = "ConnectivityChanged"
eventTypeSelfavatarChanged eventType = "SelfavatarChanged"
eventTypeWebxdcStatusUpdate eventType = "WebxdcStatusUpdate"
eventTypeWebxdcInstanceDeleted eventType = "WebxdcInstanceDeleted"
eventTypeUnknow eventType = "UnknownEvent"
eventTypeInfo eventType = "Info"
eventTypeSmtpConnected eventType = "SmtpConnected"
eventTypeImapConnected eventType = "ImapConnected"
eventTypeSmtpMessageSent eventType = "SmtpMessageSent"
eventTypeImapMessageDeleted eventType = "ImapMessageDeleted"
eventTypeImapMessageMoved eventType = "ImapMessageMoved"
eventTypeImapInboxIdle eventType = "ImapInboxIdle"
eventTypeNewBlobFile eventType = "NewBlobFile"
eventTypeDeletedBlobFile eventType = "DeletedBlobFile"
eventTypeWarning eventType = "Warning"
eventTypeError eventType = "Error"
eventTypeErrorSelfNotInGroup eventType = "ErrorSelfNotInGroup"
eventTypeMsgsChanged eventType = "MsgsChanged"
eventTypeReactionsChanged eventType = "ReactionsChanged"
eventTypeIncomingMsg eventType = "IncomingMsg"
eventTypeIncomingMsgBunch eventType = "IncomingMsgBunch"
eventTypeMsgsNoticed eventType = "MsgsNoticed"
eventTypeMsgDelivered eventType = "MsgDelivered"
eventTypeMsgFailed eventType = "MsgFailed"
eventTypeMsgRead eventType = "MsgRead"
eventTypeMsgDeleted eventType = "MsgDeleted"
eventTypeChatModified eventType = "ChatModified"
eventTypeChatEphemeralTimerModified eventType = "ChatEphemeralTimerModified"
eventTypeContactsChanged eventType = "ContactsChanged"
eventTypeLocationChanged eventType = "LocationChanged"
eventTypeConfigureProgress eventType = "ConfigureProgress"
eventTypeImexProgress eventType = "ImexProgress"
eventTypeImexFileWritten eventType = "ImexFileWritten"
eventTypeSecurejoinInviterProgress eventType = "SecurejoinInviterProgress"
eventTypeSecurejoinJoinerProgress eventType = "SecurejoinJoinerProgress"
eventTypeConnectivityChanged eventType = "ConnectivityChanged"
eventTypeSelfavatarChanged eventType = "SelfavatarChanged"
eventTypeConfigSynced eventType = "ConfigSynced"
eventTypeWebxdcStatusUpdate eventType = "WebxdcStatusUpdate"
eventTypeWebxdcInstanceDeleted eventType = "WebxdcInstanceDeleted"
eventTypeAccountsBackgroundFetchDone eventType = "AccountsBackgroundFetchDone"
)

type _Event struct {
Expand All @@ -57,6 +60,7 @@ type _EventData struct {
Comment string
Path string
StatusUpdateSerial uint
Key string
}

func (self *_EventData) ToEvent() Event {
Expand Down Expand Up @@ -139,13 +143,19 @@ func (self *_EventData) ToEvent() Event {
event = EventConnectivityChanged{}
case eventTypeSelfavatarChanged:
event = EventSelfavatarChanged{}
case eventTypeConfigSynced:
event = EventConfigSynced{Key: self.Key}

Check failure on line 147 in deltachat/event.go

View workflow job for this annotation

GitHub Actions / test

cannot use EventConfigSynced{…} (value of type EventConfigSynced) as Event value in assignment: EventConfigSynced does not implement Event (missing method eventType)

Check failure on line 147 in deltachat/event.go

View workflow job for this annotation

GitHub Actions / test

cannot use EventConfigSynced{…} (value of type EventConfigSynced) as Event value in assignment: EventConfigSynced does not implement Event (missing method eventType)
case eventTypeWebxdcStatusUpdate:
event = EventWebxdcStatusUpdate{
MsgId: self.MsgId,
StatusUpdateSerial: self.StatusUpdateSerial,
}
case eventTypeWebxdcInstanceDeleted:
event = EventWebxdcInstanceDeleted{MsgId: self.MsgId}
case eventTypeAccountsBackgroundFetchDone:
event = EventAccountsBackgroundFetchDone{}
default:
event = UnknownEvent{Kind: self.Kind}
}
return event
}
Expand All @@ -155,6 +165,15 @@ type Event interface {
eventType() eventType
}

// Unknown event from a newer unsupported core version
type UnknownEvent struct {
Kind eventType
}

func (self UnknownEvent) eventType() eventType {
return eventTypeUnknown

Check failure on line 174 in deltachat/event.go

View workflow job for this annotation

GitHub Actions / test

undefined: eventTypeUnknown

Check failure on line 174 in deltachat/event.go

View workflow job for this annotation

GitHub Actions / test

undefined: eventTypeUnknown
}

// The library-user may write an informational string to the log.
//
// This event should *not* be reported to the end-user using a popup or something like
Expand Down Expand Up @@ -526,6 +545,17 @@ func (self EventSelfavatarChanged) eventType() eventType {
return eventTypeSelfavatarChanged
}

// A multi-device synced config value changed. Maybe the app needs to refresh smth. For
// uniformity this is emitted on the source device too. The value isn't here, otherwise it
// would be logged which might not be good for privacy.
type EventConfigSynced struct {
Key string
}

func (self ConfigSynced) eventType() eventType {

Check failure on line 555 in deltachat/event.go

View workflow job for this annotation

GitHub Actions / test

undefined: ConfigSynced) (typecheck)

Check failure on line 555 in deltachat/event.go

View workflow job for this annotation

GitHub Actions / test

undefined: ConfigSynced (typecheck)
return eventTypeConfigSynced
}

// Webxdc status update received.
type EventWebxdcStatusUpdate struct {
MsgId MsgId
Expand All @@ -544,3 +574,14 @@ type EventWebxdcInstanceDeleted struct {
func (self EventWebxdcInstanceDeleted) eventType() eventType {
return eventTypeWebxdcInstanceDeleted
}

// Tells that the Background fetch was completed (or timed out).
// This event acts as a marker, when you reach this event you can be sure
// that all events emitted during the background fetch were processed.
//
// This event is only emitted by the account manager
type EventAccountsBackgroundFetchDone struct{}

func (self EventAccountsBackgroundFetchDone) eventType() eventType {
return eventTypeAccountsBackgroundFetchDone
}

0 comments on commit 8c64ba3

Please sign in to comment.