mirror of https://github.com/procxx/kepka.git
offering to send current username in crash report
This commit is contained in:
parent
b38163b026
commit
f25e63bad7
|
@ -413,6 +413,9 @@ namespace App {
|
|||
|
||||
QString pname = (showPhoneChanged || phoneChanged || nameChanged) ? ((showPhone && !phone.isEmpty()) ? formatPhone(phone) : QString()) : data->nameOrPhone;
|
||||
|
||||
if (!minimal && d.is_self() && uname != data->username) {
|
||||
SignalHandlers::setSelfUsername(uname);
|
||||
}
|
||||
data->setName(fname, lname, pname, uname);
|
||||
if (d.has_photo()) {
|
||||
data->setPhoto(d.vphoto);
|
||||
|
|
|
@ -3858,20 +3858,7 @@ void HistoryWidget::updateReportSpamStatus() {
|
|||
void HistoryWidget::requestReportSpamSetting() {
|
||||
if (_reportSpamSettingRequestId >= 0 || !_peer) return;
|
||||
|
||||
bool outFound = false;
|
||||
for (auto i : _history->blocks) {
|
||||
for (auto j : i->items) {
|
||||
if (j->out()) {
|
||||
outFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (outFound) {
|
||||
_reportSpamStatus = dbiprsNoButton;
|
||||
} else {
|
||||
_reportSpamSettingRequestId = MTP::send(MTPmessages_GetPeerSettings(_peer->input), rpcDone(&HistoryWidget::reportSpamSettingDone), rpcFail(&HistoryWidget::reportSpamSettingFail));
|
||||
}
|
||||
_reportSpamSettingRequestId = MTP::send(MTPmessages_GetPeerSettings(_peer->input), rpcDone(&HistoryWidget::reportSpamSettingDone), rpcFail(&HistoryWidget::reportSpamSettingFail));
|
||||
}
|
||||
|
||||
void HistoryWidget::reportSpamSettingDone(const MTPPeerSettings &result, mtpRequestId req) {
|
||||
|
@ -6876,6 +6863,7 @@ bool HistoryWidget::pinnedMsgVisibilityUpdated() {
|
|||
_pinnedBar->shadow.show();
|
||||
}
|
||||
connect(&_pinnedBar->cancel, SIGNAL(clicked()), this, SLOT(onPinnedHide()));
|
||||
_reportSpamPanel.raise();
|
||||
_sideShadow.raise();
|
||||
_topShadow.raise();
|
||||
updatePinnedBar();
|
||||
|
|
|
@ -739,8 +739,8 @@ namespace SignalHandlers {
|
|||
if (!LoggingCrashHeaderWritten) {
|
||||
LoggingCrashHeaderWritten = true;
|
||||
const AnnotationsMap c_ProcessAnnotations(ProcessAnnotations);
|
||||
for (AnnotationsMap::const_iterator i = c_ProcessAnnotations.begin(), e = c_ProcessAnnotations.end(); i != e; ++i) {
|
||||
dump() << i->first.c_str() << ": " << i->second.c_str() << "\n";
|
||||
for (const auto &i : c_ProcessAnnotations) {
|
||||
dump() << i.first.c_str() << ": " << i.second.c_str() << "\n";
|
||||
}
|
||||
psWriteDump();
|
||||
dump() << "\n";
|
||||
|
@ -835,6 +835,7 @@ namespace SignalHandlers {
|
|||
}
|
||||
|
||||
bool SetSignalHandlers = true;
|
||||
bool CrashLogged = false;
|
||||
#if !defined Q_OS_MAC || defined MAC_USE_BREAKPAD
|
||||
google_breakpad::ExceptionHandler* BreakpadExceptionHandler = 0;
|
||||
|
||||
|
@ -846,6 +847,9 @@ namespace SignalHandlers {
|
|||
bool DumpCallback(const google_breakpad::MinidumpDescriptor &md, void *context, bool success)
|
||||
#endif
|
||||
{
|
||||
if (CrashLogged) return success;
|
||||
CrashLogged = true;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
BreakpadDumpPathW = _minidump_id;
|
||||
Handler(-1);
|
||||
|
@ -1009,4 +1013,12 @@ namespace SignalHandlers {
|
|||
}
|
||||
}
|
||||
|
||||
void setSelfUsername(const QString &username) {
|
||||
if (username.trimmed().isEmpty()) {
|
||||
ProcessAnnotations.erase("Username");
|
||||
} else {
|
||||
ProcessAnnotations["Username"] = username.toUtf8().constData();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -107,4 +107,6 @@ namespace SignalHandlers {
|
|||
Status restart(); // can be only CantOpen or Started
|
||||
void finish();
|
||||
|
||||
void setSelfUsername(const QString &username);
|
||||
|
||||
}
|
||||
|
|
|
@ -2041,6 +2041,25 @@ void PreLaunchButton::setText(const QString &text) {
|
|||
resize(sizeHint());
|
||||
}
|
||||
|
||||
PreLaunchCheckbox::PreLaunchCheckbox(QWidget *parent) : QCheckBox(parent) {
|
||||
setTristate(false);
|
||||
setCheckState(Qt::Checked);
|
||||
|
||||
QFont closeFont(font());
|
||||
closeFont.setFamily(qsl("Open Sans Semibold"));
|
||||
closeFont.setPixelSize(static_cast<PreLaunchWindow*>(parent)->basicSize());
|
||||
setFont(closeFont);
|
||||
|
||||
setCursor(Qt::PointingHandCursor);
|
||||
show();
|
||||
};
|
||||
|
||||
void PreLaunchCheckbox::setText(const QString &text) {
|
||||
QCheckBox::setText(text);
|
||||
updateGeometry();
|
||||
resize(sizeHint());
|
||||
}
|
||||
|
||||
NotStartedWindow::NotStartedWindow()
|
||||
: _label(this)
|
||||
, _log(this)
|
||||
|
@ -2097,6 +2116,7 @@ LastCrashedWindow::LastCrashedWindow()
|
|||
, _showReport(this)
|
||||
, _saveReport(this)
|
||||
, _getApp(this)
|
||||
, _includeUsername(this)
|
||||
, _reportText(QString::fromUtf8(Sandbox::LastCrashDump()))
|
||||
, _reportShown(false)
|
||||
, _reportSaved(false)
|
||||
|
@ -2111,6 +2131,8 @@ LastCrashedWindow::LastCrashedWindow()
|
|||
, _updatingSkip(this, false)
|
||||
#endif
|
||||
{
|
||||
excludeReportUsername();
|
||||
|
||||
if (!cDevVersion() && !cBetaVersion()) { // currently accept crash reports only from testers
|
||||
_sendingState = SendingNoReport;
|
||||
}
|
||||
|
@ -2214,7 +2236,9 @@ LastCrashedWindow::LastCrashedWindow()
|
|||
_yourReportName.setCursor(style::cur_text);
|
||||
_yourReportName.setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
|
||||
_report.setPlainText(_reportText);
|
||||
_includeUsername.setText(qsl("Include username @%1 as your contact info").arg(_reportUsername));
|
||||
|
||||
_report.setPlainText(_reportTextNoUsername);
|
||||
|
||||
_showReport.setText(qsl("VIEW REPORT"));
|
||||
connect(&_showReport, SIGNAL(clicked()), this, SLOT(onViewReport()));
|
||||
|
@ -2247,17 +2271,38 @@ void LastCrashedWindow::onSaveReport() {
|
|||
if (!to.isEmpty()) {
|
||||
QFile file(to);
|
||||
if (file.open(QIODevice::WriteOnly)) {
|
||||
file.write(Sandbox::LastCrashDump());
|
||||
file.write(getCrashReportRaw());
|
||||
_reportSaved = true;
|
||||
updateControls();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray LastCrashedWindow::getCrashReportRaw() const {
|
||||
QByteArray result(Sandbox::LastCrashDump());
|
||||
if (!_reportUsername.isEmpty() && _includeUsername.checkState() != Qt::Checked) {
|
||||
result.replace((qsl("Username: ") + _reportUsername).toUtf8(), "Username: _not_included_");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void LastCrashedWindow::onGetApp() {
|
||||
QDesktopServices::openUrl(qsl("https://desktop.telegram.org"));
|
||||
}
|
||||
|
||||
void LastCrashedWindow::excludeReportUsername() {
|
||||
QString prefix = qstr("Username:");
|
||||
QStringList lines = _reportText.split('\n');
|
||||
for (int32 i = 0, l = lines.size(); i < l; ++i) {
|
||||
if (lines.at(i).trimmed().startsWith(prefix)) {
|
||||
_reportUsername = lines.at(i).trimmed().mid(prefix.size()).trimmed();
|
||||
lines.removeAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
_reportTextNoUsername = _reportUsername.isEmpty() ? _reportText : lines.join('\n');
|
||||
}
|
||||
|
||||
QString LastCrashedWindow::getReportField(const QLatin1String &name, const QLatin1String &prefix) {
|
||||
QStringList lines = _reportText.split('\n');
|
||||
for (int32 i = 0, l = lines.size(); i < l; ++i) {
|
||||
|
@ -2441,7 +2486,7 @@ void LastCrashedWindow::onCheckingFinished() {
|
|||
QHttpPart reportPart;
|
||||
reportPart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/octet-stream"));
|
||||
reportPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"report\"; filename=\"report.telegramcrash\""));
|
||||
reportPart.setBody(Sandbox::LastCrashDump());
|
||||
reportPart.setBody(getCrashReportRaw());
|
||||
multipart->append(reportPart);
|
||||
|
||||
QString dmpName = minidumpFileName();
|
||||
|
@ -2520,6 +2565,7 @@ void LastCrashedWindow::updateControls() {
|
|||
_continue.hide();
|
||||
_pleaseSendReport.hide();
|
||||
_yourReportName.hide();
|
||||
_includeUsername.hide();
|
||||
_getApp.hide();
|
||||
_showReport.hide();
|
||||
_report.hide();
|
||||
|
@ -2537,6 +2583,7 @@ void LastCrashedWindow::updateControls() {
|
|||
if (_sendingState == SendingNoReport) {
|
||||
_pleaseSendReport.hide();
|
||||
_yourReportName.hide();
|
||||
_includeUsername.hide();
|
||||
_getApp.hide();
|
||||
_showReport.hide();
|
||||
_report.hide();
|
||||
|
@ -2549,6 +2596,12 @@ void LastCrashedWindow::updateControls() {
|
|||
h += _showReport.height() + padding + _yourReportName.height() + padding;
|
||||
_pleaseSendReport.show();
|
||||
_yourReportName.show();
|
||||
if (_reportUsername.isEmpty()) {
|
||||
_includeUsername.hide();
|
||||
} else {
|
||||
h += _includeUsername.height() + padding;
|
||||
_includeUsername.show();
|
||||
}
|
||||
if (_sendingState == SendingTooOld || _sendingState == SendingUnofficial) {
|
||||
QString verStr = getReportField(qstr("version"), qstr("Version:"));
|
||||
qint64 ver = verStr.isEmpty() ? 0 : verStr.toLongLong();
|
||||
|
@ -2557,6 +2610,10 @@ void LastCrashedWindow::updateControls() {
|
|||
_getApp.show();
|
||||
h -= _yourReportName.height() + padding; // hide report name
|
||||
_yourReportName.hide();
|
||||
if (!_reportUsername.isEmpty()) {
|
||||
h -= _includeUsername.height() + padding;
|
||||
_includeUsername.hide();
|
||||
}
|
||||
} else {
|
||||
_getApp.hide();
|
||||
}
|
||||
|
@ -2612,6 +2669,7 @@ void LastCrashedWindow::updateControls() {
|
|||
_getApp.hide();
|
||||
_pleaseSendReport.hide();
|
||||
_yourReportName.hide();
|
||||
_includeUsername.hide();
|
||||
_showReport.hide();
|
||||
_report.hide();
|
||||
_minidump.hide();
|
||||
|
@ -2634,6 +2692,7 @@ void LastCrashedWindow::updateControls() {
|
|||
if (_sendingState == SendingNoReport) {
|
||||
_pleaseSendReport.hide();
|
||||
_yourReportName.hide();
|
||||
_includeUsername.hide();
|
||||
_showReport.hide();
|
||||
_report.hide();
|
||||
_minidump.hide();
|
||||
|
@ -2646,6 +2705,12 @@ void LastCrashedWindow::updateControls() {
|
|||
h += _showReport.height() + padding + _yourReportName.height() + padding;
|
||||
_pleaseSendReport.show();
|
||||
_yourReportName.show();
|
||||
if (_reportUsername.isEmpty()) {
|
||||
_includeUsername.hide();
|
||||
} else {
|
||||
h += _includeUsername.height() + padding;
|
||||
_includeUsername.show();
|
||||
}
|
||||
if (_reportShown) {
|
||||
h += (_pleaseSendReport.height() * 12.5) + padding + (_minidumpName.isEmpty() ? 0 : (_minidump.height() + padding));
|
||||
_report.show();
|
||||
|
@ -2888,6 +2953,7 @@ void LastCrashedWindow::resizeEvent(QResizeEvent *e) {
|
|||
_pleaseSendReport.move(padding, padding * 2 + _networkSettings.height() + _networkSettings.height() + padding + (_showReport.height() - _pleaseSendReport.height()) / 2);
|
||||
_showReport.move(padding * 2 + _pleaseSendReport.width(), padding * 2 + _networkSettings.height() + _networkSettings.height() + padding);
|
||||
_yourReportName.move(padding, _showReport.y() + _showReport.height() + padding);
|
||||
_includeUsername.move(padding, _yourReportName.y() + _yourReportName.height() + padding);
|
||||
_getApp.move((width() - _getApp.width()) / 2, _showReport.y() + _showReport.height() + padding);
|
||||
|
||||
if (_sendingState == SendingFail || _sendingState == SendingProgress) {
|
||||
|
@ -2909,10 +2975,15 @@ void LastCrashedWindow::resizeEvent(QResizeEvent *e) {
|
|||
_pleaseSendReport.move(padding, padding * 2 + _networkSettings.height() + _networkSettings.height() + padding + _getApp.height() + padding + (_showReport.height() - _pleaseSendReport.height()) / 2);
|
||||
_showReport.move(padding * 2 + _pleaseSendReport.width(), padding * 2 + _networkSettings.height() + _networkSettings.height() + padding + _getApp.height() + padding);
|
||||
_yourReportName.move(padding, _showReport.y() + _showReport.height() + padding);
|
||||
_includeUsername.move(padding, _yourReportName.y() + _yourReportName.height() + padding);
|
||||
|
||||
_networkSettings.move(padding * 2 + _pleaseSendReport.width(), padding * 2 + _networkSettings.height() + _networkSettings.height() + padding + _getApp.height() + padding);
|
||||
#endif
|
||||
_report.setGeometry(padding, _yourReportName.y() + _yourReportName.height() + padding, width() - 2 * padding, _pleaseSendReport.height() * 12.5);
|
||||
if (_reportUsername.isEmpty()) {
|
||||
_report.setGeometry(padding, _yourReportName.y() + _yourReportName.height() + padding, width() - 2 * padding, _pleaseSendReport.height() * 12.5);
|
||||
} else {
|
||||
_report.setGeometry(padding, _includeUsername.y() + _includeUsername.height() + padding, width() - 2 * padding, _pleaseSendReport.height() * 12.5);
|
||||
}
|
||||
_minidump.move(padding, _report.y() + _report.height() + padding);
|
||||
_saveReport.move(_showReport.x(), _showReport.y());
|
||||
|
||||
|
|
|
@ -397,6 +397,12 @@ public:
|
|||
void setText(const QString &text);
|
||||
};
|
||||
|
||||
class PreLaunchCheckbox : public QCheckBox {
|
||||
public:
|
||||
PreLaunchCheckbox(QWidget *parent);
|
||||
void setText(const QString &text);
|
||||
};
|
||||
|
||||
class NotStartedWindow : public PreLaunchWindow {
|
||||
public:
|
||||
|
||||
|
@ -467,10 +473,16 @@ private:
|
|||
PreLaunchLabel _label, _pleaseSendReport, _yourReportName, _minidump;
|
||||
PreLaunchLog _report;
|
||||
PreLaunchButton _send, _sendSkip, _networkSettings, _continue, _showReport, _saveReport, _getApp;
|
||||
PreLaunchCheckbox _includeUsername;
|
||||
|
||||
QString _minidumpName, _minidumpFull, _reportText;
|
||||
QString _reportUsername, _reportTextNoUsername;
|
||||
QByteArray getCrashReportRaw() const;
|
||||
|
||||
bool _reportShown, _reportSaved;
|
||||
|
||||
void excludeReportUsername();
|
||||
|
||||
enum SendingState {
|
||||
SendingNoReport,
|
||||
SendingUpdateCheck,
|
||||
|
|
Loading…
Reference in New Issue