Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial change for Auth Google/IO changes to just fix the compiler error #680

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions auth/src/PhoneAuthProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,6 @@ namespace Firebase.Auth {
/// send an SMS. Credential is automatically created and passed to
/// the app via @ref VerificationCompleted.
public sealed class PhoneAuthProvider : global::System.IDisposable {
/// Maximum value of `autoVerifyTimeOutMs` in @ref VerifyPhoneNumber.
/// @ref VerifyPhoneNumber will automatically clamp values to this amount.
///
/// @deprecated This value is no longer used to clamp
/// `autoVerifyTimeOutMs` in @ref VerifyPhoneNumber. The range is
/// determined by the underlying SDK, ex. <a href="/docs/reference/android/com/google/firebase/auth/PhoneAuthOptions.Builder"><code>PhoneAuthOptions.Build</code> in Android SDK</a>
[System.Obsolete("PhoneAuthProvider.MaxTimeoutMs is deprecated. This value no longer affects PhoneAuthProvider.VerifyPhoneNumber()")]
public static uint MaxTimeoutMs {
get {
return PhoneAuthProviderInternal.kMaxTimeoutMs;
}
}

/// Callback used when phone number auto-verification succeeded.
public delegate void VerificationCompleted(Credential credential);
/// Callback used when phone number verification fails.
Expand Down
161 changes: 115 additions & 46 deletions auth/src/swig/auth.i
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,14 @@ static CppInstanceManager<Auth> g_auth_instances;
std::vector< std::string > * "StringList";

// Don't expose UserInfoInterfaceList externally.
%typemap(csclassmodifiers) std::vector<firebase::auth::UserInfoInterface*> "internal class"
%template(UserInfoInterfaceList) std::vector<firebase::auth::UserInfoInterface*>;
%typemap(csclassmodifiers) std::vector<firebase::auth::UserInfoInterface> "internal class"
%template(UserInfoInterfaceList) std::vector<firebase::auth::UserInfoInterface>;
// All outputs of UserInfoInterfaceList should be IEnumerable<IUserInfo>
%typemap(cstype,
out="global::System.Collections.Generic.IEnumerable<IUserInfo>")
std::vector<firebase::auth::UserInfoInterface*>&
std::vector<firebase::auth::UserInfoInterface>*
"UserInfoInterfaceList";
%typemap(csvarout) std::vector<firebase::auth::UserInfoInterface*>& %{
%typemap(csvarout) std::vector<firebase::auth::UserInfoInterface>* %{
get {
// Convert the UserInfoInterfaceList into a List<IUserInfo>, as we don't
// expose UserInfoInterface, which inherites from the public IUserInfo.
Expand All @@ -309,6 +309,13 @@ static CppInstanceManager<Auth> g_auth_instances;
}
%}

%typemap(csclassmodifiers) firebase::auth::PhoneAuthOptions "public sealed class";
%rename(ForceResendingToken) firebase::auth::PhoneAuthOptions::force_resending_token;
%rename(PhoneNumber) firebase::auth::PhoneAuthOptions::phone_number;
%rename(TimeoutInMilliseconds) firebase::auth::PhoneAuthOptions::timeout_milliseconds;
// Ignore UIParent for now. Always use default Activity/UIView
%ignore firebase::auth::PhoneAuthOptions::ui_parent;

%SWIG_FUTURE(Future_User, FirebaseUser, internal, firebase::auth::User *,
FirebaseException)
%SWIG_FUTURE(Future_FetchProvidersResult, FetchProvidersResult, internal,
Expand Down Expand Up @@ -406,21 +413,20 @@ static CppInstanceManager<Auth> g_auth_instances;

// The following methods need to be overridden to return a customized proxy to
// each C++ object.
%rename(SignInWithCustomTokenInternal)
firebase::auth::Auth::SignInWithCustomToken;
%rename(SignInWithCredentialInternal)
firebase::auth::Auth::SignInWithCredential;
%rename(SignInAndRetrieveDataWithCredentialInternal)
firebase::auth::Auth::SignInAndRetrieveDataWithCredential;
%rename(SignInAnonymouslyInternal)
firebase::auth::Auth::SignInAnonymously;
%rename(SignInWithEmailAndPasswordInternal)
firebase::auth::Auth::SignInWithEmailAndPassword;
%rename(CreateUserWithEmailAndPasswordInternal)
firebase::auth::Auth::CreateUserWithEmailAndPassword;

%rename(SignInWithProviderInternal)
firebase::auth::Auth::SignInWithProvider;
%rename(SignInWithCustomTokenInternalAsync_DEPRECATED)
firebase::auth::Auth::SignInWithCustomToken_DEPRECATED;
%rename(SignInWithCredentialInternalAsync_DEPRECATED)
firebase::auth::Auth::SignInWithCredential_DEPRECATED;
%rename(SignInAndRetrieveDataWithCredentialInternalAsync_DEPRECATED)
firebase::auth::Auth::SignInAndRetrieveDataWithCredential_DEPRECATED;
%rename(SignInAnonymouslyInternalAsync_DEPRECATED)
firebase::auth::Auth::SignInAnonymously_DEPRECATED;
%rename(SignInWithEmailAndPasswordInternalAsync_DEPRECATED)
firebase::auth::Auth::SignInWithEmailAndPassword_DEPRECATED;
%rename(CreateUserWithEmailAndPasswordInternalAsync_DEPRECATED)
firebase::auth::Auth::CreateUserWithEmailAndPassword_DEPRECATED;
%rename(SignInWithProviderInternalAsync_DEPRECATED)
firebase::auth::Auth::SignInWithProvider_DEPRECATED;

%extend firebase::auth::Auth {
// Get a C++ instance and increment the reference count to it
Expand Down Expand Up @@ -476,12 +482,17 @@ static CppInstanceManager<Auth> g_auth_instances;
/// @note: This operation is supported only on iOS, tvOS and Android
/// platforms. On other platforms this method will return a Future with a
/// preset error code: kAuthErrorUnimplemented.
public System.Threading.Tasks.Task<SignInResult> SignInWithProviderAsync(
///
/// @deprecated This function is deprecated in favor of `Task<AuthResult>`
/// return type. Please use
/// `Task<AuthResult> SignInWithProviderAsync(FederatedAuthProvider)` instead.
[System.ObsoleteAttribute("Please use `Task<AuthResult> SignInWithProviderAsync(FederatedAuthProvider)` instead", false)]
public System.Threading.Tasks.Task<SignInResult> SignInWithProviderAsync_DEPRECATED(
FederatedAuthProvider provider) {
ThrowIfNull();
var taskCompletionSource =
new System.Threading.Tasks.TaskCompletionSource<SignInResult>();
SignInWithProviderInternalAsync(provider).ContinueWith(task => {
SignInWithProviderInternalAsync_DEPRECATED(provider).ContinueWith(task => {
CompleteSignInResultTask(task, taskCompletionSource);
});
return taskCompletionSource.Task;
Expand Down Expand Up @@ -800,12 +811,17 @@ static CppInstanceManager<Auth> g_auth_instances;
///
/// An error is returned, if the token is invalid, expired or otherwise
/// not accepted by the server.
public System.Threading.Tasks.Task<FirebaseUser> SignInWithCustomTokenAsync(
///
/// @deprecated This function is deprecated in favor of `Task<AuthResult>`
/// return type. Please use
/// `Task<AuthResult> SignInWithCustomTokenAsync(string)` instead.
[System.ObsoleteAttribute("Please use `Task<AuthResult> SignInWithCustomTokenAsync(string)` instead", false)]
public System.Threading.Tasks.Task<FirebaseUser> SignInWithCustomTokenAsync_DEPRECATED(
string token) {
ThrowIfNull();
var taskCompletionSource =
new System.Threading.Tasks.TaskCompletionSource<FirebaseUser>();
SignInWithCustomTokenInternalAsync(token).ContinueWith(task => {
SignInWithCustomTokenInternalAsync_DEPRECATED(token).ContinueWith(task => {
CompleteFirebaseUserTask(task, taskCompletionSource);
});
return taskCompletionSource.Task;
Expand All @@ -815,12 +831,17 @@ static CppInstanceManager<Auth> g_auth_instances;
///
/// An error is returned, if the token is invalid, expired or otherwise not
/// accepted by the server.
public System.Threading.Tasks.Task<FirebaseUser> SignInWithCredentialAsync(
///
/// @deprecated This function is deprecated in favor of `Task<AuthResult>`
chkuang-g marked this conversation as resolved.
Show resolved Hide resolved
/// return type. Please use
/// `Task<AuthResult> SignInWithCredentialAsync(Credential)` instead.
[System.ObsoleteAttribute("Please use `Task<AuthResult> SignInWithCredentialAsync(Credential)` instead", false)]
public System.Threading.Tasks.Task<FirebaseUser> SignInWithCredentialAsync_DEPRECATED(
Credential credential) {
ThrowIfNull();
var taskCompletionSource =
new System.Threading.Tasks.TaskCompletionSource<FirebaseUser>();
SignInWithCredentialInternalAsync(credential).ContinueWith(task => {
SignInWithCredentialInternalAsync_DEPRECATED(credential).ContinueWith(task => {
CompleteFirebaseUserTask(task, taskCompletionSource);
});
return taskCompletionSource.Task;
Expand All @@ -837,12 +858,18 @@ static CppInstanceManager<Auth> g_auth_instances;
///
/// An error is returned if the token is invalid, expired, or otherwise not
/// accepted by the server.
///
/// @deprecated This function is deprecated in favor of `Task<AuthResult>`
/// return type. Please use
/// `Task<AuthResult> SignInAndRetrieveDataWithCredentialAsync(Credential)`
/// instead.
[System.ObsoleteAttribute("Please use `Task<AuthResult> SignInAndRetrieveDataWithCredentialAsync(Credential)` instead", false)]
public System.Threading.Tasks.Task<SignInResult>
SignInAndRetrieveDataWithCredentialAsync(Credential credential) {
SignInAndRetrieveDataWithCredentialAsync_DEPRECATED(Credential credential) {
ThrowIfNull();
var taskCompletionSource =
new System.Threading.Tasks.TaskCompletionSource<SignInResult>();
SignInAndRetrieveDataWithCredentialInternalAsync(credential).ContinueWith(
SignInAndRetrieveDataWithCredentialInternalAsync_DEPRECATED(credential).ContinueWith(
task => { CompleteSignInResultTask(task, taskCompletionSource); });
return taskCompletionSource.Task;
}
Expand All @@ -868,11 +895,16 @@ static CppInstanceManager<Auth> g_auth_instances;
/// });
/// }
/// @endcode
public System.Threading.Tasks.Task<FirebaseUser> SignInAnonymouslyAsync() {
///
/// @deprecated This function is deprecated in favor of `Task<AuthResult>`
/// return type. Please use
/// `Task<AuthResult> SignInAnonymouslyAsync()` instead.
[System.ObsoleteAttribute("Please use `Task<AuthResult> SignInAnonymouslyAsync()` instead", false)]
public System.Threading.Tasks.Task<FirebaseUser> SignInAnonymouslyAsync_DEPRECATED() {
ThrowIfNull();
var taskCompletionSource =
new System.Threading.Tasks.TaskCompletionSource<FirebaseUser>();
SignInAnonymouslyInternalAsync().ContinueWith(task => {
SignInAnonymouslyInternalAsync_DEPRECATED().ContinueWith(task => {
CompleteFirebaseUserTask(task, taskCompletionSource);
});
return taskCompletionSource.Task;
Expand All @@ -881,12 +913,17 @@ static CppInstanceManager<Auth> g_auth_instances;
/// Signs in using provided email address and password.
/// An error is returned if the password is wrong or otherwise not accepted
/// by the server.
public System.Threading.Tasks.Task<FirebaseUser> SignInWithEmailAndPasswordAsync(
///
/// @deprecated This function is deprecated in favor of `Task<AuthResult>`
/// return type. Please use `Task<AuthResult> SignInAnonymouslyAsync()`
/// instead.
[System.ObsoleteAttribute("Please use `Task<AuthResult> SignInWithEmailAndPasswordAsync(string, string)` instead", false)]
public System.Threading.Tasks.Task<FirebaseUser> SignInWithEmailAndPasswordAsync_DEPRECATED(
string email, string password) {
ThrowIfNull();
var taskCompletionSource =
new System.Threading.Tasks.TaskCompletionSource<FirebaseUser>();
SignInWithEmailAndPasswordInternalAsync(email, password).ContinueWith(
SignInWithEmailAndPasswordInternalAsync_DEPRECATED(email, password).ContinueWith(
task => {
CompleteFirebaseUserTask(task, taskCompletionSource);
});
Expand All @@ -898,12 +935,18 @@ static CppInstanceManager<Auth> g_auth_instances;
///
/// An error is returned when account creation is unsuccessful
/// (due to another existing account, invalid password, etc.).
///
/// @deprecated This function is deprecated in favor of `Task<AuthResult>`
/// return type. Please use
/// `Task<AuthResult> CreateUserWithEmailAndPasswordAsync(string, string)`
/// instead.
[System.ObsoleteAttribute("Please use `Task<AuthResult> CreateUserWithEmailAndPasswordAsync(string, string)` instead", false)]
public System.Threading.Tasks.Task<FirebaseUser>
CreateUserWithEmailAndPasswordAsync(string email, string password) {
CreateUserWithEmailAndPasswordAsync_DEPRECATED(string email, string password) {
ThrowIfNull();
var taskCompletionSource =
new System.Threading.Tasks.TaskCompletionSource<FirebaseUser>();
CreateUserWithEmailAndPasswordInternalAsync(email, password).ContinueWith(
CreateUserWithEmailAndPasswordInternalAsync_DEPRECATED(email, password).ContinueWith(
task => {
CompleteFirebaseUserTask(task, taskCompletionSource);
});
Expand Down Expand Up @@ -975,7 +1018,8 @@ static CppInstanceManager<Auth> g_auth_instances;

%typemap(csclassmodifiers) firebase::auth::User::UserProfile
"public sealed class";
%typemap(csclassmodifiers) firebase::auth::Credential "public sealed class";
%typemap(csclassmodifiers) firebase::auth::Credential "public class";
%typemap(csclassmodifiers) firebase::auth::PhoneAuthCredential "public sealed class";

%typemap(csclassmodifiers) firebase::auth::FederatedAuthProvider "public class";

Expand Down Expand Up @@ -1090,12 +1134,18 @@ static CppInstanceManager<Auth> g_auth_instances;
/// @note: This operation is supported only on iOS, tvOS and Android
/// platforms. On other platforms this method will return a Future with a
/// preset error code: kAuthErrorUnimplemented.
///
/// @deprecated This function is deprecated in favor of `Task<AuthResult>`
/// return type. Please use
/// `Task<AuthResult> ReauthenticateWithProviderAsync(FederatedAuthProvider)`
/// instead.
[System.ObsoleteAttribute("Please use `Task<AuthResult> ReauthenticateWithProviderAsync(FederatedAuthProvider)` instead", false)]
public System.Threading.Tasks.Task<SignInResult>
ReauthenticateWithProviderAsync(FederatedAuthProvider provider) {
ReauthenticateWithProviderAsync_DEPRECATED(FederatedAuthProvider provider) {
ThrowIfNull();
var taskCompletionSource =
new System.Threading.Tasks.TaskCompletionSource<SignInResult>();
ReauthenticateWithProviderInternalAsync(provider).ContinueWith(task => {
ReauthenticateWithProviderInternalAsync_DEPRECATED(provider).ContinueWith(task => {
CompleteSignInResultTask(task, taskCompletionSource);
});
return taskCompletionSource.Task;
Expand All @@ -1113,12 +1163,18 @@ static CppInstanceManager<Auth> g_auth_instances;
/// @note: This operation is supported only on iOS, tvOS and Android
/// platforms. On other platforms this method will return a Future with a
/// preset error code: kAuthErrorUnimplemented.
public System.Threading.Tasks.Task<SignInResult> LinkWithProviderAsync(
///
/// @deprecated This function is deprecated in favor of `Task<AuthResult>`
/// return type. Please use
/// `Task<AuthResult> LinkWithProviderAsync(FederatedAuthProvider)`
/// instead.
[System.ObsoleteAttribute("Please use `Task<AuthResult> LinkWithProviderAsync(FederatedAuthProvider)` instead", false)]
public System.Threading.Tasks.Task<SignInResult> LinkWithProviderAsync_DEPRECATED(
FederatedAuthProvider provider) {
ThrowIfNull();
var taskCompletionSource =
new System.Threading.Tasks.TaskCompletionSource<SignInResult>();
LinkWithProviderInternalAsync(provider).ContinueWith(task => {
LinkWithProviderInternalAsync_DEPRECATED(provider).ContinueWith(task => {
CompleteSignInResultTask(task, taskCompletionSource);
});
return taskCompletionSource.Task;
Expand Down Expand Up @@ -1155,10 +1211,10 @@ static CppInstanceManager<Auth> g_auth_instances;
%}

// Rename User Federated Auth methods
%rename(ReauthenticateWithProviderInternal)
firebase::auth::User::ReauthenticateWithProvider;
%rename(LinkWithProviderInternal)
firebase::auth::User::LinkWithProvider;
%rename(ReauthenticateWithProviderInternalAsync_DEPRECATED)
firebase::auth::User::ReauthenticateWithProvider_DEPRECATED;
%rename(LinkWithProviderInternalAsync_DEPRECATED)
firebase::auth::User::LinkWithProvider_DEPRECATED;

// Rename token retrieval method.
// NOTE: This is not a property as it is an asynchronous operation.
Expand Down Expand Up @@ -1192,8 +1248,8 @@ static CppInstanceManager<Auth> g_auth_instances;
// Deprecated method that conflicts with the CurrentUser property.
%ignore firebase::auth::Auth::CurrentUser;
// Make basic getters use C# Properties instead.
%attribute(firebase::auth::Auth, firebase::auth::User *,
CurrentUserInternal, current_user);
%attributeval(firebase::auth::Auth, firebase::auth::User,
CurrentUserInternal, current_user);

%attributestring(firebase::auth::Credential, std::string, Provider, provider);

Expand All @@ -1205,8 +1261,8 @@ static CppInstanceManager<Auth> g_auth_instances;
%attributeval(firebase::auth::User, firebase::auth::UserMetadata, Metadata, metadata);
%attributestring(firebase::auth::User, std::string, PhoneNumber, phone_number);
%attributestring(firebase::auth::User, std::string, PhotoUrlInternal, photo_url);
%attribute(firebase::auth::User,
std::vector<firebase::auth::UserInfoInterface*>&, ProviderData, provider_data);
%attributeval(firebase::auth::User,
std::vector<firebase::auth::UserInfoInterface>, ProviderData, provider_data);
%attributestring(firebase::auth::User, std::string, ProviderId, provider_id);
%attributestring(firebase::auth::User, std::string, UserId, uid);

Expand Down Expand Up @@ -1317,13 +1373,26 @@ class PhoneAuthListenerImpl
virtual ~PhoneAuthListenerImpl() {}

virtual void OnVerificationCompleted(Credential credential) {
// Both `OnVerificationCompleted(Credential) and
// OnVerificationCompleted(PhoneAuthCredential) will be triggered. We
// should support both delegates but the user needs to choose to use
chkuang-g marked this conversation as resolved.
Show resolved Hide resolved
// only one of them.
if (g_verification_completed_callback) {
firebase::callback::AddCallback(
new firebase::callback::CallbackValue2<int, Credential>(
callback_id_, credential, VerificationCompleted));
}
}

virtual void OnVerificationCompleted(PhoneAuthCredential credential) {
// Both `OnVerificationCompleted(Credential) and
// OnVerificationCompleted(PhoneAuthCredential) will be triggered. We
// should support both delegates but the user needs to choose to use
chkuang-g marked this conversation as resolved.
Show resolved Hide resolved
// only one of them.

// TODO(IO2023): Add hooks to new PhoneAuthCredential. Need new delegates.
}

virtual void OnVerificationFailed(const std::string& error) {
if (g_verification_failed_callback) {
firebase::callback::AddCallback(
Expand Down
11 changes: 9 additions & 2 deletions swig_post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,16 @@ def __call__(self, file_str, filename, iteration):
# If the function name already ends with Async or is GetTask
# (since it's from a Future result class) don't replace it.
function_name = m.groups()[1]
if function_name.endswith('Async') or function_name == 'GetTask':
if (function_name.endswith('Async') or
function_name.endswith('Async_DEPRECATED') or
function_name == 'GetTask'):
break
is_deprecated = function_name.endswith('_DEPRECATED')
line = regexp.sub(r'\g<1>\g<2>Async\g<3>', line)
if function_name.endswith('_DEPRECATED'):
# Swap the location of 'Async' and '_DEPRECATED'
line = line.replace('_DEPRECATEDAsync', 'Async_DEPRECATED')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch. :) Thanks for doing that!


break
output.append(line)
return '\n'.join(output)
Expand Down Expand Up @@ -512,7 +519,7 @@ def __call__(self, file_str, filename, iteration):
line[match.end(2):]])
output.append(line)
return '\n'.join(output)

class DynamicToReinterpretCast(SWIGPostProcessingInterface):
"""Changes the use of dynamic_cast in SWIG generated code to reinterpret_cast.

Expand Down