diff --git a/integrations/nextcloud/snappymail/js/admin.js b/integrations/nextcloud/snappymail/js/admin.js
deleted file mode 100644
index a57144112..000000000
--- a/integrations/nextcloud/snappymail/js/admin.js
+++ /dev/null
@@ -1,2 +0,0 @@
-
-SnappyMailFormHelper('admin-form', 'admin.php');
diff --git a/integrations/nextcloud/snappymail/js/personal.js b/integrations/nextcloud/snappymail/js/personal.js
deleted file mode 100644
index 9d50805b2..000000000
--- a/integrations/nextcloud/snappymail/js/personal.js
+++ /dev/null
@@ -1,2 +0,0 @@
-
-SnappyMailFormHelper('personal-form', 'personal.php');
diff --git a/integrations/nextcloud/snappymail/js/resize.js b/integrations/nextcloud/snappymail/js/resize.js
deleted file mode 100644
index 93a2d2741..000000000
--- a/integrations/nextcloud/snappymail/js/resize.js
+++ /dev/null
@@ -1,18 +0,0 @@
-document.addEventListener('readystatechange', () => {
- if (document.readyState === 'complete') {
- const
- buffer = 0, //was 5 but this was creating a white space of 5px at the bottom of the page
- ifr = document.getElementById('rliframe'),
- pageY = elem => elem.offsetParent ? (elem.offsetTop + pageY(elem.offsetParent)) : elem.offsetTop,
- resizeIframe = () => {
- var height = document.documentElement.clientHeight;
- height -= pageY(ifr) + buffer;
- height = (height < 0) ? 0 : height;
- ifr.style.height = height + 'px';
- };
- if (ifr) {
- ifr.onload = resizeIframe;
- window.onresize = resizeIframe;
- }
- }
-});
diff --git a/integrations/nextcloud/snappymail/js/snappymail.js b/integrations/nextcloud/snappymail/js/snappymail.js
index 52603eae1..f3aae6f49 100644
--- a/integrations/nextcloud/snappymail/js/snappymail.js
+++ b/integrations/nextcloud/snappymail/js/snappymail.js
@@ -8,7 +8,11 @@
// Do the following things once the document is fully loaded.
document.onreadystatechange = () => {
- (document.readyState === 'complete') && watchIFrameTitle();
+ if (document.readyState === 'complete') {
+ watchIFrameTitle();
+ let form = document.querySelector('form.snappymail');
+ form && SnappyMailFormHelper(form);
+ }
};
// The SnappyMail application is already configured to modify the
element
@@ -43,12 +47,11 @@ function watchIFrameTitle() {
observer.observe(target, config);
}
-function SnappyMailFormHelper(sID, sFetchFile, fCallback)
+function SnappyMailFormHelper(oForm)
{
try
{
var
- oForm = document.getElementById('mail-snappymail-' + sID),
oSubmit = document.getElementById('snappymail-save-button'),
sSubmitValue = oSubmit.textContent,
oDesc = oForm.querySelector('.snappymail-result-desc')
@@ -64,7 +67,10 @@ function SnappyMailFormHelper(sID, sFetchFile, fCallback)
oDesc.textContent = '';
oSubmit.textContent = '...';
- fetch(OC.filePath('snappymail', 'fetch', sFetchFile), {
+ let data = new FormData(oForm);
+ data.set('appname', 'snappymail');
+
+ fetch(OC.filePath('snappymail', 'fetch', oForm.getAttribute('action')), {
mode: 'same-origin',
cache: 'no-cache',
redirect: 'error',
@@ -72,7 +78,7 @@ function SnappyMailFormHelper(sID, sFetchFile, fCallback)
credentials: 'same-origin',
method: 'POST',
headers: {},
- body: new FormData(oForm)
+ body: data
})
.then(response => response.json())
.then(oData => {
@@ -90,7 +96,6 @@ function SnappyMailFormHelper(sID, sFetchFile, fCallback)
oDesc.textContent = t('snappymail', 'Error');
}
}
- fCallback?.(bResult, oData);
});
return false;
diff --git a/integrations/nextcloud/snappymail/lib/AppInfo/Application.php b/integrations/nextcloud/snappymail/lib/AppInfo/Application.php
index e830a7df8..b04d6190c 100644
--- a/integrations/nextcloud/snappymail/lib/AppInfo/Application.php
+++ b/integrations/nextcloud/snappymail/lib/AppInfo/Application.php
@@ -5,6 +5,7 @@ namespace OCA\SnappyMail\AppInfo;
use OCA\SnappyMail\Util\SnappyMailHelper;
use OCA\SnappyMail\Controller\FetchController;
use OCA\SnappyMail\Controller\PageController;
+use OCA\SnappyMail\Search\Provider;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootstrap;
@@ -15,14 +16,64 @@ use OCP\IUser;
class Application extends App implements IBootstrap
{
+ public const APP_ID = 'snappymail';
+
+ public function __construct(array $urlParams = [])
+ {
+ parent::__construct(self::APP_ID, $urlParams);
+ }
public function register(IRegistrationContext $context): void
{
+ /**
+ * Controllers
+ */
+ $context->registerService(
+ 'PageController', function($c) {
+ return new PageController(
+ $c->query('AppName'),
+ $c->query('Request')
+ );
+ }
+ );
+
+ $context->registerService(
+ 'FetchController', function($c) {
+ return new FetchController(
+ $c->query('AppName'),
+ $c->query('Request'),
+ $c->getServer()->getAppManager(),
+ $c->query('ServerContainer')->getConfig(),
+ $c->query(IL10N::class)
+ );
+ }
+ );
+
+ /**
+ * Utils
+ */
+ $context->registerService(
+ 'SnappyMailHelper', function($c) {
+ return new SnappyMailHelper();
+ }
+ );
+
+// $context->registerSearchProvider(Provider::class);
}
public function boot(IBootContext $context): void
{
- $this->registerNavigation();
+ $container = $this->getContainer();
+ $container->query('OCP\INavigationManager')->add(function () use ($container) {
+ $urlGenerator = $container->query('OCP\IURLGenerator');
+ return [
+ 'id' => 'snappymail',
+ 'order' => 10,
+ 'href' => $urlGenerator->linkToRoute('snappymail.page.index'),
+ 'icon' => $urlGenerator->imagePath('snappymail', 'logo-64x64.png'),
+ 'name' => \OCP\Util::getL10N('snappymail')->t('Email')
+ ];
+ });
$userSession = \OC::$server->getUserSession();
$userSession->listen('\OC\User', 'postLogin', function($user, $loginName, $password, $isTokenLogin) {
@@ -47,65 +98,4 @@ class Application extends App implements IBootstrap
\RainLoop\Api::LogoutCurrentLogginedUser();
});
}
-
-// public function __construct(string $appName, array $urlParams = [])
- public function __construct()
- {
- parent::__construct('snappymail');
-
- $container = $this->getContainer();
-
- /**
- * Controllers
- */
- $container->registerService(
- 'PageController', function($c) {
- return new PageController(
- $c->query('AppName'),
- $c->query('Request')
- );
- }
- );
-
- $container->registerService(
- 'FetchController', function($c) {
- return new FetchController(
- $c->query('AppName'),
- $c->query('Request'),
- $c->getServer()->getAppManager(),
- $c->query('ServerContainer')->getConfig(),
- $c->query(IL10N::class)
- );
- }
- );
-
- /**
- * Utils
- */
- $container->registerService(
- 'SnappyMailHelper', function($c) {
- return new SnappyMailHelper();
- }
- );
-
- // Add script js/snappymail.js
- \OCP\Util::addScript('snappymail', 'snappymail');
- }
-
- public function registerNavigation()
- {
- $container = $this->getContainer();
-
- $container->query('OCP\INavigationManager')->add(function () use ($container) {
- $urlGenerator = $container->query('OCP\IURLGenerator');
- return [
- 'id' => 'snappymail',
- 'order' => 10,
- 'href' => $urlGenerator->linkToRoute('snappymail.page.index'),
- 'icon' => $urlGenerator->imagePath('snappymail', 'logo-64x64.png'),
- 'name' => \OCP\Util::getL10N('snappymail')->t('Email')
- ];
- });
- }
-
}
diff --git a/integrations/nextcloud/snappymail/lib/Controller/PageController.php b/integrations/nextcloud/snappymail/lib/Controller/PageController.php
index ea381a046..0951ee9e7 100644
--- a/integrations/nextcloud/snappymail/lib/Controller/PageController.php
+++ b/integrations/nextcloud/snappymail/lib/Controller/PageController.php
@@ -24,6 +24,7 @@ class PageController extends Controller
\OC::$server->getNavigationManager()->setActiveEntry('snappymail');
+ \OCP\Util::addScript('snappymail', 'snappymail');
\OCP\Util::addStyle('snappymail', 'style');
$query = '';
diff --git a/integrations/nextcloud/snappymail/lib/Search/Provider.php b/integrations/nextcloud/snappymail/lib/Search/Provider.php
new file mode 100644
index 000000000..e27d46a3b
--- /dev/null
+++ b/integrations/nextcloud/snappymail/lib/Search/Provider.php
@@ -0,0 +1,69 @@
+l10n->t('Mails');
+ }
+
+ public function getOrder(string $route, array $routeParameters): int
+ {
+ if (0 === \strpos($route, Application::APP_ID . '.')) {
+ // Active app, prefer Mail results
+ return -1;
+ }
+ return 20;
+ }
+
+ public function search(IUser $user, ISearchQuery $query): SearchResult
+ {
+ /**
+ * TODO
+ * And use \MailSo\Imap\SearchCriterias
+ */
+
+ return SearchResult::complete(
+ $this->getName(),
+ [
+/*
+ new SearchResultEntry(
+ // thumbnailUrl
+ '',
+ // title
+ \MailSo\Mail\Message->sSubject,
+ // subline
+ \MailSo\Mail\Message->oFrom->ToString(),
+ // resourceUrl
+ $this->urlGenerator->linkToRouteAbsolute(),
+ // icon
+ 'icon-mail',
+ // rounded
+ false
+ ),
+*/
+ ]
+ );
+ }
+}
diff --git a/integrations/nextcloud/snappymail/lib/Settings/AdminSettings.php b/integrations/nextcloud/snappymail/lib/Settings/AdminSettings.php
index 7cd32bd97..9003a30b4 100644
--- a/integrations/nextcloud/snappymail/lib/Settings/AdminSettings.php
+++ b/integrations/nextcloud/snappymail/lib/Settings/AdminSettings.php
@@ -6,41 +6,42 @@ use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\Settings\ISettings;
-class AdminSettings implements ISettings {
-
+class AdminSettings implements ISettings
+{
private $config;
- public function __construct(IConfig $config) {
+ public function __construct(IConfig $config)
+ {
$this->config = $config;
}
- public function getForm() {
+ public function getForm()
+ {
$keys = [
'snappymail-autologin',
'snappymail-autologin-with-email',
'snappymail-embed'
];
-
$parameters = [];
foreach ($keys as $k) {
$v = $this->config->getAppValue('snappymail', $k);
$parameters[$k] = $v;
}
-
$uid = \OC::$server->getUserSession()->getUser()->getUID();
if (\OC_User::isAdminUser($uid)) {
$parameters['snappymail-admin-panel-link'] = SnappyMailHelper::getAppUrl().'?admin';
}
-
+ \OCP\Util::addScript('snappymail', 'snappymail');
return new TemplateResponse('snappymail', 'admin-local', $parameters);
}
- public function getSection() {
+ public function getSection()
+ {
return 'additional';
}
- public function getPriority() {
+ public function getPriority()
+ {
return 50;
}
-
}
diff --git a/integrations/nextcloud/snappymail/lib/Settings/PersonalSettings.php b/integrations/nextcloud/snappymail/lib/Settings/PersonalSettings.php
index 0cf07befa..288a0f8f6 100644
--- a/integrations/nextcloud/snappymail/lib/Settings/PersonalSettings.php
+++ b/integrations/nextcloud/snappymail/lib/Settings/PersonalSettings.php
@@ -21,6 +21,7 @@ class PersonalSettings implements ISettings
'snappymail-email' => $this->config->getUserValue($uid, 'snappymail', 'snappymail-email'),
'snappymail-password' => $this->config->getUserValue($uid, 'snappymail', 'snappymail-password') ? '******' : ''
];
+ \OCP\Util::addScript('snappymail', 'snappymail');
return new TemplateResponse('snappymail', 'personal_settings', $parameters, '');
}
@@ -33,5 +34,4 @@ class PersonalSettings implements ISettings
{
return 50;
}
-
}
diff --git a/integrations/nextcloud/snappymail/templates/admin-local.php b/integrations/nextcloud/snappymail/templates/admin-local.php
index c90f8748f..b33f1987c 100755
--- a/integrations/nextcloud/snappymail/templates/admin-local.php
+++ b/integrations/nextcloud/snappymail/templates/admin-local.php
@@ -1,10 +1,6 @@
-
-