Menu
Home
Blog
Add-ons
Forum
Wiki
Developers
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
extensions
mashTape
components
src
GoogleBlogs.js
Go to the documentation of this file.
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"
);
4
5
const
Cc
= Components.classes;
6
const
Ci
= Components.interfaces;
7
const
Cr
= Components.results;
8
9
const
DESCRIPTION
=
"mashTape Provider: Google Blog Search Provider"
;
10
const
CID
=
"{3814ef10-7a19-11dd-ad8b-0800200c9a66}"
;
11
const
CONTRACTID
=
"@songbirdnest.com/mashTape/provider/rss/GoogleBlogs;1"
;
12
13
// XPCOM constructor for our Yahoo News mashTape provider
14
function
GoogleBlogs
() {
15
Components.utils.import(
"resource://mashtape/mtUtils.jsm"
);
16
this.wrappedJSObject =
this
;
17
}
18
19
GoogleBlogs
.prototype.constructor =
GoogleBlogs
;
20
GoogleBlogs
.prototype = {
21
classDescription
:
DESCRIPTION
,
22
classID
: Components.ID(
CID
),
23
contractID
:
CONTRACTID
,
24
QueryInterface
: XPCOMUtils.generateQI([
Ci
.sbIMashTapeRSSProvider,
25
Ci
.sbIMashTapeProvider]),
26
27
providerName:
"Google Blog Search"
,
28
providerUrl:
"http://blogsearch.google.com"
,
29
providerType:
"rss"
,
30
providerIcon:
"chrome://mashtape/content/tabs/google.png"
,
31
32
query:
function
(searchTerms, updateFn) {
33
var req =
Cc
[
"@mozilla.org/xmlextras/xmlhttprequest;1"
]
34
.createInstance(
Ci
.nsIXMLHttpRequest);
35
var
url
=
"http://blogsearch.google.com/blogsearch_feeds?hl=en&c2coff=1&lr=lang_en&safe=off&q=%22"
+ searchTerms +
"&ie=utf-8&num=10&output=rss"
;
36
mtUtils.log(
"Google Blogs"
,
"URL:"
+ url);
37
req.open(
"GET"
, url,
true
);
38
req.provider =
this
;
39
req.updateFn = updateFn;
40
req.onreadystatechange =
function
() {
41
if
(this.readyState != 4)
42
return
;
43
if
(this.status == 200) {
44
var x =
new
XML(this.responseText.replace(
45
'<?xml version="1.0" encoding="UTF-8"?>'
,
""
));
46
47
var dcNs =
new
Namespace(
"http://purl.org/dc/elements/1.1/"
);
48
var results =
new
Array
();
49
for each
(var
entry
in
x..item) {
50
var dateObj =
new
Date();
51
dateObj.setISO8601(entry.dcNs::date);
52
var item = {
53
title: entry.title,
54
time: dateObj.getTime(),
55
provider: this.provider.providerName,
56
providerUrl: this.provider.providerUrl,
57
url: entry.link,
58
content: entry.description,
59
}
60
results.push(item);
61
}
62
63
results.wrappedJSObject = results;
64
this.updateFn.wrappedJSObject.update(
CONTRACTID
, results);
65
}
66
}
67
req.send(
null
);
68
},
69
}
70
71
var
components
= [
GoogleBlogs
];
72
function
NSGetModule
(compMgr, fileSpec) {
73
return
XPCOMUtils.generateModule([
GoogleBlogs
]);
74
}
75
entry
classDescription entry
Definition:
FeedWriter.js:1427
GoogleBlogs
function GoogleBlogs()
Definition:
GoogleBlogs.js:14
contractID
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
Definition:
sbDeviceFirmwareAutoCheckForUpdate.js:125
Array
Array
Definition:
mootools-1.2-core.js:12
QueryInterface
sbOSDControlService prototype QueryInterface
Definition:
sbOSDControlService.js:510
classDescription
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
Definition:
sbDeviceFirmwareAutoCheckForUpdate.js:121
Cr
const Cr
Definition:
GoogleBlogs.js:7
Ci
const Ci
Definition:
GoogleBlogs.js:6
NSGetModule
function NSGetModule(compMgr, fileSpec)
Definition:
GoogleBlogs.js:72
DESCRIPTION
const DESCRIPTION
Definition:
GoogleBlogs.js:9
null
return null
Definition:
FeedWriter.js:1143
Cc
const Cc
Definition:
GoogleBlogs.js:5
url
function url(spec)
Definition:
browser_Bookmarks.js:7
classID
sbDeviceFirmwareAutoCheckForUpdate prototype classID
Definition:
sbDeviceFirmwareAutoCheckForUpdate.js:123
components
var components
Definition:
PartnerDistHelperInitializer.js:74
CONTRACTID
const CONTRACTID
Definition:
GoogleBlogs.js:11
CID
const CID
Definition:
GoogleBlogs.js:10