|  | 
| 209 | 209 | 		Remote.messageList(Utils.emptyFunction, Cache.getFolderInboxName(), 0, SettingsStore.messagesPerPage(), '', true); | 
| 210 | 210 | 	}; | 
| 211 | 211 | 
 | 
| 212 |  | -	AppUser.prototype.reloadMessageListHelper = function (bEmptyList) | 
| 213 |  | -	{ | 
| 214 |  | -		this.reloadMessageList(bEmptyList); | 
| 215 |  | -	}; | 
| 216 |  | - | 
| 217 | 212 | 	/** | 
| 218 | 213 | 	 * @param {Function} fResultFunc | 
| 219 | 214 | 	 * @returns {boolean} | 
|  | 
| 316 | 311 | 				} | 
| 317 | 312 | 			} | 
| 318 | 313 | 
 | 
| 319 |  | -			this.reloadMessageListHelper(0 === MessageStore.messageList().length); | 
|  | 314 | +			this.reloadMessageList(0 === MessageStore.messageList().length); | 
| 320 | 315 | 			this.quotaDebounce(); | 
| 321 | 316 | 		} | 
| 322 | 317 | 	}; | 
|  | 
| 1219 | 1214 | 		}); | 
| 1220 | 1215 | 	}; | 
| 1221 | 1216 | 
 | 
|  | 1217 | +	AppUser.prototype.bootstartTwoFactorScreen = function () | 
|  | 1218 | +	{ | 
|  | 1219 | +		kn.showScreenPopup(require('View/Popup/TwoFactorConfiguration'), [true]); | 
|  | 1220 | +	}; | 
|  | 1221 | + | 
|  | 1222 | +	AppUser.prototype.bootstartWelcomePopup = function (sUrl) | 
|  | 1223 | +	{ | 
|  | 1224 | +		kn.showScreenPopup(require('View/Popup/WelcomePage'), [sUrl]); | 
|  | 1225 | +	}; | 
|  | 1226 | + | 
| 1222 | 1227 | 	AppUser.prototype.bootstartLoginScreen = function () | 
| 1223 | 1228 | 	{ | 
| 1224 | 1229 | 		Globals.$html.removeClass('rl-user-auth').addClass('rl-user-no-auth'); | 
| 1225 | 1230 | 
 | 
| 1226 | 1231 | 		var sCustomLoginLink = Utils.pString(Settings.settingsGet('CustomLoginLink')); | 
| 1227 | 1232 | 		if (!sCustomLoginLink) | 
| 1228 | 1233 | 		{ | 
| 1229 |  | -			kn.hideLoading(); | 
| 1230 |  | - | 
| 1231 | 1234 | 			kn.startScreens([ | 
| 1232 | 1235 | 				require('Screen/User/Login') | 
| 1233 | 1236 | 			]); | 
|  | 
| 1247 | 1250 | 		} | 
| 1248 | 1251 | 	}; | 
| 1249 | 1252 | 
 | 
|  | 1253 | +	AppUser.prototype.bootend = function () | 
|  | 1254 | +	{ | 
|  | 1255 | +		kn.hideLoading(); | 
|  | 1256 | + | 
|  | 1257 | +		if (SimplePace) | 
|  | 1258 | +		{ | 
|  | 1259 | +			SimplePace.set(100); | 
|  | 1260 | +		} | 
|  | 1261 | +	}; | 
|  | 1262 | + | 
| 1250 | 1263 | 	AppUser.prototype.bootstart = function () | 
| 1251 | 1264 | 	{ | 
| 1252 | 1265 | 		AbstractApp.prototype.bootstart.call(this); | 
| @@ -1277,183 +1290,193 @@ | 
| 1277 | 1290 | 			Events.pub('left-panel.' + (bValue ? 'off' : 'on')); | 
| 1278 | 1291 | 		}); | 
| 1279 | 1292 | 
 | 
|  | 1293 | +		this.setWindowTitle(''); | 
| 1280 | 1294 | 		if (!!Settings.settingsGet('Auth')) | 
| 1281 | 1295 | 		{ | 
| 1282 | 1296 | 			Globals.$html.addClass('rl-user-auth'); | 
| 1283 | 1297 | 
 | 
| 1284 |  | -			this.setWindowTitle(Translator.i18n('TITLES/LOADING')); | 
|  | 1298 | +			if (Settings.capa(Enums.Capa.TwoFactor) && | 
|  | 1299 | +				Settings.capa(Enums.Capa.TwoFactorForce) && | 
|  | 1300 | +				Settings.settingsGet('RequireTwoFactor')) | 
|  | 1301 | +			{ | 
|  | 1302 | + | 
|  | 1303 | +				this.bootend(); | 
|  | 1304 | +				this.bootstartTwoFactorScreen(); | 
|  | 1305 | +			} | 
|  | 1306 | +			else | 
|  | 1307 | +			{ | 
|  | 1308 | +				this.setWindowTitle(Translator.i18n('TITLES/LOADING')); | 
| 1285 | 1309 | 
 | 
| 1286 | 1310 | //require.ensure([], function() { // require code splitting | 
| 1287 | 1311 | 
 | 
| 1288 |  | -			self.foldersReload(_.bind(function (bValue) { | 
|  | 1312 | +				self.foldersReload(_.bind(function (bValue) { | 
| 1289 | 1313 | 
 | 
| 1290 |  | -				kn.hideLoading(); | 
|  | 1314 | +					this.bootend(); | 
| 1291 | 1315 | 
 | 
| 1292 |  | -				if (bValue) | 
| 1293 |  | -				{ | 
| 1294 |  | -					if ($LAB && window.crypto && window.crypto.getRandomValues && Settings.capa(Enums.Capa.OpenPGP)) | 
|  | 1316 | +					if (bValue) | 
| 1295 | 1317 | 					{ | 
| 1296 |  | -						var fOpenpgpCallback = function (openpgp) { | 
| 1297 |  | -							PgpStore.openpgp = openpgp; | 
| 1298 |  | -							PgpStore.openpgpKeyring = new openpgp.Keyring(); | 
| 1299 |  | -							PgpStore.capaOpenPGP(true); | 
|  | 1318 | +						if ($LAB && window.crypto && window.crypto.getRandomValues && Settings.capa(Enums.Capa.OpenPGP)) | 
|  | 1319 | +						{ | 
|  | 1320 | +							var fOpenpgpCallback = function (openpgp) { | 
|  | 1321 | +								PgpStore.openpgp = openpgp; | 
|  | 1322 | +								PgpStore.openpgpKeyring = new openpgp.Keyring(); | 
|  | 1323 | +								PgpStore.capaOpenPGP(true); | 
| 1300 | 1324 | 
 | 
| 1301 |  | -							Events.pub('openpgp.init'); | 
|  | 1325 | +								Events.pub('openpgp.init'); | 
| 1302 | 1326 | 
 | 
| 1303 |  | -							self.reloadOpenPgpKeys(); | 
| 1304 |  | -						}; | 
|  | 1327 | +								self.reloadOpenPgpKeys(); | 
|  | 1328 | +							}; | 
| 1305 | 1329 | 
 | 
| 1306 |  | -						if (window.openpgp) | 
| 1307 |  | -						{ | 
| 1308 |  | -							fOpenpgpCallback(window.openpgp); | 
|  | 1330 | +							if (window.openpgp) | 
|  | 1331 | +							{ | 
|  | 1332 | +								fOpenpgpCallback(window.openpgp); | 
|  | 1333 | +							} | 
|  | 1334 | +							else | 
|  | 1335 | +							{ | 
|  | 1336 | +								$LAB.script(Links.openPgpJs()).wait(function () { | 
|  | 1337 | +									if (window.openpgp) | 
|  | 1338 | +									{ | 
|  | 1339 | +										fOpenpgpCallback(window.openpgp); | 
|  | 1340 | +									} | 
|  | 1341 | +								}); | 
|  | 1342 | +							} | 
| 1309 | 1343 | 						} | 
| 1310 | 1344 | 						else | 
| 1311 | 1345 | 						{ | 
| 1312 |  | -							$LAB.script(Links.openPgpJs()).wait(function () { | 
| 1313 |  | -								if (window.openpgp) | 
| 1314 |  | -								{ | 
| 1315 |  | -									fOpenpgpCallback(window.openpgp); | 
| 1316 |  | -								} | 
| 1317 |  | -							}); | 
|  | 1346 | +							PgpStore.capaOpenPGP(false); | 
| 1318 | 1347 | 						} | 
| 1319 |  | -					} | 
| 1320 |  | -					else | 
| 1321 |  | -					{ | 
| 1322 |  | -						PgpStore.capaOpenPGP(false); | 
| 1323 |  | -					} | 
| 1324 | 1348 | 
 | 
| 1325 |  | -					kn.startScreens([ | 
| 1326 |  | -						require('Screen/User/MailBox'), | 
| 1327 |  | -						require('Screen/User/Settings'), | 
| 1328 |  | -						require('Screen/User/About') | 
| 1329 |  | -					]); | 
|  | 1349 | +						kn.startScreens([ | 
|  | 1350 | +							require('Screen/User/MailBox'), | 
|  | 1351 | +							require('Screen/User/Settings'), | 
|  | 1352 | +							require('Screen/User/About') | 
|  | 1353 | +						]); | 
| 1330 | 1354 | 
 | 
| 1331 |  | -					if (bGoogle || bFacebook || bTwitter) | 
| 1332 |  | -					{ | 
| 1333 |  | -						self.socialUsers(true); | 
| 1334 |  | -					} | 
| 1335 |  | - | 
| 1336 |  | -					Events.sub('interval.2m', function () { | 
| 1337 |  | -						self.folderInformation(Cache.getFolderInboxName()); | 
| 1338 |  | -					}); | 
| 1339 |  | - | 
| 1340 |  | -					Events.sub('interval.3m', function () { | 
| 1341 |  | -						var sF = FolderStore.currentFolderFullNameRaw(); | 
| 1342 |  | -						if (Cache.getFolderInboxName() !== sF) | 
|  | 1355 | +						if (bGoogle || bFacebook || bTwitter) | 
| 1343 | 1356 | 						{ | 
| 1344 |  | -							self.folderInformation(sF); | 
|  | 1357 | +							self.socialUsers(true); | 
| 1345 | 1358 | 						} | 
| 1346 |  | -					}); | 
| 1347 |  | - | 
| 1348 |  | -					Events.sub('interval.5m-after5m', function () { | 
| 1349 |  | -						self.folderInformationMultiply(); | 
| 1350 |  | -					}); | 
| 1351 |  | - | 
| 1352 |  | -					Events.sub('interval.15m', function () { | 
| 1353 |  | -						self.quota(); | 
| 1354 |  | -					}); | 
| 1355 | 1359 | 
 | 
| 1356 |  | -					Events.sub('interval.20m', function () { | 
| 1357 |  | -						self.foldersReload(); | 
| 1358 |  | -					}); | 
| 1359 |  | - | 
| 1360 |  | -					iContactsSyncInterval = 5 <= iContactsSyncInterval ? iContactsSyncInterval : 20; | 
| 1361 |  | -					iContactsSyncInterval = 320 >= iContactsSyncInterval ? iContactsSyncInterval : 320; | 
|  | 1360 | +						Events.sub('interval.2m', function () { | 
|  | 1361 | +							self.folderInformation(Cache.getFolderInboxName()); | 
|  | 1362 | +						}); | 
| 1362 | 1363 | 
 | 
| 1363 |  | -					_.delay(function () { | 
| 1364 |  | -						self.contactsSync(); | 
| 1365 |  | -					}, 10000); | 
|  | 1364 | +						Events.sub('interval.3m', function () { | 
|  | 1365 | +							var sF = FolderStore.currentFolderFullNameRaw(); | 
|  | 1366 | +							if (Cache.getFolderInboxName() !== sF) | 
|  | 1367 | +							{ | 
|  | 1368 | +								self.folderInformation(sF); | 
|  | 1369 | +							} | 
|  | 1370 | +						}); | 
| 1366 | 1371 | 
 | 
| 1367 |  | -					_.delay(function () { | 
| 1368 |  | -						self.folderInformationMultiply(true); | 
| 1369 |  | -					}, 2000); | 
|  | 1372 | +						Events.sub('interval.5m-after5m', function () { | 
|  | 1373 | +							self.folderInformationMultiply(); | 
|  | 1374 | +						}); | 
| 1370 | 1375 | 
 | 
| 1371 |  | -					window.setInterval(function () { | 
| 1372 |  | -						self.contactsSync(); | 
| 1373 |  | -					}, iContactsSyncInterval * 60000 + 5000); | 
|  | 1376 | +						Events.sub('interval.15m', function () { | 
|  | 1377 | +							self.quota(); | 
|  | 1378 | +						}); | 
| 1374 | 1379 | 
 | 
| 1375 |  | -					self.accountsAndIdentities(true); | 
|  | 1380 | +						Events.sub('interval.20m', function () { | 
|  | 1381 | +							self.foldersReload(); | 
|  | 1382 | +						}); | 
| 1376 | 1383 | 
 | 
| 1377 |  | -					_.delay(function () { | 
| 1378 |  | -						var sF = FolderStore.currentFolderFullNameRaw(); | 
| 1379 |  | -						if (Cache.getFolderInboxName() !== sF) | 
| 1380 |  | -						{ | 
| 1381 |  | -							self.folderInformation(sF); | 
| 1382 |  | -						} | 
| 1383 |  | -					}, 1000); | 
|  | 1384 | +						iContactsSyncInterval = 5 <= iContactsSyncInterval ? iContactsSyncInterval : 20; | 
|  | 1385 | +						iContactsSyncInterval = 320 >= iContactsSyncInterval ? iContactsSyncInterval : 320; | 
| 1384 | 1386 | 
 | 
| 1385 |  | -					_.delay(function () { | 
| 1386 |  | -						self.quota(); | 
| 1387 |  | -					}, 5000); | 
|  | 1387 | +						_.delay(function () { | 
|  | 1388 | +							self.contactsSync(); | 
|  | 1389 | +						}, 10000); | 
| 1388 | 1390 | 
 | 
| 1389 |  | -					_.delay(function () { | 
| 1390 |  | -						Remote.appDelayStart(Utils.emptyFunction); | 
| 1391 |  | -					}, 35000); | 
|  | 1391 | +						_.delay(function () { | 
|  | 1392 | +							self.folderInformationMultiply(true); | 
|  | 1393 | +						}, 2000); | 
| 1392 | 1394 | 
 | 
| 1393 |  | -					Events.sub('rl.auto-logout', function () { | 
| 1394 |  | -						self.logout(); | 
| 1395 |  | -					}); | 
|  | 1395 | +						window.setInterval(function () { | 
|  | 1396 | +							self.contactsSync(); | 
|  | 1397 | +						}, iContactsSyncInterval * 60000 + 5000); | 
| 1396 | 1398 | 
 | 
| 1397 |  | -					Plugins.runHook('rl-start-user-screens'); | 
| 1398 |  | -					Events.pub('rl.bootstart-user-screens'); | 
|  | 1399 | +						self.accountsAndIdentities(true); | 
| 1399 | 1400 | 
 | 
| 1400 |  | -					if (!!Settings.settingsGet('AccountSignMe') && window.navigator.registerProtocolHandler) | 
| 1401 |  | -					{ | 
| 1402 | 1401 | 						_.delay(function () { | 
| 1403 |  | -							try { | 
| 1404 |  | -								window.navigator.registerProtocolHandler('mailto', | 
| 1405 |  | -									window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s', | 
| 1406 |  | -									'' + (Settings.settingsGet('Title') || 'RainLoop')); | 
| 1407 |  | -							} catch(e) {} | 
| 1408 |  | - | 
| 1409 |  | -							if (Settings.settingsGet('MailToEmail')) | 
|  | 1402 | +							var sF = FolderStore.currentFolderFullNameRaw(); | 
|  | 1403 | +							if (Cache.getFolderInboxName() !== sF) | 
| 1410 | 1404 | 							{ | 
| 1411 |  | -								Utils.mailToHelper(Settings.settingsGet('MailToEmail'), require('View/Popup/Compose')); | 
|  | 1405 | +								self.folderInformation(sF); | 
| 1412 | 1406 | 							} | 
| 1413 |  | -						}, 500); | 
| 1414 |  | -					} | 
|  | 1407 | +						}, 1000); | 
| 1415 | 1408 | 
 | 
| 1416 |  | -					if (!Globals.bMobileDevice) | 
| 1417 |  | -					{ | 
| 1418 |  | -						_.defer(function () { | 
| 1419 |  | -							self.initVerticalLayoutResizer(Enums.ClientSideKeyName.FolderListSize); | 
|  | 1409 | +						_.delay(function () { | 
|  | 1410 | +							self.quota(); | 
|  | 1411 | +						}, 5000); | 
|  | 1412 | + | 
|  | 1413 | +						_.delay(function () { | 
|  | 1414 | +							Remote.appDelayStart(Utils.emptyFunction); | 
|  | 1415 | +						}, 35000); | 
|  | 1416 | + | 
|  | 1417 | +						Events.sub('rl.auto-logout', function () { | 
|  | 1418 | +							self.logout(); | 
| 1420 | 1419 | 						}); | 
| 1421 | 1420 | 
 | 
| 1422 |  | -						if (Tinycon) | 
|  | 1421 | +						Plugins.runHook('rl-start-user-screens'); | 
|  | 1422 | +						Events.pub('rl.bootstart-user-screens'); | 
|  | 1423 | + | 
|  | 1424 | +						if (Settings.settingsGet('WelcomePageUrl')) | 
| 1423 | 1425 | 						{ | 
| 1424 |  | -							Tinycon.setOptions({ | 
| 1425 |  | -								fallback: false | 
| 1426 |  | -							}); | 
|  | 1426 | +							_.delay(function () { | 
|  | 1427 | +								self.bootstartWelcomePopup(Settings.settingsGet('WelcomePageUrl')); | 
|  | 1428 | +							}, 1000); | 
|  | 1429 | +						} | 
| 1427 | 1430 | 
 | 
| 1428 |  | -							Events.sub('mailbox.inbox-unread-count', function (iCount) { | 
| 1429 |  | -								Tinycon.setBubble(0 < iCount ? (99 < iCount ? 99 : iCount) : 0); | 
|  | 1431 | +						if (!!Settings.settingsGet('AccountSignMe') && window.navigator.registerProtocolHandler) | 
|  | 1432 | +						{ | 
|  | 1433 | +							_.delay(function () { | 
|  | 1434 | +								try { | 
|  | 1435 | +									window.navigator.registerProtocolHandler('mailto', | 
|  | 1436 | +										window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s', | 
|  | 1437 | +										'' + (Settings.settingsGet('Title') || 'RainLoop')); | 
|  | 1438 | +								} catch(e) {} | 
|  | 1439 | + | 
|  | 1440 | +								if (Settings.settingsGet('MailToEmail')) | 
|  | 1441 | +								{ | 
|  | 1442 | +									Utils.mailToHelper(Settings.settingsGet('MailToEmail'), require('View/Popup/Compose')); | 
|  | 1443 | +								} | 
|  | 1444 | +							}, 500); | 
|  | 1445 | +						} | 
|  | 1446 | + | 
|  | 1447 | +						if (!Globals.bMobileDevice) | 
|  | 1448 | +						{ | 
|  | 1449 | +							_.defer(function () { | 
|  | 1450 | +								self.initVerticalLayoutResizer(Enums.ClientSideKeyName.FolderListSize); | 
| 1430 | 1451 | 							}); | 
|  | 1452 | + | 
|  | 1453 | +							if (Tinycon) | 
|  | 1454 | +							{ | 
|  | 1455 | +								Tinycon.setOptions({ | 
|  | 1456 | +									fallback: false | 
|  | 1457 | +								}); | 
|  | 1458 | + | 
|  | 1459 | +								Events.sub('mailbox.inbox-unread-count', function (iCount) { | 
|  | 1460 | +									Tinycon.setBubble(0 < iCount ? (99 < iCount ? 99 : iCount) : 0); | 
|  | 1461 | +								}); | 
|  | 1462 | +							} | 
| 1431 | 1463 | 						} | 
| 1432 | 1464 | 					} | 
| 1433 |  | -				} | 
| 1434 |  | -				else | 
| 1435 |  | -				{ | 
| 1436 |  | -					this.bootstartLoginScreen(); | 
| 1437 |  | -				} | 
| 1438 |  | - | 
| 1439 |  | -				if (SimplePace) | 
| 1440 |  | -				{ | 
| 1441 |  | -					SimplePace.set(100); | 
| 1442 |  | -				} | 
|  | 1465 | +					else | 
|  | 1466 | +					{ | 
|  | 1467 | +						this.bootstartLoginScreen(); | 
|  | 1468 | +					} | 
| 1443 | 1469 | 
 | 
| 1444 |  | -			}, self)); | 
|  | 1470 | +				}, self)); | 
| 1445 | 1471 | 
 | 
| 1446 | 1472 | //}); // require code splitting | 
| 1447 | 1473 | 
 | 
|  | 1474 | +			} | 
| 1448 | 1475 | 		} | 
| 1449 | 1476 | 		else | 
| 1450 | 1477 | 		{ | 
|  | 1478 | +			this.bootend(); | 
| 1451 | 1479 | 			this.bootstartLoginScreen(); | 
| 1452 |  | - | 
| 1453 |  | -			if (SimplePace) | 
| 1454 |  | -			{ | 
| 1455 |  | -				SimplePace.set(100); | 
| 1456 |  | -			} | 
| 1457 | 1480 | 		} | 
| 1458 | 1481 | 
 | 
| 1459 | 1482 | 		if (bGoogle) | 
|  | 
0 commit comments