diff --git a/.gluon/command b/.gluon/command index e5224d533..c795b054e 100644 --- a/.gluon/command +++ b/.gluon/command @@ -1 +1 @@ -run \ No newline at end of file +build \ No newline at end of file diff --git a/.gluon/patchCount b/.gluon/patchCount index 7c091989d..d2e1cefe8 100644 --- a/.gluon/patchCount +++ b/.gluon/patchCount @@ -1 +1 @@ -37 \ No newline at end of file +44 \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..7b818271c --- /dev/null +++ b/.vscode/settings.json @@ -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" + } +} \ No newline at end of file diff --git a/init-browser.py b/init-browser.py new file mode 100644 index 000000000..ab585bc7f --- /dev/null +++ b/init-browser.py @@ -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() \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 000000000..b92c531e9 --- /dev/null +++ b/package.json @@ -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" +} diff --git a/src/browser/base/content/browser-js.patch b/src/browser/base/content/browser-js.patch index ed4d273ed..4e0f4850e 100644 --- a/src/browser/base/content/browser-js.patch +++ b/src/browser/base/content/browser-js.patch @@ -1,5 +1,5 @@ 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 +++ b/browser/base/content/browser.js @@ -13,6 +13,13 @@ ChromeUtils.importESModule("resource://gre/modules/NotificationDB.sys.mjs"); @@ -36,7 +36,7 @@ index 4f145c494973374e87f3a3ed5eb6b33a43c518c8..78915f32ef912e44fa68f809fbc9cffd switch (isVisible) { case true: case "always": -@@ -10157,3 +10168,16 @@ var FirefoxViewHandler = { +@@ -10157,3 +10168,17 @@ var FirefoxViewHandler = { this.button?.toggleAttribute("attention", shouldShow); }, }; @@ -48,8 +48,9 @@ index 4f145c494973374e87f3a3ed5eb6b33a43c518c8..78915f32ef912e44fa68f809fbc9cffd + return; + } + let profile = ProfileService.currentProfile; -+ // TODO: actually use profile data to generate the avatar, instead of just using the name + console.log(profile) -+ const url = `url(https://source.boringavatars.com/beam/120/${encodeURIComponent(profile.name)}?colors=fac89a,e290ff)`; -+ mainWindowEl.style.setProperty("--avatar-image-url", url); ++ console.log(profile.zenAvatarPath) ++ 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})`); +} diff --git a/src/browser/base/content/zen-avatars/.gitignore b/src/browser/base/content/zen-avatars/.gitignore new file mode 100644 index 000000000..613175195 --- /dev/null +++ b/src/browser/base/content/zen-avatars/.gitignore @@ -0,0 +1 @@ +*.svg \ No newline at end of file diff --git a/src/browser/base/content/zen-avatars/README.md b/src/browser/base/content/zen-avatars/README.md new file mode 100644 index 000000000..c9f32a404 --- /dev/null +++ b/src/browser/base/content/zen-avatars/README.md @@ -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. diff --git a/src/browser/base/content/zen-avatars/fetch-all-avatars.py b/src/browser/base/content/zen-avatars/fetch-all-avatars.py new file mode 100644 index 000000000..9cc89b8cb --- /dev/null +++ b/src/browser/base/content/zen-avatars/fetch-all-avatars.py @@ -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() diff --git a/src/browser/base/content/zen-avatars/jar.inc.mn b/src/browser/base/content/zen-avatars/jar.inc.mn new file mode 100644 index 000000000..69347c318 --- /dev/null +++ b/src/browser/base/content/zen-avatars/jar.inc.mn @@ -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) diff --git a/src/browser/base/content/zen-panels-ui.inc.xhtml b/src/browser/base/content/zen-panels-ui.inc.xhtml index 42089ed86..dd35bfd25 100644 --- a/src/browser/base/content/zen-panels-ui.inc.xhtml +++ b/src/browser/base/content/zen-panels-ui.inc.xhtml @@ -1,4 +1,4 @@ - +
diff --git a/src/browser/base/jar-mn.patch b/src/browser/base/jar-mn.patch new file mode 100644 index 000000000..d38af3d64 --- /dev/null +++ b/src/browser/base/jar-mn.patch @@ -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 diff --git a/src/toolkit/content/aboutProfiles-js.patch b/src/toolkit/content/aboutProfiles-js.patch new file mode 100644 index 000000000..2df066301 --- /dev/null +++ b/src/toolkit/content/aboutProfiles-js.patch @@ -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); + } diff --git a/src/toolkit/locales/en-US/toolkit/about/aboutProfiles-ftl.patch b/src/toolkit/locales/en-US/toolkit/about/aboutProfiles-ftl.patch new file mode 100644 index 000000000..94516bfce --- /dev/null +++ b/src/toolkit/locales/en-US/toolkit/about/aboutProfiles-ftl.patch @@ -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 diff --git a/src/toolkit/profile/content/createProfileWizard-js.patch b/src/toolkit/profile/content/createProfileWizard-js.patch new file mode 100644 index 000000000..2495d9ee5 --- /dev/null +++ b/src/toolkit/profile/content/createProfileWizard-js.patch @@ -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"; ++} diff --git a/src/toolkit/profile/nsIToolkitProfile-idl.patch b/src/toolkit/profile/nsIToolkitProfile-idl.patch new file mode 100644 index 000000000..0155ca3d4 --- /dev/null +++ b/src/toolkit/profile/nsIToolkitProfile-idl.patch @@ -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; + }; diff --git a/src/toolkit/profile/nsToolkitProfileService-cpp.patch b/src/toolkit/profile/nsToolkitProfileService-cpp.patch new file mode 100644 index 000000000..e1335f246 --- /dev/null +++ b/src/toolkit/profile/nsToolkitProfileService-cpp.patch @@ -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 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 profile = +- new nsToolkitProfile(aName, rootDir, localDir, false); ++ new nsToolkitProfile(aName, rootDir, localDir, false, aZenAvatar); + + if (aName.Equals(DEV_EDITION_NAME)) { + mDevEditionDefault = profile; diff --git a/src/toolkit/profile/nsToolkitProfileService-h.patch b/src/toolkit/profile/nsToolkitProfileService-h.patch new file mode 100644 index 000000000..123e3ab39 --- /dev/null +++ b/src/toolkit/profile/nsToolkitProfileService-h.patch @@ -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 { diff --git a/src/toolkit/profile/zenProfileMethodsOverride.inc.cpp b/src/toolkit/profile/zenProfileMethodsOverride.inc.cpp new file mode 100644 index 000000000..da07fdc28 --- /dev/null +++ b/src/toolkit/profile/zenProfileMethodsOverride.inc.cpp @@ -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; +} \ No newline at end of file