View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  
16  package org.fourthline.cling.support.xmicrosoft;
17  
18  import org.fourthline.cling.binding.annotations.UpnpAction;
19  import org.fourthline.cling.binding.annotations.UpnpInputArgument;
20  import org.fourthline.cling.binding.annotations.UpnpOutputArgument;
21  import org.fourthline.cling.binding.annotations.UpnpService;
22  import org.fourthline.cling.binding.annotations.UpnpServiceId;
23  import org.fourthline.cling.binding.annotations.UpnpServiceType;
24  import org.fourthline.cling.binding.annotations.UpnpStateVariable;
25  import org.fourthline.cling.binding.annotations.UpnpStateVariables;
26  import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
27  
28  import java.beans.PropertyChangeSupport;
29  
30  /**
31   * Basic implementation of service required by MSFT devices such as XBox 360.
32   *
33   * @author Mario Franco
34   */
35  @UpnpService(
36          serviceId = @UpnpServiceId(
37                  namespace = "microsoft.com",
38                  value = "X_MS_MediaReceiverRegistrar"
39          ),
40          serviceType = @UpnpServiceType(
41                  namespace = "microsoft.com",
42                  value = "X_MS_MediaReceiverRegistrar",
43                  version = 1
44          )
45  )
46  @UpnpStateVariables(
47          {
48                  @UpnpStateVariable(name = "A_ARG_TYPE_DeviceID",
49                                     sendEvents = false,
50                                     datatype = "string"),
51                  @UpnpStateVariable(name = "A_ARG_TYPE_Result",
52                                     sendEvents = false,
53                                     datatype = "int"),
54                  @UpnpStateVariable(name = "A_ARG_TYPE_RegistrationReqMsg",
55                                     sendEvents = false,
56                                     datatype = "bin.base64"),
57                  @UpnpStateVariable(name = "A_ARG_TYPE_RegistrationRespMsg",
58                                     sendEvents = false,
59                                     datatype = "bin.base64")
60          }
61  )
62  public abstract class AbstractMediaReceiverRegistrarService {
63  
64      final protected PropertyChangeSupport propertyChangeSupport;
65  
66      @UpnpStateVariable(eventMinimumDelta = 1)
67      private UnsignedIntegerFourBytes authorizationGrantedUpdateID = new UnsignedIntegerFourBytes(0);
68  
69      @UpnpStateVariable(eventMinimumDelta = 1)
70      private UnsignedIntegerFourBytes authorizationDeniedUpdateID = new UnsignedIntegerFourBytes(0);
71  
72      @UpnpStateVariable
73      private UnsignedIntegerFourBytes validationSucceededUpdateID = new UnsignedIntegerFourBytes(0);
74  
75      @UpnpStateVariable
76      private UnsignedIntegerFourBytes validationRevokedUpdateID = new UnsignedIntegerFourBytes(0);
77  
78      protected AbstractMediaReceiverRegistrarService() {
79          this(null);
80      }
81  
82      protected AbstractMediaReceiverRegistrarService(PropertyChangeSupport propertyChangeSupport) {
83          this.propertyChangeSupport = propertyChangeSupport != null ? propertyChangeSupport : new PropertyChangeSupport(this);
84      }
85  
86      public PropertyChangeSupport getPropertyChangeSupport() {
87          return propertyChangeSupport;
88      }
89  
90  
91      @UpnpAction(out = @UpnpOutputArgument(name = "AuthorizationGrantedUpdateID"))
92      public UnsignedIntegerFourBytes getAuthorizationGrantedUpdateID() {
93          return authorizationGrantedUpdateID;
94      }
95  
96      @UpnpAction(out = @UpnpOutputArgument(name = "AuthorizationDeniedUpdateID"))
97      public UnsignedIntegerFourBytes getAuthorizationDeniedUpdateID() {
98          return authorizationDeniedUpdateID;
99      }
100 
101     @UpnpAction(out = @UpnpOutputArgument(name = "ValidationSucceededUpdateID"))
102     public UnsignedIntegerFourBytes getValidationSucceededUpdateID() {
103         return validationSucceededUpdateID;
104     }
105 
106     @UpnpAction(out = @UpnpOutputArgument(name = "ValidationRevokedUpdateID"))
107     public UnsignedIntegerFourBytes getValidationRevokedUpdateID() {
108         return validationRevokedUpdateID;
109     }
110 
111     @UpnpAction(out = {
112             @UpnpOutputArgument(name = "Result",
113                                 stateVariable = "A_ARG_TYPE_Result")
114     })
115     public int isAuthorized(@UpnpInputArgument(name = "DeviceID",
116                                                    stateVariable = "A_ARG_TYPE_DeviceID")
117                                 String deviceID) {
118         return 1;
119     }
120 
121     @UpnpAction(out = {
122             @UpnpOutputArgument(name = "Result",
123                                 stateVariable = "A_ARG_TYPE_Result")
124     })
125     public int isValidated(@UpnpInputArgument(name = "DeviceID",
126                                                   stateVariable = "A_ARG_TYPE_DeviceID")
127                                String deviceID) {
128         return 1;
129     }
130 
131     @UpnpAction(out = {
132             @UpnpOutputArgument(name = "RegistrationRespMsg",
133                                 stateVariable = "A_ARG_TYPE_RegistrationRespMsg")
134     })
135     public byte[] registerDevice(@UpnpInputArgument(name = "RegistrationReqMsg",
136                                                     stateVariable = "A_ARG_TYPE_RegistrationReqMsg")
137                                  byte[] registrationReqMsg) {
138         return new byte[]{};
139     }
140 }