public void refreshList() { searchList.removeAllElements(); foreach (User user in searchedUsers) { ScrollableList.ListGameObject listObject; if (!LoggedInUser.GetLoggedInUser().HasFriendship(user)) { GameObject go = Instantiate(userSearchItemPrefab); SearchUserNotFriendListItem newItem = go.GetComponent <SearchUserNotFriendListItem> (); newItem.SetSearchedUser(user); newItem.userProfile = userProfile; listObject = (ScrollableList.ListGameObject)newItem; } else { GameObject go = Instantiate(friendSearchItemPrefab); SearchUserIsFriendListItem newItem = go.GetComponent <SearchUserIsFriendListItem> (); newItem.SetSearchedUser(user); newItem.userProfile = userProfile; listObject = (ScrollableList.ListGameObject)newItem; } searchList.addElement(listObject); } searchList.sortList(); }
private Dictionary <Button, string> GetCorrectButtonMapping() { if (currentUser is LoggedInUser) { return(isSelfMapping); } Friendship friendshipWithUser = LoggedInUser.GetLoggedInUser().GetFriendshipWithUser(currentUser); if (friendshipWithUser == null) { return(notFriendOptionMapping); } else if (friendshipWithUser.IsAccepted()) { return(friendOptionMapping); } else if (friendshipWithUser.IsRequestSentPending()) { return(receivedOptionMapping); } else if (friendshipWithUser.IsRequestReceivedPending()) { return(sentOptionMapping); } else { return(null); } }
private void interfaceWithDownloadListener() { if (LoggedInUser.GetLoggedInUser() != null) { CloseGlyphsDownloader.getInstance().addGlyphDownloadedListener(this); } }
private void setNewPlayerLocation(GPSLocation newLocation) { bool firstRun = false; if (currentPlayerLocation.Equals(GPSLocation.UNDEFINED)) { firstRun = true; } if (!newLocation.Equals(currentPlayerLocation)) { currentPlayerLocation = newLocation; if (LoggedInUser.GetLoggedInUser() != null) { if (firstRun) { loadOwnedGlyphSpheres(); } } else { statusPanel.showStatus(NO_USER_LOGGED_IN_STATUS); } } }
private void loadOwnedGlyphSpheres() { foreach (OwnedGlyphEvent glyph in LoggedInUser.GetLoggedInUser().ownedGlyphs) { GameObject go = Instantiate(glyphSpherePrefab); GlyphSphere sphere = go.GetComponent <GlyphSphere> (); sphere.setGlyph(glyph.GetGlyph()); glyphSpheres.Add(sphere); } }
private void loadGlyphs() { if (LoggedInUser.GetLoggedInUser() == null) { return; } foreach (OwnedGlyphEvent glyph in LoggedInUser.GetLoggedInUser().ownedGlyphs) { plotGlyph(glyph.GetGlyph()); } }
private void resetListToDefault() { List <User> receivedUsers = new List <User> (); List <Friendship> friends = LoggedInUser.GetLoggedInUser().GetAcceptedFriendships(); foreach (Friendship friend in friends) { receivedUsers.Add(friend.GetOtherUser()); } searchedUsers = receivedUsers.ToArray(); refreshList(); }
private IEnumerator onHandleChanged(string handleText) { saveButton.interactable = false; Object myUploadLock = new Object(); uploadLock = myUploadLock; bool setHandleToDefault = handleText.Equals(LoggedInUser.GetLoggedInUser().GetSearchableHandle()); bool setHandleToUserID = handleText.Equals(LoggedInUser.GetLoggedInUser().GetUserId()); if (handleText.Equals(string.Empty) || setHandleToDefault) { handleEdited = false; HideErrorText(); saveButton.interactable = true; } else { Boolean handleTaken; if (!setHandleToUserID) { ServerCall handleTakenCall = new ServerCall(ServerInteract.INSTANCE.IsHandleTaken(handleText)); yield return(StartCoroutine(handleTakenCall.call())); handleTaken = (Boolean)handleTakenCall.ObjectResponse; } else { handleTaken = false; } Debug.Log("Is handle taken??? " + handleTaken); if (handleTaken && ReferenceEquals(myUploadLock, uploadLock)) { ShowErrorText(HANDLE_TAKEN_ERROR); saveButton.interactable = false; handleEdited = false; } else { HideErrorText(); saveButton.interactable = true; handleEdited = true; } } yield return("Done"); }
private void doSearch(string search) { List <User> receivedUsers = new List <User>(); foreach (Friendship friend in LoggedInUser.GetLoggedInUser().GetAcceptedFriendships()) { if (friend.GetOtherUser().GetUserFriendlyName().ToLower().Contains(search)) { receivedUsers.Add(friend.GetOtherUser()); } } searchedUsers = receivedUsers.ToArray(); refreshList(); }
private void setListToAccepted() { friendsList.removeAllElements(); List <Friendship> accepted = LoggedInUser.GetLoggedInUser().GetAcceptedFriendships(); foreach (Friendship friend in accepted) { GameObject go = Instantiate(approvedFriendPrefab); AcceptedFriendListItem newItem = go.GetComponent <AcceptedFriendListItem> (); newItem.SetFriendship(friend); newItem.userProfile = userProfile; friendsList.addElement((ScrollableList.ListGameObject)newItem); Debug.LogError(friend.ToString()); } }
// private IEnumerator logout() { // setStatus(RESTARTING_SESSION); // logoutLoaded = false; // // webView.url = ServerInteract.LOGOUT_URL; // webView.Load(); // // while (!logoutLoaded) { // yield return null; // } // // if (clearCache) { // webView.CleanCache (); // webView.CleanCookie (); // } // // setStatus (SESSION_RESTARTED); // // yield return "Done"; // } // // private IEnumerator tryAutoLogin() { // setStatus (START_AUTO_LOGIN); // autoLoginWorked = false; // // SavedCredentials savedCreds = readTokenAndUsernameFromFile (); // if (savedCreds != null) { // setStatus(REAUTHORIZING_SAVED_TOKEN); // // authToken = savedCreds.savedAuthtoken; // // ServerCall testSavedAuth = new ServerCall(ServerInteract.INSTANCE.SendServerInformationRequest (ServerInteract.TEST_LOGIN, null)); // yield return StartCoroutine (testSavedAuth.call ()); // // // if(testSavedAuth.ReturnException == null) { // // setStatus(SAVED_TOKEN_SUCCESS); // // authToken = savedCreds.savedAuthtoken; // StartCoroutine(startLoadUserData ()); // autoLoginWorked = true; // // } else { // setStatus (SAVED_TOKEN_FAILED); // // authToken = null; // // if (savedCreds.savedProvider.Equals (AUTH_0_LOGIN_PROVIDER)) { // setStatus (PROVIDER_AUTH_0); // autoLoginWorked = false; // } else { // setStatus (AUTHORIZING_WITH_PROVIDER + savedCreds.savedProvider); // loadReauthorize (savedCreds.savedProvider); // autoLoginWorked = true; // } // } // } else { // create a blank file if none is there and login has failed // // autoLoginWorked = false; // } // // yield return "Done"; // } // private void loadReauthorize(string provider) { // string authorizeurl = createAuthorizeURL (provider); // // webView.url = authorizeurl; // webView.Load (); // } // private void loadManualLogin() { // setStatus(LOADING_MANUAL_LOGIN); // // webView.url = ServerInteract.MANUALLOGIN; // webView.Load(); // // setStatus (MANUAL_LOGIN_LOADED); // } // void OnLoadComplete(UniWebView webView, bool success, string errorMessage) { // Debug.Log ("Load complete: " + webView.url); // Debug.Log ("Load successful: " + success); // // if (webView.url.Equals (ServerInteract.LOGOUT_URL)) { // logoutLoaded = true; // } else if (webView.url.Equals (ServerInteract.MANUALLOGIN)) { // webView.Show(); // } else if (webView.url.Contains (ServerInteract.AUTHORIZEURL)) { // webView.Show(); // } // // if (!success) { // Debug.Log("Something wrong in webview loading: " + errorMessage); // } // // } // // void OnReceivedMessage(UniWebView webView, UniWebViewMessage message) { // // // You can check the message path and arguments to know which `uniwebview` link is clicked. // // UniWebView will help you to parse your link if it follows the url argument format. // // However, there is also a "rawMessage" property you could use if you need to use some other formats and want to parse it yourself. // Debug.Log("Received message from: " + webView.url); // Debug.Log ("Raw message: " + message.rawMessage); // // if (message.path == "success") { // string response = message.args["authToken"].Trim(); // authToken = response; // // Debug.LogWarning("Auth token: " + authToken); // // //writeTokenToFile (authToken); // //LoadUserData.populateUserData(authToken); // //LoadUserData lud = new LoadUserData(); // //StartCoroutine (lud.Start()); // // StartCoroutine(startLoadUserData ()); // } // } // This method will be called when the screen orientation changed. Here we return UniWebViewEdgeInsets(5,5,5,5) // for both situation, which means the inset is 5 point for iOS and 5 pixels for Android from all edges. // Note: UniWebView is using point instead of pixel in iOS. However, the `Screen.width` and `Screen.height` will give you a // pixel-based value. // You could get a point-based screen size by using the helper methods: `UniWebViewHelper.screenHeight` and `UniWebViewHelper.screenWidth` for iOS. // UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation) { // int INSET = 0; // if (orientation == UniWebViewOrientation.Portrait) { // return new UniWebViewEdgeInsets(INSET,INSET,INSET,INSET); // } else { // return new UniWebViewEdgeInsets(INSET,INSET,INSET,INSET); // } // } private IEnumerator startLoadUserData() { HardwareController.initialize(); setStatus("Downloading User Profile..."); ServerCall waitFor = new ServerCall(ServerInteract.INSTANCE.GetLoggedInUserInfo()); yield return(StartCoroutine(waitFor.call())); writeTokenAndUsernameToFile(authToken, LoggedInUser.GetLoggedInUser().GetUserId()); setStatus("Logging into Network..."); waitFor = new ServerCall(ServerInteract.INSTANCE.RetrieveFirebaseToken()); yield return(StartCoroutine(waitFor.call())); SceneManager.LoadScene("Scenes/GroundViewScene", LoadSceneMode.Single); }
public IEnumerator GetLoggedInUserInfo() { Debug.Log("Retrieving user info for logged in user"); ServerCall getInfo = new ServerCall(INSTANCE.SendServerInformationRequest(GET_LOGGED_IN_USER_INFO, null)); yield return(StartCoroutine(getInfo.call())); string infoText = getInfo.Response; Debug.Log("Received " + infoText); LoggedInUser.ParseFullUserProfile(infoText); Debug.Log(LoggedInUser.GetLoggedInUser().ToString()); yield return(infoText); }
private void populateGlyphList() { if (LoggedInUser.GetLoggedInUser() == null) { Debug.LogError("No user logged in"); return; } List <SharedWithUserGlyphEvent> glyphShares = LoggedInUser.GetLoggedInUser().sharedWithUserGlyphs; Glyph[] glyphs = new Glyph[glyphShares.Count]; for (int i = 0; i < glyphShares.Count; i++) { glyphs [i] = glyphShares [i].GetGlyph(); } glyphList.setGlyphs(glyphs); }
private IEnumerator downloadCloseGlyphs(GPSLocation newLocation) { Debug.LogError(downloadedGlyphs.ContainsKey(newLocation)); if (!downloadedGlyphs.ContainsKey(newLocation)) { downloadedGlyphs.Add(newLocation, null); // reserve key while (LoggedInUser.GetLoggedInUser() == null) { Debug.LogWarning("GPS updated but no user logged in. Waiting to download."); yield return(new WaitForSeconds(1.0f)); } GPSLocation[] closeBounds = newLocation.calculateLatLongBoundingBox(GlyphUniverse.MAX_RENDER_DISTANCE); ServerCall call = new ServerCall(ServerInteract.INSTANCE.GetGlyphsInArea(closeBounds)); yield return(StartCoroutine(call.call())); if (call.ReturnException != null) { Debug.LogException(call.ReturnException); } else { List <Glyph> closeGlyphs = (List <Glyph>)call.ObjectResponse; if (closeGlyphs.Count == 0) { fireGlyphDownloadedListeners(null); } else { foreach (Glyph glyph in closeGlyphs) { fireGlyphDownloadedListeners(glyph); } downloadedGlyphs [newLocation] = closeGlyphs; } } } yield return("Done"); }
public IEnumerator SetSearchableHandle(string handle) { Debug.Log("Setting searchable handle"); Dictionary <string, string> data = new Dictionary <string, string>(); data["handle"] = "" + handle; ServerCall setHandleCall = new ServerCall(INSTANCE.SendServerInformationRequest(SET_SEARCHABLE_HANDLE, data)); yield return(StartCoroutine(setHandleCall.call())); string infoText = setHandleCall.Response; Debug.Log("Received " + infoText); LoggedInUser.GetLoggedInUser().SetSearchableHandle(handle); yield return(infoText); }
public IEnumerator RejectReceivedFriendRequest(Friendship fromFriend) { Debug.Log("Rejecting friend request"); Dictionary <string, string> data = new Dictionary <string, string>(); data ["fromUser"] = fromFriend.GetOtherUser().GetUserId(); ServerCall waitFor = new ServerCall(INSTANCE.SendServerInformationRequest(REJECT_FRIEND_REQUEST, data)); yield return(StartCoroutine(waitFor.call())); string infoText = waitFor.Response; Debug.Log("Received " + infoText); LoggedInUser.GetLoggedInUser().friends.Remove(fromFriend); yield return(infoText); }
public IEnumerator CancelSentFriendRequest(Friendship toUser) { Debug.Log("Canceling sent friend request"); Dictionary <string, string> data = new Dictionary <string, string>(); data ["toUser"] = toUser.GetOtherUser().GetUserId(); ServerCall waitFor = new ServerCall(INSTANCE.SendServerInformationRequest(CANCEL_FRIEND_REQUEST, data)); yield return(StartCoroutine(waitFor.call())); string infoText = waitFor.Response; Debug.Log("Received " + infoText); LoggedInUser.GetLoggedInUser().friends.Remove(toUser); yield return(infoText); }
private void populateGlyphList() { if (LoggedInUser.GetLoggedInUser() == null) { Debug.LogError("No user logged in"); return; } List <OwnedGlyphEvent> ownedGlyphs = LoggedInUser.GetLoggedInUser().ownedGlyphs; ownedGlyphs.Sort(new OwnedGlyphEvent.GlyphEventInTimeSorter()); List <Glyph> glyphs = new List <Glyph> (); foreach (OwnedGlyphEvent ownedGlyphEvent in ownedGlyphs) { glyphs.Add(ownedGlyphEvent.GetGlyph()); } glyphList.setGlyphs(glyphs.ToArray()); }
public IEnumerator SendFriendRequest(User toUser) { Debug.Log("Sending friend request"); Dictionary <string, string> data = new Dictionary <string, string>(); data ["toUser"] = toUser.GetUserId(); ServerCall waitFor = new ServerCall(INSTANCE.SendServerInformationRequest(SEND_FRIEND_REQUEST, data)); yield return(StartCoroutine(waitFor.call())); string infoText = waitFor.Response; Debug.Log("Received " + infoText); Friendship sentFriend = JsonUtility.FromJson <Friendship> (infoText); LoggedInUser.GetLoggedInUser().friends.Add(sentFriend); yield return(sentFriend); }
public IEnumerator SearchForUser(string search) { Debug.Log("Searching for user: "******"search"] = search; ServerCall waitFor = new ServerCall(INSTANCE.SendServerInformationRequest(SEARCH_USER, data)); yield return(StartCoroutine(waitFor.call())); string infoText = waitFor.Response; Debug.Log("Received " + infoText); List <User> searchedUsers = JsonUtility.FromJson <List <User> > (infoText);; searchedUsers.Remove((User)LoggedInUser.GetLoggedInUser()); yield return(searchedUsers); }
private void reevaluateGlyphUniverseByLocation() { activeSpheres = enableOnlyCloseGlyphs(); // done by comparing glyph lat, long rather than sphere pos if (LoggedInUser.GetLoggedInUser() == null) { statusPanel.showStatus(NO_USER_LOGGED_IN_STATUS); } else if (activeSpheres.Count == 0) { statusPanel.showStatus(NO_CLOSE_GLYPHS_STATUS); } else { statusPanel.setStatusPanelVisible(false); } replotGlyphSpheres(); pushGlyphsThatAreTooCloseAway(); reevaluateGlyphUniverseByAngle(); }
private void populateGlyphList() { if (LoggedInUser.GetLoggedInUser() == null) { Debug.LogError("No user logged in"); return; } List <FoundGlyphEvent> foundGlyphs = LoggedInUser.GetLoggedInUser().foundGlyphs; foundGlyphs.Sort(); Glyph[] glyphs = new Glyph[foundGlyphs.Count]; int i = 0; foreach (FoundGlyphEvent found in foundGlyphs) { glyphs [i] = foundGlyphs [i].GetGlyph(); i++; } glyphList.setGlyphs(glyphs); }
public IEnumerator AcceptReceivedFriendRequest(Friendship existingToAccept) { Debug.Log("Accepting friend request"); Dictionary <string, string> data = new Dictionary <string, string>(); data ["fromUser"] = existingToAccept.GetOtherUser().GetUserId(); ServerCall waitFor = new ServerCall(INSTANCE.SendServerInformationRequest(ACCEPT_FRIEND_REQUEST, data)); yield return(StartCoroutine(waitFor.call())); string infoText = waitFor.Response; Debug.Log("Received " + infoText); Friendship accepted = JsonUtility.FromJson <Friendship> (infoText); LoggedInUser.GetLoggedInUser().friends.Remove(existingToAccept); LoggedInUser.GetLoggedInUser().friends.Add(accepted); yield return(accepted); }
public IEnumerator MarkGlyphAsFound(Glyph glyph) { if (LoggedInUser.GetLoggedInUser().DidAlreadyFindGlyph(glyph)) { throw new Exception("User already found glyph"); } else { Dictionary <string, string> data = new Dictionary <string, string> (); data ["glyphid"] = "" + glyph.GetGlyphId(); ServerCall markGlyphAsFound = new ServerCall(INSTANCE.SendServerInformationRequest(MARK_AS_FOUND, data)); yield return(StartCoroutine(markGlyphAsFound.call())); string infoText = markGlyphAsFound.Response; Debug.Log("Received " + infoText); FoundGlyphEvent found = JsonUtility.FromJson <FoundGlyphEvent> (infoText); LoggedInUser.GetLoggedInUser().foundGlyphs.Add(found); yield return(found); } }
private void repopulateUI() { avatarImage.SetUser(LoggedInUser.GetLoggedInUser()); searchableHandleField.text = LoggedInUser.GetLoggedInUser().GetUserFriendlyName(); }
// private static StorageReference storage_ref; //private static Firebase.Auth.FirebaseUser newUser = null; public IEnumerator RetrieveFirebaseToken() { // FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://glyph-project-1344.firebaseio.com"); // FirebaseApp.DefaultInstance.SetEditorP12FileName("Glyph Project-53a06b80ee55.p12"); // FirebaseApp.DefaultInstance.SetEditorServiceAccountEmail("*****@*****.**"); // FirebaseApp.DefaultInstance.SetEditorP12Password("notasecret"); // FirebaseApp.DefaultInstance.SetEditorAuthUserId ("facebook|1751101561581447"); if (LoggedInUser.GetLoggedInUser() == null) { throw new Exception("No logged in user"); } Debug.Log("Getting firebase access token"); string granttype = "urn:ietf:params:oauth:grant-type:jwt-bearer"; string apitype = "firebase"; // Create a Web Form WWWForm form = new WWWForm(); // Add the authorization token to the form using the Authorization request header Dictionary <string, string> headers = form.headers; headers ["Authorization"] = Authentication.authToken; form.AddField("null", "null"); /* Sample POST: * POST https://shroysha.auth0.com/delegation * Content-Type: 'application/json' * { * "client_id": "ZMBm759muZ6K5sVsg0xdgExZyyMmfidv", * "grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer", * "id_token": "{YOUR_ID_TOKEN}", * "target": "ZMBm759muZ6K5sVsg0xdgExZyyMmfidv", * "api_type": "firebase", * } */ Dictionary <string, string> data = new Dictionary <string, string> (); data ["client_id"] = AUTH0_CLIENT_ID; data ["grant_type"] = granttype; data ["id_token"] = Authentication.authToken; data ["target"] = AUTH0_CLIENT_ID; data ["api_type"] = apitype; if (data != null) { foreach (string key in data.Keys) { form.AddField(key, data [key]); } } IEnumerator waitFor = DownloadContent(AUTH0_DELEGATE_URL, form.data, headers); while (waitFor.MoveNext()) { yield return(waitFor.Current); } string response = ((string)waitFor.Current).Trim(); Auth0FirebaseCredentials auth0Creds = JsonUtility.FromJson <Auth0FirebaseCredentials> (response); Debug.Log(response); Debug.Log(auth0Creds.id_token); /* * Firebase.Auth.FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance; * bool wait = true; * * auth.SignInWithCustomTokenAsync (auth0Creds.id_token).ContinueWith (task => { * if (task.IsCanceled) { * Debug.LogError ("SignInWithCustomTokenAsync was canceled."); * wait = false; * return; * } * if (task.IsFaulted) { * Debug.LogError ("SignInWithCustomTokenAsync encountered an error: " + task.Exception); * wait = false; * return; * } * * newUser = task.Result; * * Debug.LogFormat ("User signed in successfully: {0} ({1})", * newUser.DisplayName, newUser.UserId); * }); * * while (newUser == null && wait) { * yield return null; * } * * if (newUser == null) { * yield return "N/A"; * } else { * CreateFirebaseStorageReference (); * yield return "Success"; * } */ CreateFirebaseStorageReference(); yield return("Done"); }
private IEnumerator uploadGlyph() { if (HardwareController.Instance.getLastLocation().Equals(GPSLocation.UNDEFINED)) { statusPanel.showErrorStatus(CANNOT_ACCESS_LOCATION_ERROR); yield return(null); } else if (LoggedInUser.GetLoggedInUser() == null) { statusPanel.showErrorStatus(NO_LOGGED_IN_USER_ERROR); yield return(null); } else { statusPanel.showLoadingStatus("Creating Glyph"); double latitude = HardwareController.Instance.getLastLocation().latitude; double longitude = HardwareController.Instance.getLastLocation().longitude; double altitude = HardwareController.Instance.getLastLocation().altitude; ServerCall uploadGlyphCall; if (!publicToggle.isOn) { uploadGlyphCall = new ServerCall(ServerInteract.INSTANCE.AddPrivateGlyph(latitude, longitude, altitude)); } else { uploadGlyphCall = new ServerCall(ServerInteract.INSTANCE.AddPublicGlyph(latitude, longitude, altitude, dateTimePicker.getSelectedDateTime())); } yield return(StartCoroutine(uploadGlyphCall.call())); if (uploadGlyphCall.ReturnException != null) { statusPanel.showErrorStatus(uploadGlyphCall.ReturnException.Message); } else { OwnedGlyphEvent ownedGlyph = (OwnedGlyphEvent)uploadGlyphCall.ObjectResponse; LoggedInUser.GetLoggedInUser().ownedGlyphs.Add(ownedGlyph); statusPanel.showLoadingStatus("Uploading Picture"); ServerCall uploadToFirebaseCall = new ServerCall(ServerInteract.INSTANCE.UploadAddGlyphFileToFirebase(ownedGlyph.GetGlyph())); yield return(StartCoroutine(uploadToFirebaseCall.call())); if (uploadToFirebaseCall.ReturnException != null) { statusPanel.showErrorStatus(uploadToFirebaseCall.ReturnException.Message); } else { statusPanel.showStatus("Glyph Created!"); ApplicationFileManager.DeleteAddGlyphFile(); yield return(new WaitForSeconds(3)); SceneManager.LoadScene("Scenes/GroundViewScene"); } } } yield return("Done"); }