Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
mobile Datovka
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Datovka projects
mobile Datovka
Commits
e7ce33d5
Commit
e7ce33d5
authored
Aug 08, 2018
by
Martin Straka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send log via email
parent
a172bd97
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
28 deletions
+31
-28
qml/pages/PageLog.qml
qml/pages/PageLog.qml
+6
-8
src/files.cpp
src/files.cpp
+23
-18
src/files.h
src/files.h
+2
-2
No files found.
qml/pages/PageLog.qml
View file @
e7ce33d5
...
...
@@ -43,7 +43,8 @@ Item {
Component.onCompleted
:
{
var
logTxt
=
files
.
loadLogContent
(
logFilePath
)
logContent
.
text
=
"
<b>
"
+
qsTr
(
"
Log from current run:
"
)
+
"
</b><br/><br/>
"
+
logTxt
logContent
.
text
=
qsTr
(
"
Log from current run:
"
)
+
"
\n\n
"
+
logTxt
actionButton
.
enabled
=
(
logContent
.
text
!==
""
)
logFileLocation
=
files
.
getLocFileLocation
()
}
...
...
@@ -56,7 +57,8 @@ Item {
logContent
.
clear
()
logFilePath
=
pathListModel
.
get
(
pathListModel
.
count
-
1
).
path
var
logTxt
=
files
.
loadLogContent
(
logFilePath
)
logContent
.
text
=
"
<b>
"
+
qsTr
(
"
Log file
"
)
+
"
:
"
+
getFileNameFromPath
(
logFilePath
)
+
"
</b><br/><br/>
"
+
logTxt
logContent
.
text
=
qsTr
(
"
Log file
"
)
+
"
:
"
+
getFileNameFromPath
(
logFilePath
)
+
"
\n\n
"
+
logTxt
actionButton
.
enabled
=
(
logContent
.
text
!==
""
)
}
}
}
...
...
@@ -75,9 +77,7 @@ Item {
image.sourceSize.height
:
imgHeightHeader
image.source
:
"
qrc:/ui/send-msg.svg
"
accessibleName
:
qsTr
(
"
Send log to helpdesk
"
)
onClicked
:
{
files
.
sendLogFileViaEmail
(
logFilePath
)
}
onClicked
:
files
.
sendLogViaEmail
(
logContent
.
text
)
}
}
Flickable
{
...
...
@@ -91,11 +91,10 @@ Item {
Pane
{
id
:
flickContent
anchors.fill
:
parent
Text
Area
{
Text
Edit
{
id
:
logContent
color
:
datovkaPalette
.
text
anchors.fill
:
parent
textFormat
:
TextEdit
.
RichText
readOnly
:
true
wrapMode
:
Text
.
WordWrap
font.pointSize
:
textFontSizeSmall
...
...
@@ -104,7 +103,6 @@ Item {
ScrollIndicator.vertical
:
ScrollIndicator
{}
}
// Flickable
Rectangle
{
id
:
attachmentArea
anchors.top
:
flickable
.
bottom
anchors.bottom
:
parent
.
bottom
anchors.right
:
parent
.
right
...
...
src/files.cpp
View file @
e7ce33d5
...
...
@@ -24,6 +24,7 @@
#include <QDesktopServices>
#include <QFileInfo>
#include <QQmlEngine>
#include <QSysInfo>
#include <QTextStream>
#include "ios/src/url_opener.h"
...
...
@@ -175,7 +176,6 @@ QString Files::loadLogContent(const QString &filePath)
const
QList
<
quint64
>
keys
(
mLog
->
keys
());
foreach
(
quint64
key
,
keys
)
{
log
.
append
(
mLog
->
message
(
key
));
log
.
append
(
"<br/>"
);
}
}
else
{
...
...
@@ -191,7 +191,6 @@ QString Files::loadLogContent(const QString &filePath)
while
(
!
in
.
atEnd
())
{
QString
line
=
in
.
readLine
();
log
.
append
(
line
);
log
.
append
(
"<br/>"
);
}
file
.
close
();
}
...
...
@@ -292,31 +291,37 @@ void Files::openAttachmentFromPath(const QString &filePath)
#endif
}
bool
Files
::
sendLogFileViaEmail
(
const
QString
&
filePath
)
void
Files
::
sendLogViaEmail
(
const
QString
&
logContent
)
{
QFile
file
(
filePath
);
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
Q_ASSERT
(
0
);
logErrorNL
(
"Cannot open file '%s'."
,
filePath
.
toUtf8
().
constData
());
return
false
;
debugFuncCall
();
int
msgResponse
=
Dialogues
::
message
(
Dialogues
::
QUESTION
,
tr
(
"Send log via email"
),
tr
(
"Do you want to send the log information to developers?"
),
QString
(),
Dialogues
::
NO
|
Dialogues
::
YES
,
Dialogues
::
NO
);
if
(
msgResponse
==
Dialogues
::
NO
)
{
return
;
}
QString
subject
=
"Mobile Datovka: Log File"
;
QString
body
=
"Mobile Datovka"
;
body
.
append
(
"
\n
Version: "
+
QStringLiteral
(
VERSION
));
body
.
append
(
"
\n
OS: "
+
QSysInfo
::
productType
()
+
" "
+
QSysInfo
::
productVersion
());
body
.
append
(
"
\n
Arch: "
+
QSysInfo
::
currentCpuArchitecture
());
removeDirFromDocLoc
(
DATOVKA_MAIL_DIR_NAME
);
/* TODO */
QString
log
(
file
.
readAll
());
QString
targetPath
(
appEmailDirPath
(
"Log"
));
QString
filePath
(
writeFile
(
targetPath
,
"mobile-datovka.log"
,
base64ToRaw
(
logContent
.
toUtf8
())));
QStringList
attachmentList
;
attachmentList
.
append
(
filePath
);
QString
subject
=
tr
(
"Log file"
);
QString
body
=
tr
(
"Log file"
);
removeDirFromDocLoc
(
DATOVKA_MAIL_DIR_NAME
);
const
QString
boundary
=
generateBoundaryString
();
QString
emailMessage
=
createEmailMessage
(
body
,
subject
,
boundary
);
addAttachmentToEmailMessage
(
emailMessage
,
"mdatovka.log"
,
log
.
toUtf8
().
toBase64
(),
boundary
);
addAttachmentToEmailMessage
(
emailMessage
,
"m
obile-
datovka.log"
,
log
Content
.
toUtf8
().
toBase64
(),
boundary
);
finishEmailMessage
(
emailMessage
,
boundary
);
sendEmail
(
emailMessage
,
attachmentList
,
subject
,
body
,
0
);
return
true
;
}
void
Files
::
sendMsgFilesWithEmail
(
const
QString
&
userName
,
qint64
msgId
,
...
...
src/files.h
View file @
e7ce33d5
...
...
@@ -162,10 +162,10 @@ public:
/*!
* @brief Send log via email.
*
* @param[in]
filePath Log file path (empty = send memory log)
.
* @param[in]
logContent Log content to be sent
.
*/
Q_INVOKABLE
static
bool
sendLogFileViaEmail
(
const
QString
&
filePath
);
void
sendLogViaEmail
(
const
QString
&
logContent
);
/*!
* @brief Send message attachments or complete zfo message
...
...
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