summaryrefslogtreecommitdiff
path: root/raveos-calamares/0007-raveos-naplo-hozzajarulas.patch
blob: 91d835a40c01f83513fcab1b6e8ca89946f83d05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
--- a/src/libcalamaresui/ViewManager.cpp
+++ b/src/libcalamaresui/ViewManager.cpp
@@ -34,6 +34,7 @@
 #include <QFile>
 #include <QMessageBox>
 #include <QMetaObject>
+#include <QProcess>
 
 #define UPDATE_BUTTON_PROPERTY( name, value ) \
     do \
@@ -171,12 +172,14 @@
     QString heading = Calamares::Settings::instance()->isSetupMode() ? tr( "Setup Failed", "@title" )
                                                                      : tr( "Installation Failed", "@title" );
 
-    ErrorDialog* errorDialog = new ErrorDialog();
+    ErrorDialog* errorDialog = new ErrorDialog( m_widget->window() );
+    errorDialog->setWindowModality( Qt::ApplicationModal );
     errorDialog->setWindowTitle( tr( "Error", "@title" ) );
     errorDialog->setHeading( "<strong>" + heading + "</strong>" );
     errorDialog->setInformativeText( message );
     errorDialog->setShouldOfferWebPaste( Calamares::Branding::instance()->uploadServer() );
     errorDialog->setDetails( details );
+    errorDialog->adjustSize();
     errorDialog->show();
 
     cDebug() << "Calamares will quit when the dialog closes.";
@@ -184,9 +187,10 @@
              &QDialog::finished,
              [ errorDialog ]( int result )
              {
-                 if ( result == QDialog::Accepted && errorDialog->shouldOfferWebPaste() )
+                 if ( result == QDialog::Accepted && errorDialog->shouldOfferWebPaste()
+                      && !Calamares::Paste::doLogUploadUI( errorDialog->parentWidget() ).isEmpty() )
                  {
-                     Calamares::Paste::doLogUploadUI( errorDialog );
+                     QProcess::startDetached( QStringLiteral( "systemctl" ), { QStringLiteral( "reboot" ) } );
                  }
 #if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
                  QApplication::quit();
--- a/src/libcalamaresui/widgets/ErrorDialog.cpp
+++ b/src/libcalamaresui/widgets/ErrorDialog.cpp
@@ -12,6 +12,7 @@
 
 #include "widgets/TranslationFix.h"
 #include <QDialogButtonBox>
+#include <QPushButton>
 #include <QIcon>
 
 namespace Calamares
@@ -25,6 +26,7 @@
     ui->iconLabel->setPixmap( QIcon::fromTheme( "dialog-error" ).pixmap( 64 ) );
     ui->detailsWidget->hide();
     ui->offerWebPasteLabel->hide();
+    ui->detailsBrowser->setMinimumHeight( 180 );
 }
 
 ErrorDialog::~ErrorDialog()
@@ -98,6 +100,15 @@
         ui->buttonBox->setStandardButtons( m_shouldOfferWebPaste ? ( QDialogButtonBox::Yes | QDialogButtonBox::No )
                                                                  : QDialogButtonBox::Close );
         fixButtonLabels( ui->buttonBox );
+        if ( m_shouldOfferWebPaste )
+        {
+            QPushButton* nem = ui->buttonBox->button( QDialogButtonBox::No );
+            nem->setDefault( true );
+            nem->setFocus();
+            ui->offerWebPasteLabel->setMinimumWidth( 520 );
+            ui->offerWebPasteLabel->setMinimumHeight( ui->offerWebPasteLabel->heightForWidth( 520 ) );
+            adjustSize();
+        }
 
         emit shouldOfferWebPasteChanged();
     }
--- a/src/libcalamaresui/widgets/ErrorDialog.ui
+++ b/src/libcalamaresui/widgets/ErrorDialog.ui
@@ -53,8 +53,15 @@
       <string/>
      </property>
      <property name="text">
-      <string>Would you like to paste the install log to the web?</string>
+      <string>Would you like to send the installation log to the RaveOS developers? It helps us find and fix the problem.
+
+The log contains the steps of the installer and their error messages, your hardware (processor, graphics card, disks and partitions), the settings you chose (language, time zone, keyboard, desktop, user name and computer name) and the output of the package installation. It contains no passwords.
+
+It is sent over an encrypted connection, only the RaveOS developers can see it, and it is deleted automatically after 30 days.</string>
      </property>
+     <property name="wordWrap">
+      <bool>true</bool>
+     </property>
     </widget>
    </item>
    <item row="8" column="0" colspan="2">
--- a/src/libcalamaresui/utils/Paste.cpp
+++ b/src/libcalamaresui/utils/Paste.cpp
@@ -17,9 +17,17 @@
 
 #include <QApplication>
 #include <QClipboard>
+#include <QEventLoop>
 #include <QFile>
 #include <QFileInfo>
+#include <QJsonDocument>
+#include <QJsonObject>
 #include <QMessageBox>
+#include <QNetworkAccessManager>
+#include <QNetworkReply>
+#include <QNetworkRequest>
+#include <QProcess>
+#include <QPushButton>
 #include <QTcpSocket>
 #include <QUrl>
 #include <QWidget>
@@ -115,6 +123,66 @@
     }
 }
 
