sbIRemoteSecurityEvent.idl
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
27 #include "nsISupports.idl"
28 
29 interface nsIDOMDocument;
30 interface nsIDOMEvent;
31 interface nsIURI;
32 
33 /*
34 Event: SecurityEvent
35 
36 A <SecurityEvent> is passed to any event handlers listening for
37 security permissions status related events fired on the document object.
38 
39 Note that the <Songbird> object must be accessed before any events will be
40 raised. This will likely change in the future.
41 
42 Example:
43  The JavaScript code.
44 
45  (start code)
46  var myDiv;
47 
48  function load() {
49  document.addEventListener('RemoteAPIPermissionChanged', handleEvent, true);
50  document.addEventListener('RemoteAPIPermissionDenied', handleEvent, true);
51 
52  myDiv = document.getElementById("output");
53 
54  // Enumerate some items in the mainLibrary.
55  var listener = {
56  onEnumerationBegin: function() {
57  },
58  onEnumeratedItem: function(list, item) {
59  var artistName = item.getProperty("http://songbirdnest.com/data/1.0#artistName");
60  var trackName = item.getProperty("http://songbirdnest.com/data/1.0#trackName");
61 
62  //I love this track.
63  var msg = "I love this song, it's by " +
64  artistName +
65  " and I think the track name is " +
66  trackName;
67 
68  myDiv.appendChild( document.createTextNode(msg) );
69  myDiv.appendChild( document.createElement("br") );
70 
71  // Returning CANCEL stops the enumeration process, returning CONTINUE
72  // or omitting the return statement continues.
73  return Components.interfaces.sbIMediaListEnumerationListener.CONTINUE;
74  },
75  onEnumerationEnd: function() {
76  var msg = "I like a lot of tracks."
77 
78  // I like a lot of tracks.
79  myDiv.appendChild( document.createTextNode(msg) );
80  }
81  };
82 
83  // Attempt to enumerate all items
84  songbird.mainLibrary.enumerateAllItems(listener, 0);
85  }
86 
87  function unload() {
88  document.removeEventListener('RemoteAPIPermissionChanged', handleEvent, true);
89  document.removeEventListener('RemoteAPIPermissionDenied', handleEvent, true);
90  }
91 
92  function handleEvent(aEvent) {
93  var msg = "";
94 
95  if ( aEvent.type == 'RemoteAPIPermissionDenied' ) {
96  msg = "You have opted to not configure Songbird so our webpage can interact " +
97  "with it at its fullest. Please open tools->options and configure the " +
98  "RemoteAPI preferences to allow us XYZ permissions. " +
99  "Below are the permissions that were requested.";
100 
101  myDiv.appendChild( document.createTextNode(msg) );
102 
103  myDiv.appendChild( document.createElement("br") );
104 
105  myDiv.appendChild( document.createTextNode(aEvent.category +
106  " ( " + aEvent.categoryID + " ) , " +
107  aEvent.hasAccess));
108  }
109  else if( aEvent.type == "RemoteAPIPermissionChanged" ) {
110  msg = "Thanks! You've granted the following permissions:";
111 
112  myDiv.appendChild( document.createTextNode(msg) );
113 
114  myDiv.appendChild( document.createElement("br") );
115 
116  myDiv.appendChild( document.createTextNode(aEvent.category +
117  " ( " + aEvent.categoryID + " ) , " +
118  aEvent.hasAccess) );
119  myDiv.appendChild(document.createElement("br"));
120  }
121 
122  try {
123  myDiv.appendChild(document.createTextNode(aEvent.originalTarget.location));
124  } catch (e) { }
125 
126  myDiv.appendChild(document.createElement("br"));
127 
128  try {
129  myDiv.appendChild(document.createTextNode(aEvent.type));
130  } catch (e) { }
131 
132  myDiv.appendChild(document.createElement("br"));
133  }
134  (end code)
135 
136  And then don't forget to add this to your HTML code.
137 
138  (start code)
139  <body onload="load();" onunload="unload();">
140  <div id="output">
141  </div>
142  </body>
143  (end code)
144 
145  See Also:
146  <MediaItem>
147  <http://developer.mozilla.org/en/docs/DOM:event>
148  <http://developer.mozilla.org/en/docs/DOM:element.addEventListener>
149 */
150 
156 [scriptable, uuid(2faa8d0f-b3b0-4545-b06b-2ce92d53e7e3)]
158 {
159  /*
160  Prop: siteScope
161 
162  The <Security> site scope.
163 
164  Type:
165  URI
166  */
167  readonly attribute nsIURI siteScope;
168 
169  /*
170  Prop: category
171 
172  The <Security> category.
173 
174  Type:
175  String
176  */
177  readonly attribute AString category;
178 
179  /*
180  Prop: categoryID
181 
182  The <Security> category ID. This is the internal ID for the <category>.
183 
184  Type:
185  String
186  */
187  readonly attribute AString categoryID;
188 
189  /*
190  Prop: hasAccess
191 
192  Indicates if access is granted for the <Security> category.
193 
194  Type:
195  Boolean
196  */
197  readonly attribute boolean hasAccess;
198 };
199 
200 [scriptable, uuid(422A0C68-C4A3-40c6-974D-37D1E71BAE8C)]
202 {
203  void initSecurityEvent(in nsIDOMDocument aDoc, in nsIURI aSiteScope, in AString aCategory, in AString aCategoryID, in boolean aHasAccess);
204 };
var D
readonly attribute boolean hasAccess
var uuid
readonly attribute nsIURI siteScope
readonly attribute AString category
readonly attribute AString categoryID
void initSecurityEvent(in nsIDOMDocument aDoc, in nsIURI aSiteScope, in AString aCategory, in AString aCategoryID, in boolean aHasAccess)
An interface to maintain information about the last security event that occurred. ...