2012-11-05 03:54:21 +00:00
|
|
|
/* splash_overlay.cpp
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program 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 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "splash_overlay.h"
|
2015-06-25 16:17:03 +00:00
|
|
|
#include <ui_splash_overlay.h>
|
2012-11-05 03:54:21 +00:00
|
|
|
#include "wireshark_application.h"
|
|
|
|
|
|
|
|
#include <QPainter>
|
|
|
|
|
2012-11-05 22:43:15 +00:00
|
|
|
#include "ui/util.h"
|
2015-10-04 17:10:29 +00:00
|
|
|
#include <wsutil/utf8_entities.h>
|
2012-11-05 03:54:21 +00:00
|
|
|
#include "tango_colors.h"
|
|
|
|
|
2015-08-07 12:55:50 +00:00
|
|
|
#ifdef HAVE_LUA
|
|
|
|
#include "epan/wslua/init_wslua.h"
|
|
|
|
#endif
|
|
|
|
|
2012-11-05 19:11:11 +00:00
|
|
|
// Uncomment to slow the update progress
|
|
|
|
//#define THROTTLE_STARTUP 1
|
|
|
|
|
2012-11-05 03:54:21 +00:00
|
|
|
/*
|
|
|
|
* Update frequency for the splash screen, given in milliseconds.
|
|
|
|
*/
|
2015-09-17 17:32:55 +00:00
|
|
|
static int info_update_freq_ = 100;
|
2012-11-05 03:54:21 +00:00
|
|
|
|
2015-07-07 06:24:50 +00:00
|
|
|
void splash_update(register_action_e action, const char *message, void *) {
|
2012-11-05 03:54:21 +00:00
|
|
|
emit wsApp->registerUpdate(action, message);
|
|
|
|
}
|
|
|
|
|
|
|
|
SplashOverlay::SplashOverlay(QWidget *parent) :
|
|
|
|
QWidget(parent),
|
2012-11-05 22:25:06 +00:00
|
|
|
so_ui_(new Ui::SplashOverlay),
|
2016-07-03 20:46:33 +00:00
|
|
|
blurred_(false),
|
2012-11-05 03:54:21 +00:00
|
|
|
last_action_(RA_NONE),
|
|
|
|
register_cur_(0)
|
|
|
|
{
|
2012-11-05 22:25:06 +00:00
|
|
|
so_ui_->setupUi(this);
|
2012-11-05 03:54:21 +00:00
|
|
|
|
2015-08-07 19:37:33 +00:00
|
|
|
// Number of register action transitions (e.g. RA_NONE -> RA_DISSECTORS,
|
|
|
|
// RA_DISSECTORS -> RA_PLUGIN_REGISTER) minus two.
|
2016-06-24 23:48:23 +00:00
|
|
|
int register_add = 5;
|
2012-11-05 03:54:21 +00:00
|
|
|
#ifdef HAVE_LUA
|
2015-08-07 12:55:50 +00:00
|
|
|
register_add += wslua_count_plugins(); /* get count of lua plugins */
|
2012-11-05 03:54:21 +00:00
|
|
|
#endif
|
2012-11-05 22:25:06 +00:00
|
|
|
so_ui_->progressBar->setMaximum((int)register_count() + register_add);
|
2015-09-17 17:32:55 +00:00
|
|
|
elapsed_timer_.start();
|
2012-11-05 03:54:21 +00:00
|
|
|
|
2016-03-31 20:25:44 +00:00
|
|
|
QColor bg = QColor(tango_aluminium_6);
|
|
|
|
bg.setAlphaF(0.4);
|
|
|
|
QPalette pal;
|
|
|
|
pal.setColor(QPalette::Background, bg);
|
|
|
|
setPalette(pal);
|
|
|
|
setAutoFillBackground(true);
|
|
|
|
|
2012-11-05 03:54:21 +00:00
|
|
|
setStyleSheet(QString(
|
|
|
|
"QLabel {"
|
|
|
|
" color: white;"
|
|
|
|
" background: rgba(0,0,0,0);"
|
|
|
|
"}"
|
|
|
|
"QProgressBar {"
|
|
|
|
" height: 1em;"
|
|
|
|
" width: 20em;"
|
|
|
|
" border: 0.1em solid white;"
|
|
|
|
" border-radius: 0.2em;"
|
|
|
|
" color: white;"
|
|
|
|
" background: rgba(0,0,0,0);"
|
|
|
|
"}"
|
|
|
|
"QProgressBar::chunk {"
|
|
|
|
" width: 0.1em;"
|
|
|
|
" background: rgba(255, 255, 255, 50%);"
|
|
|
|
"}"
|
|
|
|
));
|
|
|
|
|
2013-10-05 22:39:49 +00:00
|
|
|
#ifndef THROTTLE_STARTUP
|
2012-11-05 22:43:15 +00:00
|
|
|
// Check for a remote connection
|
2015-07-16 16:14:07 +00:00
|
|
|
if (display_is_remote())
|
2012-11-05 22:43:15 +00:00
|
|
|
info_update_freq_ = 1000;
|
2013-10-05 22:39:49 +00:00
|
|
|
#endif
|
2012-11-05 22:43:15 +00:00
|
|
|
|
2012-11-05 03:54:21 +00:00
|
|
|
connect(wsApp, SIGNAL(splashUpdate(register_action_e,const char*)),
|
|
|
|
this, SLOT(splashUpdate(register_action_e,const char*)));
|
|
|
|
}
|
|
|
|
|
|
|
|
SplashOverlay::~SplashOverlay()
|
|
|
|
{
|
2012-11-05 22:25:06 +00:00
|
|
|
delete so_ui_;
|
2012-11-05 03:54:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Useful for debugging on fast machines.
|
2012-11-05 19:11:11 +00:00
|
|
|
#ifdef THROTTLE_STARTUP
|
|
|
|
#include <QThread>
|
|
|
|
class ThrottleThread : public QThread
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static void msleep(unsigned long msecs)
|
|
|
|
{
|
|
|
|
QThread::msleep(msecs);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|
2012-11-05 03:54:21 +00:00
|
|
|
|
|
|
|
void SplashOverlay::splashUpdate(register_action_e action, const char *message)
|
|
|
|
{
|
|
|
|
QString action_msg = UTF8_HORIZONTAL_ELLIPSIS;
|
|
|
|
|
2012-11-05 19:11:11 +00:00
|
|
|
#ifdef THROTTLE_STARTUP
|
2015-08-07 19:37:33 +00:00
|
|
|
ThrottleThread::msleep(10);
|
2012-11-05 19:11:11 +00:00
|
|
|
#endif
|
2012-11-05 03:54:21 +00:00
|
|
|
|
|
|
|
register_cur_++;
|
2015-09-17 17:32:55 +00:00
|
|
|
if (last_action_ == action && elapsed_timer_.elapsed() < info_update_freq_ && register_cur_ != so_ui_->progressBar->maximum()) {
|
2012-11-05 03:54:21 +00:00
|
|
|
/* Only update every splash_register_freq milliseconds */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
last_action_ = action;
|
|
|
|
|
|
|
|
switch(action) {
|
|
|
|
case RA_DISSECTORS:
|
2013-01-20 18:33:06 +00:00
|
|
|
action_msg = tr("Initializing dissectors");
|
2012-11-05 03:54:21 +00:00
|
|
|
break;
|
|
|
|
case RA_LISTENERS:
|
2013-01-20 18:33:06 +00:00
|
|
|
action_msg = tr("Initializing tap listeners");
|
2012-11-05 03:54:21 +00:00
|
|
|
break;
|
|
|
|
case RA_REGISTER:
|
2014-10-10 09:30:59 +00:00
|
|
|
action_msg = tr("Registering dissectors");
|
2012-11-05 03:54:21 +00:00
|
|
|
break;
|
|
|
|
case RA_PLUGIN_REGISTER:
|
2013-01-20 18:33:06 +00:00
|
|
|
action_msg = tr("Registering plugins");
|
2012-11-05 03:54:21 +00:00
|
|
|
break;
|
|
|
|
case RA_HANDOFF:
|
2014-10-10 09:30:59 +00:00
|
|
|
action_msg = tr("Handing off dissectors");
|
2012-11-05 03:54:21 +00:00
|
|
|
break;
|
|
|
|
case RA_PLUGIN_HANDOFF:
|
2013-01-20 18:33:06 +00:00
|
|
|
action_msg = tr("Handing off plugins");
|
2012-11-05 03:54:21 +00:00
|
|
|
break;
|
|
|
|
case RA_LUA_PLUGINS:
|
2013-01-20 18:33:06 +00:00
|
|
|
action_msg = tr("Loading Lua plugins");
|
2012-11-05 03:54:21 +00:00
|
|
|
break;
|
2015-08-11 12:08:08 +00:00
|
|
|
case RA_LUA_DEREGISTER:
|
|
|
|
action_msg = tr("Removing Lua plugins");
|
|
|
|
break;
|
2012-11-05 03:54:21 +00:00
|
|
|
case RA_PREFERENCES:
|
2013-01-20 18:33:06 +00:00
|
|
|
action_msg = tr("Loading module preferences");
|
2012-11-05 03:54:21 +00:00
|
|
|
break;
|
2016-06-24 23:48:23 +00:00
|
|
|
case RA_INTERFACES:
|
|
|
|
action_msg = tr("Finding local interfaces");
|
|
|
|
break;
|
2012-11-05 03:54:21 +00:00
|
|
|
case RA_CONFIGURATION:
|
2013-01-20 18:33:06 +00:00
|
|
|
action_msg = tr("Loading configuration files");
|
2012-11-05 03:54:21 +00:00
|
|
|
break;
|
|
|
|
default:
|
2013-01-20 18:33:06 +00:00
|
|
|
action_msg = tr("(Unknown action)");
|
2012-11-05 03:54:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (message) {
|
|
|
|
if (!strncmp(message, "proto_register_", 15))
|
|
|
|
message += 15;
|
|
|
|
else if (!strncmp(message, "proto_reg_handoff_", 18))
|
|
|
|
message += 18;
|
|
|
|
action_msg.append(" ").append(message);
|
|
|
|
}
|
2012-11-05 22:25:06 +00:00
|
|
|
so_ui_->actionLabel->setText(action_msg);
|
2012-11-05 03:54:21 +00:00
|
|
|
|
2012-11-05 22:25:06 +00:00
|
|
|
so_ui_->progressBar->setValue(register_cur_);
|
2012-11-05 03:54:21 +00:00
|
|
|
|
2016-03-31 20:25:44 +00:00
|
|
|
wsApp->processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers, 1);
|
2015-09-17 17:32:55 +00:00
|
|
|
elapsed_timer_.restart();
|
2012-11-05 03:54:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|