//
// Copyright (C) 2014 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#if UNITY_ANDROID
namespace GooglePlayGames.BasicApi
{
using System;
using GooglePlayGames.OurUtils;
using UnityEngine.SocialPlatforms;
///
/// Dummy client used in Editor.
///
/// Google Play Game Services are not supported in the Editor
/// environment, so this client is used as a placeholder.
///
public class DummyClient : IPlayGamesClient
{
///
/// Starts the authentication process.
///
/// If silent == true, no UIs will be shown
/// (if UIs are needed, it will fail rather than show them). If silent == false,
/// this may show UIs, consent dialogs, etc.
/// At the end of the process, callback will be invoked to notify of the result.
/// Once the callback returns true, the user is considered to be authenticated
/// forever after.
///
/// Callback when completed.
/// If set to true silent.
public void Authenticate(bool silent, Action callback)
{
LogUsage();
if (callback != null)
{
callback(SignInStatus.Failed);
}
}
///
/// Returns whether or not user is authenticated.
///
/// true if authenticated
/// false
public bool IsAuthenticated()
{
LogUsage();
return false;
}
///
/// Signs the user out.
///
public void SignOut()
{
LogUsage();
}
///
/// Retrieves an id token, which can be verified server side, if they are logged in.
///
/// The identifier token.
public string GetIdToken()
{
LogUsage();
return null;
}
///
/// Returns the authenticated user's ID. Note that this value may change if a user signs
/// on and signs in with a different account.
///
/// The user identifier.
public string GetUserId()
{
LogUsage();
return "DummyID";
}
public string GetServerAuthCode()
{
LogUsage();
return null;
}
public void GetAnotherServerAuthCode(bool reAuthenticateIfNeeded,
Action callback)
{
LogUsage();
callback(null);
}
///
/// Gets the user's email.
///
/// The email address returned is selected by the user from the accounts present
/// on the device. There is no guarantee this uniquely identifies the player.
/// For unique identification use the id property of the local player.
/// The user can also choose to not select any email address, meaning it is not
/// available.
/// The user email or null if not authenticated or the permission is
/// not available.
public string GetUserEmail()
{
return string.Empty;
}
///
/// Gets the player stats.
///
/// Callback for response.
public void GetPlayerStats(Action callback)
{
LogUsage();
callback(CommonStatusCodes.ApiNotConnected, new PlayerStats());
}
///
/// Returns a human readable name for the user, if they are logged in.
///
/// The user display name.
public string GetUserDisplayName()
{
LogUsage();
return "Player";
}
///
/// Returns the user's avatar url, if they are logged in and have an avatar.
///
/// The user image URL.
public string GetUserImageUrl()
{
LogUsage();
return null;
}
///
/// Loads the players specified.
///
/// This is mainly used by the leaderboard
/// APIs to get the information of a high scorer.
///
/// User identifiers.
/// Callback to invoke when completed.
public void LoadUsers(string[] userIds, Action callback)
{
LogUsage();
if (callback != null)
{
callback.Invoke(null);
}
}
///
/// Loads the achievements for the current player.
///
/// Callback to invoke when completed.
public void LoadAchievements(Action callback)
{
LogUsage();
if (callback != null)
{
callback.Invoke(null);
}
}
///
/// Unlocks the achievement.
///
/// Achievement identifier.
/// Callback to invoke when complete.
public void UnlockAchievement(string achId, Action callback)
{
LogUsage();
if (callback != null)
{
callback.Invoke(false);
}
}
///
/// Reveals the achievement.
///
/// Achievement identifier.
/// Callback to invoke when complete.
public void RevealAchievement(string achId, Action callback)
{
LogUsage();
if (callback != null)
{
callback.Invoke(false);
}
}
///
/// Increments the achievement.
///
/// Achievement identifier.
/// Steps to increment by..
/// Callback to invoke when complete.
public void IncrementAchievement(string achId, int steps, Action callback)
{
LogUsage();
if (callback != null)
{
callback.Invoke(false);
}
}
///
/// Set an achievement to have at least the given number of steps completed.
///
///
/// Calling this method while the achievement already has more steps than
/// the provided value is a no-op. Once the achievement reaches the
/// maximum number of steps, the achievement is automatically unlocked,
/// and any further mutation operations are ignored.
///
/// Achievement identifier.
/// Steps to increment to at least.
/// Callback to invoke when complete.
public void SetStepsAtLeast(string achId, int steps, Action callback)
{
LogUsage();
if (callback != null)
{
callback.Invoke(false);
}
}
///
/// Shows the achievements UI
///
/// Callback to invoke when complete.
public void ShowAchievementsUI(Action callback)
{
LogUsage();
if (callback != null)
{
callback.Invoke(UIStatus.VersionUpdateRequired);
}
}
public void AskForLoadFriendsResolution(Action callback) {
LogUsage();
if (callback != null) {
callback.Invoke(UIStatus.VersionUpdateRequired);
}
}
public LoadFriendsStatus GetLastLoadFriendsStatus() {
LogUsage();
return LoadFriendsStatus.Unknown;
}
public void LoadFriends(int pageSize, bool forceReload,
Action callback) {
LogUsage();
if (callback != null) {
callback.Invoke(LoadFriendsStatus.Unknown);
}
}
public void LoadMoreFriends(int pageSize, Action callback) {
LogUsage();
if (callback != null) {
callback.Invoke(LoadFriendsStatus.Unknown);
}
}
public void ShowCompareProfileWithAlternativeNameHintsUI(string userId,
string otherPlayerInGameName,
string currentPlayerInGameName,
Action callback) {
LogUsage();
if (callback != null) {
callback.Invoke(UIStatus.VersionUpdateRequired);
}
}
public void GetFriendsListVisibility(bool forceReload,
Action callback) {
LogUsage();
if (callback != null) {
callback.Invoke(FriendsListVisibilityStatus.Unknown);
}
}
///
/// Shows the leaderboard UI
///
/// Leaderboard identifier.
/// Timespan to display.
/// Callback to invoke when complete.
public void ShowLeaderboardUI(
string leaderboardId,
LeaderboardTimeSpan span,
Action callback)
{
LogUsage();
if (callback != null)
{
callback.Invoke(UIStatus.VersionUpdateRequired);
}
}
///
/// Returns the max number of scores returned per call.
///
/// The max results.
public int LeaderboardMaxResults()
{
return 25;
}
///
/// Loads the score data for the given leaderboard.
///
/// Leaderboard identifier.
/// Start indicating the top scores or player centric
/// Row count.
/// Collection to display.
/// Time span.
/// Callback to invoke when complete.
public void LoadScores(
string leaderboardId,
LeaderboardStart start,
int rowCount,
LeaderboardCollection collection,
LeaderboardTimeSpan timeSpan,
Action callback)
{
LogUsage();
if (callback != null)
{
callback(new LeaderboardScoreData(
leaderboardId,
ResponseStatus.LicenseCheckFailed));
}
}
///
/// Loads the more scores for the leaderboard.
///
/// The token is accessed
/// by calling LoadScores() with a positive row count.
///
/// Token used to start loading scores.
/// Max number of scores to return.
/// This can be limited by the SDK.
/// Callback to invoke when complete.
public void LoadMoreScores(
ScorePageToken token,
int rowCount,
Action callback)
{
LogUsage();
if (callback != null)
{
callback(new LeaderboardScoreData(
token.LeaderboardId,
ResponseStatus.LicenseCheckFailed));
}
}
///
/// Submits the score.
///
/// Leaderboard identifier.
/// Score to submit.
/// Callback to invoke when complete.
public void SubmitScore(string leaderboardId, long score, Action callback)
{
LogUsage();
if (callback != null)
{
callback.Invoke(false);
}
}
///
/// Submits the score for the currently signed-in player
/// to the leaderboard associated with a specific id
/// and metadata (such as something the player did to earn the score).
///
/// Leaderboard identifier.
/// Score value to submit.
/// Metadata about the score.
/// Callback upon completion.
public void SubmitScore(
string leaderboardId,
long score,
string metadata,
Action callback)
{
LogUsage();
if (callback != null)
{
callback.Invoke(false);
}
}
/// Asks user to give permissions for the given scopes.
/// Scope to ask permission for
/// Callback used to indicate the outcome of the operation.
public void RequestPermissions(string[] scopes, Action callback)
{
LogUsage();
if (callback != null)
{
callback.Invoke(SignInStatus.Failed);
}
}
/// Returns whether or not user has given permissions for given scopes.
///
/// array of scopes
/// true, if given, false otherwise.
public bool HasPermissions(string[] scopes)
{
LogUsage();
return false;
}
///
/// Gets the saved game client.
///
/// The saved game client.
public SavedGame.ISavedGameClient GetSavedGameClient()
{
LogUsage();
return null;
}
///
/// Gets the events client.
///
/// The events client.
public GooglePlayGames.BasicApi.Events.IEventsClient GetEventsClient()
{
LogUsage();
return null;
}
///
/// Gets the video client.
///
/// The video client.
public GooglePlayGames.BasicApi.Video.IVideoClient GetVideoClient()
{
LogUsage();
return null;
}
///
/// Load friends of the authenticated user
///
/// Callback invoked when complete. bool argument
/// indicates success.
public void LoadFriends(Action callback)
{
LogUsage();
callback(false);
}
///
/// Gets the friends.
///
/// The friends.
public IUserProfile[] GetFriends()
{
LogUsage();
return new IUserProfile[0];
}
///
/// Sets the gravity for popups (Android only).
///
/// This can only be called after authentication. It affects
/// popups for achievements and other game services elements.
/// Gravity for the popup.
public void SetGravityForPopups(Gravity gravity)
{
LogUsage();
}
///
/// Logs the usage.
///
private static void LogUsage()
{
Logger.d("Received method call on DummyClient - using stub implementation.");
}
}
}
#endif