Move the getConsumer method to the Connection
authorAndy Allan <gravitystorm@gmail.com>
Tue, 19 Oct 2010 10:10:26 +0000 (10:10 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Tue, 19 Oct 2010 10:10:26 +0000 (10:10 +0000)
net/systemeD/halcyon/connection/Connection.as
net/systemeD/halcyon/connection/XMLConnection.as
net/systemeD/potlatch2/save/SaveManager.as

index 22696c9..bebd589 100755 (executable)
@@ -368,6 +368,7 @@ package net.systemeD.halcyon.connection {
         public function fetchUserTraces(refresh:Boolean=false):void {}
         public function fetchTrace(id:Number, callback:Function):void {}
         public function getAccessToken(data:Object):OAuthToken { return null; } //todo make private and remove import org.ioshtan etc
+        public function getConsumer():OAuthConsumer { return null; }
     }
 
 }
index f64c2ad..09779f2 100644 (file)
@@ -61,7 +61,7 @@ package net.systemeD.halcyon.connection {
            }
 
         /* Get the stored access token, or try setting it up from loader params or passed SharedObject */
-        /* todo: make this private */
+        /* todo: make this private, fix indentation */
         override public function getAccessToken(data:Object):OAuthToken {
           if (authToken == null) {
             var key:String = Connection.getParam("oauth_token", null);
@@ -79,6 +79,18 @@ package net.systemeD.halcyon.connection {
           return authToken;
         }
 
+        override public function getConsumer():OAuthConsumer {
+            if (appID == null) {
+              var key:String = Connection.getParam("oauth_consumer_key", null);
+              var secret:String = Connection.getParam("oauth_consumer_secret", null);
+
+              if ( key != null && secret != null ) {
+                  appID =  new OAuthConsumer(key, secret);
+              }
+            }
+            return appID;
+        }
+
         private var httpStatus:int = 0;
         
         private function recordStatus(event:HTTPStatusEvent):void {
index 547293f..56cff40 100644 (file)
@@ -31,7 +31,7 @@ package net.systemeD.potlatch2.save {
         private function save(callback:Function):void {
             var conn:Connection = Connection.getConnectionInstance();
             if ( consumer == null )
-                consumer = getConsumer();
+                consumer = conn.getConsumer();
             if ( accessToken == null )
                 accessToken = conn.getAccessToken(SharedObject.getLocal("access_token").data);
         
@@ -41,16 +41,6 @@ package net.systemeD.potlatch2.save {
                 callback();
         }
 
-        private function getConsumer():OAuthConsumer {
-            var key:String = Connection.getParam("oauth_consumer_key", null);
-            var secret:String = Connection.getParam("oauth_consumer_secret", null);
-            
-            if ( key == null || secret == null )
-                return null;
-            else    
-                return new OAuthConsumer(key, secret);
-        }
-        
         private function getNewToken(onCompletion:Function):void {
             var oauthPanel:OAuthPanel = OAuthPanel(
                 PopUpManager.createPopUp(Application(Application.application), OAuthPanel, true));