Skip to content

Commit

Permalink
Merge bc9b085 into 09f8d60
Browse files Browse the repository at this point in the history
  • Loading branch information
leha-bot committed May 12, 2018
2 parents 09f8d60 + bc9b085 commit 52d5b47
Show file tree
Hide file tree
Showing 416 changed files with 1,492 additions and 7,998 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
cmake_minimum_required(VERSION 3.10)
project(kepka-desktop)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cotire/CMake;${PROJECT_SOURCE_DIR}/modules/")
include(cotire)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules/")
include(CTest)

if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.10)
Expand Down
22 changes: 6 additions & 16 deletions Telegram/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ if (PACKAGED_BUILD)
add_definitions(-DTDESKTOP_DISABLE_DESKTOP_FILE_GENERATION)
endif()


#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -H")

##================================================
## Codegen Tools
##================================================
Expand Down Expand Up @@ -189,8 +192,6 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
# cmakelists file. To do: get rid of the PCH requirement for more flexible build structure.

add_executable(Telegram WIN32 MACOSX_BUNDLE
SourceFiles/stdafx.cpp

${CMAKE_CURRENT_BINARY_DIR}/styles/palette.cpp
${CMAKE_CURRENT_BINARY_DIR}/numbers.cpp
${CMAKE_CURRENT_BINARY_DIR}/lang_auto.cpp
Expand Down Expand Up @@ -568,7 +569,7 @@ include_directories(ThirdParty) # For minizip/ but we use fully-qualified
include_directories(ThirdParty/GSL/include ThirdParty/variant/include
ThirdParty/emoji_suggestions ThirdParty/libtgvoip)

include_directories(SourceFiles SourceFiles/core)
include_directories(SourceFiles)

include_directories(${OPENAL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}
${OPUS_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS} ${ALSA_INCLUDE_DIRS} ${PULSEAUDIO_INCLUDE_DIR})
Expand All @@ -581,9 +582,9 @@ endif()

if (WIN32)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -D_USING_V110_SDK71_
-DWIN32 -D_WINDOWS -D_UNICODE -DUNICODE
-DWIN32 -D_WINDOWS -D_UNICODE -DUNICODE
-DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP
-DHAVE_STDINT_H)
-DHAVE_STDINT_H -DNOMINMAX)
endif()

add_definitions(-DAL_LIBTYPE_STATIC)
Expand Down Expand Up @@ -706,17 +707,6 @@ endif()

target_link_libraries(Telegram Threads::Threads)

set_target_properties(Telegram
PROPERTIES
COTIRE_CXX_PREFIX_HEADER_INIT SourceFiles/stdafx.h
COTIRE_ADD_UNITY_BUILD FALSE
)
cotire(Telegram)

# See https://github.com/sakra/cotire/blob/master/MANUAL.md#objective-c
# ObjC and ObjC++ files cannot be cotired, so they have to include appropriate Qt and Tg
# headers themselves, this applies to macOS platform sources.

##================================================
## Tests
##================================================
Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/apiwrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "window/notifications_manager.h"
#include "chat_helpers/message_field.h"
#include "chat_helpers/stickers.h"
#include "base/algorithm.h" // for_each_apply

