Profiles can now have avatars

This commit is contained in:
mauro-balades
2024-04-02 12:35:44 +02:00
parent 821d8181b8
commit 49f539cf14
19 changed files with 410 additions and 8 deletions

View File

@@ -1 +1 @@
run build

View File

@@ -1 +1 @@
37 44

16
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,16 @@
{
"files.associations": {
"*.inc": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"functional": "cpp",
"array": "cpp",
"*.tcc": "cpp",
"memory": "cpp",
"future": "cpp",
"istream": "cpp",
"tuple": "cpp",
"utility": "cpp",
"variant": "cpp"
}
}

11
init-browser.py Normal file
View File

@@ -0,0 +1,11 @@
import os
def initialize_avatars():
os.system("cd src/browser/base/content/zen-avatars && python3 fetch-all-avatars.py")
def main():
initialize_avatars()
if __name__ == "__main__":
main()

23
package.json Normal file
View File

@@ -0,0 +1,23 @@
{
"name": "core",
"version": "1.0.0",
"description": "",
"scripts": {
"build": "gluon build",
"start": "gluon run",
"import": "gluon import",
"export": "gluon export",
"init": "python3 init-browser.py"
},
"repository": {
"type": "git",
"url": "git+https://github.com/zen-browser/core.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/zen-browser/core/issues"
},
"homepage": "https://github.com/zen-browser/core#readme"
}

View File

@@ -1,5 +1,5 @@
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
index 4f145c494973374e87f3a3ed5eb6b33a43c518c8..78915f32ef912e44fa68f809fbc9cffdcc97f41a 100644 index 4f145c494973374e87f3a3ed5eb6b33a43c518c8..8518d8a337acab19fb3bc22e8d5b3e8b1ee7902a 100644
--- a/browser/base/content/browser.js --- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js +++ b/browser/base/content/browser.js
@@ -13,6 +13,13 @@ ChromeUtils.importESModule("resource://gre/modules/NotificationDB.sys.mjs"); @@ -13,6 +13,13 @@ ChromeUtils.importESModule("resource://gre/modules/NotificationDB.sys.mjs");
@@ -36,7 +36,7 @@ index 4f145c494973374e87f3a3ed5eb6b33a43c518c8..78915f32ef912e44fa68f809fbc9cffd
switch (isVisible) { switch (isVisible) {
case true: case true:
case "always": case "always":
@@ -10157,3 +10168,16 @@ var FirefoxViewHandler = { @@ -10157,3 +10168,17 @@ var FirefoxViewHandler = {
this.button?.toggleAttribute("attention", shouldShow); this.button?.toggleAttribute("attention", shouldShow);
}, },
}; };
@@ -48,8 +48,9 @@ index 4f145c494973374e87f3a3ed5eb6b33a43c518c8..78915f32ef912e44fa68f809fbc9cffd
+ return; + return;
+ } + }
+ let profile = ProfileService.currentProfile; + let profile = ProfileService.currentProfile;
+ // TODO: actually use profile data to generate the avatar, instead of just using the name
+ console.log(profile) + console.log(profile)
+ const url = `url(https://source.boringavatars.com/beam/120/${encodeURIComponent(profile.name)}?colors=fac89a,e290ff)`; + console.log(profile.zenAvatarPath)
+ mainWindowEl.style.setProperty("--avatar-image-url", url); + if (profile.zenAvatarPath == "") return;
+ // TODO: actually use profile data to generate the avatar, instead of just using the name
+ mainWindowEl.style.setProperty("--avatar-image-url", `url(${profile.zenAvatarPath})`);
+} +}

View File

@@ -0,0 +1 @@
*.svg

View File

