├── .gitignore ├── test ├── fixtures │ └── box1 │ │ └── Maildir │ │ ├── .R&AOQ-mpspost.T&AOQ-htis │ │ ├── maildirfolder │ │ ├── courierimapacl │ │ ├── cur │ │ │ ├── 1505297612.M848220P6469V000000000000FC00I0000000000042F63_0.ubuntu,S=6:2,S │ │ │ ├── 1505297634.M393426P6469V000000000000FC00I0000000000043267_1.ubuntu,S=7:2, │ │ │ ├── 1505297645.M902486P6469V000000000000FC00I0000000000043284_2.ubuntu,S=7:2,F │ │ │ └── 1505298136.M631733P6523V000000000000FC00I000000000004796C_0.ubuntu,S=11:2,DFS │ │ ├── courierimapkeywords │ │ │ ├── .5017661.1505297645.M902486P6469V000000000000FC00I0000000000043284_2.ubuntu,S=7 │ │ │ ├── 1505298136.M631733P6523V000000000000FC00I000000000004796C_0.ubuntu,S=11 │ │ │ └── :list │ │ └── courierimapuiddb │ │ ├── .Sent │ │ └── courierimapacl │ │ ├── .Drafts │ │ └── courierimapacl │ │ ├── .Templates │ │ └── courierimapacl │ │ ├── .Trash │ │ └── courierimapacl │ │ ├── courierimaphieracl │ │ └── R&AOQ-mpspost │ │ ├── new │ │ └── 1505297736.Z810083P6469V000000000000FC00I0000000000044B99_3.ubuntu,S=9 │ │ ├── courierimapuiddb │ │ └── cur │ │ └── random.name └── maildir-scan-test.js ├── .prettierrc.js ├── .eslintrc ├── Gruntfile.js ├── README.md ├── package.json ├── lib ├── special-use-boxes.js └── maildir-scan.js ├── LICENSE_ET └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | package-lock.json* 4 | -------------------------------------------------------------------------------- /test/fixtures/box1/Maildir/.R&AOQ-mpspost.T&AOQ-htis/maildirfolder: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/box1/Maildir/.Sent/courierimapacl: -------------------------------------------------------------------------------- 1 | owner aceilrstwx 2 | administrators aceilrstwx 3 | -------------------------------------------------------------------------------- /test/fixtures/box1/Maildir/.Drafts/courierimapacl: -------------------------------------------------------------------------------- 1 | owner aceilrstwx 2 | administrators aceilrstwx 3 | -------------------------------------------------------------------------------- /test/fixtures/box1/Maildir/.Templates/courierimapacl: -------------------------------------------------------------------------------- 1 | owner aceilrstwx 2 | administrators aceilrstwx 3 | -------------------------------------------------------------------------------- /test/fixtures/box1/Maildir/.Trash/courierimapacl: -------------------------------------------------------------------------------- 1 | owner aceilrstwx 2 | administrators aceilrstwx 3 | -------------------------------------------------------------------------------- /test/fixtures/box1/Maildir/courierimaphieracl/R&AOQ-mpspost: -------------------------------------------------------------------------------- 1 | owner aceilrstwx 2 | administrators aceilrstwx 3 | -------------------------------------------------------------------------------- /test/fixtures/box1/Maildir/.R&AOQ-mpspost.T&AOQ-htis/courierimapacl: -------------------------------------------------------------------------------- 1 | owner aceilrstwx 2 | administrators aceilrstwx 3 | -------------------------------------------------------------------------------- /test/fixtures/box1/Maildir/new/1505297736.Z810083P6469V000000000000FC00I0000000000044B99_3.ubuntu,S=9: -------------------------------------------------------------------------------- 1 | 12345678 2 | -------------------------------------------------------------------------------- /test/fixtures/box1/Maildir/courierimapuiddb: -------------------------------------------------------------------------------- 1 | 1 505297487 2 2 | 1 1505297735.M810083P6469V000000000000FC00I0000000000044B99_3.ubuntu,S=9 3 | -------------------------------------------------------------------------------- /test/fixtures/box1/Maildir/.R&AOQ-mpspost.T&AOQ-htis/cur/1505297612.M848220P6469V000000000000FC00I0000000000042F63_0.ubuntu,S=6:2,S: -------------------------------------------------------------------------------- 1 | 12345 2 | -------------------------------------------------------------------------------- /test/fixtures/box1/Maildir/.R&AOQ-mpspost.T&AOQ-htis/cur/1505297634.M393426P6469V000000000000FC00I0000000000043267_1.ubuntu,S=7:2,: -------------------------------------------------------------------------------- 1 | 123456 2 | -------------------------------------------------------------------------------- /test/fixtures/box1/Maildir/.R&AOQ-mpspost.T&AOQ-htis/cur/1505297645.M902486P6469V000000000000FC00I0000000000043284_2.ubuntu,S=7:2,F: -------------------------------------------------------------------------------- 1 | a noop 2 | -------------------------------------------------------------------------------- /test/fixtures/box1/Maildir/.R&AOQ-mpspost.T&AOQ-htis/cur/1505298136.M631733P6523V000000000000FC00I000000000004796C_0.ubuntu,S=11:2,DFS: -------------------------------------------------------------------------------- 1 | 12345 2 | 1234 3 | -------------------------------------------------------------------------------- /test/fixtures/box1/Maildir/.R&AOQ-mpspost.T&AOQ-htis/courierimapkeywords/.5017661.1505297645.M902486P6469V000000000000FC00I0000000000043284_2.ubuntu,S=7: -------------------------------------------------------------------------------- 1 | gupi 2 | jupi 3 | -------------------------------------------------------------------------------- /test/fixtures/box1/Maildir/.R&AOQ-mpspost.T&AOQ-htis/courierimapkeywords/1505298136.M631733P6523V000000000000FC00I000000000004796C_0.ubuntu,S=11: -------------------------------------------------------------------------------- 1 | jupi 2 | kupi 3 | mupi 4 | -------------------------------------------------------------------------------- /test/fixtures/box1/Maildir/.R&AOQ-mpspost.T&AOQ-htis/courierimapkeywords/:list: -------------------------------------------------------------------------------- 1 | jupi 2 | gupi 3 | 4 | 1505297645.M902486P6469V000000000000FC00I0000000000043284_2.ubuntu,S=7:1 0 5 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | printWidth: 160, 3 | tabWidth: 4, 4 | singleQuote: true, 5 | endOfLine: 'lf', 6 | trailingComma: 'none', 7 | arrowParens: 'avoid' 8 | }; 9 | -------------------------------------------------------------------------------- /test/fixtures/box1/Maildir/cur/random.name: -------------------------------------------------------------------------------- 1 | From: sender@exmaple.com 2 | To: recipient@exmaple.com 3 | Date: Thu, 21 Sep 2017 11:01:34 +0000 4 | Subject: test 5 | Mime-Version: 1.0 6 | 7 | Hello world! 8 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "indent": 0, 4 | "no-await-in-loop": 0, 5 | "require-atomic-updates": 0 6 | }, 7 | "globals": { 8 | "BigInt": true 9 | }, 10 | "extends": ["nodemailer", "prettier"], 11 | "parserOptions": { 12 | "ecmaVersion": 2018, 13 | "sourceType": "script" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/fixtures/box1/Maildir/.R&AOQ-mpspost.T&AOQ-htis/courierimapuiddb: -------------------------------------------------------------------------------- 1 | 1 505297575 5 2 | 1 1505297612.M848220P6469V000000000000FC00I0000000000042F63_0.ubuntu,S=6 3 | 2 1505297634.M393426P6469V000000000000FC00I0000000000043267_1.ubuntu,S=7 4 | 3 1505297645.M902486P6469V000000000000FC00I0000000000043284_2.ubuntu,S=7 5 | 4 1505298136.M631733P6523V000000000000FC00I000000000004796C_0.ubuntu,S=11 6 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function(grunt) { 4 | // Project configuration. 5 | grunt.initConfig({ 6 | eslint: { 7 | all: ['lib/**/*.js', 'test/**/*.js', 'Gruntfile.js'] 8 | }, 9 | 10 | nodeunit: { 11 | all: ['test/**/*-test.js'] 12 | } 13 | }); 14 | 15 | // Load the plugin(s) 16 | grunt.loadNpmTasks('grunt-eslint'); 17 | grunt.loadNpmTasks('grunt-contrib-nodeunit'); 18 | 19 | // Tasks 20 | grunt.registerTask('default', ['eslint', 'nodeunit']); 21 | }; 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # maildir-scan 2 | 3 | Finds messages from Maildir. Output is an array of folder objects that include an array of message objects. Actual message content is not loaded, this module is used for listing only. Tested on Courier based Maildir folders. 4 | 5 | ## Install 6 | 7 | npm install maildir-scan 8 | 9 | ## Usage 10 | 11 | ```javascript 12 | const MaildirScan = require('maildir-scan'); 13 | let scanner = new MaildirScan(); 14 | scanner.scan('/path/to/Maildir', (err, list) => { 15 | console.log(err || list); 16 | }); 17 | ``` 18 | 19 | ## License 20 | 21 | **EUPL-1.1 or later** 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "maildir-scan", 3 | "version": "2.2.0", 4 | "description": "Scan maildir folder and output a list of messages", 5 | "main": "lib/maildir-scan.js", 6 | "scripts": { 7 | "test": "grunt" 8 | }, 9 | "keywords": [ 10 | "maildir" 11 | ], 12 | "author": "Andris Reinman", 13 | "license": "EUPL-1.1+", 14 | "devDependencies": { 15 | "eslint-config-nodemailer": "1.2.0", 16 | "eslint-config-prettier": "8.5.0", 17 | "grunt": "1.5.3", 18 | "grunt-cli": "1.4.3", 19 | "grunt-contrib-nodeunit": "4.0.0", 20 | "grunt-eslint": "24.0.0" 21 | }, 22 | "dependencies": { 23 | "mailparser": "3.5.0", 24 | "utf7": "1.0.2" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/special-use-boxes.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // https://raw.githubusercontent.com/emailjs/emailjs-imap-client/master/src/emailjs-imap-client.js 4 | const SPECIAL_USE_BOXES = new Map([ 5 | [ 6 | '\\Sent', 7 | [ 8 | 'aika', 9 | 'bidaliak', 10 | 'bidalita', 11 | 'dihantar', 12 | 'e rometsweng', 13 | 'e tindami', 14 | 'elküldött', 15 | 'elküldöttek', 16 | 'enviadas', 17 | 'enviadas', 18 | 'enviados', 19 | 'enviats', 20 | 'envoyés', 21 | 'ethunyelweyo', 22 | 'expediate', 23 | 'ezipuru', 24 | 'gesendete', 25 | 'gestuur', 26 | 'gönderilmiş öğeler', 27 | 'göndərilənlər', 28 | 'iberilen', 29 | 'inviati', 30 | 'išsiųstieji', 31 | 'kuthunyelwe', 32 | 'lasa', 33 | 'lähetetyt', 34 | 'messages envoyés', 35 | 'naipadala', 36 | 'nalefa', 37 | 'napadala', 38 | 'nosūtītās ziņas', 39 | 'odeslané', 40 | 'padala', 41 | 'poslane', 42 | 'poslano', 43 | 'poslano', 44 | 'poslané', 45 | 'poslato', 46 | 'saadetud', 47 | 'saadetud kirjad', 48 | 'sendt', 49 | 'sendt', 50 | 'sent', 51 | 'sent items', 52 | 'sent messages', 53 | 'sända poster', 54 | 'sänt', 55 | 'terkirim', 56 | 'ti fi ranṣẹ', 57 | 'të dërguara', 58 | 'verzonden', 59 | 'vilivyotumwa', 60 | 'wysłane', 61 | 'đã gửi', 62 | 'σταλθέντα', 63 | 'жиберилген', 64 | 'жіберілгендер', 65 | 'изпратени', 66 | 'илгээсэн', 67 | 'ирсол шуд', 68 | 'испратено', 69 | 'надіслані', 70 | 'отправленные', 71 | 'пасланыя', 72 | 'юборилган', 73 | 'ուղարկված', 74 | 'נשלחו', 75 | 'פריטים שנשלחו', 76 | 'المرسلة', 77 | 'بھیجے گئے', 78 | 'سوزمژہ', 79 | 'لېګل شوی', 80 | 'موارد ارسال شده', 81 | 'पाठविले', 82 | 'पाठविलेले', 83 | 'प्रेषित', 84 | 'भेजा गया', 85 | 'প্রেরিত', 86 | 'প্রেরিত', 87 | 'প্ৰেৰিত', 88 | 'ਭੇਜੇ', 89 | 'મોકલેલા', 90 | 'ପଠାଗଲା', 91 | 'அனுப்பியவை', 92 | 'పంపించబడింది', 93 | 'ಕಳುಹಿಸಲಾದ', 94 | 'അയച്ചു', 95 | 'යැවු පණිවුඩ', 96 | 'ส่งแล้ว', 97 | 'გაგზავნილი', 98 | 'የተላኩ', 99 | 'បាន​ផ្ញើ', 100 | '寄件備份', 101 | '寄件備份', 102 | '已发信息', 103 | '送信済みメール', 104 | '발신 메시지', 105 | '보낸 편지함' 106 | ] 107 | ], 108 | [ 109 | '\\Trash', 110 | [ 111 | 'articole șterse', 112 | 'bin', 113 | 'borttagna objekt', 114 | 'deleted', 115 | 'deleted items', 116 | 'deleted messages', 117 | 'elementi eliminati', 118 | 'elementos borrados', 119 | 'elementos eliminados', 120 | 'gelöschte objekte', 121 | 'item dipadam', 122 | 'itens apagados', 123 | 'itens excluídos', 124 | 'mục đã xóa', 125 | 'odstraněné položky', 126 | 'pesan terhapus', 127 | 'poistetut', 128 | 'praht', 129 | 'prügikast', 130 | 'silinmiş öğeler', 131 | 'slettede beskeder', 132 | 'slettede elementer', 133 | 'trash', 134 | 'törölt elemek', 135 | 'usunięte wiadomości', 136 | 'verwijderde items', 137 | 'vymazané správy', 138 | 'éléments supprimés', 139 | 'видалені', 140 | 'жойылғандар', 141 | 'удаленные', 142 | 'פריטים שנמחקו', 143 | 'العناصر المحذوفة', 144 | 'موارد حذف شده', 145 | 'รายการที่ลบ', 146 | '已删除邮件', 147 | '已刪除項目', 148 | '已刪除項目' 149 | ] 150 | ], 151 | [ 152 | '\\Junk', 153 | [ 154 | 'bulk mail', 155 | 'correo no deseado', 156 | 'courrier indésirable', 157 | 'istenmeyen', 158 | 'istenmeyen e-posta', 159 | 'junk', 160 | 'levélszemét', 161 | 'nevyžiadaná pošta', 162 | 'nevyžádaná pošta', 163 | 'no deseado', 164 | 'posta indesiderata', 165 | 'pourriel', 166 | 'roskaposti', 167 | 'skräppost', 168 | 'spam', 169 | 'spam', 170 | 'spamowanie', 171 | 'søppelpost', 172 | 'thư rác', 173 | 'спам', 174 | 'דואר זבל', 175 | 'الرسائل العشوائية', 176 | 'هرزنامه', 177 | 'สแปม', 178 | '‎垃圾郵件', 179 | '垃圾邮件', 180 | '垃圾電郵' 181 | ] 182 | ], 183 | [ 184 | '\\Drafts', 185 | [ 186 | 'ba brouillon', 187 | 'borrador', 188 | 'borrador', 189 | 'borradores', 190 | 'bozze', 191 | 'brouillons', 192 | 'bản thảo', 193 | 'ciorne', 194 | 'concepten', 195 | 'draf', 196 | 'drafts', 197 | 'drög', 198 | 'entwürfe', 199 | 'esborranys', 200 | 'garalamalar', 201 | 'ihe edeturu', 202 | 'iidrafti', 203 | 'izinhlaka', 204 | 'juodraščiai', 205 | 'kladd', 206 | 'kladder', 207 | 'koncepty', 208 | 'koncepty', 209 | 'konsep', 210 | 'konsepte', 211 | 'kopie robocze', 212 | 'layihələr', 213 | 'luonnokset', 214 | 'melnraksti', 215 | 'meralo', 216 | 'mesazhe të padërguara', 217 | 'mga draft', 218 | 'mustandid', 219 | 'nacrti', 220 | 'nacrti', 221 | 'osnutki', 222 | 'piszkozatok', 223 | 'rascunhos', 224 | 'rasimu', 225 | 'skice', 226 | 'taslaklar', 227 | 'tsararrun saƙonni', 228 | 'utkast', 229 | 'vakiraoka', 230 | 'vázlatok', 231 | 'zirriborroak', 232 | 'àwọn àkọpamọ́', 233 | 'πρόχειρα', 234 | 'жобалар', 235 | 'нацрти', 236 | 'нооргууд', 237 | 'сиёҳнавис', 238 | 'хомаки хатлар', 239 | 'чарнавікі', 240 | 'чернетки', 241 | 'чернови', 242 | 'черновики', 243 | 'черновиктер', 244 | 'սևագրեր', 245 | 'טיוטות', 246 | 'مسودات', 247 | 'مسودات', 248 | 'موسودې', 249 | 'پیش نویسها', 250 | 'ڈرافٹ/', 251 | 'ड्राफ़्ट', 252 | 'प्रारूप', 253 | 'খসড়া', 254 | 'খসড়া', 255 | 'ড্ৰাফ্ট', 256 | 'ਡ੍ਰਾਫਟ', 257 | 'ડ્રાફ્ટસ', 258 | 'ଡ୍ରାଫ୍ଟ', 259 | 'வரைவுகள்', 260 | 'చిత్తు ప్రతులు', 261 | 'ಕರಡುಗಳು', 262 | 'കരടുകള്‍', 263 | 'කෙටුම් පත්', 264 | 'ฉบับร่าง', 265 | 'მონახაზები', 266 | 'ረቂቆች', 267 | 'សារព្រាង', 268 | '下書き', 269 | '草稿', 270 | '草稿', 271 | '草稿', 272 | '임시 보관함' 273 | ] 274 | ] 275 | ]); 276 | 277 | module.exports = name => { 278 | name = name.toLowerCase().trim(); 279 | let done = false; 280 | let entries = SPECIAL_USE_BOXES.entries(); 281 | while (!done) { 282 | let entry = entries.next(); 283 | done = entry.done; 284 | if (entry.value && entry.value[1] && entry.value[1].includes(name)) { 285 | return entry.value[0]; 286 | } 287 | } 288 | return false; 289 | }; 290 | -------------------------------------------------------------------------------- /test/maildir-scan-test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const MaildirScan = require('../lib/maildir-scan'); 4 | 5 | module.exports.recursiveFolderScan = test => { 6 | let scanner = new MaildirScan(); 7 | scanner.recursiveFolderScan(__dirname + '/fixtures/box1/Maildir', false, 0, (err, output) => { 8 | test.ifError(err); 9 | test.deepEqual(output, [ 10 | { 11 | name: '.Drafts', 12 | path: '.Drafts', 13 | dir: true, 14 | children: [{ name: 'courierimapacl', path: '.Drafts/courierimapacl', file: true }] 15 | }, 16 | { 17 | name: '.R&AOQ-mpspost.T&AOQ-htis', 18 | path: '.R&AOQ-mpspost.T&AOQ-htis', 19 | dir: true, 20 | children: [ 21 | { name: 'courierimapacl', path: '.R&AOQ-mpspost.T&AOQ-htis/courierimapacl', file: true }, 22 | { 23 | name: 'courierimapkeywords', 24 | path: '.R&AOQ-mpspost.T&AOQ-htis/courierimapkeywords', 25 | dir: true, 26 | children: [ 27 | { name: ':list', path: '.R&AOQ-mpspost.T&AOQ-htis/courierimapkeywords/:list', file: true }, 28 | { 29 | name: '.5017661.1505297645.M902486P6469V000000000000FC00I0000000000043284_2.ubuntu,S=7', 30 | path: '.R&AOQ-mpspost.T&AOQ-htis/courierimapkeywords/.5017661.1505297645.M902486P6469V000000000000FC00I0000000000043284_2.ubuntu,S=7', 31 | file: true 32 | }, 33 | { 34 | name: '1505298136.M631733P6523V000000000000FC00I000000000004796C_0.ubuntu,S=11', 35 | path: '.R&AOQ-mpspost.T&AOQ-htis/courierimapkeywords/1505298136.M631733P6523V000000000000FC00I000000000004796C_0.ubuntu,S=11', 36 | file: true 37 | } 38 | ] 39 | }, 40 | { name: 'courierimapuiddb', path: '.R&AOQ-mpspost.T&AOQ-htis/courierimapuiddb', file: true }, 41 | { 42 | name: 'cur', 43 | path: '.R&AOQ-mpspost.T&AOQ-htis/cur', 44 | dir: true, 45 | children: [ 46 | { 47 | name: '1505297612.M848220P6469V000000000000FC00I0000000000042F63_0.ubuntu,S=6:2,S', 48 | path: '.R&AOQ-mpspost.T&AOQ-htis/cur/1505297612.M848220P6469V000000000000FC00I0000000000042F63_0.ubuntu,S=6:2,S', 49 | file: true 50 | }, 51 | { 52 | name: '1505297634.M393426P6469V000000000000FC00I0000000000043267_1.ubuntu,S=7:2,', 53 | path: '.R&AOQ-mpspost.T&AOQ-htis/cur/1505297634.M393426P6469V000000000000FC00I0000000000043267_1.ubuntu,S=7:2,', 54 | file: true 55 | }, 56 | { 57 | name: '1505297645.M902486P6469V000000000000FC00I0000000000043284_2.ubuntu,S=7:2,F', 58 | path: '.R&AOQ-mpspost.T&AOQ-htis/cur/1505297645.M902486P6469V000000000000FC00I0000000000043284_2.ubuntu,S=7:2,F', 59 | file: true 60 | }, 61 | { 62 | name: '1505298136.M631733P6523V000000000000FC00I000000000004796C_0.ubuntu,S=11:2,DFS', 63 | path: '.R&AOQ-mpspost.T&AOQ-htis/cur/1505298136.M631733P6523V000000000000FC00I000000000004796C_0.ubuntu,S=11:2,DFS', 64 | file: true 65 | } 66 | ] 67 | }, 68 | { name: 'maildirfolder', path: '.R&AOQ-mpspost.T&AOQ-htis/maildirfolder', file: true } 69 | ] 70 | }, 71 | { 72 | name: '.Sent', 73 | path: '.Sent', 74 | dir: true, 75 | children: [{ name: 'courierimapacl', path: '.Sent/courierimapacl', file: true }] 76 | }, 77 | { 78 | name: '.Templates', 79 | path: '.Templates', 80 | dir: true, 81 | children: [{ name: 'courierimapacl', path: '.Templates/courierimapacl', file: true }] 82 | }, 83 | { 84 | name: '.Trash', 85 | path: '.Trash', 86 | dir: true, 87 | children: [{ name: 'courierimapacl', path: '.Trash/courierimapacl', file: true }] 88 | }, 89 | { 90 | name: 'courierimaphieracl', 91 | path: 'courierimaphieracl', 92 | dir: true, 93 | children: [{ name: 'R&AOQ-mpspost', path: 'courierimaphieracl/R&AOQ-mpspost', file: true }] 94 | }, 95 | { name: 'courierimapuiddb', path: 'courierimapuiddb', file: true }, 96 | { name: 'cur', path: 'cur', dir: true, children: [{ name: 'random.name', path: 'cur/random.name', file: true }] }, 97 | { 98 | name: 'new', 99 | path: 'new', 100 | dir: true, 101 | children: [ 102 | { 103 | name: '1505297736.Z810083P6469V000000000000FC00I0000000000044B99_3.ubuntu,S=9', 104 | path: 'new/1505297736.Z810083P6469V000000000000FC00I0000000000044B99_3.ubuntu,S=9', 105 | file: true 106 | } 107 | ] 108 | } 109 | ]); 110 | test.done(); 111 | }); 112 | }; 113 | 114 | module.exports.scan = test => { 115 | let scanner = new MaildirScan(); 116 | scanner.scan(__dirname + '/fixtures/box1/Maildir', (err, output) => { 117 | test.ifError(err); 118 | test.deepEqual(output, [ 119 | { 120 | folder: ['INBOX'], 121 | name: 'INBOX', 122 | path: '.', 123 | messages: [ 124 | { name: 'random.name', path: 'cur/random.name', time: 1505991694, flags: [] }, 125 | { 126 | name: '1505297736.Z810083P6469V000000000000FC00I0000000000044B99_3.ubuntu,S=9', 127 | path: 'new/1505297736.Z810083P6469V000000000000FC00I0000000000044B99_3.ubuntu,S=9', 128 | time: 1505297736, 129 | flags: [] 130 | } 131 | ] 132 | }, 133 | { 134 | folder: ['Rämpspost', 'Tähtis'], 135 | name: '.R&AOQ-mpspost.T&AOQ-htis', 136 | path: '.R&AOQ-mpspost.T&AOQ-htis', 137 | messages: [ 138 | { 139 | name: '1505297612.M848220P6469V000000000000FC00I0000000000042F63_0.ubuntu,S=6:2,S', 140 | path: '.R&AOQ-mpspost.T&AOQ-htis/cur/1505297612.M848220P6469V000000000000FC00I0000000000042F63_0.ubuntu,S=6:2,S', 141 | time: 1505297612, 142 | flags: ['\\Seen'] 143 | }, 144 | { 145 | name: '1505297634.M393426P6469V000000000000FC00I0000000000043267_1.ubuntu,S=7:2,', 146 | path: '.R&AOQ-mpspost.T&AOQ-htis/cur/1505297634.M393426P6469V000000000000FC00I0000000000043267_1.ubuntu,S=7:2,', 147 | time: 1505297634, 148 | flags: [] 149 | }, 150 | { 151 | name: '1505297645.M902486P6469V000000000000FC00I0000000000043284_2.ubuntu,S=7:2,F', 152 | path: '.R&AOQ-mpspost.T&AOQ-htis/cur/1505297645.M902486P6469V000000000000FC00I0000000000043284_2.ubuntu,S=7:2,F', 153 | time: 1505297645, 154 | flags: ['\\Flagged', 'gupi', 'jupi'] 155 | }, 156 | { 157 | name: '1505298136.M631733P6523V000000000000FC00I000000000004796C_0.ubuntu,S=11:2,DFS', 158 | path: '.R&AOQ-mpspost.T&AOQ-htis/cur/1505298136.M631733P6523V000000000000FC00I000000000004796C_0.ubuntu,S=11:2,DFS', 159 | time: 1505298136, 160 | flags: ['\\Draft', '\\Flagged', '\\Seen', 'jupi', 'kupi', 'mupi'] 161 | } 162 | ] 163 | } 164 | ]); 165 | test.done(); 166 | }); 167 | }; 168 | -------------------------------------------------------------------------------- /lib/maildir-scan.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const pathlib = require('path'); 5 | const utf7 = require('utf7').imap; 6 | const simpleParser = require('mailparser').simpleParser; 7 | const specialUseBoxes = require('./special-use-boxes'); 8 | 9 | class MaildirScan { 10 | constructor(options) { 11 | this.options = options || {}; 12 | } 13 | 14 | scan(maildirPath, callback) { 15 | this.recursiveFolderScan(maildirPath, false, 0, (err, dir) => { 16 | if (err) { 17 | return callback(err); 18 | } 19 | this.scanPrepared(maildirPath, dir, callback); 20 | }); 21 | } 22 | 23 | scanPrepared(maildirPath, dir, callback) { 24 | let root = { 25 | name: 'INBOX', 26 | path: '.', 27 | dir: true, 28 | children: dir 29 | }; 30 | 31 | let mailboxes = []; 32 | 33 | let walk = (parent, entry, next) => { 34 | if (entry.dir) { 35 | let nameParts = entry.name 36 | .split('.') 37 | .map(part => utf7.decode(part.trim())) 38 | .filter(part => part.trim()); 39 | 40 | let folder = { 41 | folder: nameParts, 42 | name: entry.name, 43 | path: entry.path, 44 | messages: [] 45 | }; 46 | 47 | if (folder.name === 'courierimapkeywords') { 48 | parent.keywords = folder.keywords = new Map(); 49 | folder.checkKeywords = true; 50 | } else if (['cur', 'new', 'tmp'].includes(folder.name)) { 51 | parent.maildir = true; 52 | folder = parent; 53 | } else if (!['.git', '.svn'].includes(folder.name)) { 54 | mailboxes.push(folder); 55 | } 56 | 57 | let entryPos = 0; 58 | let processEntry = () => { 59 | if (entryPos >= entry.children.length) { 60 | return next(); 61 | } 62 | let child = entry.children[entryPos++]; 63 | walk(folder, child, () => setImmediate(processEntry)); 64 | }; 65 | 66 | return setImmediate(processEntry); 67 | } 68 | 69 | if ( 70 | entry.file && 71 | !['.DS_Store', 'thumbs.db'].includes(entry.name) && 72 | (entry.name.indexOf(':2') >= 0 || entry.name.indexOf('S=') >= 0 || /(^|\/)(cur|new|tmp)\//.test(entry.path)) 73 | ) { 74 | if (parent.checkKeywords) { 75 | return fs.readFile(pathlib.join(maildirPath, entry.path), 'utf-8', (err, keywords) => { 76 | if (err) { 77 | // ignore 78 | } else { 79 | keywords = (keywords || '') 80 | .toString() 81 | .replace(/[\r\n]+/g, '\n') 82 | .trim() 83 | .split('\n') 84 | .filter(kw => kw); 85 | if (keywords.length) { 86 | parent.keywords.set(entry.name.replace(/^\.[^.]+\./, ''), keywords); 87 | } 88 | } 89 | return next(); 90 | }); 91 | } 92 | return this.parseFile(maildirPath, entry, (err, parsed) => { 93 | if (!err && parsed) { 94 | parent.messages.push(parsed); 95 | } 96 | return next(); 97 | }); 98 | } 99 | 100 | return next(); 101 | }; 102 | 103 | walk(false, root, () => { 104 | let specialUse = new Set(); 105 | 106 | mailboxes = mailboxes 107 | .map(folder => { 108 | // push custom keywords to message flags 109 | if (folder.keywords && folder.keywords.size && folder.messages && folder.messages.length) { 110 | folder.messages.forEach(msg => { 111 | let customFlags = folder.keywords.get(msg.name.split(':2')[0]); 112 | if (customFlags) { 113 | let existingFlags = msg.flags.map(fl => fl.toLowerCase().trim()); 114 | customFlags.forEach(fl => { 115 | let flC = fl.toLowerCase().trim(); 116 | if (!existingFlags.includes(flC)) { 117 | existingFlags.push(flC); 118 | msg.flags.push(fl); 119 | } 120 | }); 121 | } 122 | }); 123 | } 124 | return folder; 125 | }) 126 | .filter(folder => folder.maildir) 127 | .map(folder => { 128 | delete folder.keywords; 129 | delete folder.maildir; 130 | let fname = folder.folder[folder.folder.length - 1]; 131 | if (fname && fname !== 'INBOX') { 132 | let su = specialUseBoxes(fname); 133 | if (su) { 134 | if (this.options.mergeSpecial) { 135 | folder.specialUse = su; 136 | } else if (!specialUse.has(su)) { 137 | folder.specialUse = su; 138 | specialUse.add(su); 139 | } 140 | } 141 | } 142 | return folder; 143 | }); 144 | 145 | callback(null, mailboxes); 146 | }); 147 | } 148 | 149 | parseFile(maildirPath, entry, next) { 150 | let base; 151 | let tail; 152 | let flags = []; 153 | let cflags = []; 154 | if (/:2,?$/.test(entry.name)) { 155 | base = entry.name.split(/:2,?/).shift(); 156 | } else if (/:2,/.test(entry.name)) { 157 | let parts = entry.name.split(':2,'); 158 | base = parts.shift(); 159 | tail = parts.join(':2,'); 160 | for (let i = 0, len = tail.length; i < len; i++) { 161 | let chr = tail.charAt(i); 162 | switch (chr) { 163 | case 'P': 164 | flags.push('$Forwarded'); 165 | break; 166 | case 'R': 167 | flags.push('\\Answered'); 168 | break; 169 | case 'S': 170 | flags.push('\\Seen'); 171 | break; 172 | case 'T': 173 | flags.push('\\Deleted'); 174 | break; 175 | case 'D': 176 | flags.push('\\Draft'); 177 | break; 178 | case 'F': 179 | flags.push('\\Flagged'); 180 | break; 181 | default: 182 | if (/[a-z]/i.test(chr)) { 183 | cflags.push(chr); 184 | } 185 | } 186 | } 187 | } else { 188 | base = entry.name; 189 | } 190 | 191 | let parts = base.split('.'); 192 | if (!parts[0]) { 193 | parts.splice(0, 2); 194 | } 195 | 196 | let time = Number(parts.shift()) || 0; 197 | 198 | let checkTime = done => { 199 | if (time) { 200 | return done(); 201 | } 202 | 203 | return fs.readFile(pathlib.join(maildirPath, entry.path), (err, raw) => { 204 | if (err) { 205 | return done(); 206 | } else { 207 | simpleParser(raw, (err, mail) => { 208 | if (!err && mail) { 209 | time = (mail.date && mail.date.getTime()) || 0; 210 | time = Math.round(time / 1000); 211 | } 212 | return done(); 213 | }); 214 | } 215 | }); 216 | }; 217 | 218 | checkTime(() => 219 | next(null, { 220 | name: entry.name, 221 | path: entry.path, 222 | time: time || Math.round(new Date('2000-01-01').getTime() / 1000), 223 | flags //, 224 | //cflags 225 | }) 226 | ); 227 | } 228 | 229 | recursiveFolderScan(basepath, path, level, callback) { 230 | level = level || 0; 231 | 232 | if (!path) { 233 | path = basepath; 234 | } 235 | 236 | fs.readdir(path, { encoding: 'utf8' }, (err, list) => { 237 | if (err) { 238 | return callback(err); 239 | } 240 | 241 | let output = []; 242 | list = list || []; 243 | let pos = 0; 244 | let processList = () => { 245 | if (pos >= list.length) { 246 | output = output.sort((a, b) => a.name.localeCompare(b.name)); 247 | return callback(null, output); 248 | } 249 | 250 | let name = list[pos++]; 251 | if (!name || ['.', '..'].includes(name)) { 252 | return setImmediate(processList); 253 | } 254 | 255 | let realpath = pathlib.join(path, name); 256 | let entry = { 257 | name, 258 | path: pathlib.relative(basepath, realpath) 259 | }; 260 | 261 | fs.stat(realpath, (err, stat) => { 262 | if (err) { 263 | entry.error = err.message; 264 | output.push(entry); 265 | return setImmediate(processList); 266 | } 267 | 268 | if (stat.isFile()) { 269 | entry.file = true; 270 | output.push(entry); 271 | return setImmediate(processList); 272 | } 273 | 274 | if (stat.isDirectory()) { 275 | entry.dir = true; 276 | if (level > 128) { 277 | entry.children = []; 278 | entry.status = 'EMAXLEVEL'; 279 | output.push(entry); 280 | return setImmediate(processList); 281 | } 282 | this.recursiveFolderScan(basepath, realpath, level + 1, (err, children) => { 283 | if (err) { 284 | return callback(err); 285 | } 286 | entry.children = children; 287 | output.push(entry); 288 | return setImmediate(processList); 289 | }); 290 | return; 291 | } 292 | 293 | // unknown 294 | return setImmediate(processList); 295 | }); 296 | }; 297 | 298 | setImmediate(processList); 299 | }); 300 | } 301 | } 302 | 303 | module.exports = MaildirScan; 304 | -------------------------------------------------------------------------------- /LICENSE_ET: -------------------------------------------------------------------------------- 1 | EUROOPA LIIDU TARKVARA VABA KASUTUSE LITSENTS v. 1.2 2 | EUPL © Euroopa Liit 2007, 2016 3 | Euroopa Liidu tarkvara vaba kasutuse litsents („EUPL“) kehtib allpool määratletud teose suhtes, mida levitatakse vastavalt käesoleva litsentsi tingimustele. Teost on keelatud kasutada muul viisil kui vastavalt käesoleva litsentsi tingimustele niivõrd, kuivõrd sellise kasutamise suhtes kehtivad teose autoriõiguse omaja õigused). Teost levitatakse vastavalt käesoleva litsentsi tingimustele, kui allpool määratletud litsentsiandja paneb vahetult teose autoriõiguse märke järele järgmise märke: 4 | Litsentsitud EUPL alusel 5 | või on muul viisil väljendanud soovi litsentsida originaalteos EUPL alusel. 6 | 7 | 1.Mõisted 8 | Käesolevas litsentsis kasutatakse järgmisi mõisteid: 9 | — „litsents“–käesolev litsents; 10 | — „originaalteos“–teos või tarkvara, mida litsentsiandja käesoleva litsentsi alusel levitab või edastab ning mis on kättesaadav lähtekoodina ja teatavatel juhtudel ka täitmiskoodina; 11 | — „tuletatud teos“–teos või tarkvara, mida litsentsisaajal on olnud võimalik luua tuginedes originaalteosele või selle muudetud versioonile. Käesolevas litsentsis ei määratleta muudatuse ulatust või sõltuvust originaalteosest, mis on vajalik selleks, et klassifitseerida teos tuletatud teoseks; selline ulatus määratakse kindlaks vastavalt artiklis 15 nimetatud riigis kehtivatele autoriõigust käsitlevatele õigusaktidele; 12 | — „teos“–originaalteos või sellest tuletatud teosed; 13 | — „lähtekood“–teose inimloetav vorm, mida inimestel on kõige lihtsam uurida ja muuta; 14 | — „täitmiskood“–igasugune kood, mille on tavaliselt koostanud arvuti ja mis on mõeldud arvuti poolt programmina tõlgendamiseks; 15 | — „litsentsiandja“–füüsiline või juriidiline isik, kes levitab või edastab teost litsentsi alusel; 16 | — „edasiarendaja“–füüsiline või juriidiline isik, kes muudab teost litsentsi alusel või osaleb muul moel tuletatud teose loomises; 17 | — „litsentsisaaja“ või „Teie“–iga füüsiline või juriidiline isik, kes kasutab teost ükskõik mis moel vastavalt litsentsi tingimustele; 18 | — „levitamine“ või „edastamine“–teose koopiate müümine, teisele isikule andmine, laenutamine, rentimine, levitamine, edastamine, ülekandmine või teose koopiate või selle oluliste funktsioonide muul viisil teistele füüsilistele või juriidilistele isikutele kättesaadavaks tegemine võrgus või võrguväliselt. 19 | 20 | 2.Litsentsiga antavate õiguste ulatus 21 | Käesolevaga annab litsentsiandja Teile ülemaailmse, tasuta, all-litsentsi andmise õigusega lihtlitsentsi, mille alusel võite teha originaalteose autoriõiguse kehtivusaja jooksul järgmist: 22 | — kasutada teost mis tahes eesmärgil ja mis tahes viisil, 23 | — teost reprodutseerida, 24 | — teost muuta ja luua teosel põhinevaid tuletatud teoseid, 25 | — teost või selle koopiaid üldsusele edastada, sealhulgas neid kättesaadavaks teha või eksponeerida, samuti avalikult esitada, 26 | — teost või selle koopiaid levitada, 27 | — teost või selle koopiaid laenutada ja rentida, 28 | — anda all-litsentse teose või selle koopiate suhtes kehtivate õiguste kohta. 29 | Neid õigusi võib teostada mistahes praegu tuntud või hiljem leiutatud keskkonnas, toel või formaadis, ja sellises ulatuses, nagu lubab kohaldatav õigus. Riikides, kus kehtivad isiklikud õigused, loobub litsentsiandja seadusega lubatud ulatuses oma õigusest teostada isiklikke õigusi, et oleks võimalik eespool loetletud varalisi õigusi litsentsida. Litsentsiandja annab litsentsisaajale tasuta lihtlitsentsi kõigi litsentsiandjale kuuluvate patentide kasutamiseks ulatuses, mis on vajalik teose suhtes käesoleva litsentsiga antud õiguste kasutamiseks. 30 | 31 | 3.Lähtekoodi edastamine 32 | Litsentsiandja võib teose kättesaadavaks teha kas lähtekoodi või täitmiskoodi kujul. Kui teos tehakse kättesaadavaks täitmiskoodi kujul, lisab litsentsiandja igale tema poolt levitatavale teose koopiale lähtekoodi masinloetava koopia või näitab teose autoriõiguse märke järele lisatud märkega ära hoidla, kust lähtekood on kergesti ja tasuta kättesaadav seni, kuni litsentsiandja jätkab teose levitamist või edastamist. 33 | 34 | 4.Autoriõiguse piiramine 35 | Käesolev litsents ei võta litsentsisaajalt võimalusi, mis tulenevad teose õiguste omaja ainuõiguste suhtes kehtestatud eranditest või ainuõiguste piiramisest, nende õiguste ammendumisest või muudest nende õiguste suhtes kohaldatavatest piirangutest. 36 | 37 | 5.Litsentsisaaja kohustused 38 | Eespool nimetatud õigused antakse litsentsisaajale tingimusel, et ta peab kinni teatavatest piirangutest ja täidab teatavaid talle pandud kohustusi. Need kohustused on järgmised: 39 | 40 | Õigus autorsusele. Litsentsisaaja hoiab puutumatuna kõik autoriõiguse, patentide ja kaubamärkide kohta käivad märked ja kõik märked, mis viitavad litsentsile ja garantii puudumisele. Litsentsisaaja peab teose iga tema poolt levitatavale või edastatavale koopiale lisama nimetatud märgete koopiad ja litsentsi koopia. Litsentsisaaja peab tagama, et iga tuletatud teos kannab selget märget selle kohta, et teost on muudetud ja muutmise kuupäeva. 41 | 42 | Klausel vaba kasutamise tagamise kohta (copyleft). Kui litsentsisaaja levitab või edastab originaalteose või tuletatud teoste koopiaid, toimub see levitamine või edastamine vastavalt käesoleva litsentsi tingimustele või käesoleva litsentsi hilisema versiooni tingimustele, välja arvatud juhul, kui originaalteost levitatakse ainult vastavalt litsentsi käesolevale versioonile (näiteks märkides „ainult EUPL v.1.2“). Litsentsisaaja ei tohi (litsentsiandjaks saades) teosele või tuletatud teosele lisada ega kehtestada mingeid lisatingimusi, mis muudavad või piiravad litsentsi tingimusi. 43 | 44 | Ühilduvuse klausel. Kui litsentsisaaja levitab või edastab tuletatud teoseid või nende koopiaid, mis põhinevad nii teosel kui ka teisel, käesoleva litsentsiga ühilduva litsentsi alusel litsentsitud teosel, võib see levitamine või edastamine toimuda vastavalt nimetatud ühilduva litsentsi tingimustele. Käesolevas klauslis tähendab „ühilduv litsents“ käesoleva litsentsi lisas loetletud litsentse. Kui litsentsisaaja ühilduvale litsentsile vastavad kohustused on vastuolus tema kohustustega vastavalt käesolevale litsentsile, loetakse kehtivaks ühilduva litsentsi kohased kohustused. 45 | 46 | Lähtekoodi lisamine. Teose koopiate levitamisel või edastamisel lisab litsentsisaaja igale koopiale lähtekoodi masinloetava koopia või näitab ära hoidla, kust lähtekood on kergesti ja tasuta kättesaadav seni, kuni litsentsisaaja jätkab teose levitamist või edastamist. 47 | 48 | Õiguskaitse. Käesoleva litsentsiga ei anta luba kasutada litsentsiandja ärinimesid, kaubamärke, teenindusmärke või nimesid, välja arvatud juhul, kui see on vajalik mõistlikuks ja tavapäraseks kasutamiseks teose päritolu kirjeldamisel ja autoriõiguse märke sisu reprodutseerimisel. 49 | 50 | 6.Autorsuse ahel 51 | Esialgne litsentsiandja tagab, et käesoleva litsentsiga antav autoriõigus originaalteosele kuulub talle või on talle litsentsitud ja et tal on õigus seda litsentsiga edasi anda. Iga edasiarendaja tagab, et autoriõigus tema poolt teosele tehtavatele muudatustele kuulub talle või on talle litsentsitud ja et tal on õigus litsentsi anda. Iga kord, kui Te võtate vastu litsentsi, annavad esialgne litsentsiandja ja hilisemad edasiarendajad Teile litsentsi nende osaluse kasutamiseks teoses vastavalt käesoleva litsentsi tingimustele. 52 | 53 | 7.Garantii puudumine 54 | Teos on veel pooleli ja arvukad edasiarendajad parendavad seda järjepidevalt. See ei ole lõpetatud teos ja võib seetõttu sisaldada defekte ja programmivigu, mis on omased seda liiki arendustegevusele. Seetõttu levitatakse teost litsentsi alusel „sellisena, nagu see on“ ilma teose suhtes kehtiva garantiita, muu hulgas garantiita kaubandusliku kvaliteedi kohta, garantiita sobivuse kohta mingi kindla eesmärgi jaoks, garantiita defektide ja vigade puudumise kohta, garantiita täpsuse kohta ja selle kohta, et ei ole rikutud muid intellektuaalse omandi õigusi peale käesoleva litsentsi artiklis 6 nimetatud autoriõiguse. Käesolev garantii puudumise klausel on litsentsi oluline osa ja teosele õiguste andmise eeltingimus. 55 | 56 | 8.Vastutuse välistamine 57 | Välja arvatud tahtliku õiguserikkumise või füüsilistele isikutele tekitatud otsese kahju puhul, ei vastuta litsentsiandja mitte mingil juhul litsentsi või teose kasutamise tagajärjel tekkinud mistahes otsese või kaudse, varalise või moraalse kahju eest, muu hulgas maineväärtuse langusest tekkinud kahju, tööseisakute, arvutirikke ja talitlushäirete, andmete kadumise ja ärikahju eest, isegi juhul kui litsentsiandjat on sellise kahju tekkimise võimalikkusest teavitatud. Litsentsiandja vastutab siiski vastavalt tootevastutust käsitlevatele õigusaktidele niivõrd, kuivõrd need õigusaktid on teose suhtes kohaldatavad. 58 | 59 | 9.Lisakokkulepped 60 | Teose levitamisel võite Te sõlmida lisakokkuleppe, milles määratakse kindlaks käesoleva litsentsiga vastavuses olevad kohustused või teenused. Kuid kui olete nõus võtma kohustusi, võite Te tegutseda ainult iseenda nimel ja vastutusel, mitte esialgse litsentsiandja või teiste edasiarendajate nimel, ja ainult juhul, kui Te nõustute vabastama edasiarendajad vastutusest, kaitsma ja hoidma neid kahju tekkimise eest vastutuse või nõuete osas, mida nende vastu võidakse esitada selle tagajärjel, et Teie pakute garantiid või võtate lisavastutuse. 61 | 62 | 10.Litsentsiga nõustumine 63 | Käesoleva litsentsi sätetega saab nõustuda, klõpsates ikoonile „Nõustun“ litsentsi teksti näitava akna all või väljendades nõusolekut muul sarnasel viisil vastavalt kehtivatele õigusaktidele. Sellele ikoonile klõpsates väljendate selgelt ja pöördumatult oma nõusolekut käesoleva litsentsi ja kõigi selle tingimuste suhtes. Samuti nõustute pöördumatult käesoleva litsentsi ja kõigi selle tingimustega, kui teostate Teile käesoleva litsentsi artikliga 2 antud õigusi, näiteks kasutate teost, loote tuletatud teose või levitate või edastate teost või selle koopiaid. 64 | 65 | 11.Üldsuse teavitamine 66 | Juhul, kui Te kasutate teose levitamiseks või edastamiseks elektroonilisi sidevahendeid (näiteks võimaldate teose allalaadimist veebisaidilt), tuleb levitamiskanalil või andmekandjal (näiteks veebisaidil) teha üldsusele kättesaadavaks vähemalt kohaldatava õiguse alusel kohustuslik teave litsentsiandja ja litsentsi kohta ning selle kohta, kuidas see on litsentsisaajale kättesaadav, litsentsilepingu sõlmimise kohta ja selle kohta, kuidas litsentsisaaja saab litsentsi säilitada ja reprodutseerida. 67 | 68 | 12.Litsentsi lõppemine 69 | Litsents ja sellega antud õigused lõppevad automaatselt juhul, kui litsentsisaaja rikub litsentsi tingimusi. Sellise lõppemise korral ei lõpe ühegi sellise isiku litsents, kes sai teose litsentsisaajalt vastavalt litsentsi tingimustele, juhul kui see isik täidab jätkuvalt litsentsi tingimusi. 70 | 71 | 13.Muud sätted 72 | Ilma et see piiraks litsentsi artikli 9 kohaldamist, sisaldab litsents kogu kokkulepet, mis osapoolte vahel seose teosega on. Kui mõni litsentsi säte on vastavalt kohaldatavatele õigusaktidele kehtetu või seda ei ole võimalik jõustada, ei mõjuta see litsentsi kui terviku kehtivust ega jõustatavust. Sellist sätet tõlgendatakse või muudetakse nii nagu vaja, et see kehtiks ja saaks tagada selle täitmise. Euroopa Komisjon võib avaldada käesoleva litsentsi muid keeleversioone või uusi versioone või lisa uuendatud versioone, kuivõrd see on vajalik ja mõistlik, vähendamata sellega litsentsiga antavate õiguste ulatust. Litsentsi uued versioonid avaldatakse kordumatu versiooninumbriga. Käesoleva litsentsi kõik keeleversioonid, mille Euroopa Komisjon on heaks kiitnud, on võrdväärsed. Osapooled võivad kasutada enda valitud keeleversiooni. 73 | 74 | 14.Kohtualluvus 75 | Ilma et see piiraks konkreetse osapooltevahelise kokkuleppe kohaldamist, 76 | — kuuluvad käesoleva litsentsi tõlgendamisest tulenevad kohtuvaidlused Euroopa Liidu institutsioonide, organite, büroode või asutuste kui litsentsiandja ja mistahes litsentsisaaja vahel Euroopa Liidu Kohtu pädevusse, nagu on sätestatud Euroopa Liidu toimimise lepingu artiklis 272, 77 | — kuuluvad käesoleva litsentsi tõlgendamisest tulenevad kohtuvaidlused muude osapoolte vahel selle pädeva kohtu ainupädevusse, kelle tööpiirkonnas asub litsentsiandja elukoht või peamine tegevuskoht. 78 | 79 | 15.Kohaldatav õigus 80 | Ilma et see piiraks konkreetse osapooltevahelise kokkuleppe kohaldamist, 81 | — kohaldatakse käesoleva litsentsi suhtes selle Euroopa Liidu liikmesriigi õigust, kus paikneb litsentsiandja peakorter, elukoht või asukoht, 82 | — kohaldatakse litsentsi suhtes Belgia õigust, kui litsentsiandja peakorter, elukoht või asukoht asub väljaspool Euroopa Liidu liikmesriike. 83 | 84 | Liide 85 | Euroopa Liidu tarkvara vaba kasutuse litsentsi artiklis 5 osutatud „ühilduvad litsentsid“ on järgmised: 86 | — GNU General Public License (GPL) v. 2, v. 3 87 | — GNU Affero General Public License (AGPL) v. 3 88 | — Open Software License (OSL) v. 2.1, v. 3.0 89 | — Eclipse Public License (EPL) v. 1.0 90 | — CeCILL v. 2.0, v. 2.1 91 | — Mozilla Public Licence (MPL) v. 2 92 | — GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3 93 | — Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) muude teoste puhul peale tarkvara 94 | — European Union Public Licence (EUPL) v. 1.1, v. 1.2 95 | — Québec Free and Open-Source Licence – Reciprocity (LiLiQ-R) or Strong Reciprocity (LiLiQ-R+). 96 | Euroopa Komisjon võib käesolevat lisa ajakohastada loetletud litsentside hilisemate versioonidega ilma, et peaks selleks koostama EUPLi uue versiooni, eeldusel et nende litsentsidega tagatakse käesoleva litsentsi artiklis 2 sätestatud õigused ja kaitstakse hõlmatud lähtekoodi eksklusiivse omastamise eest. 97 | Kõigi muude käesoleva liite muudatuste või täienduste jaoks on vaja koostada EUPLi uus versioon. 98 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | EUROPEAN UNION PUBLIC LICENCE v. 1.2 2 | EUPL © the European Union 2007, 2016 3 | 4 | This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined below) which is provided under the 5 | terms of this Licence. Any use of the Work, other than as authorised under this Licence is prohibited (to the extent such 6 | use is covered by a right of the copyright holder of the Work). 7 | The Work is provided under the terms of this Licence when the Licensor (as defined below) has placed the following 8 | notice immediately following the copyright notice for the Work: 9 | Licensed under the EUPL 10 | or has expressed by any other means his willingness to license under the EUPL. 11 | 12 | 1.Definitions 13 | In this Licence, the following terms have the following meaning: 14 | — ‘The Licence’:this Licence. 15 | — ‘The Original Work’:the work or software distributed or communicated by the Licensor under this Licence, available 16 | as Source Code and also as Executable Code as the case may be. 17 | — ‘Derivative Works’:the works or software that could be created by the Licensee, based upon the Original Work or 18 | modifications thereof. This Licence does not define the extent of modification or dependence on the Original Work 19 | required in order to classify a work as a Derivative Work; this extent is determined by copyright law applicable in 20 | the country mentioned in Article 15. 21 | — ‘The Work’:the Original Work or its Derivative Works. 22 | — ‘The Source Code’:the human-readable form of the Work which is the most convenient for people to study and 23 | modify. 24 | — ‘The Executable Code’:any code which has generally been compiled and which is meant to be interpreted by 25 | a computer as a program. 26 | — ‘The Licensor’:the natural or legal person that distributes or communicates the Work under the Licence. 27 | — ‘Contributor(s)’:any natural or legal person who modifies the Work under the Licence, or otherwise contributes to 28 | the creation of a Derivative Work. 29 | — ‘The Licensee’ or ‘You’:any natural or legal person who makes any usage of the Work under the terms of the 30 | Licence. 31 | — ‘Distribution’ or ‘Communication’:any act of selling, giving, lending, renting, distributing, communicating, 32 | transmitting, or otherwise making available, online or offline, copies of the Work or providing access to its essential 33 | functionalities at the disposal of any other natural or legal person. 34 | 35 | 2.Scope of the rights granted by the Licence 36 | The Licensor hereby grants You a worldwide, royalty-free, non-exclusive, sublicensable licence to do the following, for 37 | the duration of copyright vested in the Original Work: 38 | — use the Work in any circumstance and for all usage, 39 | — reproduce the Work, 40 | — modify the Work, and make Derivative Works based upon the Work, 41 | — communicate to the public, including the right to make available or display the Work or copies thereof to the public 42 | and perform publicly, as the case may be, the Work, 43 | — distribute the Work or copies thereof, 44 | — lend and rent the Work or copies thereof, 45 | — sublicense rights in the Work or copies thereof. 46 | Those rights can be exercised on any media, supports and formats, whether now known or later invented, as far as the 47 | applicable law permits so. 48 | In the countries where moral rights apply, the Licensor waives his right to exercise his moral right to the extent allowed 49 | by law in order to make effective the licence of the economic rights here above listed. 50 | The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to any patents held by the Licensor, to the 51 | extent necessary to make use of the rights granted on the Work under this Licence. 52 | 53 | 3.Communication of the Source Code 54 | The Licensor may provide the Work either in its Source Code form, or as Executable Code. If the Work is provided as 55 | Executable Code, the Licensor provides in addition a machine-readable copy of the Source Code of the Work along with 56 | each copy of the Work that the Licensor distributes or indicates, in a notice following the copyright notice attached to 57 | the Work, a repository where the Source Code is easily and freely accessible for as long as the Licensor continues to 58 | distribute or communicate the Work. 59 | 60 | 4.Limitations on copyright 61 | Nothing in this Licence is intended to deprive the Licensee of the benefits from any exception or limitation to the 62 | exclusive rights of the rights owners in the Work, of the exhaustion of those rights or of other applicable limitations 63 | thereto. 64 | 65 | 5.Obligations of the Licensee 66 | The grant of the rights mentioned above is subject to some restrictions and obligations imposed on the Licensee. Those 67 | obligations are the following: 68 | 69 | Attribution right: The Licensee shall keep intact all copyright, patent or trademarks notices and all notices that refer to 70 | the Licence and to the disclaimer of warranties. The Licensee must include a copy of such notices and a copy of the 71 | Licence with every copy of the Work he/she distributes or communicates. The Licensee must cause any Derivative Work 72 | to carry prominent notices stating that the Work has been modified and the date of modification. 73 | 74 | Copyleft clause: If the Licensee distributes or communicates copies of the Original Works or Derivative Works, this 75 | Distribution or Communication will be done under the terms of this Licence or of a later version of this Licence unless 76 | the Original Work is expressly distributed only under this version of the Licence — for example by communicating 77 | ‘EUPL v. 1.2 only’. The Licensee (becoming Licensor) cannot offer or impose any additional terms or conditions on the 78 | Work or Derivative Work that alter or restrict the terms of the Licence. 79 | 80 | Compatibility clause: If the Licensee Distributes or Communicates Derivative Works or copies thereof based upon both 81 | the Work and another work licensed under a Compatible Licence, this Distribution or Communication can be done 82 | under the terms of this Compatible Licence. For the sake of this clause, ‘Compatible Licence’ refers to the licences listed 83 | in the appendix attached to this Licence. Should the Licensee's obligations under the Compatible Licence conflict with 84 | his/her obligations under this Licence, the obligations of the Compatible Licence shall prevail. 85 | 86 | Provision of Source Code: When distributing or communicating copies of the Work, the Licensee will provide 87 | a machine-readable copy of the Source Code or indicate a repository where this Source will be easily and freely available 88 | for as long as the Licensee continues to distribute or communicate the Work. 89 | Legal Protection: This Licence does not grant permission to use the trade names, trademarks, service marks, or names 90 | of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and 91 | reproducing the content of the copyright notice. 92 | 93 | 6.Chain of Authorship 94 | The original Licensor warrants that the copyright in the Original Work granted hereunder is owned by him/her or 95 | licensed to him/her and that he/she has the power and authority to grant the Licence. 96 | Each Contributor warrants that the copyright in the modifications he/she brings to the Work are owned by him/her or 97 | licensed to him/her and that he/she has the power and authority to grant the Licence. 98 | Each time You accept the Licence, the original Licensor and subsequent Contributors grant You a licence to their contributions 99 | to the Work, under the terms of this Licence. 100 | 101 | 7.Disclaimer of Warranty 102 | The Work is a work in progress, which is continuously improved by numerous Contributors. It is not a finished work 103 | and may therefore contain defects or ‘bugs’ inherent to this type of development. 104 | For the above reason, the Work is provided under the Licence on an ‘as is’ basis and without warranties of any kind 105 | concerning the Work, including without limitation merchantability, fitness for a particular purpose, absence of defects or 106 | errors, accuracy, non-infringement of intellectual property rights other than copyright as stated in Article 6 of this 107 | Licence. 108 | This disclaimer of warranty is an essential part of the Licence and a condition for the grant of any rights to the Work. 109 | 110 | 8.Disclaimer of Liability 111 | Except in the cases of wilful misconduct or damages directly caused to natural persons, the Licensor will in no event be 112 | liable for any direct or indirect, material or moral, damages of any kind, arising out of the Licence or of the use of the 113 | Work, including without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, loss 114 | of data or any commercial damage, even if the Licensor has been advised of the possibility of such damage. However, 115 | the Licensor will be liable under statutory product liability laws as far such laws apply to the Work. 116 | 117 | 9.Additional agreements 118 | While distributing the Work, You may choose to conclude an additional agreement, defining obligations or services 119 | consistent with this Licence. However, if accepting obligations, You may act only on your own behalf and on your sole 120 | responsibility, not on behalf of the original Licensor or any other Contributor, and only if You agree to indemnify, 121 | defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against such Contributor by 122 | the fact You have accepted any warranty or additional liability. 123 | 124 | 10.Acceptance of the Licence 125 | The provisions of this Licence can be accepted by clicking on an icon ‘I agree’ placed under the bottom of a window 126 | displaying the text of this Licence or by affirming consent in any other similar way, in accordance with the rules of 127 | applicable law. Clicking on that icon indicates your clear and irrevocable acceptance of this Licence and all of its terms 128 | and conditions. 129 | Similarly, you irrevocably accept this Licence and all of its terms and conditions by exercising any rights granted to You 130 | by Article 2 of this Licence, such as the use of the Work, the creation by You of a Derivative Work or the Distribution 131 | or Communication by You of the Work or copies thereof. 132 | 133 | 11.Information to the public 134 | In case of any Distribution or Communication of the Work by means of electronic communication by You (for example, 135 | by offering to download the Work from a remote location) the distribution channel or media (for example, a website) 136 | must at least provide to the public the information requested by the applicable law regarding the Licensor, the Licence 137 | and the way it may be accessible, concluded, stored and reproduced by the Licensee. 138 | 139 | 12.Termination of the Licence 140 | The Licence and the rights granted hereunder will terminate automatically upon any breach by the Licensee of the terms 141 | of the Licence. 142 | Such a termination will not terminate the licences of any person who has received the Work from the Licensee under 143 | the Licence, provided such persons remain in full compliance with the Licence. 144 | 145 | 13.Miscellaneous 146 | Without prejudice of Article 9 above, the Licence represents the complete agreement between the Parties as to the 147 | Work. 148 | If any provision of the Licence is invalid or unenforceable under applicable law, this will not affect the validity or 149 | enforceability of the Licence as a whole. Such provision will be construed or reformed so as necessary to make it valid 150 | and enforceable. 151 | The European Commission may publish other linguistic versions or new versions of this Licence or updated versions of 152 | the Appendix, so far this is required and reasonable, without reducing the scope of the rights granted by the Licence. 153 | New versions of the Licence will be published with a unique version number. 154 | All linguistic versions of this Licence, approved by the European Commission, have identical value. Parties can take 155 | advantage of the linguistic version of their choice. 156 | 157 | 14.Jurisdiction 158 | Without prejudice to specific agreement between parties, 159 | — any litigation resulting from the interpretation of this License, arising between the European Union institutions, 160 | bodies, offices or agencies, as a Licensor, and any Licensee, will be subject to the jurisdiction of the Court of Justice 161 | of the European Union, as laid down in article 272 of the Treaty on the Functioning of the European Union, 162 | — any litigation arising between other parties and resulting from the interpretation of this License, will be subject to 163 | the exclusive jurisdiction of the competent court where the Licensor resides or conducts its primary business. 164 | 165 | 15.Applicable Law 166 | Without prejudice to specific agreement between parties, 167 | — this Licence shall be governed by the law of the European Union Member State where the Licensor has his seat, 168 | resides or has his registered office, 169 | — this licence shall be governed by Belgian law if the Licensor has no seat, residence or registered office inside 170 | a European Union Member State. 171 | 172 | 173 | Appendix 174 | 175 | ‘Compatible Licences’ according to Article 5 EUPL are: 176 | — GNU General Public License (GPL) v. 2, v. 3 177 | — GNU Affero General Public License (AGPL) v. 3 178 | — Open Software License (OSL) v. 2.1, v. 3.0 179 | — Eclipse Public License (EPL) v. 1.0 180 | — CeCILL v. 2.0, v. 2.1 181 | — Mozilla Public Licence (MPL) v. 2 182 | — GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3 183 | — Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for works other than software 184 | — European Union Public Licence (EUPL) v. 1.1, v. 1.2 185 | — Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong Reciprocity (LiLiQ-R+). 186 | 187 | The European Commission may update this Appendix to later versions of the above licences without producing 188 | a new version of the EUPL, as long as they provide the rights granted in Article 2 of this Licence and protect the 189 | covered Source Code from exclusive appropriation. 190 | All other changes or additions to this Appendix require the production of a new EUPL version. 191 | 192 | --------------------------------------------------------------------------------