Skip to content

Commit

Permalink
Default profile avatars (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
eoger committed Jan 24, 2019
1 parent 07bb924 commit 1040b6f
Show file tree
Hide file tree
Showing 41 changed files with 1,916 additions and 220 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,16 @@

- Autocomplete will no longer return an error when asked to match a unicode string. ([#298](https://github.com/mozilla/application-services/issues/298))

## FxA

### What's New

- It is now possible to know whether a profile avatar has been set by the user. ([#579](https://github.com/mozilla/application-services/pull/579))

### Breaking Changes

- The `avatar` accessor from the `Profile` class in the Swift framework now returns an optional `Avatar` struct instead of a `String`. ([#579](https://github.com/mozilla/application-services/pull/579))

# 0.14.0 (_2019-01-23_)

[Full Changelog](https://github.com/mozilla/application-services/compare/v0.13.3...v0.14.0)
Expand Down
Expand Up @@ -14,20 +14,22 @@ class Profile internal constructor(raw: Raw) {
val uid: String?
val email: String?
val avatar: String?
val avatarDefault: Boolean
val displayName: String?

internal class Raw(p: Pointer) : Structure(p) {
@JvmField var uid: Pointer? = null
@JvmField var email: Pointer? = null
@JvmField var avatar: Pointer? = null
@JvmField var avatarDefault: Byte = 0
@JvmField var displayName: Pointer? = null

init {
read()
}

override fun getFieldOrder(): List<String> {
return Arrays.asList("uid", "email", "avatar", "displayName")
return Arrays.asList("uid", "email", "avatar", "avatarDefault", "displayName")
}
}

Expand All @@ -36,6 +38,7 @@ class Profile internal constructor(raw: Raw) {
this.uid = raw.uid?.getRustString()
this.email = raw.email?.getRustString()
this.avatar = raw.avatar?.getRustString()
this.avatarDefault = raw.avatarDefault == 1.toByte()
this.displayName = raw.displayName?.getRustString()
} finally {
FxaClient.INSTANCE.fxa_profile_free(raw.pointer)
Expand Down
12 changes: 10 additions & 2 deletions components/fxa-client/ios/FxAClient/FirefoxAccount.swift
Expand Up @@ -287,6 +287,11 @@ open class AccessTokenInfo: RustStructPointer<AccessTokenInfoC> {
}
}

public struct Avatar {
let url: String
let isDefault: Bool
}

open class Profile: RustStructPointer<ProfileC> {
open var uid: String {
get {
Expand All @@ -300,9 +305,12 @@ open class Profile: RustStructPointer<ProfileC> {
}
}

open var avatar: String {
open var avatar: Avatar? {
get {
return String(cString: raw.pointee.avatar)
guard let pointer = raw.pointee.avatar else {
return nil
}
return Avatar(url: String(cString: pointer), isDefault: raw.pointee.avatar_default == 0x01)
}
}

Expand Down
3 changes: 2 additions & 1 deletion components/fxa-client/ios/FxAClient/fxa.h
Expand Up @@ -50,7 +50,8 @@ typedef struct SyncKeysC {
typedef struct ProfileC {
const char *const _Nonnull uid;
const char *const _Nonnull email;
const char *const _Nonnull avatar;
const char *const _Nullable avatar;
const uint8_t avatar_default;
const char *const _Nullable display_name;
} ProfileC;

Expand Down
21 changes: 16 additions & 5 deletions components/fxa-client/ios/docs/Classes.html
Expand Up @@ -14,7 +14,7 @@
<a title="Classes Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="index.html"> Docs</a> (31% documented)</p>
<p><a href="index.html"> Docs</a> (20% documented)</p>
</div>
</header>
<div class="content-wrapper">
Expand All @@ -39,6 +39,9 @@
<li class="nav-group-task">
<a href="Classes/FxAConfig.html">FxAConfig</a>
</li>
<li class="nav-group-task">
<a href="Classes/FxAConfig/Server.html">– Server</a>
</li>
<li class="nav-group-task">
<a href="Classes/Profile.html">Profile</a>
</li>
Expand All @@ -63,6 +66,14 @@
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Structs.html#/s:9FxAClient6AvatarV">Avatar</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
Expand Down Expand Up @@ -96,7 +107,7 @@ <h1>Classes</h1>
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">open</span> <span class="kd">class</span> <span class="kt">FxAConfig</span> <span class="p">:</span> <span class="kt">MovableRustOpaquePointer</span></code></pre>
<pre class="highlight swift"><code><span class="kd">open</span> <span class="kd">class</span> <span class="kt">FxAConfig</span></code></pre>

</div>
</div>
Expand Down Expand Up @@ -124,7 +135,7 @@ <h4>Declaration</h4>
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">open</span> <span class="kd">class</span> <span class="kt">FirefoxAccount</span> <span class="p">:</span> <span class="kt">RustOpaquePointer</span></code></pre>
<pre class="highlight swift"><code><span class="kd">open</span> <span class="kd">class</span> <span class="kt">FirefoxAccount</span> <span class="p">:</span> <span class="kt">RustHandle</span></code></pre>

</div>
</div>
Expand Down Expand Up @@ -220,8 +231,8 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external"></a>. All rights reserved. (Last updated: 2018-11-14)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>&copy; 2019 <a class="link" href="" target="_blank" rel="external"></a>. All rights reserved. (Last updated: 2019-01-23)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.4</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>
Expand Down
17 changes: 14 additions & 3 deletions components/fxa-client/ios/docs/Classes/AccessTokenInfo.html
Expand Up @@ -14,7 +14,7 @@
<a title="AccessTokenInfo Class Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html"> Docs</a> (31% documented)</p>
<p><a href="../index.html"> Docs</a> (20% documented)</p>
</div>
</header>
<div class="content-wrapper">
Expand All @@ -39,6 +39,9 @@
<li class="nav-group-task">
<a href="../Classes/FxAConfig.html">FxAConfig</a>
</li>
<li class="nav-group-task">
<a href="../Classes/FxAConfig/Server.html">– Server</a>
</li>
<li class="nav-group-task">
<a href="../Classes/Profile.html">Profile</a>
</li>
Expand All @@ -63,6 +66,14 @@
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Structs.html#/s:9FxAClient6AvatarV">Avatar</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
Expand Down Expand Up @@ -194,8 +205,8 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external"></a>. All rights reserved. (Last updated: 2018-11-14)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>&copy; 2019 <a class="link" href="" target="_blank" rel="external"></a>. All rights reserved. (Last updated: 2019-01-23)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.4</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>
Expand Down
58 changes: 48 additions & 10 deletions components/fxa-client/ios/docs/Classes/FirefoxAccount.html
Expand Up @@ -14,7 +14,7 @@
<a title="FirefoxAccount Class Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html"> Docs</a> (31% documented)</p>
<p><a href="../index.html"> Docs</a> (20% documented)</p>
</div>
</header>
<div class="content-wrapper">
Expand All @@ -39,6 +39,9 @@
<li class="nav-group-task">
<a href="../Classes/FxAConfig.html">FxAConfig</a>
</li>
<li class="nav-group-task">
<a href="../Classes/FxAConfig/Server.html">– Server</a>
</li>
<li class="nav-group-task">
<a href="../Classes/Profile.html">Profile</a>
</li>
Expand All @@ -63,6 +66,14 @@
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Structs.html#/s:9FxAClient6AvatarV">Avatar</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
Expand All @@ -71,7 +82,7 @@
<h1>FirefoxAccount</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">open</span> <span class="kd">class</span> <span class="kt">FirefoxAccount</span> <span class="p">:</span> <span class="kt">RustOpaquePointer</span></code></pre>
<pre class="highlight swift"><code><span class="kd">open</span> <span class="kd">class</span> <span class="kt">FirefoxAccount</span> <span class="p">:</span> <span class="kt">RustHandle</span></code></pre>

</div>
</div>
Expand All @@ -85,8 +96,8 @@ <h1>FirefoxAccount</h1>
<div>
<code>
<a name="/"></a>
<a name="//apple_ref/swift/Method/from(config:clientId:redirectUri:webChannelResponse:)" class="dashAnchor"></a>
<a class="token" href="#/">from(config:clientId:redirectUri:webChannelResponse:)</a>
<a name="//apple_ref/swift/Method/from(config:webChannelResponse:)" class="dashAnchor"></a>
<a class="token" href="#/">from(config:webChannelResponse:)</a>
</code>
</div>
<div class="height-container">
Expand Down Expand Up @@ -134,9 +145,9 @@ <h4>Declaration</h4>
<li class="item">
<div>
<code>
<a name="/s:9FxAClient14FirefoxAccountC6config8clientId11redirectUriAcA0A7AConfigC_S2StKcfc"></a>
<a name="//apple_ref/swift/Method/init(config:clientId:redirectUri:)" class="dashAnchor"></a>
<a class="token" href="#/s:9FxAClient14FirefoxAccountC6config8clientId11redirectUriAcA0A7AConfigC_S2StKcfc">init(config:clientId:redirectUri:)</a>
<a name="/s:9FxAClient14FirefoxAccountC6configAcA0A7AConfigC_tKcfc"></a>
<a name="//apple_ref/swift/Method/init(config:)" class="dashAnchor"></a>
<a class="token" href="#/s:9FxAClient14FirefoxAccountC6configAcA0A7AConfigC_tKcfc">init(config:)</a>
</code>
</div>
<div class="height-container">
Expand All @@ -154,7 +165,7 @@ <h4>Declaration</h4>
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="n">convenience</span> <span class="nf">init</span><span class="p">(</span><span class="nv">config</span><span class="p">:</span> <span class="kt"><a href="../Classes/FxAConfig.html">FxAConfig</a></span><span class="p">,</span> <span class="nv">clientId</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">redirectUri</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="k">throws</span></code></pre>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">convenience</span> <span class="nf">init</span><span class="p">(</span><span class="nv">config</span><span class="p">:</span> <span class="kt"><a href="../Classes/FxAConfig.html">FxAConfig</a></span><span class="p">)</span> <span class="k">throws</span></code></pre>

</div>
</div>
Expand Down Expand Up @@ -320,6 +331,33 @@ <h4>Declaration</h4>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:9FxAClient14FirefoxAccountC23getConnectionSuccessURL10Foundation0H0VyKF"></a>
<a name="//apple_ref/swift/Method/getConnectionSuccessURL()" class="dashAnchor"></a>
<a class="token" href="#/s:9FxAClient14FirefoxAccountC23getConnectionSuccessURL10Foundation0H0VyKF">getConnectionSuccessURL()</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Undocumented</p>

</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">open</span> <span class="kd">func</span> <span class="nf">getConnectionSuccessURL</span><span class="p">()</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">URL</span></code></pre>

</div>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
Expand Down Expand Up @@ -439,8 +477,8 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external"></a>. All rights reserved. (Last updated: 2018-11-14)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>&copy; 2019 <a class="link" href="" target="_blank" rel="external"></a>. All rights reserved. (Last updated: 2019-01-23)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.4</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>
Expand Down

0 comments on commit 1040b6f

Please sign in to comment.