Exemple #1
0
static void send_crash_message_to_server(QString message, QString plugin_names, QString emergency_save_filename, Crash_Type crash_type){

  fprintf(stderr,"Got message:\n%s\n",message.toUtf8().constData());

  bool is_crash = crash_type==CT_CRASH;

  {
    QMessageBox box;
    
    box.setIcon(QMessageBox::Critical);
    box.addButton("SEND", QMessageBox::AcceptRole);
    box.addButton("DON'T SEND", QMessageBox::RejectRole);
    
    if (crash_type==CT_CRASH)
      box.setText("Radium Crashed. :((");
    else if (crash_type==CT_ERROR)
      box.setText("Error! Radium is in a state it should not be in.\n(Note that Radium has NOT crashed)\n");
    else
      box.setText("Warning! Radium is in a state it should not be in.\n(Note that Radium has NOT crashed, you can continue working)\n");


    bool dosave = emergency_save_filename!=QString(NOEMERGENCYSAVE);
    
    box.setInformativeText(QString("This %0 will be automatically reported when you press \"SEND\".\n"
                                   "\n"
                                   "The report is sent anonymously, and will only be seen by the author of Radium.\n"
                                   "\n"
                                   "Only the information in \"Show details...\" is sent.\n"
                                   "\n"
                                   "Please don't report the same %0 more than two or three times.\n"
                                   ).arg(crash_type==CT_CRASH ? "crash" : crash_type==CT_ERROR ? "error" : "warning")
                           + ( (is_crash && plugin_names != NOPLUGINNAMES)
                               ? QString("\nPlease note that the following third party plugins: \"" + plugin_names + "\" was/were currently processing audio. It/they might be responsible for the crash.\n")
                               : QString())
                           + (crash_type==CT_ERROR ? "\nAfterwards, you should save your work and start the program again.\n\nIf this window just pops up again immediately after closing it, just hide it instead." : "")
                           + (dosave ? "\nAn emergency version of your song has been saved as \""+emergency_save_filename+"\". However, this file should not be trusted. It could be malformed. (it is most likely okay though)" : "")
                           + "\n"
                           );
    box.setDetailedText(message);

    QLabel space(" ");
    box.layout()->addWidget(&space);

    QLabel text_edit_label("<br><br>"
                           "Please also include additional information below.<br>"
                           "<br>"
                           "The best type of help you "
                           "can give is to write "
                           "down<br>a step by step "
                           "recipe in the following "
                           "format:"
                           "<br><br>"
                           "1. Start Radium<br>"
                           "2. Move the cursor to track 3.<br>"
                           "3. Press the Q button.<br>"
                           "4. Radium crashes<br>"
                           "<br>"
                           "<b>Note: Sometimes it is virtually impossible to fix the bug<br>"
                           "without a recipe on how to reproduce the bug</b><br>"
                           "<br>"
                           );

    //text_edit.setMinimumWidth(1000000);
    //text_edit.setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
    box.layout()->addWidget(&text_edit_label);

    QLabel space2(" ");
    box.layout()->addWidget(&space2);

    QTextEdit text_edit;
    text_edit.setText("<Please add recipe and/or email address here>");
    //text_edit.setMinimumWidth(1000000);
    //text_edit.setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
    box.layout()->addWidget(&text_edit);

    if (crash_type==CT_CRASH)
      box.setWindowTitle("Report crash");
    else if (crash_type==CT_ERROR)
      box.setWindowTitle("Report error");
    else
      box.setWindowTitle("Report warning");

    box.show();

    box.activateWindow();
    box.raise();
    //box.stackUnder(box.parentWidget());
    box.setWindowFlags(Qt::WindowStaysOnTopHint);
    box.setWindowModality(Qt::ApplicationModal);

#ifdef FOR_WINDOWS
    HWND wnd=box.winId();
    SetFocus(wnd);
    SetWindowPos(wnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
#endif

    int ret = box.exec();

    if(ret==QMessageBox::AcceptRole){

      QByteArray data;
      QUrl params;
      params.addQueryItem("data", message);
      data.append(params.toString().toAscii(),params.toString().length()-1);
      data.remove(0,1);
      data.append("\n");
      data.append(text_edit.toPlainText());

      QNetworkAccessManager nam;
      QNetworkRequest request(QUrl("http://users.notam02.no/~kjetism/radium/crashreport.php"));
      request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded" );

      nam.post(request,data);

#if 1
      {
        QMessageBox box;
        box.setText("Thanks for reporting the bug!");
        
        box.setInformativeText("The bug will hopefully be fixed in the next version of Radium.");
        box.exec();
      }
#endif

    }
  }

}