@@ -0,0 +1,16 @@
# Zen's Avatars
All avatars are fetched from [boring avatars](https://boringavatars.com/). Thanks a lot! <3
# Downloading avatars
Go directly to the `content/zen-avatars` folder (where this README is located) and execute the following script:
```
python3 fetch-all-avatars.py
```
# Notes
100 (0-99) avatars will be created and that's what the browser will handle. If you want to add more avatars, you can modify the `fetch-all-avatars.py` script and the browser's code to handle more avatars.

View File

@@ -0,0 +1,36 @@
import requests
import random
JAR_ENTRY_TEMPLATE = "\tcontent/browser/zen-avatars/{}\t(content/zen-avatars/{})"
URL = "https://source.boringavatars.com/beam/120/${}?colors=fac89a,e290ff"
def random_string(length):
return ''.join(random.choices("abcdefghijklmnopqrstuvwxyz", k=length))
def generate_list_names():
names = []
for i in range(1, 101):
names.append(random_string(random.randint(5, 10)))
return names
def write_jar_file(jar_file):
with open("jar.inc.mn", "w") as f:
f.write(jar_file)
def fetch_all_avatars():
names = generate_list_names()
jar_file = ""
for [i, name] in enumerate(names):
url = URL.format(name)
response = requests.get(url)
with open(f"avatar-{i}.svg", "w") as f:
f.write(response.text)
jar_file += JAR_ENTRY_TEMPLATE.format(f"avatar-{i}.svg", f"avatar-{i}.svg") + "\n"
print(f"SUCCESS: Fetched 'avatar-{i}.svg' with name '{name}'")
write_jar_file(jar_file)
def main():
fetch_all_avatars()
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,100 @@
content/browser/zen-avatars/avatar-0.svg (content/zen-avatars/avatar-0.svg)
content/browser/zen-avatars/avatar-1.svg (content/zen-avatars/avatar-1.svg)
content/browser/zen-avatars/avatar-2.svg (content/zen-avatars/avatar-2.svg)
content/browser/zen-avatars/avatar-3.svg (content/zen-avatars/avatar-3.svg)
content/browser/zen-avatars/avatar-4.svg (content/zen-avatars/avatar-4.svg)
content/browser/zen-avatars/avatar-5.svg (content/zen-avatars/avatar-5.svg)
content/browser/zen-avatars/avatar-6.svg (content/zen-avatars/avatar-6.svg)
content/browser/zen-avatars/avatar-7.svg (content/zen-avatars/avatar-7.svg)
content/browser/zen-avatars/avatar-8.svg (content/zen-avatars/avatar-8.svg)
content/browser/zen-avatars/avatar-9.svg (content/zen-avatars/avatar-9.svg)
content/browser/zen-avatars/avatar-10.svg (content/zen-avatars/avatar-10.svg)
content/browser/zen-avatars/avatar-11.svg (content/zen-avatars/avatar-11.svg)
content/browser/zen-avatars/avatar-12.svg (content/zen-avatars/avatar-12.svg)
content/browser/zen-avatars/avatar-13.svg (content/zen-avatars/avatar-13.svg)
content/browser/zen-avatars/avatar-14.svg (content/zen-avatars/avatar-14.svg)
content/browser/zen-avatars/avatar-15.svg (content/zen-avatars/avatar-15.svg)
content/browser/zen-avatars/avatar-16.svg (content/zen-avatars/avatar-16.svg)
content/browser/zen-avatars/avatar-17.svg (content/zen-avatars/avatar-17.svg)
content/browser/zen-avatars/avatar-18.svg (content/zen-avatars/avatar-18.svg)
content/browser/zen-avatars/avatar-19.svg (content/zen-avatars/avatar-19.svg)
content/browser/zen-avatars/avatar-20.svg (content/zen-avatars/avatar-20.svg)
content/browser/zen-avatars/avatar-21.svg (content/zen-avatars/avatar-21.svg)
content/browser/zen-avatars/avatar-22.svg (content/zen-avatars/avatar-22.svg)
content/browser/zen-avatars/avatar-23.svg (content/zen-avatars/avatar-23.svg)
content/browser/zen-avatars/avatar-24.svg (content/zen-avatars/avatar-24.svg)
content/browser/zen-avatars/avatar-25.svg (content/zen-avatars/avatar-25.svg)
content/browser/zen-avatars/avatar-26.svg (content/zen-avatars/avatar-26.svg)
content/browser/zen-avatars/avatar-27.svg (content/zen-avatars/avatar-27.svg)
content/browser/zen-avatars/avatar-28.svg (content/zen-avatars/avatar-28.svg)
content/browser/zen-avatars/avatar-29.svg (content/zen-avatars/avatar-29.svg)
content/browser/zen-avatars/avatar-30.svg (content/zen-avatars/avatar-30.svg)
content/browser/zen-avatars/avatar-31.svg (content/zen-avatars/avatar-31.svg)
content/browser/zen-avatars/avatar-32.svg (content/zen-avatars/avatar-32.svg)
content/browser/zen-avatars/avatar-33.svg (content/zen-avatars/avatar-33.svg)
content/browser/zen-avatars/avatar-34.svg (content/zen-avatars/avatar-34.svg)
content/browser/zen-avatars/avatar-35.svg (content/zen-avatars/avatar-35.svg)
content/browser/zen-avatars/avatar-36.svg (content/zen-avatars/avatar-36.svg)
content/browser/zen-avatars/avatar-37.svg (content/zen-avatars/avatar-37.svg)
content/browser/zen-avatars/avatar-38.svg (content/zen-avatars/avatar-38.svg)
content/browser/zen-avatars/avatar-39.svg (content/zen-avatars/avatar-39.svg)
content/browser/zen-avatars/avatar-40.svg (content/zen-avatars/avatar-40.svg)
content/browser/zen-avatars/avatar-41.svg (content/zen-avatars/avatar-41.svg)
content/browser/zen-avatars/avatar-42.svg (content/zen-avatars/avatar-42.svg)
content/browser/zen-avatars/avatar-43.svg (content/zen-avatars/avatar-43.svg)
content/browser/zen-avatars/avatar-44.svg (content/zen-avatars/avatar-44.svg)
content/browser/zen-avatars/avatar-45.svg (content/zen-avatars/avatar-45.svg)
content/browser/zen-avatars/avatar-46.svg (content/zen-avatars/avatar-46.svg)
content/browser/zen-avatars/avatar-47.svg (content/zen-avatars/avatar-47.svg)
content/browser/zen-avatars/avatar-48.svg (content/zen-avatars/avatar-48.svg)
content/browser/zen-avatars/avatar-49.svg (content/zen-avatars/avatar-49.svg)
content/browser/zen-avatars/avatar-50.svg (content/zen-avatars/avatar-50.svg)
content/browser/zen-avatars/avatar-51.svg (content/zen-avatars/avatar-51.svg)
content/browser/zen-avatars/avatar-52.svg (content/zen-avatars/avatar-52.svg)
content/browser/zen-avatars/avatar-53.svg (content/zen-avatars/avatar-53.svg)
content/browser/zen-avatars/avatar-54.svg (content/zen-avatars/avatar-54.svg)
content/browser/zen-avatars/avatar-55.svg (content/zen-avatars/avatar-55.svg)
content/browser/zen-avatars/avatar-56.svg (content/zen-avatars/avatar-56.svg)
content/browser/zen-avatars/avatar-57.svg (content/zen-avatars/avatar-57.svg)
content/browser/zen-avatars/avatar-58.svg (content/zen-avatars/avatar-58.svg)
content/browser/zen-avatars/avatar-59.svg (content/zen-avatars/avatar-59.svg)
content/browser/zen-avatars/avatar-60.svg (content/zen-avatars/avatar-60.svg)
content/browser/zen-avatars/avatar-61.svg (content/zen-avatars/avatar-61.svg)
content/browser/zen-avatars/avatar-62.svg (content/zen-avatars/avatar-62.svg)
content/browser/zen-avatars/avatar-63.svg (content/zen-avatars/avatar-63.svg)
content/browser/zen-avatars/avatar-64.svg (content/zen-avatars/avatar-64.svg)
content/browser/zen-avatars/avatar-65.svg (content/zen-avatars/avatar-65.svg)
content/browser/zen-avatars/avatar-66.svg (content/zen-avatars/avatar-66.svg)
content/browser/zen-avatars/avatar-67.svg (content/zen-avatars/avatar-67.svg)
content/browser/zen-avatars/avatar-68.svg (content/zen-avatars/avatar-68.svg)
content/browser/zen-avatars/avatar-69.svg (content/zen-avatars/avatar-69.svg)
content/browser/zen-avatars/avatar-70.svg (content/zen-avatars/avatar-70.svg)
content/browser/zen-avatars/avatar-71.svg (content/zen-avatars/avatar-71.svg)
content/browser/zen-avatars/avatar-72.svg (content/zen-avatars/avatar-72.svg)
content/browser/zen-avatars/avatar-73.svg (content/zen-avatars/avatar-73.svg)
content/browser/zen-avatars/avatar-74.svg (content/zen-avatars/avatar-74.svg)
content/browser/zen-avatars/avatar-75.svg (content/zen-avatars/avatar-75.svg)
content/browser/zen-avatars/avatar-76.svg (content/zen-avatars/avatar-76.svg)
content/browser/zen-avatars/avatar-77.svg (content/zen-avatars/avatar-77.svg)
content/browser/zen-avatars/avatar-78.svg (content/zen-avatars/avatar-78.svg)
content/browser/zen-avatars/avatar-79.svg (content/zen-avatars/avatar-79.svg)
content/browser/zen-avatars/avatar-80.svg (content/zen-avatars/avatar-80.svg)
content/browser/zen-avatars/avatar-81.svg (content/zen-avatars/avatar-81.svg)
content/browser/zen-avatars/avatar-82.svg (content/zen-avatars/avatar-82.svg)
content/browser/zen-avatars/avatar-83.svg (content/zen-avatars/avatar-83.svg)
content/browser/zen-avatars/avatar-84.svg (content/zen-avatars/avatar-84.svg)
content/browser/zen-avatars/avatar-85.svg (content/zen-avatars/avatar-85.svg)
content/browser/zen-avatars/avatar-86.svg (content/zen-avatars/avatar-86.svg)
content/browser/zen-avatars/avatar-87.svg (content/zen-avatars/avatar-87.svg)
content/browser/zen-avatars/avatar-88.svg (content/zen-avatars/avatar-88.svg)
content/browser/zen-avatars/avatar-89.svg (content/zen-avatars/avatar-89.svg)
content/browser/zen-avatars/avatar-90.svg (content/zen-avatars/avatar-90.svg)
content/browser/zen-avatars/avatar-91.svg (content/zen-avatars/avatar-91.svg)
content/browser/zen-avatars/avatar-92.svg (content/zen-avatars/avatar-92.svg)
content/browser/zen-avatars/avatar-93.svg (content/zen-avatars/avatar-93.svg)
content/browser/zen-avatars/avatar-94.svg (content/zen-avatars/avatar-94.svg)
content/browser/zen-avatars/avatar-95.svg (content/zen-avatars/avatar-95.svg)
content/browser/zen-avatars/avatar-96.svg (content/zen-avatars/avatar-96.svg)
content/browser/zen-avatars/avatar-97.svg (content/zen-avatars/avatar-97.svg)
content/browser/zen-avatars/avatar-98.svg (content/zen-avatars/avatar-98.svg)
content/browser/zen-avatars/avatar-99.svg (content/zen-avatars/avatar-99.svg)

View File

@@ -1,4 +1,4 @@
<panelview id="PanelUI-zen-profiles" side="right"> <panelview id="PanelUI-zen-profiles" position="bottomleft topleft" side="right">
<vbox class="panel-subview-body"> <vbox class="panel-subview-body">
<div id="PanelUI-zen-profiles-header"></div> <div id="PanelUI-zen-profiles-header"></div>
<div id="PanelUI-zen-profiles-user-picture" /> <div id="PanelUI-zen-profiles-user-picture" />

View File

@@ -0,0 +1,11 @@
diff --git a/browser/base/jar.mn b/browser/base/jar.mn
index e3eb0e6e5f30152905456a07cfe532fe173375fb..15968304e9597e8bfc08cd03dc7615d1a5ff7f7f 100644
--- a/browser/base/jar.mn
+++ b/browser/base/jar.mn
@@ -105,3 +105,5 @@ browser.jar:
# L10n resources and overrides.
% override chrome://global/locale/appstrings.properties chrome://browser/locale/appstrings.properties
+
+#include content/zen-avatars/jar.inc.mn
\ No newline at end of file

View File

@@ -0,0 +1,13 @@
diff --git a/toolkit/content/aboutProfiles.js b/toolkit/content/aboutProfiles.js
index 15c0419a11fee377f17dd766938943024723aab0..8bf3cb00a6f1fbbec421110c5d631d88d89cbb67 100644
--- a/toolkit/content/aboutProfiles.js
+++ b/toolkit/content/aboutProfiles.js
@@ -155,6 +155,8 @@ function display(profileData) {
createItem("profiles-rootdir", profileData.profile.rootDir, true);
+ createItem("profiles-avatar", profileData.profile.zenAvatarPath);
+
if (profileData.profile.localDir.path != profileData.profile.rootDir.path) {
createItem("profiles-localdir", profileData.profile.localDir, true);
}

View File

@@ -0,0 +1,12 @@
diff --git a/toolkit/locales/en-US/toolkit/about/aboutProfiles.ftl b/toolkit/locales/en-US/toolkit/about/aboutProfiles.ftl
index c11b89b3214cc17826a0be745f5d14d8c5c5cae3..417295cc42f1c61a02d9f26d1df442237b8e720c 100644
--- a/toolkit/locales/en-US/toolkit/about/aboutProfiles.ftl
+++ b/toolkit/locales/en-US/toolkit/about/aboutProfiles.ftl
@@ -20,6 +20,7 @@ profiles-flush-restart-button = Restart { -brand-short-name }
profiles-name = Profile: { $name }
profiles-is-default = Default Profile
profiles-rootdir = Root Directory
+profiles-avatar = Profile Avatar
# localDir is used to show the directory corresponding to
# the main profile directory that exists for the purpose of storing data on the

View File

@@ -0,0 +1,23 @@
diff --git a/toolkit/profile/content/createProfileWizard.js b/toolkit/profile/content/createProfileWizard.js
index 9e87fb42207d6d8e2cb054562bf50080fe9bb929..955f424bba004dd0fcd393500acbb66b4d5fce06 100644
--- a/toolkit/profile/content/createProfileWizard.js
+++ b/toolkit/profile/content/createProfileWizard.js
@@ -233,7 +233,7 @@ function onFinish(event) {
// Create profile named profileName in profileRoot.
try {
- profile = gProfileService.createProfile(gProfileRoot, profileName);
+ profile = gProfileService.createProfile(gProfileRoot, profileName, zenGetProfileAvatar());
} catch (e) {
var profileCreationFailed = gProfileManagerBundle.getString(
"profileCreationFailed"
@@ -264,3 +264,9 @@ function onFinish(event) {
dialogParams.objects.insertElementAt(profileLock, 0);
}
}
+
+function zenGetProfileAvatar() {
+ // From 0 to 99
+ let avatarId = Math.floor(Math.random() * 100);
+ return "chrome://browser/content/zen-avatars/avatar-" + avatarId + ".svg";
+}

View File

@@ -0,0 +1,14 @@
diff --git a/toolkit/profile/nsIToolkitProfile.idl b/toolkit/profile/nsIToolkitProfile.idl
index b194cd956382039f24844ded1f2b0edb2fbca2ee..e8a4bce343c7b7a402de3d7d387481a981640fa8 100644
--- a/toolkit/profile/nsIToolkitProfile.idl
+++ b/toolkit/profile/nsIToolkitProfile.idl
@@ -96,4 +96,9 @@ interface nsIToolkitProfile : nsISupports
* @throws NS_ERROR_FILE_ACCESS_DENIED if the profile was already locked.
*/
nsIProfileLock lock(out nsIProfileUnlocker aUnlocker);
+
+ /**
+ * Zen Avatar Path
+ */
+ attribute AUTF8String zenAvatarPath;
};

View File

@@ -0,0 +1,83 @@
diff --git a/toolkit/profile/nsToolkitProfileService.cpp b/toolkit/profile/nsToolkitProfileService.cpp
index aeab25c61f3b04cfa19ec93e2abe0772d8656e61..6ac40c71ad35b5ce1d4e55fce0644991a9903b4d 100644
--- a/toolkit/profile/nsToolkitProfileService.cpp
+++ b/toolkit/profile/nsToolkitProfileService.cpp
@@ -234,13 +234,14 @@ void RemoveProfileFiles(nsIToolkitProfile* aProfile, bool aInBackground) {
}
nsToolkitProfile::nsToolkitProfile(const nsACString& aName, nsIFile* aRootDir,
- nsIFile* aLocalDir, bool aFromDB)
+ nsIFile* aLocalDir, bool aFromDB, const nsACString& aZenAvatarPath)
: mName(aName),
mRootDir(aRootDir),
mLocalDir(aLocalDir),
mLock(nullptr),
mIndex(0),
- mSection("Profile") {
+ mSection("Profile"),
+ mZenAvatarPath(aZenAvatarPath){
NS_ASSERTION(aRootDir, "No file!");
RefPtr<nsToolkitProfile> prev =
@@ -253,8 +254,8 @@ nsToolkitProfile::nsToolkitProfile(const nsACString& aName, nsIFile* aRootDir,
nsToolkitProfileService::gService->mProfiles.insertBack(this);
// If this profile isn't in the database already add it.
+ nsINIParser* db = &nsToolkitProfileService::gService->mProfileDB;
if (!aFromDB) {
- nsINIParser* db = &nsToolkitProfileService::gService->mProfileDB;
db->SetString(mSection.get(), "Name", mName.get());
bool isRelative = false;
@@ -264,6 +265,10 @@ nsToolkitProfile::nsToolkitProfile(const nsACString& aName, nsIFile* aRootDir,
db->SetString(mSection.get(), "IsRelative", isRelative ? "1" : "0");
db->SetString(mSection.get(), "Path", descriptor.get());
+ db->SetString(mSection.get(), "ZenAvatarPath", mZenAvatarPath.get());
+ } else if (mZenAvatarPath == ""_ns) {
+ // Load the profile's avatar from the database.
+ db->GetString(mSection.get(), "ZenAvatarPath", mZenAvatarPath);
}
}
@@ -318,6 +323,8 @@ nsToolkitProfile::SetName(const nsACString& aName) {
return NS_OK;
}
+#include "zenProfileMethodsOverride.inc.cpp"
+
nsresult nsToolkitProfile::RemoveInternal(bool aRemoveFiles,
bool aInBackground) {
NS_ASSERTION(nsToolkitProfileService::gService, "Whoa, my service is gone.");
@@ -992,7 +999,15 @@ nsresult nsToolkitProfileService::Init() {
localDir = rootDir;
}
- currentProfile = new nsToolkitProfile(name, rootDir, localDir, true);
+ nsAutoCString zenProfileAvatar;
+
+ rv = mProfileDB.GetString(profileID.get(), "ZenAvatarPath", zenProfileAvatar);
+ if (NS_FAILED(rv)) {
+ NS_ERROR("Malformed profiles.ini: ZenAvatarPath= not found");
+ continue;
+ }
+
+ currentProfile = new nsToolkitProfile(name, rootDir, localDir, true, zenProfileAvatar);
// If a user has modified the ini file path it may make for a valid profile
// path but not match what we would have serialised and so may not match
@@ -1994,8 +2009,13 @@ nsToolkitProfileService::CreateProfile(nsIFile* aRootDir,
rv = CreateTimesInternal(rootDir);
NS_ENSURE_SUCCESS(rv, rv);
+ if (aZenAvatar == ""_ns) {
+ rv = mProfileDB.GetString(aName, "ZenAvatar", aZenAvatar);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+
nsCOMPtr<nsIToolkitProfile> profile =
- new nsToolkitProfile(aName, rootDir, localDir, false);
+ new nsToolkitProfile(aName, rootDir, localDir, false, aZenAvatar);
if (aName.Equals(DEV_EDITION_NAME)) {
mDevEditionDefault = profile;

View File

@@ -0,0 +1,21 @@
diff --git a/toolkit/profile/nsToolkitProfileService.h b/toolkit/profile/nsToolkitProfileService.h
index 9de18b8ae349853f4f78b92d1a0b485add4e716e..b8a051cb5fd4c7a26af5377c1398d9a270985920 100644
--- a/toolkit/profile/nsToolkitProfileService.h
+++ b/toolkit/profile/nsToolkitProfileService.h
@@ -30,7 +30,7 @@ class nsToolkitProfile final
~nsToolkitProfile() = default;
nsToolkitProfile(const nsACString& aName, nsIFile* aRootDir,
- nsIFile* aLocalDir, bool aFromDB);
+ nsIFile* aLocalDir, bool aFromDB, const nsACString& aZenAvatarPath);
nsresult RemoveInternal(bool aRemoveFiles, bool aInBackground);
@@ -42,6 +42,7 @@ class nsToolkitProfile final
nsIProfileLock* mLock;
uint32_t mIndex;
nsCString mSection;
+ nsCString mZenAvatarPath;
};
class nsToolkitProfileLock final : public nsIProfileLock {

View File

@@ -0,0 +1,21 @@
NS_IMETHODIMP
nsToolkitProfile::GetZenAvatarPath(nsACString& aResult) {
aResult = mZenAvatarPath;
return NS_OK;
}
NS_IMETHODIMP
nsToolkitProfile::SetZenAvatarPath(const nsACString& aZenAvatar) {
NS_ASSERTION(nsToolkitProfileService::gService, "Where did my service go?");
if (mZenAvatarPath.Equals(aZenAvatar)) {
return NS_OK;
}
mZenAvatarPath = aZenAvatar;
nsresult rv = nsToolkitProfileService::gService->mProfileDB.SetString(
mSection.get(), "ZenAvatarPath", mZenAvatarPath.get());
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}