diff --git a/wiiu/accept_friend_request.go b/wiiu/accept_friend_request.go index 91756b2..4001983 100644 --- a/wiiu/accept_friend_request.go +++ b/wiiu/accept_friend_request.go @@ -20,7 +20,7 @@ func AcceptFriendRequest(err error, client *nex.Client, callID uint32, id uint64 senderFriendInfo := nexproto.NewFriendInfo() senderFriendInfo.NNAInfo = senderConnectedUser.NNAInfo - senderFriendInfo.Presence = senderConnectedUser.Presence + senderFriendInfo.Presence = senderConnectedUser.PresenceV2 senderFriendInfo.Status = database_wiiu.GetUserComment(senderPID) senderFriendInfo.BecameFriend = friendInfo.BecameFriend senderFriendInfo.LastOnline = friendInfo.LastOnline // TODO: Change this diff --git a/wiiu/notifications.go b/wiiu/notifications.go new file mode 100644 index 0000000..95c1292 --- /dev/null +++ b/wiiu/notifications.go @@ -0,0 +1,64 @@ +package friends_wiiu + +import ( + "time" + + database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu" + "github.com/PretendoNetwork/friends-secure/globals" + nex "github.com/PretendoNetwork/nex-go" + nexproto "github.com/PretendoNetwork/nex-protocols-go" +) + +// Notifications that are used in other files with no main file + +func SendUserWentOfflineNotifications(client *nex.Client) { + lastOnline := nex.NewDateTime(0) + lastOnline.FromTimestamp(time.Now()) + + nintendoNotificationEventGeneral := nexproto.NewNintendoNotificationEventGeneral() + + nintendoNotificationEventGeneral.U32Param = 0 + nintendoNotificationEventGeneral.U64Param1 = 0 + nintendoNotificationEventGeneral.U64Param2 = lastOnline.Value() + nintendoNotificationEventGeneral.StrParam = "" + + eventObject := nexproto.NewNintendoNotificationEvent() + eventObject.Type = 10 + eventObject.SenderPID = client.PID() + eventObject.DataHolder = nex.NewDataHolder() + eventObject.DataHolder.SetTypeName("NintendoNotificationEventGeneral") + eventObject.DataHolder.SetObjectData(nintendoNotificationEventGeneral) + + stream := nex.NewStreamOut(globals.NEXServer) + stream.WriteStructure(eventObject) + + rmcRequest := nex.NewRMCRequest() + rmcRequest.SetProtocolID(nexproto.NintendoNotificationsProtocolID) + rmcRequest.SetCallID(3810693103) + rmcRequest.SetMethodID(nexproto.NintendoNotificationsMethodProcessNintendoNotificationEvent1) + rmcRequest.SetParameters(stream.Bytes()) + + rmcRequestBytes := rmcRequest.Bytes() + + friendList := database_wiiu.GetUserFriendList(client.PID()) + + for i := 0; i < len(friendList); i++ { + friendPID := friendList[i].NNAInfo.PrincipalBasicInfo.PID + connectedUser := globals.ConnectedUsers[friendPID] + + if connectedUser != nil { + requestPacket, _ := nex.NewPacketV0(connectedUser.Client, nil) + + requestPacket.SetVersion(0) + requestPacket.SetSource(0xA1) + requestPacket.SetDestination(0xAF) + requestPacket.SetType(nex.DataPacket) + requestPacket.SetPayload(rmcRequestBytes) + + requestPacket.AddFlag(nex.FlagNeedsAck) + requestPacket.AddFlag(nex.FlagReliable) + + globals.NEXServer.Send(requestPacket) + } + } +} diff --git a/wiiu/update_and_get_all_information.go b/wiiu/update_and_get_all_information.go index a3b19f2..4a3c75f 100644 --- a/wiiu/update_and_get_all_information.go +++ b/wiiu/update_and_get_all_information.go @@ -27,7 +27,7 @@ func UpdateAndGetAllInformation(err error, client *nex.Client, callID uint32, nn pid := client.PID() globals.ConnectedUsers[pid].NNAInfo = nnaInfo - globals.ConnectedUsers[pid].Presence = presence + globals.ConnectedUsers[pid].PresenceV2 = presence principalPreference := database_wiiu.GetUserPrincipalPreference(pid) comment := database_wiiu.GetUserComment(pid) diff --git a/wiiu/update_presence.go b/wiiu/update_presence.go index 31a0c5c..53072d3 100644 --- a/wiiu/update_presence.go +++ b/wiiu/update_presence.go @@ -15,7 +15,7 @@ func UpdatePresence(err error, client *nex.Client, callID uint32, presence *nexp presence.Online = true // Force online status. I have no idea why this is always false presence.PID = client.PID() // WHY IS THIS SET TO 0 BY DEFAULT?? - globals.ConnectedUsers[pid].Presence = presence + globals.ConnectedUsers[pid].PresenceV2 = presence sendUpdatePresenceWiiUNotifications(presence) rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)