2016-10-02 09:30:28 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
|
|
|
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|
|
|
*/
|
|
|
|
#include "stdafx.h"
|
2016-10-02 13:54:27 +00:00
|
|
|
#include "window/notifications_manager.h"
|
2016-10-02 09:30:28 +00:00
|
|
|
|
|
|
|
#include "platform/platform_notifications_manager.h"
|
2016-10-02 13:54:27 +00:00
|
|
|
#include "window/notifications_manager_default.h"
|
2016-10-02 09:30:28 +00:00
|
|
|
#include "lang.h"
|
|
|
|
|
|
|
|
namespace Window {
|
|
|
|
namespace Notifications {
|
|
|
|
|
|
|
|
void start() {
|
2016-10-02 13:54:27 +00:00
|
|
|
Default::start();
|
2016-10-02 09:30:28 +00:00
|
|
|
Platform::Notifications::start();
|
|
|
|
}
|
|
|
|
|
2016-10-02 13:54:27 +00:00
|
|
|
Manager *manager() {
|
2016-10-02 09:30:28 +00:00
|
|
|
if (auto result = Platform::Notifications::manager()) {
|
|
|
|
return result;
|
|
|
|
}
|
2016-10-02 13:54:27 +00:00
|
|
|
return Default::manager();
|
2016-10-02 09:30:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void finish() {
|
|
|
|
Platform::Notifications::finish();
|
2016-10-02 13:54:27 +00:00
|
|
|
Default::finish();
|
2016-10-02 09:30:28 +00:00
|
|
|
}
|
|
|
|
|
2016-10-02 13:54:27 +00:00
|
|
|
void NativeManager::doShowNotification(HistoryItem *item, int forwardedCount) {
|
2016-10-02 09:30:28 +00:00
|
|
|
auto hideEverything = (App::passcoded() || Global::ScreenIsLocked());
|
|
|
|
auto hideName = hideEverything || (Global::NotifyView() > dbinvShowName);
|
|
|
|
auto hidePreview = hideEverything || (Global::NotifyView() > dbinvShowPreview);
|
|
|
|
|
|
|
|
QString title = hideName ? qsl("Telegram Desktop") : item->history()->peer->name;
|
|
|
|
QString subtitle = hideName ? QString() : item->notificationHeader();
|
|
|
|
bool showUserpic = hideName ? false : true;
|
|
|
|
|
|
|
|
QString msg = hidePreview ? lang(lng_notification_preview) : (forwardedCount < 2 ? item->notificationText() : lng_forward_messages(lt_count, forwardedCount));
|
|
|
|
bool showReplyButton = hidePreview ? false : item->history()->peer->canWrite();
|
|
|
|
|
2016-10-02 13:54:27 +00:00
|
|
|
doShowNativeNotification(item->history()->peer, item->id, title, subtitle, showUserpic, msg, showReplyButton);
|
2016-10-02 09:30:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Notifications
|
|
|
|
} // namespace Window
|