namespace {

Expand Down
4 changes: 4 additions & 0 deletions Telegram/SourceFiles/apiwrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "mtproto/sender.h"
#include "base/flat_map.h"
#include "base/flat_set.h"
#include "structs.h"
#include "facades.h"

class AuthSession;

Expand All @@ -43,6 +45,8 @@ inline const MTPVector<MTPChat> *getChatsFromMessagesChats(const MTPmessages_Cha

} // namespace Api

class History;

class ApiWrap : private MTP::Sender, private base::Subscriber {
public:
ApiWrap(not_null<AuthSession*> session);
Expand Down
5 changes: 5 additions & 0 deletions Telegram/SourceFiles/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "window/notifications_manager.h"
#include "platform/platform_notifications_manager.h"

#include <QLinkedList> // used in list of PhotosData
#include <QFontDatabase>
#include <QBuffer>
#include <QImageReader>

namespace {
App::LaunchState _launchState = App::Launched;

Expand Down
5 changes: 5 additions & 0 deletions Telegram/SourceFiles/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/
#pragma once

#include <QString>
#include <QNetworkAccessManager>

#include "ui/animation.h"
#include "core/basic_types.h"
#include "history/history.h"
#include "history/history_item.h"
#include "layout.h"
#include "media/media_clip_reader.h"

class Messenger;
class MainWindow;
Expand Down
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "messenger.h"
#include "base/timer.h"

#include <QDesktopWidget>
#include <QScreen>

namespace {

// @todo are there no other ways to get/set hex?
Expand Down
5 changes: 4 additions & 1 deletion Telegram/SourceFiles/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/
#pragma once

#include "stdafx.h"
#include <QApplication>
#include <QLocalSocket>
#include <QLocalServer>

class Messenger;

class Application : public QApplication {
Q_OBJECT
Expand Down
2 changes: 2 additions & 0 deletions Telegram/SourceFiles/auth_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "window/section_widget.h"
#include "chat_helpers/tabbed_selector.h"

#include "app.h" // App::user

namespace {

constexpr auto kAutoLockTimeoutLateMs = TimeMs(3000);
Expand Down
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/auth_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#pragma once

#include "base/timer.h"
#include "structs.h"

namespace Storage {
class Downloader;
Expand All @@ -43,6 +44,8 @@ enum class SelectorTab;
} // namespace ChatHelpers

class ApiWrap;
class History;
class HistoryItem;

class AuthSessionData final {
public:
Expand Down
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/base/algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/
#pragma once

#include <iterator>
#include <algorithm>

namespace base {

// @todo use ranges-v3 here
Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/base/assertion.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#pragma once

#include <cstdlib>
#include <gsl/gsl>

namespace base {
namespace assertion {
Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/base/flat_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#pragma once

#include <deque>
#include <algorithm>
#include "base/optional.h"

namespace base {
Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/base/flat_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#pragma once

#include <deque>
#include <algorithm>

namespace base {

Expand Down
2 changes: 2 additions & 0 deletions Telegram/SourceFiles/base/functors.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/
#pragma once

#include <utility>

namespace base {
namespace functors {

Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/base/lambda_guard.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#pragma once

#include <QPointer>
#include "base/lambda.h"

namespace base {

Expand Down
126 changes: 126 additions & 0 deletions Telegram/SourceFiles/base/object_ptr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
This file is part of Kepka - The Unofficial Telegram Desktop client,
see https://github.com/procxx/kepka
Kepka 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/procxx/kepka/blob/master/LICENSE
Copyright (c) 2018 pro.cxx Community
*/
#pragma once

#include <QObject>
#include <QPointer>

// Smart pointer for QObject*, has move semantics, destroys object if it doesn't have a parent.
template <typename Object>
class object_ptr {
public:
object_ptr(std::nullptr_t) {
}

// No default constructor, but constructors with at least
// one argument are simply make functions.
template <typename Parent, typename... Args>
explicit object_ptr(Parent &&parent, Args&&... args) : _object(new Object(std::forward<Parent>(parent), std::forward<Args>(args)...)) {
}

object_ptr(const object_ptr &other) = delete;
object_ptr &operator=(const object_ptr &other) = delete;
object_ptr(object_ptr &&other) : _object(base::take(other._object)) {
}
object_ptr &operator=(object_ptr &&other) {
auto temp = std::move(other);
destroy();
std::swap(_object, temp._object);
return *this;
}

template <typename OtherObject, typename = std::enable_if_t<std::is_base_of<Object, OtherObject>::value>>
object_ptr(object_ptr<OtherObject> &&other) : _object(base::take(other._object)) {
}

template <typename OtherObject, typename = std::enable_if_t<std::is_base_of<Object, OtherObject>::value>>
object_ptr &operator=(object_ptr<OtherObject> &&other) {
_object = base::take(other._object);
return *this;
}

object_ptr &operator=(std::nullptr_t) {
_object = nullptr;
return *this;
}

// So we can pass this pointer to methods like connect().
Object *data() const {
return static_cast<Object*>(_object.data());
}
operator Object*() const {
return data();
}

explicit operator bool() const {
return _object != nullptr;
}

Object *operator->() const {
return data();
}
Object &operator*() const {
return *data();
}

// Use that instead "= new Object(parent, ...)"
template <typename Parent, typename... Args>
void create(Parent &&parent, Args&&... args) {
destroy();
_object = new Object(std::forward<Parent>(parent), std::forward<Args>(args)...);
}
void destroy() {
delete base::take(_object);
}
void destroyDelayed() {
if (_object) {
if (auto widget = base::up_cast<QWidget*>(data())) {
widget->hide();
}
base::take(_object)->deleteLater();
}
}

~object_ptr() {
if (auto pointer = _object) {
if (!pointer->parent()) {
destroy();
}
}
}

template <typename ResultType, typename SourceType>
friend object_ptr<ResultType> static_object_cast(object_ptr<SourceType> source);

private:
template <typename OtherObject>
friend class object_ptr;

QPointer<QObject> _object;

};

template <typename ResultType, typename SourceType>
inline object_ptr<ResultType> static_object_cast(object_ptr<SourceType> source) {
auto result = object_ptr<ResultType>(nullptr);
result._object = static_cast<ResultType*>(base::take(source._object).data());
return std::move(result);
}
1 change: 1 addition & 0 deletions Telegram/SourceFiles/base/observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/
#include "base/observer.h"
#include "facades.h"

namespace base {
namespace internal {
Expand Down
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/base/observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include <vector>
#include <deque>
#include <QSharedPointer>
#include "base/assertion.h"
#include "base/lambda.h"
#include "base/type_traits.h"
#include "core/utils.h"

namespace base {
namespace internal {
Expand Down
2 changes: 2 additions & 0 deletions Telegram/SourceFiles/base/openssl_help.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include <openssl/sha.h>
#include <openssl/rand.h>

#include "base/assertion.h"
#include "core/utils.h"
namespace openssl {

class Context {
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/base/ordered_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/
#pragma once

#include <QtCore/QMap>
#include <QMap>

// ordered set template based on QMap
template <typename T>
Expand Down
5 changes: 5 additions & 0 deletions Telegram/SourceFiles/base/parse_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/
#pragma once

#include <QByteArray>
#include <QLatin1String>
#include "base/assertion.h"


namespace base {
namespace parse {

Expand Down
Loading

0 comments on commit 52d5b47

Please sign in to comment.