+STATICTEST QByteArray
+raveosHardwareSummary()
+{
+    static QByteArray summary;
+    static bool collected = false;
+    if ( collected )
+    {
+        return summary;
+    }
+    collected = true;
+    const QString script = QStringLiteral( "/etc/calamares/modules/raveos-hwinfo.sh" );
+    if ( !QFileInfo::exists( script ) )
+    {
+        return QByteArray();
+    }
+    QProcess process;
+    process.start( QStringLiteral( "/bin/bash" ), { script } );
+    if ( !process.waitForFinished( 15000 ) )
+    {
+        process.kill();
+        process.waitForFinished();
+        cWarning() << "Hardware summary timed out";
+        return QByteArray();
+    }
+    summary = process.readAllStandardOutput();
+    return summary;
+}
+
+STATICTEST QString
+raveosLogUpload( const QByteArray& logData, const QUrl& serverUrl )
+{
+    const QByteArray pasteData = raveosHardwareSummary() + logData;
+    QNetworkAccessManager manager;
+    QNetworkRequest request( serverUrl );
+    request.setHeader( QNetworkRequest::ContentTypeHeader, QStringLiteral( "text/plain; charset=utf-8" ) );
+    request.setTransferTimeout( 60000 );
+
+    QNetworkReply* reply = manager.post( request, pasteData );
+    QEventLoop loop;
+    QObject::connect( reply, &QNetworkReply::finished, &loop, &QEventLoop::quit );
+    loop.exec( QEventLoop::ExcludeUserInputEvents );
+
+    const QByteArray response = reply->readAll();
+    const QNetworkReply::NetworkError error = reply->error();
+    delete reply;
+
+    if ( error != QNetworkReply::NoError )
+    {
+        cError() << "Log upload failed" << error;
+        return QString();
+    }
+
+    const QString identifier = QJsonDocument::fromJson( response ).object().value( QStringLiteral( "azonosito" ) ).toString();
+    if ( identifier.isEmpty() )
+    {
+        cError() << "No identifier from log upload server";
+    }
+    return identifier;
+}
+
 QString
 Calamares::Paste::doLogUpload( QObject* parent )
 {
@@ -149,6 +217,10 @@
         cWarning() << "No upload configured.";
         return QString();
     case Calamares::Branding::UploadServerType::Fiche:
+        if ( serverUrl.scheme() == QStringLiteral( "https" ) )
+        {
+            return raveosLogUpload( pasteData, serverUrl );
+        }
         return ficheLogUpload( pasteData, serverUrl, parent );
     }
     return QString();
@@ -157,32 +229,52 @@
 QString
 Calamares::Paste::doLogUploadUI( QWidget* parent )
 {
-    // These strings originated in the ViewManager class
-    QString pasteUrl = Calamares::Paste::doLogUpload( parent );
-    QString pasteUrlMessage;
-    if ( pasteUrl.isEmpty() )
+    QString pasteUrl;
+    while ( true )
     {
-        pasteUrlMessage = QCoreApplication::translate( "Calamares::ViewManager",
-                                                       "The upload was unsuccessful. No web-paste was done." );
-    }
-    else
-    {
-        QClipboard* clipboard = QApplication::clipboard();
-        clipboard->setText( pasteUrl, QClipboard::Clipboard );
-
-        if ( clipboard->supportsSelection() )
+        QApplication::setOverrideCursor( Qt::WaitCursor );
+        pasteUrl = Calamares::Paste::doLogUpload( parent );
+        QApplication::restoreOverrideCursor();
+        if ( !pasteUrl.isEmpty() )
         {
-            clipboard->setText( pasteUrl, QClipboard::Selection );
+            break;
         }
-        QString pasteUrlFmt = QCoreApplication::translate( "Calamares::ViewManager",
-                                                           "Install log posted to\n\n%1\n\nLink copied to clipboard" );
-        pasteUrlMessage = pasteUrlFmt.arg( pasteUrl );
+        QMessageBox retry( QMessageBox::Warning,
+                           QCoreApplication::translate( "Calamares::ViewManager", "Installation log" ),
+                           QCoreApplication::translate( "Calamares::ViewManager",
+                                                        "The installation log could not be sent. There is probably no "
+                                                        "internet connection.\n\nCheck the network connection and "
+                                                        "try again." ),
+                           QMessageBox::Retry | QMessageBox::Close,
+                           parent );
+        Calamares::fixButtonLabels( &retry );
+        retry.button( QMessageBox::Retry )
+            ->setText( QCoreApplication::translate( "Calamares::ViewManager", "Try again" ) );
+        retry.setDefaultButton( QMessageBox::Retry );
+        if ( retry.exec() != QMessageBox::Retry )
+        {
+            return QString();
+        }
     }
 
-    QMessageBox mb( QMessageBox::Critical,
-                    QCoreApplication::translate( "Calamares::ViewManager", "Install Log Paste URL" ),
+    QClipboard* clipboard = QApplication::clipboard();
+    clipboard->setText( pasteUrl, QClipboard::Clipboard );
+    if ( clipboard->supportsSelection() )
+    {
+        clipboard->setText( pasteUrl, QClipboard::Selection );
+    }
+
+    const QString pasteUrlMessage
+        = QCoreApplication::translate(
+              "Calamares::ViewManager",
+              "The installation log has been sent to the RaveOS developers.\n\nIdentifier: %1\n\nThank you!" )
+              .arg( pasteUrl );
+
+    QMessageBox mb( QMessageBox::Information,
+                    QCoreApplication::translate( "Calamares::ViewManager", "Installation log" ),
                     pasteUrlMessage,
-                    QMessageBox::Ok );
+                    QMessageBox::Ok,
+                    parent );
     Calamares::fixButtonLabels( &mb );
     mb.exec();
     return pasteUrl;