Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
PIM
PIM Messagelib
Commits
8c187f38
Commit
8c187f38
authored
Apr 13, 2017
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor optimization
parent
eaad8e44
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
13 deletions
+13
-13
webengineviewer/src/checkphishingurl/autotests/checkphishingurlcachetest.cpp
.../checkphishingurl/autotests/checkphishingurlcachetest.cpp
+4
-4
webengineviewer/src/checkphishingurl/autotests/checkphishingurlutiltest.cpp
...c/checkphishingurl/autotests/checkphishingurlutiltest.cpp
+2
-2
webengineviewer/src/checkphishingurl/autotests/hashcachemanagertest.cpp
...r/src/checkphishingurl/autotests/hashcachemanagertest.cpp
+3
-3
webengineviewer/src/checkphishingurl/backoffmodemanager.cpp
webengineviewer/src/checkphishingurl/backoffmodemanager.cpp
+1
-1
webengineviewer/src/checkphishingurl/checkphishingurlutil.cpp
...ngineviewer/src/checkphishingurl/checkphishingurlutil.cpp
+1
-1
webengineviewer/src/checkphishingurl/localdatabasemanager.cpp
...ngineviewer/src/checkphishingurl/localdatabasemanager.cpp
+2
-2
No files found.
webengineviewer/src/checkphishingurl/autotests/checkphishingurlcachetest.cpp
View file @
8c187f38
...
...
@@ -46,9 +46,9 @@ void CheckPhishingUrlCacheTest::shouldAddValue_data()
{
QTest
::
addColumn
<
QUrl
>
(
"url"
);
QTest
::
addColumn
<
bool
>
(
"validurl"
);
QTest
::
addColumn
<
double
>
(
"seconds"
);
QTest
::
addColumn
<
uint
>
(
"seconds"
);
QTest
::
addColumn
<
WebEngineViewer
::
CheckPhishingUrlCache
::
UrlStatus
>
(
"status"
);
double
currentValue
=
QDateTime
::
currentDateTime
().
toTime_t
();
uint
currentValue
=
QDateTime
::
currentDateTime
Utc
().
toTime_t
();
QTest
::
newRow
(
"valid"
)
<<
QUrl
(
QStringLiteral
(
"http://www.kde.org"
))
<<
true
<<
currentValue
<<
WebEngineViewer
::
CheckPhishingUrlCache
::
UrlOk
;
QTest
::
newRow
(
"malware1validcache"
)
<<
QUrl
(
QStringLiteral
(
"http://www.kde.org"
))
<<
false
<<
(
currentValue
+
2000
)
<<
WebEngineViewer
::
CheckPhishingUrlCache
::
MalWare
;
QTest
::
newRow
(
"malware1invalidcache"
)
<<
QUrl
(
QStringLiteral
(
"http://www.kde.org"
))
<<
false
<<
(
currentValue
-
2000
)
<<
WebEngineViewer
::
CheckPhishingUrlCache
::
Unknown
;
...
...
@@ -58,7 +58,7 @@ void CheckPhishingUrlCacheTest::shouldAddValue()
{
QFETCH
(
QUrl
,
url
);
QFETCH
(
bool
,
validurl
);
QFETCH
(
double
,
seconds
);
QFETCH
(
uint
,
seconds
);
QFETCH
(
WebEngineViewer
::
CheckPhishingUrlCache
::
UrlStatus
,
status
);
WebEngineViewer
::
CheckPhishingUrlCache
cache
;
...
...
@@ -72,7 +72,7 @@ void CheckPhishingUrlCacheTest::shouldStoreValues()
WebEngineViewer
::
CheckPhishingUrlCache
cache
;
QUrl
url
=
QUrl
(
QStringLiteral
(
"http://www.kde.org"
));
double
currentValue
=
QDateTime
::
currentDateTime
().
toTime_t
();
uint
currentValue
=
QDateTime
::
currentDateTime
Utc
().
toTime_t
();
cache
.
addCheckingUrlResult
(
url
,
false
,
currentValue
+
2000
);
//Add malware
...
...
webengineviewer/src/checkphishingurl/autotests/checkphishingurlutiltest.cpp
View file @
8c187f38
...
...
@@ -54,14 +54,14 @@ void CheckPhishingUrlUtilTest::shouldCacheIsStillValid_data()
{
QTest
::
addColumn
<
double
>
(
"second"
);
QTest
::
addColumn
<
bool
>
(
"valid"
);
double
currentTime
=
QDateTime
::
currentDateTime
().
toTime_t
();
uint
currentTime
=
QDateTime
::
currentDateTime
Utc
().
toTime_t
();
QTest
::
newRow
(
"valid"
)
<<
(
currentTime
+
2000
)
<<
true
;
QTest
::
newRow
(
"invalid"
)
<<
(
currentTime
-
2000
)
<<
false
;
}
void
CheckPhishingUrlUtilTest
::
shouldCacheIsStillValid
()
{
QFETCH
(
double
,
second
);
QFETCH
(
uint
,
second
);
QFETCH
(
bool
,
valid
);
QCOMPARE
(
WebEngineViewer
::
CheckPhishingUrlUtil
::
cachedValueStillValid
(
second
),
valid
);
}
...
...
webengineviewer/src/checkphishingurl/autotests/hashcachemanagertest.cpp
View file @
8c187f38
...
...
@@ -43,9 +43,9 @@ void HashCacheManagerTest::shouldBeUnknowByDefault()
void
HashCacheManagerTest
::
shouldAddValue_data
()
{
QTest
::
addColumn
<
QByteArray
>
(
"hash"
);
QTest
::
addColumn
<
double
>
(
"seconds"
);
QTest
::
addColumn
<
uint
>
(
"seconds"
);
QTest
::
addColumn
<
WebEngineViewer
::
HashCacheManager
::
UrlStatus
>
(
"status"
);
double
currentValue
=
QDateTime
::
currentDateTime
().
toTime_t
();
uint
currentValue
=
QDateTime
::
currentDateTime
Utc
().
toTime_t
();
QTest
::
newRow
(
"valid"
)
<<
QByteArrayLiteral
(
"foo"
)
<<
(
currentValue
+
2000
)
<<
WebEngineViewer
::
HashCacheManager
::
UrlOk
;
QTest
::
newRow
(
"malware1validcache"
)
<<
QByteArrayLiteral
(
"bla"
)
<<
(
currentValue
+
2000
)
<<
WebEngineViewer
::
HashCacheManager
::
MalWare
;
QTest
::
newRow
(
"malware1invalidcache"
)
<<
QByteArrayLiteral
(
"blu"
)
<<
(
currentValue
-
2000
)
<<
WebEngineViewer
::
HashCacheManager
::
Unknown
;
...
...
@@ -54,7 +54,7 @@ void HashCacheManagerTest::shouldAddValue_data()
void
HashCacheManagerTest
::
shouldAddValue
()
{
QFETCH
(
QByteArray
,
hash
);
QFETCH
(
double
,
seconds
);
QFETCH
(
uint
,
seconds
);
QFETCH
(
WebEngineViewer
::
HashCacheManager
::
UrlStatus
,
status
);
WebEngineViewer
::
HashCacheManager
cache
;
...
...
webengineviewer/src/checkphishingurl/backoffmodemanager.cpp
View file @
8c187f38
...
...
@@ -96,7 +96,7 @@ void BackOffModeManagerPrivate::load()
isInOffMode
=
grp
.
readEntry
(
"Enabled"
,
false
);
if
(
isInOffMode
)
{
const
uint
delay
=
grp
.
readEntry
(
"Delay"
,
0
);
const
uint
now
=
QDateTime
::
currentDateTime
().
toTime_t
();
const
uint
now
=
QDateTime
::
currentDateTime
Utc
().
toTime_t
();
if
(
delay
>
now
)
{
const
int
diff
=
(
delay
-
now
);
updateTimer
(
diff
);
...
...
webengineviewer/src/checkphishingurl/checkphishingurlutil.cpp
View file @
8c187f38
...
...
@@ -82,7 +82,7 @@ uint CheckPhishingUrlUtil::refreshingCacheAfterThisTime(double seconds)
bool
CheckPhishingUrlUtil
::
cachedValueStillValid
(
uint
seconds
)
{
return
QDateTime
::
currentDateTime
().
toTime_t
()
<
seconds
;
return
QDateTime
::
currentDateTime
Utc
().
toTime_t
()
<
seconds
;
}
int
CheckPhishingUrlUtil
::
generateRandomSecondValue
(
int
numberOfFailed
)
...
...
webengineviewer/src/checkphishingurl/localdatabasemanager.cpp
View file @
8c187f38
...
...
@@ -159,7 +159,7 @@ void LocalDataBaseManager::initialize()
if
(
!
QFileInfo
::
exists
(
databaseFullPath
()))
{
downloadFullDataBase
();
}
else
{
const
uint
now
=
QDateTime
::
currentDateTime
().
toTime_t
();
const
uint
now
=
QDateTime
::
currentDateTime
Utc
().
toTime_t
();
//qDebug() << " now "<< now << " d->mSecondToStartRefreshing "<<d->mSecondToStartRefreshing << " now > d->mSecondToStartRefreshing" << (now > d->mSecondToStartRefreshing);
if
((
d
->
mSecondToStartRefreshing
!=
0
)
&&
(
d
->
mSecondToStartRefreshing
>
now
))
{
qCWarning
(
WEBENGINEVIEWER_LOG
)
<<
" It's not necessary to check database now"
;
...
...
@@ -176,7 +176,7 @@ void LocalDataBaseManager::initialize()
void
LocalDataBaseManager
::
slotCheckDataBase
()
{
const
uint
now
=
QDateTime
::
currentDateTime
().
toTime_t
();
const
uint
now
=
QDateTime
::
currentDateTime
Utc
().
toTime_t
();
if
(
d
->
mDataBaseOk
&&
!
d
->
mDownloadProgress
&&
(
d
->
mSecondToStartRefreshing
<
now
))
{
downloadPartialDataBase
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment