This repository has been archived by the owner on Jan 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
overhaul architecture for toolbar. more full-fledged xpcom service ru…
…ns in the background for the duration of the browser session, polling facebook every 5 minutes. next up: notification service to establish communication between back-end and front-end.
- Loading branch information
Ari Steinberg
committed
Oct 6, 2006
1 parent
40ddc33
commit 098a085
Showing
11 changed files
with
664 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,45 @@ | ||
var client = new FacebookRestClient(); | ||
function debug(s) { dump('** login.js: ' + s + '\n'); } | ||
var client = new FacebookLoginClient(); | ||
function startup() { | ||
if (client.settings.sessionKey) { | ||
dump('already logged in!\n'); | ||
if (client.fbSvc.loggedIn) { | ||
debug('already logged in!'); | ||
window.close(); | ||
} else if (!client.settings.authToken) { | ||
client.settings.apiKey = '64f19267b0e6177ea503046d801c00df'; | ||
client.settings.secret = 'a8a5a57a9f9cd57473797c4612418908'; | ||
dump('requesting token\n'); | ||
} else if (!client.authToken) { | ||
debug('requesting token'); | ||
try { | ||
client.callMethod('facebook.auth.createToken', [], function(req) { | ||
dump('received token response:\n'); | ||
debug('received token response:'); | ||
dump(req.responseText); | ||
client.settings.authToken = req.xmldata.token; | ||
dump('token is: '+client.settings.authToken+'\n'); | ||
client.authToken = req.xmldata.token; | ||
debug('token is: '+client.authToken); | ||
startup(); | ||
}); | ||
} catch (e) { | ||
dump('exception: ' + e + '\n'); | ||
debug('exception: ' + e); | ||
} | ||
} else { | ||
document.getElementById('facebook-login-body'). | ||
setAttribute('src', 'http://api.facebook.com/login.php?api_key=' + | ||
client.settings.apiKey + '&auth_token=' + | ||
client.settings.authToken); | ||
dump('loading login page\n'); | ||
client.fbSvc.apiKey + '&auth_token=' + client.authToken); | ||
debug('loading login page'); | ||
} | ||
} | ||
window.addEventListener('load', startup, false); | ||
|
||
function done() { | ||
dump('done called\n'); | ||
client.callMethod('facebook.auth.getSession', ['auth_token='+client.settings.authToken], function(req) { | ||
dump('received session response:\n'); | ||
debug('done()'); | ||
client.callMethod('facebook.auth.getSession', ['auth_token='+client.authToken], function(req) { | ||
debug('received session response:'); | ||
dump(req.responseText); | ||
client.settings.sessionKey = req.xmldata.session_key; | ||
client.settings.uid = req.xmldata.uid; | ||
client.settings.sessionSecret = req.xmldata.secret; | ||
client.settings.authToken = null; | ||
dump('session: ' + client.settings.sessionKey + ', uid: ' + client.settings.uid + ', secret: ' + client.settings.sessionSecret + '\n'); | ||
var sessionKey = req.xmldata.session_key; | ||
var sessionSecret = req.xmldata.secret; | ||
var uid = req.xmldata.uid; | ||
client.fbSvc.sessionStart(sessionKey, sessionSecret, uid); | ||
client.authToken = null; | ||
debug('session: ' + sessionKey + ', uid: ' + uid + ', secret: ' + sessionSecret); | ||
window.setTimeout("window.close();",1); // for some reason calling window.close directly does not work | ||
parent.getElementById('facebook-panel').label = 'logged in!'; | ||
parent.getElementById('facebook-panel').label = 'logged in!'; // XXX will be handled by observer | ||
}); | ||
} | ||
|
||
function ready() { | ||
dump('readystatechanged\n'); | ||
} | ||
dump('loaded login.js\n'); | ||
debug('loaded login.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "nsISupports.idl" | ||
|
||
/* | ||
[scriptable, uuid(c4051391-2b3a-427d-8cd0-8398d168858d)] | ||
interface fbIFacebookCallListener : nsISupports | ||
{ | ||
void onFail(in string result); | ||
void onSuccess(in string result); | ||
}; | ||
*/ | ||
|
||
[scriptable, uuid(19baf81b-d1bd-4a99-9010-dd6f478bfd22)] | ||
interface fbIFacebookService : nsISupports | ||
{ | ||
readonly attribute AString apiKey; | ||
readonly attribute AString secret; | ||
|
||
// login.xul is responsible for performing the login sequence. Once that | ||
// is finished, it should call sessionStart, which initiates the polling | ||
// process. If the session ever ends, the polling will stop until | ||
// sessionStart is called again. Aside from the facebook.auth methods, | ||
// all other Facebook API calls should be done inside this service. | ||
void sessionStart(in AString sessionKey, in AString sessionSecret, in AString uid); | ||
void sessionEnd(); | ||
|
||
// All other interaction comes by windows listing themselves as observers | ||
// and notifications that get triggered by the polling process. | ||
// Notifications that we fire: | ||
// facebook-session-start | ||
// facebook-session-end | ||
// facebook-new-message | ||
// facebook-new-poke | ||
// Windows can also query the most recent status of these things via the | ||
// readonly attributes below: | ||
readonly attribute boolean loggedIn; | ||
readonly attribute long numMsgs; | ||
}; |
Oops, something went wrong.