From 591f82dacdce10d90ca52603eb85db90367c1e1c Mon Sep 17 00:00:00 2001 From: Philipp Kewisch Date: Mon, 21 Oct 2019 13:47:14 +0200 Subject: [PATCH 1/2] WiP - WebExtension Version --- client/thunderbird-filelink-dl/.eslintrc | 473 ++++++++++++++++++ client/thunderbird-filelink-dl/.gitignore | 1 - .../_locales/en/messages.json | 20 + .../background/background.js | 124 +++++ client/thunderbird-filelink-dl/build.sh | 128 ----- .../thunderbird-filelink-dl/chrome.manifest | 12 - .../chrome/content/compose.js | 85 ---- .../chrome/content/compose.xul | 20 - .../chrome/content/management.js | 77 --- .../chrome/content/management.xhtml | 73 --- .../chrome/content/settings.js | 7 - .../chrome/content/settings.xhtml | 22 - .../chrome/locale/en-US/compose.dtd | 1 - .../chrome/locale/en-US/compose.properties | 4 - .../chrome/locale/en-US/management.dtd | 5 - .../chrome/locale/en-US/settings.dtd | 3 - .../chrome/locale/hu/compose.dtd | 1 - .../chrome/locale/hu/compose.properties | 4 - .../chrome/locale/hu/management.dtd | 5 - .../chrome/locale/hu/settings.dtd | 3 - .../chrome/skin/compose.css | 4 - .../components/nsDL.idl | 9 - .../components/nsDL.js | 393 --------------- .../thunderbird-filelink-dl/config_build.sh | 11 - .../content/management.css | 9 + .../content/management.js | 76 +++ .../{chrome/skin => images}/dl-icon.png | Bin .../thunderbird-filelink-dl/images/logo.svg | 13 + client/thunderbird-filelink-dl/install.rdf | 37 -- client/thunderbird-filelink-dl/manifest.json | 34 ++ 30 files changed, 749 insertions(+), 905 deletions(-) create mode 100644 client/thunderbird-filelink-dl/.eslintrc create mode 100644 client/thunderbird-filelink-dl/_locales/en/messages.json create mode 100644 client/thunderbird-filelink-dl/background/background.js delete mode 100755 client/thunderbird-filelink-dl/build.sh delete mode 100644 client/thunderbird-filelink-dl/chrome.manifest delete mode 100644 client/thunderbird-filelink-dl/chrome/content/compose.js delete mode 100644 client/thunderbird-filelink-dl/chrome/content/compose.xul delete mode 100644 client/thunderbird-filelink-dl/chrome/content/management.js delete mode 100644 client/thunderbird-filelink-dl/chrome/content/management.xhtml delete mode 100644 client/thunderbird-filelink-dl/chrome/content/settings.js delete mode 100644 client/thunderbird-filelink-dl/chrome/content/settings.xhtml delete mode 100644 client/thunderbird-filelink-dl/chrome/locale/en-US/compose.dtd delete mode 100644 client/thunderbird-filelink-dl/chrome/locale/en-US/compose.properties delete mode 100644 client/thunderbird-filelink-dl/chrome/locale/en-US/management.dtd delete mode 100644 client/thunderbird-filelink-dl/chrome/locale/en-US/settings.dtd delete mode 100644 client/thunderbird-filelink-dl/chrome/locale/hu/compose.dtd delete mode 100644 client/thunderbird-filelink-dl/chrome/locale/hu/compose.properties delete mode 100644 client/thunderbird-filelink-dl/chrome/locale/hu/management.dtd delete mode 100644 client/thunderbird-filelink-dl/chrome/locale/hu/settings.dtd delete mode 100644 client/thunderbird-filelink-dl/chrome/skin/compose.css delete mode 100644 client/thunderbird-filelink-dl/components/nsDL.idl delete mode 100644 client/thunderbird-filelink-dl/components/nsDL.js delete mode 100644 client/thunderbird-filelink-dl/config_build.sh create mode 100644 client/thunderbird-filelink-dl/content/management.css create mode 100644 client/thunderbird-filelink-dl/content/management.js rename client/thunderbird-filelink-dl/{chrome/skin => images}/dl-icon.png (100%) create mode 100644 client/thunderbird-filelink-dl/images/logo.svg delete mode 100644 client/thunderbird-filelink-dl/install.rdf create mode 100644 client/thunderbird-filelink-dl/manifest.json diff --git a/client/thunderbird-filelink-dl/.eslintrc b/client/thunderbird-filelink-dl/.eslintrc new file mode 100644 index 0000000..35998c1 --- /dev/null +++ b/client/thunderbird-filelink-dl/.eslintrc @@ -0,0 +1,473 @@ +{ + "env": { + "es6": true, + "webextensions": true + }, + "parserOptions": { + "ecmaVersion": 11 + }, + "globals": { + "self": true, + "messenger": true + }, + "rules": { + // Enforce one true brace style (opening brace on the same line) + // Allow single line (for now) because of the vast number of changes needed + "brace-style": [2, "1tbs", {"allowSingleLine": true}], + + // Enforce newline at the end of file, with no multiple empty lines. + "eol-last": 2, + + // Disallow using variables outside the blocks they are defined + "block-scoped-var": 2, + + // Allow trailing commas for easy list extension. Having them does not + // impair readability, but also not required either. + "comma-dangle": 0, + + // Enforce spacing before and after comma + "comma-spacing": [2, {"before": false, "after": true}], + + // Enforce one true comma style. + "comma-style": [2, "last"], + + // Enforce curly brace conventions for all control statements. + "curly": 2, + + // Enforce the spacing around the * in generator functions. + "generator-star-spacing": [2, "after"], + + // Require space before/after arrow function's arrow + "arrow-spacing": [2, { "before": true, "after": true }], + + // Enforces spacing between keys and values in object literal properties. + "key-spacing": [2, {"beforeColon": false, "afterColon": true, "mode": "minimum"}], + + // Disallow the omission of parentheses when invoking a constructor with no + // arguments. + "new-parens": 2, + + // Disallow use of the Array constructor. + "no-array-constructor": 2, + + // disallow use of the Object constructor + "no-new-object": 2, + + // Disallow Primitive Wrapper Instances + "no-new-wrappers": 2, + + // Disallow the catch clause parameter name being the same as a variable in + // the outer scope, to avoid confusion. + "no-catch-shadow": 2, + + // Disallow assignment in conditional expressions. + "no-cond-assign": 2, + + // Disallow use of debugger. + "no-debugger": 2, + + // Disallow deletion of variables (deleting properties is fine). + "no-delete-var": 2, + + // Disallow duplicate arguments in functions. + "no-dupe-args": 2, + + // Disallow duplicate keys when creating object literals. + "no-dupe-keys": 2, + + // Disallow a duplicate case label. + "no-duplicate-case": 2, + + // Disallow the use of empty character classes in regular expressions. + "no-empty-character-class": 2, + + // Disallow assigning to the exception in a catch block. + "no-ex-assign": 2, + + // Disallow adding to native types + "no-extend-native": 2, + + // Disallow double-negation boolean casts in a boolean context. + "no-extra-boolean-cast": 2, + + // Disallow unnecessary semicolons. + "no-extra-semi": 2, + + // Disallow mixed spaces and tabs for indentation. + "no-mixed-spaces-and-tabs": 2, + + // Disallow reassignments of native objects. + "no-native-reassign": 2, + + // Disallow use of octal literals. + "no-octal": 2, + + // Disallow comparisons where both sides are exactly the same. + "no-self-compare": 2, + + // Disallow sparse arrays, eg. let arr = [,,2]. + // Array destructuring is fine though: + // for (let [, breakpointPromise] of aPromises) + "no-sparse-arrays": 2, + + // Disallow trailing whitespace at the end of lines. + "no-trailing-spaces": 2, + + // Disallow use of the with statement. + "no-with": 2, + + // Disallow comparisons with the value NaN. + "use-isnan": 2, + + // Ensure that the results of typeof are compared against a valid string. + "valid-typeof": 2, + + // disallow the use of object properties of the global object (Math and + // JSON) as functions + "no-obj-calls": 2, + + // disallow use of octal escape sequences in string literals, such as + // var foo = "Copyright \251"; + "no-octal-escape": 2, + + // disallow use of void operator + "no-void": 2, + + // Disallow Yoda conditions (where literal value comes first). + "yoda": 2, + + // Require a space immediately following the // in a line comment. + "spaced-comment": [2, "always"], + + // Require use of the second argument for parseInt(). + "radix": 2, + + // Require spaces before/after unary operators (words on by default, + // nonwords off by default). + "space-unary-ops": [2, { "words": true, "nonwords": false }], + + // Enforce spacing after semicolons. + "semi-spacing": [2, {"before": false, "after": true}], + + // Disallow the use of Boolean literals in conditional expressions. + "no-unneeded-ternary": 2, + + // Disallow use of multiple spaces (sometimes used to align const values, + // array or object items, etc.). It's hard to maintain and doesn't add that + // much benefit. + "no-multi-spaces": 2, + + // Require spaces around operators, except for a|0. + // Disabled for now given eslint doesn't support default args yet + // "space-infix-ops": [2, {"int32Hint": true}], + + // Require a space around all keywords. + "keyword-spacing": 2, + + // Disallow space between function identifier and application. + "no-spaced-func": 2, + + // Disallow shadowing of names such as arguments. + "no-shadow-restricted-names": 2, + + // Disallow use of comma operator. + "no-sequences": 2, + + // Disallow use of assignment in return statement. It is preferable for a + // single line of code to have only one easily predictable effect. + "no-return-assign": 2, + + // Require return statements to either always or never specify values + "consistent-return": 2, + + // Disallow padding within blocks. + "padded-blocks": [2, "never"], + + // Disallow spaces inside parentheses. + "space-in-parens": [2, "never"], + + // Require space after keyword for anonymous functions, but disallow space + // after name of named functions. + "space-before-function-paren": [2, {"anonymous": "never", "named": "never"}], + + // Disallow unreachable statements after a return, throw, continue, or break + // statement. + "no-unreachable": 2, + + // Always require use of semicolons wherever they are valid. + "semi": [2, "always"], + + // Disallow empty statements. This will report an error for: + // try { something(); } catch (e) {} + // but will not report it for: + // try { something(); } catch (e) { /* Silencing the error because ...*/ } + // which is a valid use case. + "no-empty": 2, + + // Disallow declaring the same variable more than once (we use let anyway). + "no-redeclare": 2, + + // Warn about declaration of variables already declared in the outer scope. + // This isn't an error because it sometimes is useful to use the same name + // in a small helper function rather than having to come up with another + // random name. Still, making this a warning can help people avoid being + // confused. + "no-shadow": 2, + + // We use var-only-at-top-level instead of no-var as we allow top level + // vars. + "no-var": 0, + + // Disallow global and local variables that aren't used, but allow unused function arguments. + "no-unused-vars": [2, {"vars": "all", "args": "none", "varsIgnorePattern": "EXPORTED_SYMBOLS|rest"}], + + // Require padding inside curly braces + "object-curly-spacing": [2, "always"], + + // Disallow spaces inside of brackets + "array-bracket-spacing": [2, "never"], + + // Disallow control characters in regular expressions + "no-control-regex": 2, + + // Disallow invalid regular expression strings in RegExp constructors + "no-invalid-regexp": 2, + + // Disallow multiple spaces in regular expression literals + "no-regex-spaces": 2, + + // Disallow irregular whitespace + "no-irregular-whitespace": 2, + + // Disallow negating the left operand in `in` expressions + "no-negated-in-lhs": 2, + + // Allow constant expressions in conditions + // With 2.11.0 we can enable this with checkLoops: false + "no-constant-condition": [2, {"checkLoops": false}], + + // Disallow Regexs That Look Like Division + "no-div-regex": 2, + + // Disallow Iterator (using __iterator__) + "no-iterator": 2, + + // Enforce consistent linebreak style + "linebreak-style": [2, "unix"], + + // Enforces return statements in callbacks of array's methods + "array-callback-return": 2, + + // Verify super() calls in constructors + "constructor-super": 2, + + // Disallow modifying variables of class declarations + "no-class-assign": 2, + + // Disallow modifying variables that are declared using const + "no-const-assign": 2, + + // Disallow duplicate name in class members + "no-dupe-class-members": 2, + + // Disallow use of this/super before calling super() in constructors + "no-this-before-super": 2, + + // Disallow duplicate imports + "no-duplicate-imports": 2, + + // Disallow empty destructuring patterns + "no-empty-pattern": 2, + + // Disallow Labeled Statements + "no-labels": 2, + + // Disallow Multiline Strings + "no-multi-str": 2, + + // Disallow Symbol Constructor + "no-new-symbol": 2, + + // Disallow Initializing to undefined + "no-undef-init": 2, + + // Disallow control flow statements in finally blocks + "no-unsafe-finally": 2, + + // Disallow Unused Labels + "no-unused-labels": 2, + + // Disallow unnecessary computed property keys on objects + "no-useless-computed-key": 2, + + // Disallow unnecessary constructor + "no-useless-constructor": 2, + + // Disallow renaming import, export, and destructured assignments to the + // same name + "no-useless-rename": 2, + + // Enforce spacing between rest and spread operators and their expressions + "rest-spread-spacing": [2, "never"], + + // Disallow usage of spacing in template string expressions + "template-curly-spacing": [2, "never"], + + // Disallow the Unicode Byte Order Mark + "unicode-bom": [2, "never"], + + // Enforce spacing around the * in yield* expressions + "yield-star-spacing": [2, "after"], + + // Disallow Implied eval + "no-implied-eval": 2, + + // Disallow unnecessary function binding + "no-extra-bind": 2, + + // Disallow new For Side Effects + "no-new": 2, + + // Disallow Self Assignment + "no-self-assign": 2, + + // Disallow confusing multiline expressions + "no-unexpected-multiline": 2, + + // Require IIFEs to be Wrapped + "wrap-iife": [2, "inside"], + + // Disallow Unused Expressions + "no-unused-expressions": 2, + + // Disallow function or var declarations in nested blocks + "no-inner-declarations": 2, + + // Enforce newline before and after dot + "dot-location": [2, "property"], + + // Disallow Use of caller/callee + "no-caller": 2, + + // Disallow Case Statement Fallthrough + "no-fallthrough": 2, + + // Disallow Floating Decimals + "no-floating-decimal": 2, + + // Require Space Before Blocks + "space-before-blocks": 2, + + // Operators always before the line break + "operator-linebreak": [2, "after", { "overrides": { ":": "before", "?": "ignore"}}], + + // Restricts the use of parentheses to only where they are necessary + // Disabled for now since this also removes parens around assignments, e.g. let foo = bar == baz + // "no-extra-parens": [2, "all", { "conditionalAssign": false, "returnAssign": false, "nestedBinaryExpressions": false }], + + // Double quotes should be used. + "quotes": [2, "double", { "avoidEscape": true }], + + // Disallow if as the only statement in an else block. + "no-lonely-if": 2, + + // Not more than two empty lines with in the file, and no extra lines at + // beginning or end of file. + "no-multiple-empty-lines": [2, { "max": 2, "maxEOF": 0, "maxBOF": 0 }], + + // Make sure all setters have a corresponding getter + "accessor-pairs": 2, + + // Enforce spaces inside of single line blocks + "block-spacing": [2, "always"], + + // Disallow spaces inside of computed properties + "computed-property-spacing": [2, "never"], + + // Require consistent this (using |self|) + "consistent-this": [2, "self"], + + // Disallow unnecessary .call() and .apply() + "no-useless-call": 2, + + // Disallow named function expressions + "func-names": [2, "never"], + + // Enforce placing object properties on separate lines + "object-property-newline": [2, { "allowMultiplePropertiesPerLine": true }], + + // Enforce consistent line breaks inside braces + "object-curly-newline": [2, { "multiline": true }], + + // Disallow whitespace before properties + "no-whitespace-before-property": 2, + + // Disallow unnecessary escape usage + "no-useless-escape": 2, + + // Disallow mixes of different operators, but allow simple math operations. + "no-mixed-operators": [2, { + "groups": [ + /* ["+", "-", "*", "/", "%", "**"], */ + ["&", "|", "^", "~", "<<", ">>", ">>>"], + ["==", "!=", "===", "!==", ">", ">=", "<", "<="], + ["&&", "||"], + ["in", "instanceof"] + ] + }], + + // Disallow unnecessary concatenation of strings + "no-useless-concat": 2, + + // Disallow unmodified conditions of loops + "no-unmodified-loop-condition": 2, + + // Suggest using arrow functions as callbacks + "prefer-arrow-callback": [2, { "allowNamedFunctions": true }], + + // Suggest using the spread operator instead of .apply() + "prefer-spread": 2, + + // Quoting style for property names + "quote-props": ["error", "consistent-as-needed", { "keywords": true }], + + // Disallow negated conditions + "no-negated-condition": 2, + + // Enforce a maximum number of statements allowed per line + "max-statements-per-line": [2, { "max": 2 }], + + // Disallow arrow functions where they could be confused with comparisons + "no-confusing-arrow": 2, + + // Disallow Unnecessary Nested Blocks + "no-lone-blocks": 2, + + // Enforce minimum identifier length + "id-length": [2, { + "min": 3, + "exceptions": [ + /* jQuery */ "$", + /* sorting */ "a", "b", + /* exceptions */ "e", "ex", + /* loop indices */ "i", "j", "k", "n", + /* coordinates */ "x", "y", + /* regexes */ "re", + /* known words */ "rc", "rv", "id", "OS", "os", "db", "op", + /* known html elements */ "tr", "td", "th", + /* mail/calendar words */ "to", "cc", + /* Components */ "Ci", "Cc", "Cu", "Cr", + ] + }], + + // Disallow lexical declarations in case/default clauses + "no-case-declarations": 2, + + // Enforce consistent indentation (4-space) + "indent": [2, 2, { "SwitchCase": 1 }], + + // The following rules will not be enabled currently, but are kept here for + // easier updates in the future. + "no-else-return": 0, + } +} diff --git a/client/thunderbird-filelink-dl/.gitignore b/client/thunderbird-filelink-dl/.gitignore index 94cf0f7..15af1aa 100644 --- a/client/thunderbird-filelink-dl/.gitignore +++ b/client/thunderbird-filelink-dl/.gitignore @@ -1,2 +1 @@ *.xpi -*.xpt diff --git a/client/thunderbird-filelink-dl/_locales/en/messages.json b/client/thunderbird-filelink-dl/_locales/en/messages.json new file mode 100644 index 0000000..f3329fa --- /dev/null +++ b/client/thunderbird-filelink-dl/_locales/en/messages.json @@ -0,0 +1,20 @@ +{ + "extensionDescription": { + "message": "Convert large attachments to links automatically, directly within the Composer window, using your own “DL” server/service instead of relying on 3rd-party providers" + }, + "extensionName": { + "message": "DL FileLink Provider for Thunderbird" + }, + "serviceName": { + "message": "DL" + }, + "serviceURL": { + "message": "Service URL" + }, + "username": { + "message": "Username" + }, + "password": { + "message": "Password" + } +} diff --git a/client/thunderbird-filelink-dl/background/background.js b/client/thunderbird-filelink-dl/background/background.js new file mode 100644 index 0000000..7c5296f --- /dev/null +++ b/client/thunderbird-filelink-dl/background/background.js @@ -0,0 +1,124 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Portions Copyright (C) Philipp Kewisch, 2019 */ + +var abortControllers = new Map(); +var tickets = new Map(); + +async function accountPrefs(accountId) { + let { + [`accounts.${accountId}.restURL`]: restURL, + [`accounts.${accountId}.username`]: username, + [`accounts.${accountId}.password`]: password + } = await messenger.storage.local.get([ + `accounts.${accountId}.restURL`, + `accounts.${accountId}.username`, + `accounts.${accountId}.password`, + ]); + + return { restURL, username, password }; +} + +async function updateAccount(account) { + let resp = await request({ + account: account, + method: "GET", + url: "info", + }); + + let prefs = await accountPrefs(account.id); + + let { maxsize } = await resp.json(); + + await messenger.cloudFile.updateAccount(account.id, { + uploadSizeLimit: maxsize, + configured: !!(prefs.restURL && prefs.username && prefs.password) + }); +} + +async function request({ account, url, formData, signal, method="POST" }) { + let prefs = await accountPrefs(account.id); + let auth = "Basic " + btoa(prefs.username + ":" + prefs.password); + + if (!formData && method == "POST") { + formData = new FormData(); + } + + if (formData && !formData.has("msg")) { + formData.append("msg", "{}"); + } + + let headers = { + "Authorization": auth, + "X-Authorization": auth, + }; + + let resp = await fetch(new URL(url, prefs.restURL).href, { + method: method, + headers: headers, + body: formData, + signal: signal + }); + + if (!resp.ok) { + let json = await resp.json(); + throw new Error(json.error); + } + + return resp; +} + + +messenger.cloudFile.onFileUpload.addListener( + async (account, { id, name, data }) => { + let controller = new AbortController(); + abortControllers.set(id, controller); + + let formData = new FormData(); + console.log(data); + formData.append("file", new Blob([data]), name); + + try { + let resp = await request({ + account: account, + url: "newticket", + formData: formData, + signal: controller.signal + }); + let json = await resp.json(); + + tickets.set(id, json.id); + + return { url: json.url }; + } finally { + abortControllers.delete(id); + } + } +); + +messenger.cloudFile.onFileUploadAbort.addListener((account, id) => { + let controller = abortControllers.get(id); + if (controller) { + controller.abort(); + abortControllers.delete(id); + } +}); + +messenger.cloudFile.onFileDeleted.addListener(async (account, id) => { + let ticketId = tickets.get(id); + if (ticketId) { + await request({ + account: account, + url: "purgeticket/" + ticketId + }); + tickets.delete(id); + } +}); + + +messenger.cloudFile.getAllAccounts().then(async accounts => { + await Promise.all(accounts.map(updateAccount)); +}); + +messenger.cloudFile.onAccountAdded.addListener(account => updateAccount(account)); diff --git a/client/thunderbird-filelink-dl/build.sh b/client/thunderbird-filelink-dl/build.sh deleted file mode 100755 index 07af23c..0000000 --- a/client/thunderbird-filelink-dl/build.sh +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/bash -# build.sh -- builds JAR and XPI files for mozilla extensions -# by Nickolay Ponomarev -# (original version based on Nathan Yergler's build script) -# Most recent version is at - -# This script assumes the following directory structure: -# ./ -# chrome.manifest (optional - for newer extensions) -# install.rdf -# (other files listed in $ROOT_FILES) -# -# content/ | -# locale/ |} these can be named arbitrary and listed in $CHROME_PROVIDERS -# skin/ | -# -# defaults/ | -# components/ |} these must be listed in $ROOT_DIRS in order to be packaged -# ... | -# -# It uses a temporary directory ./build when building; don't use that! -# Script's output is: -# ./$APP_NAME.xpi -# ./$APP_NAME.jar (only if $KEEP_JAR=1) -# ./files -- the list of packaged files -# -# Note: It modifies chrome.manifest when packaging so that it points to -# chrome/$APP_NAME.jar!/* - -# -# default configuration file is ./config_build.sh, unless another file is -# specified in command-line. Available config variables: -APP_NAME= # short-name, jar and xpi files name. Must be lowercase with no spaces -CHROME_PROVIDERS= # which chrome providers we have (space-separated list) -CLEAN_UP= # delete the jar / "files" when done? (1/0) -ROOT_FILES= # put these files in root of xpi (space separated list of leaf filenames) -ROOT_DIRS= # ...and these directories (space separated list) -BEFORE_BUILD= # run this before building (bash command) -AFTER_BUILD= # ...and this after the build (bash command) - -if [ -z $1 ]; then - . ./config_build.sh -else - . $1 -fi - -if [ -z $APP_NAME ]; then - echo "You need to create build config file first!" - echo "Read comments at the beginning of this script for more info." - exit; -fi - -ROOT_DIR=`pwd` -TMP_DIR=build - -#uncomment to debug -#set -x - -# remove any left-over files from previous build -rm -f $APP_NAME.jar $APP_NAME.xpi files -rm -rf $TMP_DIR - -$BEFORE_BUILD - -mkdir --parents --verbose $TMP_DIR/chrome - -# generate the JAR file, excluding CVS, SVN, and temporary files -JAR_FILE=$TMP_DIR/chrome/$APP_NAME.jar -echo "Generating $JAR_FILE..." -for CHROME_SUBDIR in $CHROME_PROVIDERS; do - find $CHROME_SUBDIR \( -path '*CVS*' -o -path '*.svn*' \) -prune -o -type f -print | grep -v \~ >> files -done - -zip -0 -r $JAR_FILE -@ < files -# The following statement should be used instead if you don't wish to use the JAR file -#cp --verbose --parents `cat files` $TMP_DIR/chrome - -# prepare components and defaults -echo "Copying various files to $TMP_DIR folder..." -for DIR in $ROOT_DIRS; do - mkdir $TMP_DIR/$DIR - FILES="`find $DIR \( -path '*CVS*' -o -path '*.svn*' \) -prune -o -type f -print | grep -v \~`" - echo $FILES >> files - cp --verbose --parents $FILES $TMP_DIR -done - -# Copy other files to the root of future XPI. -for ROOT_FILE in $ROOT_FILES install.rdf chrome.manifest; do - cp --verbose $ROOT_FILE $TMP_DIR - if [ -f $ROOT_FILE ]; then - echo $ROOT_FILE >> files - fi -done - -cd $TMP_DIR - -if [ -f "chrome.manifest" ]; then - echo "Preprocessing chrome.manifest..." - # You think this is scary? - #s/^(content\s+\S*\s+)(\S*\/)(.*)$/\1jar:chrome\/$APP_NAME\.jar!\/\2\3/ - #s/^(skin|locale)(\s+\S*\s+\S*\s+)(.*\/)$/\1\2jar:chrome\/$APP_NAME\.jar!\/\3/ - # - # Then try this! (Same, but with characters escaped for bash :) - sed -i -r s/^\(content\\s+\\S*\\s+\)\(\\S*\\/\)\(.*\)$/\\1jar:chrome\\/$APP_NAME\\.jar!\\/\\2\\3/ chrome.manifest - sed -i -r s/^\(skin\|locale\)\(\\s+\\S*\\s+\\S*\\s+\)\(.*\\/\)$/\\1\\2jar:chrome\\/$APP_NAME\\.jar!\\/\\3/ chrome.manifest - - # (it simply adds jar:chrome/whatever.jar!/ at appropriate positions of chrome.manifest) -fi - -# generate the XPI file -echo "Generating $APP_NAME.xpi..." -zip -r ../$APP_NAME.xpi * - -cd "$ROOT_DIR" - -echo "Cleanup..." -if [ $CLEAN_UP = 0 ]; then - # save the jar file - mv $TMP_DIR/chrome/$APP_NAME.jar . -else - rm ./files -fi - -# remove the working files -rm -rf $TMP_DIR -echo "Done!" - -$AFTER_BUILD diff --git a/client/thunderbird-filelink-dl/chrome.manifest b/client/thunderbird-filelink-dl/chrome.manifest deleted file mode 100644 index 3669e95..0000000 --- a/client/thunderbird-filelink-dl/chrome.manifest +++ /dev/null @@ -1,12 +0,0 @@ -content thunderbird-filelink-dl chrome/content/ -skin thunderbird-filelink-dl default chrome/skin/ -locale thunderbird-filelink-dl en-US chrome/locale/en-US/ -locale thunderbird-filelink-dl en-US chrome/locale/hu/ - -component {c0bee36d-3c0d-460b-bb9a-f0e9c873a833} components/nsDL.js -contract @thregr.org/thunderbird-filelink-dl;1 {c0bee36d-3c0d-460b-bb9a-f0e9c873a833} -category cloud-files DL @thregr.org/thunderbird-filelink-dl;1 - -interfaces components/nsDL.xpt - -overlay chrome://messenger/content/messengercompose/messengercompose.xul chrome://thunderbird-filelink-dl/content/compose.xul diff --git a/client/thunderbird-filelink-dl/chrome/content/compose.js b/client/thunderbird-filelink-dl/chrome/content/compose.js deleted file mode 100644 index 5be8a4d..0000000 --- a/client/thunderbird-filelink-dl/chrome/content/compose.js +++ /dev/null @@ -1,85 +0,0 @@ -const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components; - -Cu.import("resource:///modules/Services.jsm"); -Cu.import("resource:///modules/cloudFileAccounts.js"); -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); - -var composeBundle = Services.strings.createBundle( - "chrome://thunderbird-filelink-dl/locale/compose.properties"); - -function insertUploadGrantListener(provider) -{ - this.provider = provider; -} - -insertUploadGrantListener.prototype = -{ - id: null, - - onStartRequest: function(aRequest, aContext) - { - // show some progress - ToggleWindowLock(true); - document.getElementById("compose-progressmeter").setAttribute("mode", "undetermined"); - document.getElementById("statusbar-progresspanel").collapsed = false; - - let msg = composeBundle.GetStringFromName("newGrantProgress"); - document.getElementById('statusText').setAttribute('label', msg); - }, - - onStopRequest: function(aRequest, aContext, aStatusCode) - { - // restore progress state - ToggleWindowLock(false); - document.getElementById("compose-progressmeter").setAttribute("mode", "normal"); - document.getElementById("compose-progressmeter").setAttribute("value", 0); - document.getElementById("statusbar-progresspanel").collapsed = true; - - if(aStatusCode != Cr.NS_OK) - { - let msg = composeBundle.GetStringFromName("newGrantFailure"); - document.getElementById('statusText').setAttribute('label', msg); - } - else - { - // insert grant URL - let url = this.provider.urlForGrant(this.id); - let editor = GetCurrentEditor(); - editor.beginTransaction(); - editor.insertHTML("" + encodeURI(url) + "\n"); - editor.endTransaction(); - document.getElementById('statusText').setAttribute('label', ''); - } - }, - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIRequestObserver, Ci.nsISupportsWeakReference]) -}; - -function insertUploadGrant() -{ - // search for a DL account - let provider = Cc["@thregr.org/thunderbird-filelink-dl;1"].getService(Ci.nsIDL); - let accounts = cloudFileAccounts.getAccountsForType(provider.type); - if(!accounts.length) - { - let title = composeBundle.GetStringFromName("accountNeededTitle"); - let msg = composeBundle.GetStringFromName("accountNeededMsg"); - let prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Ci.nsIPromptService); - if(prompts.confirm(window, title, msg)) - cloudFileAccounts.addAccountDialog(); - return; - } - - // initialize the first valid DL account - let accountKey = accounts[0].accountKey; - try { provider.init(accountKey); } - catch(e) - { - Cu.reportError(e); - return; - } - - // request a new grant URL - let listener = new insertUploadGrantListener(provider); - listener.id = provider.newGrant(listener, gCurrentIdentity.email); -} diff --git a/client/thunderbird-filelink-dl/chrome/content/compose.xul b/client/thunderbird-filelink-dl/chrome/content/compose.xul deleted file mode 100644 index 9cdf58d..0000000 --- a/client/thunderbird-filelink-dl/chrome/content/compose.xul +++ /dev/null @@ -1,20 +0,0 @@ - - - - - -