pd.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package server
  2. import (
  3. "fmt"
  4. "github.com/mkaminski/goaim/oscar"
  5. "io"
  6. )
  7. const (
  8. PDErr uint16 = 0x0001
  9. PDRightsQuery = 0x0002
  10. PDRightsReply = 0x0003
  11. PDSetGroupPermitMask = 0x0004
  12. PDAddPermListEntries = 0x0005
  13. PDDelPermListEntries = 0x0006
  14. PDAddDenyListEntries = 0x0007
  15. PDDelDenyListEntries = 0x0008
  16. PDBosErr = 0x0009
  17. PDAddTempPermitListEntries = 0x000A
  18. PDDelTempPermitListEntries = 0x000B
  19. )
  20. func routePD(snac oscar.SnacFrame, r io.Reader, w io.Writer, sequence *uint32) error {
  21. switch snac.SubGroup {
  22. case PDRightsQuery:
  23. return SendAndReceivePDRightsQuery(snac, r, w, sequence)
  24. default:
  25. return ErrUnsupportedSubGroup
  26. }
  27. }
  28. func SendAndReceivePDRightsQuery(snac oscar.SnacFrame, _ io.Reader, w io.Writer, sequence *uint32) error {
  29. fmt.Printf("sendAndReceivePDRightsQuery read SNAC frame: %+v\n", snac)
  30. snacFrameOut := oscar.SnacFrame{
  31. FoodGroup: PD,
  32. SubGroup: PDRightsReply,
  33. }
  34. snacPayloadOut := oscar.SNAC_0x09_0x03_PDRightsReply{
  35. TLVRestBlock: oscar.TLVRestBlock{
  36. TLVList: oscar.TLVList{
  37. {
  38. TType: 0x01,
  39. Val: uint16(100),
  40. },
  41. {
  42. TType: 0x02,
  43. Val: uint16(100),
  44. },
  45. {
  46. TType: 0x03,
  47. Val: uint16(100),
  48. },
  49. },
  50. },
  51. }
  52. return writeOutSNAC(snac, snacFrameOut, snacPayloadOut, sequence, w)
  53. }