├── skin ├── icon16.png ├── icon32.png └── icon64.png ├── api ├── Google4TbSync │ ├── schema.json │ └── implementation.js └── LegacyHelper │ ├── schema.json │ ├── README.md │ └── implementation.js ├── CONTRIBUTORS.md ├── background.js ├── content ├── locales.js ├── manager │ ├── authenticate.xhtml │ ├── editAccountOverlay.js │ ├── createAccount.js │ ├── createAccount.xhtml │ └── editAccountOverlay.xhtml ├── includes │ ├── NetworkError.js │ ├── ResponseError.js │ ├── IllegalArgumentError.js │ ├── AuthorizationCodeError.js │ ├── Logger.js │ ├── sync.js │ ├── PeopleAPI.js │ └── AddressBookSynchronizer.js └── provider.js ├── _locales ├── nb-NO │ └── messages.json ├── nl │ └── messages.json ├── de │ └── messages.json ├── en-US │ └── messages.json └── it │ └── messages.json ├── manifest.json ├── README.md └── LICENSE /skin/icon16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zanonmark/Google-4-TbSync/HEAD/skin/icon16.png -------------------------------------------------------------------------------- /skin/icon32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zanonmark/Google-4-TbSync/HEAD/skin/icon32.png -------------------------------------------------------------------------------- /skin/icon64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zanonmark/Google-4-TbSync/HEAD/skin/icon64.png -------------------------------------------------------------------------------- /api/Google4TbSync/schema.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "namespace": "Google4TbSync", 4 | "functions": [ 5 | { 6 | "name": "load", 7 | "type": "function", 8 | "async": true, 9 | "parameters": [] 10 | } 11 | ] 12 | } 13 | ] -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | ## Development 2 | * Marco Zanon 3 | 4 | ## Documentation 5 | * Marco Zanon 6 | * David Taber 7 | 8 | ## Translations 9 | * de: Sebastian Jentschke 10 | * en-US: John Bieling, Marco Zanon 11 | * it: Marco Zanon 12 | * nb-NO: Sebastian Jentschke 13 | * nl: Jeroen B. 14 | 15 | ## Other contributions 16 | * John Bieling (original TbSync add-on template and advices) 17 | * All the nice people who reported issues and helped beta-testing, fixing bugs and improving the documentation 18 | -------------------------------------------------------------------------------- /background.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Google-4-TbSync. 3 | * See CONTRIBUTORS.md for details. 4 | * 5 | * This Source Code Form is subject to the terms of the Mozilla Public 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | */ 9 | 10 | await browser.LegacyHelper.registerGlobalUrls([ 11 | ["content", "google-4-tbsync", "content/"], 12 | ["resource", "google-4-tbsync", "."], 13 | ]); 14 | 15 | await browser.Google4TbSync.load(); 16 | -------------------------------------------------------------------------------- /content/locales.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Google-4-TbSync. 3 | * See CONTRIBUTORS.md for details. 4 | * 5 | * This Source Code Form is subject to the terms of the Mozilla Public 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | */ 9 | var { ExtensionParent } = ChromeUtils.importESModule( 10 | "resource://gre/modules/ExtensionParent.sys.mjs" 11 | ); 12 | var tbsyncExtension = ExtensionParent.GlobalManager.getExtension( 13 | "tbsync@jobisoft.de" 14 | ); 15 | var { TbSync } = ChromeUtils.importESModule( 16 | `chrome://tbsync/content/tbsync.sys.mjs?${tbsyncExtension.manifest.version}` 17 | ); 18 | 19 | TbSync.localizeOnLoad(window, "google"); 20 | -------------------------------------------------------------------------------- /content/manager/authenticate.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /content/includes/NetworkError.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Google-4-TbSync. 3 | * See CONTRIBUTORS.md for details. 4 | * 5 | * This Source Code Form is subject to the terms of the Mozilla Public 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | */ 9 | 10 | "use strict"; 11 | 12 | class NetworkError extends Error { // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error 13 | 14 | /* */ 15 | 16 | constructor(...args) { 17 | // Pass the arguments (including vendor specific ones) to parent constructor. 18 | super(...args); 19 | // Maintain proper stack trace for where our error was thrown from (only available on V8). 20 | if (Error.captureStackTrace) { 21 | Error.captureStackTrace(this, NetworkError); 22 | } 23 | // Set the internal name. 24 | this.name = "NetworkError"; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /content/includes/ResponseError.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Google-4-TbSync. 3 | * See CONTRIBUTORS.md for details. 4 | * 5 | * This Source Code Form is subject to the terms of the Mozilla Public 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | */ 9 | 10 | "use strict"; 11 | 12 | class ResponseError extends Error { // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error 13 | 14 | /* */ 15 | 16 | constructor(...args) { 17 | // Pass the arguments (including vendor specific ones) to parent constructor. 18 | super(...args); 19 | // Maintain proper stack trace for where our error was thrown from (only available on V8). 20 | if (Error.captureStackTrace) { 21 | Error.captureStackTrace(this, ResponseError); 22 | } 23 | // Set the internal name. 24 | this.name = "ResponseError"; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /content/includes/IllegalArgumentError.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Google-4-TbSync. 3 | * See CONTRIBUTORS.md for details. 4 | * 5 | * This Source Code Form is subject to the terms of the Mozilla Public 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | */ 9 | 10 | "use strict"; 11 | 12 | class IllegalArgumentError extends Error { // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error 13 | 14 | /* */ 15 | 16 | constructor(...args) { 17 | // Pass the arguments (including vendor specific ones) to parent constructor. 18 | super(...args); 19 | // Maintain proper stack trace for where our error was thrown from (only available on V8). 20 | if (Error.captureStackTrace) { 21 | Error.captureStackTrace(this, IllegalArgumentError); 22 | } 23 | // Set the internal name. 24 | this.name = "IllegalArgumentError"; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /content/includes/AuthorizationCodeError.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Google-4-TbSync. 3 | * See CONTRIBUTORS.md for details. 4 | * 5 | * This Source Code Form is subject to the terms of the Mozilla Public 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | */ 9 | 10 | "use strict"; 11 | 12 | class AuthorizationCodeError extends Error { // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error 13 | 14 | /* */ 15 | 16 | constructor(...args) { 17 | // Pass the arguments (including vendor specific ones) to parent constructor. 18 | super(...args); 19 | // Maintain proper stack trace for where our error was thrown from (only available on V8). 20 | if (Error.captureStackTrace) { 21 | Error.captureStackTrace(this, AuthorizationCodeError); 22 | } 23 | // Set the internal name. 24 | this.name = "AuthorizationCodeError"; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /api/LegacyHelper/schema.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "namespace": "LegacyHelper", 4 | "functions": [ 5 | { 6 | "name": "registerGlobalUrls", 7 | "type": "function", 8 | "async": true, 9 | "description": "Register folders which should be available as legacy chrome:// urls or resource:// urls", 10 | "parameters": [ 11 | { 12 | "name": "data", 13 | "type": "array", 14 | "items": { 15 | "type": "array", 16 | "items": { 17 | "type": "string" 18 | } 19 | }, 20 | "description": "Array of manifest url definitions (content, locale or resource)" 21 | } 22 | ] 23 | }, 24 | { 25 | "name": "openDialog", 26 | "type": "function", 27 | "parameters": [ 28 | { 29 | "name": "name", 30 | "type": "string", 31 | "description": "name of the new dialog" 32 | }, 33 | { 34 | "name": "path", 35 | "type": "string", 36 | "description": "path of the dialog to be opened" 37 | } 38 | ] 39 | } 40 | ] 41 | } 42 | ] -------------------------------------------------------------------------------- /_locales/nb-NO/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "extensionName": { 3 | "message": "Google-4-TbSync" 4 | }, 5 | "extensionDescription": { 6 | "message": "Dette add-on legger til Google-synkroniseringsfunksjoner i TbSync. Bare kontakter og kontaktgrupper administreres for øyeblikket ved hjelp av Googles People API." 7 | }, 8 | 9 | "menu.name": { 10 | "message": "Googles People API" 11 | }, 12 | 13 | "add.account.title": { 14 | "message": "Skriv inn informasjonen for den nye kontoen" 15 | }, 16 | "add.title": { 17 | "message": "Legge til en Google-konto i TbSync" 18 | }, 19 | 20 | "manager.tabs.accountsettings": { 21 | "message": "Kontoinnstillinger" 22 | }, 23 | "manager.tabs.syncsettings": { 24 | "message": "Instillinger" 25 | }, 26 | 27 | "pref.accountName": { 28 | "message": "Kontonavn" 29 | }, 30 | "pref.checkConnection": { 31 | "message": "Sjekk tilkoblingen" 32 | }, 33 | "pref.clientID": { 34 | "message": "Klient-ID" 35 | }, 36 | "pref.clientSecret": { 37 | "message": "Klient-passord" 38 | }, 39 | "pref.includeSystemContactGroups": { 40 | "message": "Inkluder systemkontaktgrupper" 41 | }, 42 | "pref.readOnlyMode": { 43 | "message": "Skrivebeskyttet modus" 44 | }, 45 | "pref.useFakeEmailAddresses": { 46 | "message": "Bruk genererte (fake) e-postadresser" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /_locales/nl/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "extensionName": { 3 | "message": "Google-4-TbSync" 4 | }, 5 | "extensionDescription": { 6 | "message": "Deze add-on voegt Google-syncronisatiemogelijkheden toe aan de 'TbSync' add-on. Op dit moment worden alleen contacten en contactgroepen ondersteund, door middel van Google's People API." 7 | }, 8 | 9 | "menu.name": { 10 | "message": "Google's People API" 11 | }, 12 | 13 | "add.account.title": { 14 | "message": "Voer de gegevens in voor het nieuwe account" 15 | }, 16 | "add.title": { 17 | "message": "Een Google account toevoegen aan TbSync" 18 | }, 19 | 20 | "manager.tabs.accountsettings": { 21 | "message": "Account-instellingen" 22 | }, 23 | "manager.tabs.syncsettings": { 24 | "message": "Opties" 25 | }, 26 | 27 | "pref.accountName": { 28 | "message": "Accountnaam" 29 | }, 30 | "pref.checkConnection": { 31 | "message": "Controleer verbinding" 32 | }, 33 | "pref.clientID": { 34 | "message": "Client ID" 35 | }, 36 | "pref.clientSecret": { 37 | "message": "Client secret" 38 | }, 39 | "pref.includeSystemContactGroups": { 40 | "message": "Inclusief Systeem contactgroepen" 41 | }, 42 | "pref.readOnlyMode": { 43 | "message": "Alleen-lezen modus" 44 | }, 45 | "pref.useFakeEmailAddresses": { 46 | "message": "Gebruik nep e-mailadressen" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /_locales/de/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "extensionName": { 3 | "message": "Google-4-TbSync" 4 | }, 5 | "extensionDescription": { 6 | "message": "Dieses Add-On erweitert TbSync um Google-Synchronisierungsfunktionen. Derzeit werden nur Kontakte und Kontaktgruppen mithilfe der People-API von Google verwaltet." 7 | }, 8 | 9 | "menu.name": { 10 | "message": "People-API von Google" 11 | }, 12 | 13 | "add.account.title": { 14 | "message": "Geben Sie die Informationen für das neue Konto ein" 15 | }, 16 | "add.title": { 17 | "message": "Hinzufügen eines Google-Kontos mithilfe von TbSync" 18 | }, 19 | 20 | "manager.tabs.accountsettings": { 21 | "message": "Kontoeinstellungen" 22 | }, 23 | "manager.tabs.syncsettings": { 24 | "message": "Optionen" 25 | }, 26 | 27 | "pref.accountName": { 28 | "message": "Kontobezeichnung" 29 | }, 30 | "pref.checkConnection": { 31 | "message": "Überprüfen Sie Ihre Verbindung" 32 | }, 33 | "pref.clientID": { 34 | "message": "Client-ID" 35 | }, 36 | "pref.clientSecret": { 37 | "message": "Client-Passwort" 38 | }, 39 | "pref.includeSystemContactGroups": { 40 | "message": "Inkl. der Systemkontaktgruppen" 41 | }, 42 | "pref.readOnlyMode": { 43 | "message": "Schreibgeschützter Modus" 44 | }, 45 | "pref.useFakeEmailAddresses": { 46 | "message": "Verwende systemgenerierte (fake) e-Mail-Adressen" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /_locales/en-US/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "extensionName": { 3 | "message": "Google-4-TbSync" 4 | }, 5 | "extensionDescription": { 6 | "message": "This provider add-on adds Google synchronization capabilities to TbSync. Only contacts and contact groups are currently managed, using Google's People API." 7 | }, 8 | 9 | "menu.name": { 10 | "message": "Google's People API" 11 | }, 12 | 13 | "add.account.title": { 14 | "message": "Enter the information for the new account" 15 | }, 16 | "add.title": { 17 | "message": "Adding a Google account to TbSync" 18 | }, 19 | 20 | "manager.tabs.accountsettings": { 21 | "message": "Account settings" 22 | }, 23 | "manager.tabs.syncsettings": { 24 | "message": "Options" 25 | }, 26 | 27 | "pref.accountName": { 28 | "message": "Account name" 29 | }, 30 | "pref.checkConnection": { 31 | "message": "Check connection" 32 | }, 33 | "pref.clientID": { 34 | "message": "Client ID" 35 | }, 36 | "pref.clientSecret": { 37 | "message": "Client secret" 38 | }, 39 | "pref.includeSystemContactGroups": { 40 | "message": "Include system contact groups" 41 | }, 42 | "pref.readOnlyMode": { 43 | "message": "Read-only mode" 44 | }, 45 | "pref.useFakeEmailAddresses": { 46 | "message": "Use fake email addresses" 47 | }, 48 | "pref.verboseLogging": { 49 | "message": "Verbose logging" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /content/includes/Logger.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Google-4-TbSync. 3 | * See CONTRIBUTORS.md for details. 4 | * 5 | * This Source Code Form is subject to the terms of the Mozilla Public 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | */ 9 | 10 | "use strict"; 11 | 12 | if ("undefined" === typeof IllegalArgumentError) { 13 | Services.scriptloader.loadSubScript("chrome://google-4-tbsync/content/includes/IllegalArgumentError.js", this, "UTF-8"); 14 | } 15 | 16 | class Logger { 17 | 18 | /* FIXME: disabled as it is still not fully supported. 19 | _verboseLogging = false; 20 | */ 21 | 22 | constructor(verboseLogging) { 23 | // FIXME: the next two lines are necessary as a workaround for a TbSync's bug. 24 | if ("true" === verboseLogging) verboseLogging = true; 25 | if ("false" === verboseLogging) verboseLogging = false; 26 | if ("boolean" != typeof verboseLogging) { 27 | throw new IllegalArgumentError("Invalid 'verboseLogging': not a boolean."); 28 | } 29 | // 30 | this._verboseLogging = verboseLogging; 31 | } 32 | 33 | getVerboseLogging() { 34 | return this._verboseLogging; 35 | } 36 | 37 | /* */ 38 | 39 | /* Logging. */ 40 | 41 | log0(message) { 42 | console.log(message); 43 | } 44 | 45 | log1(message) { 46 | if (this.getVerboseLogging()) { 47 | this.log0(message); 48 | } 49 | } 50 | 51 | } 52 | 53 | var logger = null; 54 | -------------------------------------------------------------------------------- /_locales/it/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "extensionName": { 3 | "message": "Google-4-TbSync" 4 | }, 5 | "extensionDescription": { 6 | "message": "Questo add-on provider aggiunge funzionalità di sincronizzazione con Google a TbSync. Al momento sono gestiti solo i contatti ed i gruppi di contatti, tramite Google's People API." 7 | }, 8 | 9 | "menu.name": { 10 | "message": "Google's People API" 11 | }, 12 | 13 | "add.account.title": { 14 | "message": "Inserisci le informazioni per il nuovo account" 15 | }, 16 | "add.title": { 17 | "message": "Aggiunta di un account Google a TbSync" 18 | }, 19 | 20 | "manager.tabs.accountsettings": { 21 | "message": "Impostazioni dell'account" 22 | }, 23 | "manager.tabs.syncsettings": { 24 | "message": "Opzioni" 25 | }, 26 | 27 | "pref.accountName": { 28 | "message": "Nome dell'account" 29 | }, 30 | "pref.checkConnection": { 31 | "message": "Controlla la connessione" 32 | }, 33 | "pref.clientID": { 34 | "message": "ID client" 35 | }, 36 | "pref.clientSecret": { 37 | "message": "Chiave segreta client" 38 | }, 39 | "pref.includeSystemContactGroups": { 40 | "message": "Includi i gruppi di contatti di sistema" 41 | }, 42 | "pref.readOnlyMode": { 43 | "message": "Modalità sola-lettura" 44 | }, 45 | "pref.useFakeEmailAddresses": { 46 | "message": "Usa indirizzi email fittizi" 47 | }, 48 | "pref.verboseLogging": { 49 | "message": "Log dettagliato" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "__MSG_extensionName__", 4 | "description": "__MSG_extensionDescription__", 5 | "version": "0.9.0", 6 | "author": "Marco Zanon", 7 | "default_locale": "en-US", 8 | "applications": { 9 | "gecko": { 10 | "id": "google-4-tbsync@marcozanon.com", 11 | "strict_min_version": "136.0", 12 | "strict_max_version": "140.*" 13 | } 14 | }, 15 | "icons": { 16 | "16": "skin/icon16.png", 17 | "32": "skin/icon32.png", 18 | "64": "skin/icon64.png" 19 | }, 20 | "background": { 21 | "type": "module", 22 | "scripts": [ 23 | "background.js" 24 | ] 25 | }, 26 | "permissions": [], 27 | "experiment_apis": { 28 | "LegacyHelper": { 29 | "schema": "api/LegacyHelper/schema.json", 30 | "parent": { 31 | "scopes": [ 32 | "addon_parent" 33 | ], 34 | "paths": [ 35 | [ 36 | "LegacyHelper" 37 | ] 38 | ], 39 | "script": "api/LegacyHelper/implementation.js" 40 | } 41 | }, 42 | "Google4TbSync": { 43 | "schema": "api/Google4TbSync/schema.json", 44 | "parent": { 45 | "scopes": [ 46 | "addon_parent" 47 | ], 48 | "paths": [ 49 | [ 50 | "Google4TbSync" 51 | ] 52 | ], 53 | "script": "api/Google4TbSync/implementation.js" 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /api/LegacyHelper/README.md: -------------------------------------------------------------------------------- 1 | ## Objective 2 | 3 | This API is a temporary helper while converting legacy extensions to modern WebExtensions. It allows to register `resource://` URLs, which are needed to load custom system modules (*.sys.mjs), and `chrome://` URLs, which are needed to open legacy XUL dialogs. 4 | 5 | ## Usage 6 | 7 | Add the [LegacyHelper API](https://github.com/thunderbird/webext-support/tree/master/experiments/LegacyHelper) to your add-on. Your `manifest.json` needs an entry like this: 8 | 9 | ```json 10 | "experiment_apis": { 11 | "LegacyHelper": { 12 | "schema": "api/LegacyHelper/schema.json", 13 | "parent": { 14 | "scopes": ["addon_parent"], 15 | "paths": [["LegacyHelper"]], 16 | "script": "api/LegacyHelper/implementation.js" 17 | } 18 | } 19 | }, 20 | ``` 21 | 22 | ## API Functions 23 | 24 | This API provides the following functions: 25 | 26 | ### async registerGlobalUrls(data) 27 | 28 | Register `chrome://*/content/` and `resource://*/` URLs. The function accepts a `data` parameter, which is an array of URL definition items. For example: 29 | 30 | ```javascript 31 | await browser.LegacyHelper.registerGlobalUrls([ 32 | ["content", "myaddon", "chrome/content/"], 33 | ["resource", "myaddon", "modules/"], 34 | ]); 35 | ``` 36 | 37 | This registers the following URLs: 38 | * `chrome://myaddon/content/` pointing to the `/chrome/content/` folder (the `/content/` part in the URL is fix and does not depend on the name of the folder it is pointing to) 39 | * `resource://myaddon/` pointing to the `/modules/` folder. To register a `resource://` URL which points to the root folder, use `.` instead". 40 | 41 | ### async openDialog(name, path) 42 | 43 | Open a XUL dialog. The `name` parameter is a unique name identifying the dialog. If the dialog with that name is already open, it will be focused instead of being re-opened. The `path` parameter is a `chrome://*/content/` URL pointing to the XUL dialog file (*.xul or *.xhtml). 44 | 45 | ```javascript 46 | browser.LegacyHelper.openDialog( 47 | "XulAddonOptions", 48 | "chrome://myaddon/content/options.xhtml" 49 | ); 50 | ``` 51 | -------------------------------------------------------------------------------- /api/Google4TbSync/implementation.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 | */ 6 | 7 | "use strict"; 8 | 9 | // Using a closure to not leak anything but the API to the outside world. 10 | (function (exports) { 11 | 12 | const { ExtensionParent } = ChromeUtils.importESModule( 13 | "resource://gre/modules/ExtensionParent.sys.mjs" 14 | ); 15 | 16 | async function observeTbSyncInitialized(aSubject, aTopic, aData) { 17 | try { 18 | const tbsyncExtension = ExtensionParent.GlobalManager.getExtension( 19 | "tbsync@jobisoft.de" 20 | ); 21 | const { TbSync } = ChromeUtils.importESModule( 22 | `chrome://tbsync/content/tbsync.sys.mjs?${tbsyncExtension.manifest.version}` 23 | ); 24 | // Load this provider add-on into TbSync 25 | if (TbSync.enabled) { 26 | const googleExtension = ExtensionParent.GlobalManager.getExtension( 27 | "google-4-tbsync@marcozanon.com" 28 | ); 29 | console.log(`Registering GOOGLE provider v${googleExtension.manifest.version} with TbSync v${tbsyncExtension.manifest.version}`); 30 | await TbSync.providers.loadProvider(googleExtension, "google", "chrome://google-4-tbsync/content/provider.js"); 31 | } 32 | } catch (e) { 33 | // If this fails, TbSync is not loaded yet and we will get the notification later again. 34 | } 35 | 36 | } 37 | 38 | var Google4TbSync = class extends ExtensionCommon.ExtensionAPI { 39 | 40 | getAPI(context) { 41 | return { 42 | Google4TbSync: { 43 | async load() { 44 | Services.obs.addObserver(observeTbSyncInitialized, "tbsync.observer.initialized", false); 45 | 46 | // Did we miss the observer? 47 | observeTbSyncInitialized(); 48 | } 49 | }, 50 | }; 51 | } 52 | 53 | onShutdown(isAppShutdown) { 54 | if (isAppShutdown) { 55 | return; // the application gets unloaded anyway 56 | } 57 | 58 | Services.obs.removeObserver(observeTbSyncInitialized, "tbsync.observer.initialized"); 59 | //unload this provider add-on from TbSync 60 | try { 61 | const tbsyncExtension = ExtensionParent.GlobalManager.getExtension( 62 | "tbsync@jobisoft.de" 63 | ); 64 | const { TbSync } = ChromeUtils.importESModule( 65 | `chrome://tbsync/content/tbsync.sys.mjs?${tbsyncExtension.manifest.version}` 66 | ); 67 | TbSync.providers.unloadProvider("google"); 68 | } catch (e) { 69 | //if this fails, TbSync has been unloaded already and has unloaded this addon as well 70 | } 71 | } 72 | }; 73 | exports.Google4TbSync = Google4TbSync; 74 | })(this); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Google-4-TbSync 2 | 3 | This provider add-on adds Google synchronization capabilities to [TbSync](https://github.com/jobisoft/TbSync). 4 | 5 | Only contacts and contact groups are currently managed, using Google's People API. There's currently no plan on supporting calendars. Please see [FAQ](https://github.com/zanonmark/Google-4-TbSync/wiki/FAQ-(Frequently-Asked-Questions)) for details. 6 | 7 | The work is partly based on [EteSync4TbSync](https://github.com/etesync/EteSync-4-TbSync), [DAV4TbSync](https://github.com/jobisoft/DAV-4-TbSync), [gContactSync](https://github.com/jdgeenen/gcontactsync) and many advices by [John Bieling](https://github.com/jobisoft) himself. 8 | 9 | ## Current status and roadmap / Known limitations 10 | 11 | What already works: 12 | * Google-to-Thunderbird creation / update / deletion of contacts; 13 | * Google-to-Thunderbird creation / update / deletion of contact groups; 14 | * Google-to-Thunderbird creation / update / deletion of contact group members. 15 | * Thunderbird-to-Google creation / update / deletion of contacts; 16 | * Thunderbird-to-Google creation / update / deletion of contact groups; 17 | 18 | What is missing: 19 | * Thunderbird-to-Google creation / update / deletion of contact group members. Please note that for this to be fixed the undergoing port of TbSync to WebExtension must be completed first: only then this add-on will be partially rewritten and will be able to fully manage contact group memberships. 20 | 21 | A full working version could probably be ready by mid 2025. 22 | 23 | **Thunderbird 102+ users please note**. Google-4-TbSync 0.4.x runs much slower than 0.3.x (in my tests it performs 7x slower!). This is a known issue, please see [FAQ](https://github.com/zanonmark/Google-4-TbSync/wiki/FAQ-(Frequently-Asked-Questions)) for details. Upgrading to 0.5.x will greatly improve things, especially when updating an addressbook. 24 | 25 | ## How to use it 26 | 27 | You first need to [install TbSync](https://addons.thunderbird.net/addon/tbsync) and [generate your own Google Cloud Console project credentials](https://github.com/zanonmark/Google-4-TbSync/wiki/How-to-generate-your-own-Google-Cloud-Console-project-credentials). Then do one of the following: 28 | 29 | ### Download an official release 30 | 31 | .xpi packages can be downloaded from [Thunderbird Add-ons](https://addons.thunderbird.net/addon/google-4-tbsync), or through the _Thunderbird_ > _Tools_ > _Add-ons_ menu. 32 | 33 | ### Test the latest code 34 | 35 | 1. [Grab the latest .zip package](https://github.com/zanonmark/Google-4-TbSync/archive/refs/heads/main.zip). 36 | 2. Unzip it wherever you want. 37 | 3. Load it as a temporary add-on from _Thunderbird_ > _Tools_ > _Add-ons_ > cog icon > _Debug Add-ons_ > _Load Temporary Add-on_ (pick _manifest.json_ for example). 38 | 4. Test it, preferably using the _Read-only mode_ option (see below). 39 | 40 | ## Warning 41 | 42 | * Even if early reports seem to confirm the add-on is working properly, the project is still in its early development stage: **do regular backups of both your Google and Thunderbird address books!** 43 | * **You are strongly suggested to use the [_Read-only mode_ option](https://github.com/zanonmark/Google-4-TbSync/wiki/Account-options#read-only-mode)**. 44 | 45 | ## Additional information 46 | 47 | Please refer to the [wiki section](https://github.com/zanonmark/Google-4-TbSync/wiki) for other useful information, including [FAQ](https://github.com/zanonmark/Google-4-TbSync/wiki/FAQ-(Frequently-Asked-Questions)), guides and user contributions. 48 | -------------------------------------------------------------------------------- /api/LegacyHelper/implementation.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is provided by the webext-support repository at 3 | * https://github.com/thunderbird/webext-support 4 | * 5 | * Version 1.1 6 | * - registerGlobalUrls() is now async, to be able to properly await registration 7 | * 8 | * Version 1.0 9 | * - initial release 10 | * 11 | * Author: 12 | * - John Bieling (john@thunderbird.net) 13 | * 14 | * This Source Code Form is subject to the terms of the Mozilla Public 15 | * License, v. 2.0. If a copy of the MPL was not distributed with this 16 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 17 | */ 18 | 19 | "use strict"; 20 | 21 | // Using a closure to not leak anything but the API to the outside world. 22 | (function (exports) { 23 | 24 | const aomStartup = Cc[ 25 | "@mozilla.org/addons/addon-manager-startup;1" 26 | ].getService(Ci.amIAddonManagerStartup); 27 | const resProto = Cc[ 28 | "@mozilla.org/network/protocol;1?name=resource" 29 | ].getService(Ci.nsISubstitutingProtocolHandler); 30 | 31 | const chromeHandlers = []; 32 | const resourceUrls = []; 33 | 34 | var LegacyHelper = class extends ExtensionCommon.ExtensionAPI { 35 | getAPI(context) { 36 | return { 37 | LegacyHelper: { 38 | registerGlobalUrls(data) { 39 | const manifestURI = Services.io.newURI( 40 | "manifest.json", 41 | null, 42 | context.extension.rootURI 43 | ); 44 | 45 | for (let entry of data) { 46 | // [ "resource", "shortname" , "path" ] 47 | 48 | switch (entry[0]) { 49 | case "resource": 50 | { 51 | let uri = Services.io.newURI( 52 | entry[2], 53 | null, 54 | context.extension.rootURI 55 | ); 56 | resProto.setSubstitutionWithFlags( 57 | entry[1], 58 | uri, 59 | resProto.ALLOW_CONTENT_ACCESS 60 | ); 61 | resourceUrls.push(entry[1]); 62 | } 63 | break; 64 | 65 | case "content": 66 | case "locale": 67 | { 68 | let handle = aomStartup.registerChrome( 69 | manifestURI, 70 | [entry] 71 | ); 72 | chromeHandlers.push(handle); 73 | } 74 | break; 75 | 76 | default: 77 | console.warn(`LegacyHelper: Unsupported url type: ${entry[0]}`) 78 | } 79 | } 80 | }, 81 | 82 | openDialog(name, path) { 83 | let window = Services.wm.getMostRecentWindow("mail:3pane"); 84 | window.openDialog( 85 | path, 86 | name, 87 | "chrome,resizable,centerscreen" 88 | ); 89 | }, 90 | }, 91 | }; 92 | } 93 | 94 | onShutdown(isAppShutdown) { 95 | if (isAppShutdown) { 96 | return; // the application gets unloaded anyway 97 | } 98 | 99 | for (let chromeHandler of chromeHandlers) { 100 | if (chromeHandler) { 101 | chromeHandler.destruct(); 102 | chromeHandler = null; 103 | } 104 | } 105 | 106 | for (let resourceUrl of resourceUrls) { 107 | resProto.setSubstitution( 108 | resourceUrl, 109 | null 110 | ); 111 | } 112 | 113 | // Flush all caches. 114 | Services.obs.notifyObservers(null, "startupcache-invalidate"); 115 | } 116 | }; 117 | exports.LegacyHelper = LegacyHelper; 118 | })(this); -------------------------------------------------------------------------------- /content/manager/editAccountOverlay.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Google-4-TbSync. 3 | * See CONTRIBUTORS.md for details. 4 | * 5 | * This Source Code Form is subject to the terms of the Mozilla Public 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | */ 9 | 10 | "use strict"; 11 | var { ExtensionParent } = ChromeUtils.importESModule( 12 | "resource://gre/modules/ExtensionParent.sys.mjs" 13 | ); 14 | var tbsyncExtension = ExtensionParent.GlobalManager.getExtension( 15 | "tbsync@jobisoft.de" 16 | ); 17 | var { TbSync } = ChromeUtils.importESModule( 18 | `chrome://tbsync/content/tbsync.sys.mjs?${tbsyncExtension.manifest.version}` 19 | ); 20 | const google = TbSync.providers.google; 21 | 22 | var tbSyncEditAccountOverlay = { 23 | 24 | accountNameWidget: null, 25 | clientIDWidget: null, 26 | clientSecretWidget: null, 27 | includeSystemContactGroupsWidget: null, 28 | useFakeEmailAddressesWidget: null, 29 | readOnlyModeWidget: null, 30 | verboseLoggingWidget: null, 31 | /* 32 | checkConnectionWidget: null, 33 | */ 34 | 35 | onload: function(window, accountData) { 36 | this.accountData = accountData; 37 | // 38 | this.accountNameWidget = document.getElementById("tbsync.accountsettings.pref.accountname"); 39 | this.clientIDWidget = document.getElementById("tbsync.accountsettings.pref.clientID"); 40 | this.clientSecretWidget = document.getElementById("tbsync.accountsettings.pref.clientSecret"); 41 | this.includeSystemContactGroupsWidget = document.getElementById('tbsync.accountsettings.pref.includeSystemContactGroups'); 42 | this.useFakeEmailAddressesWidget = document.getElementById('tbsync.accountsettings.pref.useFakeEmailAddresses'); 43 | this.readOnlyModeWidget = document.getElementById('tbsync.accountsettings.pref.readOnlyMode'); 44 | this.verboseLoggingWidget = document.getElementById('tbsync.accountsettings.pref.verboseLogging'); 45 | // 46 | this.accountNameWidget.value = this.accountData.getAccountProperty("accountname"); 47 | this.clientIDWidget.value = this.accountData.getAccountProperty("clientID"); 48 | this.clientSecretWidget.value = this.accountData.getAccountProperty("clientSecret"); 49 | this.includeSystemContactGroupsWidget.checked = this.accountData.getAccountProperty("includeSystemContactGroups"); 50 | this.useFakeEmailAddressesWidget.checked = this.accountData.getAccountProperty("useFakeEmailAddresses"); 51 | this.readOnlyModeWidget.checked = this.accountData.getAccountProperty("readOnlyMode"); 52 | this.verboseLoggingWidget.checked = this.accountData.getAccountProperty("verboseLogging"); 53 | }, 54 | 55 | updateAccountProperty: function(accountProperty) { 56 | switch (accountProperty) { 57 | case "accountName": 58 | this.accountData.setAccountProperty("accountname", this.accountNameWidget.value); 59 | break; 60 | case "clientID": 61 | this.accountData.setAccountProperty("clientID", this.clientIDWidget.value); 62 | break; 63 | case "clientSecret": 64 | this.accountData.setAccountProperty("clientSecret", this.clientSecretWidget.value); 65 | break; 66 | case "includeSystemContactGroups": 67 | this.accountData.setAccountProperty("includeSystemContactGroups", this.includeSystemContactGroupsWidget.checked); 68 | break; 69 | case "useFakeEmailAddresses": 70 | this.accountData.setAccountProperty("useFakeEmailAddresses", this.useFakeEmailAddressesWidget.checked); 71 | break; 72 | case "readOnlyMode": 73 | this.accountData.setAccountProperty("readOnlyMode", this.readOnlyModeWidget.checked); 74 | break; 75 | case "verboseLogging": 76 | this.accountData.setAccountProperty("verboseLogging", this.verboseLoggingWidget.checked); 77 | break; 78 | default: 79 | break; 80 | } 81 | }, 82 | 83 | onCheckConnection: function() { 84 | let accountData = this.accountData; 85 | // 86 | let peopleAPI = new PeopleAPI(accountData); 87 | // 88 | peopleAPI.checkConnection(); 89 | }, 90 | 91 | }; 92 | -------------------------------------------------------------------------------- /content/manager/createAccount.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Google-4-TbSync. 3 | * See CONTRIBUTORS.md for details. 4 | * 5 | * This Source Code Form is subject to the terms of the Mozilla Public 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | */ 9 | 10 | "use strict"; 11 | 12 | var { ExtensionParent } = ChromeUtils.importESModule( 13 | "resource://gre/modules/ExtensionParent.sys.mjs" 14 | ); 15 | var tbsyncExtension = ExtensionParent.GlobalManager.getExtension( 16 | "tbsync@jobisoft.de" 17 | ); 18 | var { TbSync } = ChromeUtils.importESModule( 19 | `chrome://tbsync/content/tbsync.sys.mjs?${tbsyncExtension.manifest.version}` 20 | ); 21 | const google = TbSync.providers.google; 22 | 23 | var tbSyncNewAccount = { 24 | 25 | accountNameWidget: null, 26 | clientIDWidget: null, 27 | clientSecretWidget: null, 28 | includeSystemContactGroupsWidget: null, 29 | useFakeEmailAddressesWidget: null, 30 | readOnlyModeWidget: null, 31 | verboseLoggingWidget: null, 32 | 33 | onLoad: function () { 34 | this.providerData = new TbSync.ProviderData("google"); 35 | // 36 | document.getElementById('tbsync.newaccount.wizard')._adjustWizardHeader(); // https://bugzilla.mozilla.org/show_bug.cgi?id=1618252 37 | document.getElementById("firstPage").label = TbSync.getString("__GOOGLE4TBSYNCMSG_add.account.title__", "google"); 38 | // 39 | this.accountNameWidget = document.getElementById("tbsync.newaccount.accountName"); 40 | this.clientIDWidget = document.getElementById("tbsync.newaccount.clientID"); 41 | this.clientSecretWidget = document.getElementById("tbsync.newaccount.clientSecret"); 42 | this.includeSystemContactGroupsWidget = document.getElementById('tbsync.newaccount.includeSystemContactGroups'); 43 | this.useFakeEmailAddressesWidget = document.getElementById('tbsync.newaccount.useFakeEmailAddresses'); 44 | this.readOnlyModeWidget = document.getElementById('tbsync.newaccount.readOnlyMode'); 45 | this.verboseLoggingWidget = document.getElementById('tbsync.newaccount.verboseLogging'); 46 | // 47 | this.accountNameWidget.value = ""; 48 | this.clientIDWidget.value = ""; 49 | this.clientSecretWidget.value = ""; 50 | this.includeSystemContactGroupsWidget.checked = false; 51 | this.useFakeEmailAddressesWidget.checked = false; 52 | this.readOnlyModeWidget.checked = true; 53 | this.verboseLoggingWidget.checked = false; 54 | // 55 | document.getElementById("tbsync.newaccount.wizard").canRewind = false; 56 | document.getElementById("tbsync.newaccount.wizard").canAdvance = false; 57 | // 58 | this.accountNameWidget.focus(); 59 | // 60 | document.addEventListener("wizardfinish", tbSyncNewAccount.onFinish.bind(this)); 61 | }, 62 | 63 | onUnload: function () { 64 | }, 65 | 66 | onClose: function () { 67 | return true; 68 | }, 69 | 70 | onUserTextInput: function () { 71 | document.getElementById("tbsync.newaccount.wizard").canAdvance = (("" !== this.accountNameWidget.value.trim()) && ("" !== this.clientIDWidget.value.trim()) && ("" !== this.clientSecretWidget.value.trim())); 72 | }, 73 | 74 | onFinish: function (event) { 75 | let accountName = this.accountNameWidget.value.trim(); 76 | let clientID = this.clientIDWidget.value.trim(); 77 | let clientSecret = this.clientSecretWidget.value.trim(); 78 | let includeSystemContactGroups = this.includeSystemContactGroupsWidget.checked; 79 | let useFakeEmailAddresses = this.useFakeEmailAddressesWidget.checked; 80 | let readOnlyMode = this.readOnlyModeWidget.checked; 81 | let verboseLogging = this.verboseLoggingWidget.checked; 82 | // 83 | tbSyncNewAccount.addAccount(accountName, clientID, clientSecret, includeSystemContactGroups, useFakeEmailAddresses, readOnlyMode, verboseLogging); 84 | }, 85 | 86 | addAccount: function (accountName, clientID, clientSecret, includeSystemContactGroups, useFakeEmailAddresses, readOnlyMode, verboseLogging) { 87 | // Retrieve a new object with default values. 88 | let newAccountEntry = this.providerData.getDefaultAccountEntries(); 89 | // Override the default values. 90 | newAccountEntry.clientID = clientID; 91 | newAccountEntry.clientSecret = clientSecret; 92 | newAccountEntry.includeSystemContactGroups = includeSystemContactGroups; 93 | newAccountEntry.useFakeEmailAddresses = useFakeEmailAddresses; 94 | newAccountEntry.readOnlyMode = readOnlyMode; 95 | newAccountEntry.verboseLogging = verboseLogging; 96 | // Add the new account. 97 | let newAccountData = this.providerData.addAccount(accountName, newAccountEntry); 98 | // Close the window. 99 | window.close(); 100 | }, 101 | 102 | }; 103 | -------------------------------------------------------------------------------- /content/manager/createAccount.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |