1 Components.utils.import(
"resource://gre/modules/XPCOMUtils.jsm");
2 Components.utils.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
3 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
5 const Cc = Components.classes;
6 const Ci = Components.interfaces;
7 const Cr = Components.results;
10 const CID =
"{a86cc290-6990-11dd-ad8b-0800200c9a66}";
11 const CONTRACTID =
"@songbirdnest.com/mashTape/provider/photo/Flickr;1";
15 this.wrappedJSObject =
this;
16 Components.utils.import(
"resource://mashtape/mtUtils.jsm");
25 Ci.sbIMashTapeProvider]),
27 providerName:
"Flickr",
28 providerType:
"photo",
29 providerIcon:
"chrome://mashTape/content/tabs/flickr.png",
31 sort:
"&sort=relevance",
33 searchURL:
"https://api.flickr.com/services/rest/?" +
34 "method=flickr.photos.search&api_key=461354d3cdcc5425055670cbd3b8e16e" +
35 "&extras=owner_name,date_taken,o_dims,original_format",
37 query:
function(searchTerms, updateFn) {
38 var req =
Cc[
"@mozilla.org/xmlextras/xmlhttprequest;1"]
39 .createInstance(
Ci.nsIXMLHttpRequest);
41 var prefBranch =
Cc[
"@mozilla.org/preferences-service;1"]
42 .getService(
Ci.nsIPrefService).getBranch(
"extensions.mashTape.");
43 var keywords = prefBranch.getCharPref(
"photo.keywords");
45 searchTerms +=
"%20" + escape(keywords);
47 var query =
"&per_page=" + this.
limit + this.sort + this.searchType +
48 '"' + searchTerms +
'"';
55 var
url = this.searchURL + query;
57 var songbirdmode =
false;
58 if (searchTerms ==
"Songbird") {
63 url =
"https://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key=33a6c9b21ada1e5b7d85f5cde788e6c7&photoset_id=72157607854460548&extras=owner_name,date_taken,o_dims,original_format";
66 mtUtils.log(
"Flickr",
"URL:" + url);
68 req.open(
"GET", url,
true);
70 req.updateFn = updateFn;
71 req.onreadystatechange =
function() {
72 if (this.readyState != 4)
74 if (this.status == 200) {
75 var x =
new XML(this.responseText.replace(
76 '<?xml version="1.0" encoding="utf-8" ?>',
""));
77 var results =
new Array();
80 set = x..photoset.photo;
82 set = x..photos.photo;
83 for each (var
entry in set) {
84 var origFormat = entry.@originalformat.toString();
88 var
width = entry.@o_width.toString();
89 var
height = entry.@o_height.toString();
91 var imgUrl =
"https://farm" + entry.@farm +
92 ".static.flickr.com/" + entry.@
server +
"/" +
93 entry.@
id +
"_" + entry.@secret;
94 var url =
"https://www.flickr.com/photos/" +
96 var timestamp = entry.@datetaken;
97 var
year = timestamp.substr(0,4);
98 var mon = timestamp.substr(5,2) - 1;
99 var
date = timestamp.substr(8,2);
100 var hour = timestamp.substr(11,2);
101 var
min = timestamp.substr(14,2);
102 var sec = timestamp.substr(17,2);
103 timestamp = Date.UTC(year,mon,date,hour,min,sec);
105 title: entry.@title.toString(),
107 small: imgUrl +
"_m.jpg",
108 medium: imgUrl +
".jpg",
109 large: imgUrl +
"_b.jpg",
110 owner: entry.@ownername.toString(),
111 ownerUrl:
"https://flickr.com/photos/" +
112 escape(entry.@ownername.toString()),
119 mtUtils.log(
"Flickr", x..photos.photo.length()+
" photos found");
121 results.wrappedJSObject = results;
122 this.updateFn.wrappedJSObject.update(
CONTRACTID, results);
131 return XPCOMUtils.generateModule([
Flickr]);
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
function server(port, basePath)
function NSGetModule(compMgr, fileSpec)
BogusChannel prototype owner
sbDeviceFirmwareAutoCheckForUpdate prototype classID