Permalink
Browse files

Now checking token on home scene activation, added text to auth error…

… dialog suggesting refresh to work around cache issue
  • Loading branch information...
1 parent ce336bf commit c02ce86d8e21efcfe5ddbf51f902655dd6f666ef @lmorchard committed Oct 1, 2009
Showing with 101 additions and 46 deletions.
  1. +2 −2 Makefile
  2. +1 −1 README.md
  3. +16 −9 TODO.md
  4. +20 −5 src/app/assistants/auth-assistant.js
  5. +20 −2 src/app/assistants/home-assistant.js
  6. +41 −26 src/app/assistants/photo-assistant.js
  7. +1 −1 src/sources.json
View
@@ -28,8 +28,8 @@ ifeq ($(TARGET),device)
else
NOVACOM_ID=$(shell novacom -l | grep emulator | head -1 | cut -d' ' -f2)
DEVICE=tcp
- UPDATE_TARGETS=kill-inspector remove restart launch launch-inspector tail-log
- #UPDATE_TARGETS=remove launch tail-log
+ #UPDATE_TARGETS=kill-inspector remove restart launch launch-inspector tail-log
+ UPDATE_TARGETS=remove launch tail-log
TESTS_TARGETS=launch-tests tail-log
endif
View
@@ -1,4 +1,4 @@
-# Flickr Uploadr for webOS, v0.0.1
+# Flickr Uploadr for webOS
* l.m.orchard
* <http://decafbad.com>
View
25 TODO.md
@@ -1,30 +1,37 @@
# TODO
-## v0.0.1
+## v0.0.2
-* Basic photo uploading
+* Run checkToken on home scene, discard token and re-auth if fails
-## v0.0.2
+## v0.0.3
* Better icon
+* Display name of auth'd user
+* App support scene
+ * Help
+ * Links to support forum
* Metadata editing
* Title
* Description
* Tags
-* App support scene
- * Help
- * Links to support forum
-## v0.0.3
+## v0.0.4
* Metadata editing
- * Sets
* Privacy
+ * Sets
* Content type
## v1.0.0
+* Custom multiple photo selection UI using MediaDB service
+* Better progress bars for individual uploads in queue
+* Better icons for queue item upload status
* Cancel upload
-* Better progress bars for individual uploads
* Manage existing photos?
* Rotate photos?
+
+## v2.0.0
+
+* Background auto-uploading of new photos
@@ -32,6 +32,14 @@ AuthAssistant.prototype = (function () { /** @lends AuthAssistant# */
['auth-button', Mojo.Event.tap, this.handleAuthTap],
['continue-button', Mojo.Event.tap, this.handleContinueTap]
], this);
+
+ // Since this scene may be pushed by a reauth request, clear the
+ // credentials if any exist.
+ AppGlobals.frob = null;
+ var token_cookie = new Mojo.Model.Cookie('flickr_token');
+ token_cookie.put(AppGlobals.api.options.token = null);
+ var user_cookie = new Mojo.Model.Cookie('flickr_user');
+ user_cookie.put(AppGlobals.api.options.user = null);
},
/**
@@ -54,22 +62,25 @@ AuthAssistant.prototype = (function () { /** @lends AuthAssistant# */
Decafbad.Utils.setupLoadingSpinner(this);
AppGlobals.api.auth_getFrob(
{},
- function (frob, login_url) {
+ function (frob, grant_url) {
Decafbad.Utils.hideLoadingSpinner(this);
AppGlobals.frob = frob;
- Mojo.log("AUTH URL %j", login_url);
+ Mojo.log("AUTH URL %s %j", frob, grant_url);
+
this.controller.serviceRequest(
"palm://com.palm.applicationManager",
{
method: "open",
parameters: {
id: 'com.palm.app.browser',
- params: { target: login_url }
+ params: { target: grant_url }
}
}
);
+
}.bind(this),
function (ev) {
+ Mojo.log("AUTH GETFROB FAILED %j", (ev.responseText));
this.controller.showAlertDialog({
onChoose: function(value) {},
title: $L("Authentication Failed"),
@@ -102,12 +113,16 @@ AuthAssistant.prototype = (function () { /** @lends AuthAssistant# */
}.bind(this),
function (ev) {
+ Mojo.log("AUTH GETTOKEN FAILED %j", (ev.responseText));
this.controller.showAlertDialog({
onChoose: function(value) {},
title: $L("Authentication Failed"),
message:
- $L("Access was not approved. " +
- "Please try authenticating again."),
+ $L("Access was not approved. " +
+ "Please try authenticating again. " +
+ "It may help to refresh the Flickr page " +
+ "in the browser once before authorizing, " +
+ "due to caching issues."),
choices: [
{label:$L("OK"), value:""}
]
@@ -51,6 +51,7 @@ HomeAssistant.prototype = (function () { /** @lends HomeAssistant# */
visible: true,
items: [
//Mojo.Menu.editItem,
+ { label: "Re-authenticate", command: 'MenuReauthenticate' },
{ label: "About", command: 'MenuAbout' }
]
}
@@ -104,10 +105,20 @@ HomeAssistant.prototype = (function () { /** @lends HomeAssistant# */
Mojo.log('No auth cookie, pushing auth scene');
return this.controller.stageController.pushScene('auth');
} else {
- // Token found, so go ahead and use it.
- Mojo.log('Auth: %j %j', token, user);
+ // Stuff the retained auth token into the API object
AppGlobals.api.options.token = token;
AppGlobals.api.options.user = user;
+
+ // Check the token and discard if checkToken fails.
+ AppGlobals.api.auth_checkToken(
+ {},
+ function (token, user, perms) {
+ Mojo.log('Auth: %j %j %j', token, perms, user);
+ }.bind(this),
+ function () {
+ this.controller.stageController.pushScene('auth');
+ }.bind(this)
+ );
}
this.refreshUploadsQueue();
@@ -319,6 +330,13 @@ HomeAssistant.prototype = (function () { /** @lends HomeAssistant# */
}
},
+ /**
+ * Push the auth scene to re-authenticate.
+ */
+ handleCommandMenuReauthenticate: function () {
+ return this.controller.stageController.pushScene('auth');
+ },
+
/**
* Show the about dialog.
*/
@@ -1,32 +1,47 @@
-function PhotoAssistant() {
- /* this is the creator function for your scene assistant object. It will be passed all the
- additional parameters (after the scene name) that were passed to pushScene. The reference
- to the scene controller (this.controller) has not be established yet, so any initialization
- that needs the scene controller should be done in the setup function below. */
+/**
+ * @fileOverview Photo scene assistant
+ * @Photoor <a href="http://decafbad.com">l.m.orchard@pobox.com</a>
+ * @version 0.1
+ */
+/*jslint laxbreak: true */
+/*global Decafbad, AppGlobals, FlickrUploadr, Mojo, $, $L, $A, $H, SimpleDateFormat */
+function PhotoAssistant(Photo_url) {
+ this.Photo_url = Photo_url;
}
-PhotoAssistant.prototype.setup = function() {
- /* this function is for setup tasks that have to happen when the scene is first created */
-
- /* use Mojo.View.render to render view templates and add them to the scene, if needed. */
-
- /* setup widgets here */
-
- /* add event handlers to listen to events from widgets */
-}
+PhotoAssistant.prototype = (function () { /** @lends PhotoAssistant# */
-PhotoAssistant.prototype.activate = function(event) {
- /* put in event handlers here that should only be in effect when this scene is active. For
- example, key handlers that are observing the document */
-}
+ return {
+ /**
+ * Setup the application.
+ */
+ setup: function () {
+ },
-PhotoAssistant.prototype.deactivate = function(event) {
- /* remove any event handlers you added in activate and do any other cleanup that should happen before
- this scene is popped or another scene is pushed on top */
-}
+ /**
+ * React to card activation.
+ */
+ activate: function (ev) {
-PhotoAssistant.prototype.cleanup = function(event) {
- /* this function should do any cleanup needed before the scene is destroyed as
- a result of being popped off the scene stack */
-}
+ Decafbad.Utils.setupListeners([
+ ], this);
+
+ },
+
+ /**
+ * React for card deactivation.
+ */
+ deactivate: function (ev) {
+ Decafbad.Utils.clearListeners(this);
+ },
+
+ /**
+ * Handle ultimate card clean up.
+ */
+ cleanup: function (ev) {
+ },
+
+ EOF:null
+ };
+}());
View
@@ -25,4 +25,4 @@
"scenes": "photo",
"source": "app/assistants/photo-assistant.js"
}
-]
+]

0 comments on commit c02ce86

Please sign in to comment.