Skip to content

Commit

Permalink
Start data export in lib_export.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jun 11, 2018
1 parent c2fa149 commit c587c01
Show file tree
Hide file tree
Showing 52 changed files with 1,996 additions and 322 deletions.
6 changes: 6 additions & 0 deletions Telegram/Resources/langs/lang.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1653,6 +1653,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_passport_error_cant_read" = "Can't read this file. Please choose an image.";
"lng_passport_bad_name" = "Please use latin characters only.";

"lng_export_title" = "Personal data export";
"lng_export_option_info" = "Personal info";
"lng_export_option_contacts" = "Contacts list";
"lng_export_option_sessions" = "Sessions list";
"lng_export_start" = "Export";

// Wnd specific

"lng_wnd_choose_program_menu" = "Choose Default Program...";
Expand Down
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/base/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ For license and copyright information please follow this link:
*/
#pragma once

#include <QtCore/QObject>
#include <QtCore/QThread>
#include "base/observer.h"
#include "base/flat_map.h"

namespace base {

Expand Down
14 changes: 7 additions & 7 deletions Telegram/SourceFiles/base/unique_any.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ class unique_any final {

unique_any(const unique_any &other) = delete;
unique_any &operator=(const unique_any &other) = delete;

unique_any(unique_any &&other) noexcept
: _impl(std::move(other._impl)) {
}

unique_any &operator=(unique_any &&other) noexcept {
_impl = std::move(other._impl);
return *this;
Expand All @@ -88,7 +88,7 @@ class unique_any final {
std::forward<Value>(other),
std::is_copy_constructible<std::decay_t<Value>>()) {
}

template <
typename Value,
typename = std::enable_if_t<
Expand All @@ -106,7 +106,7 @@ class unique_any final {
}
return *this;
}

template <
typename Value,
typename ...Args,
Expand Down Expand Up @@ -143,7 +143,7 @@ class unique_any final {
unique_any(Value &&other, std::true_type)
: _impl(std::forward<Value>(other)) {
}

template <
typename Value,
typename = std::enable_if_t<
Expand Down Expand Up @@ -177,7 +177,7 @@ inline void swap(unique_any &a, unique_any &b) noexcept {
template <
typename Value,
typename ...Args>
inline auto make_any(Args &&...args)
inline auto make_any(Args &&...args)
-> std::enable_if_t<
std::is_copy_constructible_v<std::decay_t<Value>>,
unique_any> {
Expand All @@ -187,7 +187,7 @@ inline auto make_any(Args &&...args)
template <
typename Value,
typename ...Args>
inline auto make_any(Args &&...args)
inline auto make_any(Args &&...args)
-> std::enable_if_t<
!std::is_copy_constructible_v<std::decay_t<Value>>
&& std::is_move_constructible_v<std::decay_t<Value>>,
Expand Down
4 changes: 2 additions & 2 deletions Telegram/SourceFiles/codegen/scheme/codegen_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ def addTextSerializeInit(lst, dct):
getters += '\tconst MTPD' + name + ' &c_' + name + '() const;\n'; # const getter
constructsBodies += 'const MTPD' + name + ' &MTP' + restype + '::c_' + name + '() const {\n';
if (withType):
constructsBodies += '\tAssert(_type == mtpc_' + name + ');\n';
constructsBodies += '\tExpects(_type == mtpc_' + name + ');\n\n';
constructsBodies += '\treturn queryData<MTPD' + name + '>();\n';
constructsBodies += '}\n';

Expand Down Expand Up @@ -771,7 +771,7 @@ def addTextSerializeInit(lst, dct):
typesText += '\tmtpTypeId type() const;\n'; # type id method
methods += 'mtpTypeId MTP' + restype + '::type() const {\n';
if (withType):
methods += '\tAssert(_type != 0);\n';
methods += '\tExpects(_type != 0);\n\n';
methods += '\treturn _type;\n';
else:
methods += '\treturn mtpc_' + v[0][0] + ';\n';
Expand Down
2 changes: 0 additions & 2 deletions Telegram/SourceFiles/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ enum {

MTPKillFileSessionTimeout = 5000, // how much time without upload / download causes additional session kill

MTPDebugBufferSize = 1024 * 1024, // 1 mb start size

MaxUsersPerInvite = 100, // max users in one super group invite request

MTPChannelGetDifferenceLimit = 100,
Expand Down
4 changes: 3 additions & 1 deletion Telegram/SourceFiles/core/basic_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ For license and copyright information please follow this link:
#include <memory>
#include <ctime>
#include <functional>
#include <gsl/gsl>

#include <crl/crl.h>
#include "base/build_config.h"
#include "base/ordered_set.h"
#include "base/unique_function.h"
Expand All @@ -39,5 +39,7 @@ using uint64 = quint64;
using float32 = float;
using float64 = double;

using TimeMs = int64;

#define qsl(s) QStringLiteral(s)
#define qstr(s) QLatin1String((s), sizeof(s) - 1)
14 changes: 8 additions & 6 deletions Telegram/SourceFiles/core/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ static_assert(sizeof(MTPdouble) == 8, "Basic types size check failed");
// Unixtime functions

namespace {

std::atomic<int> GlobalAtomicRequestId = 0;

QReadWriteLock unixtimeLock;
volatile int32 unixtimeDelta = 0;
volatile bool unixtimeWasSet = false;
volatile uint64 _msgIdStart, _msgIdLocal = 0, _msgIdMsStart;
int32 _reqId = 0;

void _initMsgIdConstants() {
#ifdef Q_OS_WIN
Expand Down Expand Up @@ -433,12 +435,12 @@ uint64 msgid() {
return result + (_msgIdLocal += 4);
}

int32 reqid() {
QWriteLocker locker(&unixtimeLock);
if (_reqId == INT_MAX) {
_reqId = 0;
int GetNextRequestId() {
const auto result = ++GlobalAtomicRequestId;
if (result == std::numeric_limits<int>::max() / 2) {
GlobalAtomicRequestId = 0;
}
return ++_reqId;
return result;
}

// crc32 hash, taken somewhere from the internet
Expand Down
27 changes: 4 additions & 23 deletions Telegram/SourceFiles/core/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ For license and copyright information please follow this link:
*/
#pragma once

#include <set>
#include "logs.h"
#include "core/basic_types.h"
#include "base/flags.h"
#include "base/algorithm.h"
#include "base/assertion.h"

// Define specializations for QByteArray for Qt 5.3.2, because
// QByteArray in Qt 5.3.2 doesn't declare "pointer" subtype.
Expand Down Expand Up @@ -179,33 +182,12 @@ inline void accumulate_max(T &a, const T &b) { if (a < b) a = b; }
template <typename T>
inline void accumulate_min(T &a, const T &b) { if (a > b) a = b; }

class Exception : public std::exception {
public:
Exception(const QString &msg, bool isFatal = true) : _fatal(isFatal), _msg(msg.toUtf8()) {
LOG(("Exception: %1").arg(msg));
}
bool fatal() const {
return _fatal;
}

virtual const char *what() const throw() {
return _msg.constData();
}
virtual ~Exception() throw() {
}

private:
bool _fatal;
QByteArray _msg;

};

using TimeId = int32;
void unixtimeInit();
void unixtimeSet(TimeId serverTime, bool force = false);
TimeId unixtime();
uint64 msgid();
int32 reqid();
int GetNextRequestId();

QDateTime ParseDateTime(TimeId serverTime);

Expand All @@ -224,7 +206,6 @@ void finish();

}

using TimeMs = int64;
bool checkms(); // returns true if time has changed
TimeMs getms(bool checked = false);

Expand Down
Loading

0 comments on commit c587c01

Please sign in to comment.