home *** CD-ROM | disk | FTP | other *** search
- package com.althea.client.shufflr.model
- {
- import com.althea.client.shufflr.ApplicationFacade;
- import com.althea.client.shufflr.controller.errors.ApplicationError;
- import com.facebook.events.FacebookEvent;
- import mx.logging.LogEventLevel;
- import mx.rpc.AsyncToken;
- import mx.rpc.Fault;
- import mx.rpc.IResponder;
- import mx.rpc.events.FaultEvent;
- import mx.rpc.http.HTTPService;
- import org.puremvc.as3.multicore.patterns.proxy.Proxy;
-
- public class PostCommandProxy extends Proxy implements IResponder
- {
- public static const NAME:String = "PostCommandProxy";
-
- private var _attachment:Object = new Object();
-
- private var username:String;
-
- private var _shareOnFB:Boolean = false;
-
- private var service:HTTPService;
-
- public function PostCommandProxy(param1:Object = null)
- {
- super(NAME,param1);
- this.service = new HTTPService();
- this.service.method = "POST";
- this.service.requestTimeout = 20;
- }
-
- public function sendInvite(param1:String, param2:String) : void
- {
- var _loc3_:Object = new Object();
- this.service.url = NavMapProxy.serverUrl + "/users/invites";
- _loc3_["email"] = param1;
- _loc3_["invite_text"] = param2;
- var _loc4_:AsyncToken = this.service.send(_loc3_);
- _loc4_.dataType = "emailInvite";
- _loc4_.addResponder(this);
- }
-
- public function reportBrokenLink(param1:String) : void
- {
- this.service.url = NavMapProxy.serverUrl + "videos/broken_link/" + param1;
- var _loc2_:Object = new Object();
- _loc2_["viewed"] = 1;
- var _loc3_:AsyncToken = this.service.send(_loc2_);
- _loc3_.addResponder(this);
- }
-
- public function feedback(param1:String, param2:String) : void
- {
- this.service.url = NavMapProxy.serverUrl + "users/feedbacks";
- var _loc3_:Object = {};
- _loc3_["feedback[component]"] = param1;
- _loc3_["feedback[content]"] = param2;
- var _loc4_:AsyncToken = this.service.send(_loc3_);
- _loc4_.dataType = "feedback";
- _loc4_.addResponder(this);
- }
-
- private function sendQuestionnaireNote(param1:Object) : void
- {
- var _loc2_:String = param1.result.rss.channel.status;
- this.sendNotification(ApplicationFacade.HIDE_QUESTIONNAIRE);
- }
-
- public function result(param1:Object) : void
- {
- var authValid:String = null;
- var dataType:String = null;
- var rpcEvent:Object = param1;
- try
- {
- authValid = rpcEvent.result.rss.channel.status;
- dataType = rpcEvent.token.dataType;
- if(authValid == "success")
- {
- switch(dataType)
- {
- case "bookmark":
- this.sendNotification(ApplicationFacade.POST_BOOKMARK_SUCCESS);
- break;
- case "comment":
- this.sendNotification(ApplicationFacade.POST_COMMENT_SUCCESS);
- break;
- case "share":
- this.sendNotification(ApplicationFacade.POST_SHARE_SUCCESS);
- break;
- case "rate":
- this.sendNotification(ApplicationFacade.POST_RATING_SUCCESS);
- break;
- case "follow":
- this.sendNotification(ApplicationFacade.POST_FOLLOW_SUCCESS,rpcEvent.result.rss.channel.friend.id);
- break;
- case "shortcut":
- this.sendNotification(ApplicationFacade.POST_SHORTCUT_SUCCESS);
- break;
- case "feedback":
- this.sendNotification(ApplicationFacade.FEEDBACK_SUCCESS);
- break;
- case "editprofile":
- this.sendNotification(ApplicationFacade.EDIT_PROFILE_SUCCESS);
- break;
- case "changepassword":
- this.sendNotification(ApplicationFacade.CHANGE_PASSWORD_SUCCESS);
- break;
- case "recoverPassword":
- this.sendNotification(ApplicationFacade.PASSWORD_RECOVERY_SUCCESS);
- break;
- case "fbKeys":
- this.sendNotification(ApplicationFacade.FACEBOOK_KEYS_SUCCESS);
- break;
- case "questionnaire":
- this.sendQuestionnaireNote(rpcEvent);
- break;
- case "emailInvite":
- this.sendNotification(ApplicationFacade.EMAIL_INVITE_SUCCESS);
- }
- }
- else
- {
- if(rpcEvent.result.rss.channel.error == "invalid session")
- {
- this.sendNotification(ApplicationFacade.LOGOUT);
- }
- switch(dataType)
- {
- case "bookmark":
- this.sendNotification(ApplicationFacade.POST_BOOKMARK_FAILURE);
- break;
- case "comment":
- this.sendNotification(ApplicationFacade.POST_COMMENT_FAILURE);
- break;
- case "share":
- this.sendNotification(ApplicationFacade.POST_SHARE_FAILURE);
- break;
- case "rate":
- this.sendNotification(ApplicationFacade.POST_RATING_FAILURE);
- break;
- case "follow":
- this.sendNotification(ApplicationFacade.POST_FOLLOW_FAILURE);
- break;
- case "shortcut":
- this.sendNotification(ApplicationFacade.POST_SHORTCUT_FAILURE);
- break;
- case "feedback":
- this.sendNotification(ApplicationFacade.FEEDBACK_FAILURE);
- break;
- case "editprofile":
- this.sendNotification(ApplicationFacade.EDIT_PROFILE_FAILURE);
- break;
- case "changepassword":
- this.sendNotification(ApplicationFacade.CHANGE_PASSWORD_FAILURE);
- break;
- case "recoverPassword":
- this.sendNotification(ApplicationFacade.PASSWORD_RECOVERY_FAILURE);
- break;
- case "fbKeys":
- this.sendNotification(ApplicationFacade.FACEBOOK_KEYS_FAILURE);
- break;
- case "questionnaire":
- this.sendNotification(ApplicationFacade.QUESTIONNAIRE_FAILURE);
- break;
- case "emailInvite":
- this.sendNotification(ApplicationFacade.EMAIL_INVITE_FAILURE);
- }
- }
- }
- catch(errObj:Error)
- {
- trace(errObj.message);
- }
- }
-
- public function recoverPassword(param1:String) : void
- {
- var _loc2_:Object = new Object();
- this.service.url = NavMapProxy.serverUrl + "/users/passwords/reset";
- _loc2_["login"] = param1;
- var _loc3_:AsyncToken = this.service.send(_loc2_);
- _loc3_.dataType = "recoverPassword";
- _loc3_.addResponder(this);
- }
-
- public function rate(param1:String, param2:Number) : void
- {
- this.service.url = NavMapProxy.serverUrl + "users/rated/videos/" + param1;
- var _loc3_:Object = {};
- _loc3_["rate[value]"] = param2;
- var _loc4_:AsyncToken = this.service.send(_loc3_);
- _loc4_.dataType = "rate";
- _loc4_.addResponder(this);
- }
-
- public function createShortcut(param1:String) : void
- {
- this.service.url = NavMapProxy.serverUrl + "users/shortcuts";
- var _loc2_:Object = {};
- _loc2_["shortcut[path]"] = param1;
- var _loc3_:AsyncToken = this.service.send(_loc2_);
- _loc3_.dataType = "shortcut";
- _loc3_.addResponder(this);
- }
-
- public function postComment(param1:String, param2:String) : void
- {
- this.service.url = NavMapProxy.serverUrl + "users/commented/videos/" + param1;
- var _loc3_:Object = {};
- _loc3_["comment[comment]"] = param2;
- var _loc4_:AsyncToken = this.service.send(_loc3_);
- _loc4_.dataType = "comment";
- _loc4_.addResponder(this);
- }
-
- public function fault(param1:Object) : void
- {
- var _loc2_:Fault = FaultEvent(param1).fault;
- var _loc3_:String = param1.token.dataType;
- switch(_loc3_)
- {
- case "bookmark":
- this.sendNotification(ApplicationFacade.POST_BOOKMARK_TIMEOUT);
- break;
- case "comment":
- this.sendNotification(ApplicationFacade.POST_COMMENT_TIMEOUT);
- break;
- case "share":
- this.sendNotification(ApplicationFacade.POST_SHARE_TIMEOUT);
- break;
- case "rate":
- this.sendNotification(ApplicationFacade.POST_RATING_TIMEOUT);
- break;
- case "follow":
- this.sendNotification(ApplicationFacade.POST_FOLLOW_TIMEOUT);
- break;
- case "shortcut":
- this.sendNotification(ApplicationFacade.POST_SHORTCUT_TIMEOUT);
- break;
- case "feedback":
- this.sendNotification(ApplicationFacade.FEEDBACK_TIMEOUT);
- break;
- case "editprofile":
- this.sendNotification(ApplicationFacade.EDIT_PROFILE_TIMEOUT);
- break;
- case "changepassword":
- this.sendNotification(ApplicationFacade.CHANGE_PASSWORD_TIMEOUT);
- break;
- case "recoverPassword":
- this.sendNotification(ApplicationFacade.PASSWORD_RECOVERY_FAILURE);
- break;
- case "fbKeys":
- this.sendNotification(ApplicationFacade.FACEBOOK_KEYS_FAILURE);
- break;
- case "questionnaire":
- this.sendNotification(ApplicationFacade.QUESTIONNAIRE_TIMEOUT);
- break;
- case "emailInvite":
- this.sendNotification(ApplicationFacade.EMAIL_INVITE_TIMEOUT);
- }
- var _loc4_:ApplicationError = new ApplicationError(LogEventLevel.ERROR,9000,"authError");
- sendNotification(ApplicationFacade.ERROR,_loc4_,"authError");
- }
-
- public function changePassword(param1:String, param2:String) : void
- {
- var _loc3_:Object = new Object();
- this.service.url = NavMapProxy.serverUrl + "/users/profile";
- _loc3_["type"] = "password_edit";
- _loc3_["user[verify_password]"] = param1;
- _loc3_["user[new_password]"] = param2;
- var _loc4_:AsyncToken = this.service.send(_loc3_);
- _loc4_.dataType = "changepassword";
- _loc4_.addResponder(this);
- }
-
- public function videoViewed(param1:String, param2:int) : void
- {
- this.service.url = NavMapProxy.serverUrl + "users/viewed/videos/" + param1;
- var _loc3_:Object = new Object();
- _loc3_["view[privacy]"] = param2.toString();
- var _loc4_:AsyncToken = this.service.send(_loc3_);
- _loc4_.dataType = "videoviewed";
- _loc4_.addResponder(this);
- }
-
- protected function onPublishPost(param1:FacebookEvent) : void
- {
- trace("Facebook: Post published");
- this.sendNotification(ApplicationFacade.POST_SHARE_SUCCESS);
- }
-
- public function follow(param1:Number) : void
- {
- this.service.url = NavMapProxy.serverUrl + "users/connections/" + param1.toString();
- var _loc2_:Object = {};
- _loc2_["temp"] = "";
- var _loc3_:AsyncToken = this.service.send(_loc2_);
- _loc3_.dataType = "follow";
- _loc3_.addResponder(this);
- }
-
- public function share(param1:String, param2:String, param3:Boolean) : void
- {
- this.service.url = NavMapProxy.serverUrl + "users/shared/videos/" + param1;
- var _loc4_:Object = {};
- _loc4_["share[note]"] = param2;
- _loc4_["share_on_fb"] = param3.toString();
- var _loc5_:AsyncToken = this.service.send(_loc4_);
- _loc5_.dataType = "share";
- _loc5_.addResponder(this);
- }
-
- public function sendFbKeys(param1:String, param2:String, param3:String) : void
- {
- var _loc4_:Object = new Object();
- this.service.url = NavMapProxy.serverUrl + "/users/fb_info/extended_permissions";
- _loc4_["fb_info[session_secret]"] = param1;
- _loc4_["fb_info[session_key]"] = param2;
- _loc4_["fb_info[uid]"] = param3;
- var _loc5_:AsyncToken = this.service.send(_loc4_);
- _loc5_.dataType = "fbKeys";
- _loc5_.addResponder(this);
- }
-
- public function sendQuestionnaire(param1:Array) : void
- {
- this.service.url = NavMapProxy.serverUrl + "users/fav_categories";
- var _loc2_:Object = {};
- _loc2_["fav_categories"] = param1.toString();
- var _loc3_:AsyncToken = this.service.send(_loc2_);
- _loc3_.dataType = "questionnaire";
- _loc3_.addResponder(this);
- }
-
- public function bookmark(param1:String, param2:String, param3:int) : void
- {
- this.service.url = NavMapProxy.serverUrl + "users/bookmarked/videos/" + param1;
- var _loc4_:Object = {};
- _loc4_["bookmark[tags]"] = param2;
- _loc4_["bookmark[privacy]"] = param3.toString();
- var _loc5_:AsyncToken = this.service.send(_loc4_);
- _loc5_.dataType = "bookmark";
- _loc5_.addResponder(this);
- }
-
- public function editProfile(param1:Object) : void
- {
- this.service.url = NavMapProxy.serverUrl + "/users/profile";
- param1["type"] = "info_edit";
- var _loc2_:AsyncToken = this.service.send(param1);
- _loc2_.dataType = "editprofile";
- _loc2_.addResponder(this);
- }
- }
- }
-
-