Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sbkpay
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhenfei.zhang
sbkpay
Commits
566f0949
Commit
566f0949
authored
Aug 19, 2017
by
NitefullWind
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 实现签名功能。 2. 解析OLTP的返回。 3. 修改退款逻辑,由POS传fmId。4.日志打印文件名和行号。
parent
7f2d56e3
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
576 additions
and
94 deletions
+576
-94
sbkpay/QsLog/QsLog.pri
+1
-1
sbkpay/control.cpp
+199
-44
sbkpay/control.h
+2
-0
sbkpay/fmtool.h
+19
-0
sbkpay/hostwidget.cpp
+37
-25
sbkpay/hostwidget.h
+3
-0
sbkpay/jsonfactory.h
+12
-0
sbkpay/main.cpp
+1
-1
sbkpay/rspfactory.h
+54
-2
sbkpay/sbkpay.pro
+8
-4
sbkpay/sbkpay.pro.user
+78
-17
sbkpay/xmlreader.cpp
+122
-0
sbkpay/xmlreader.h
+40
-0
No files found.
sbkpay/QsLog/QsLog.pri
View file @
566f0949
INCLUDEPATH += $$PWD
INCLUDEPATH += $$PWD
#
DEFINES += QS_LOG_LINE_NUMBERS # automatically writes the file and line for each log message
DEFINES += QS_LOG_LINE_NUMBERS # automatically writes the file and line for each log message
#DEFINES += QS_LOG_DISABLE # logging code is replaced with a no-op
#DEFINES += QS_LOG_DISABLE # logging code is replaced with a no-op
#DEFINES += QS_LOG_SEPARATE_THREAD # messages are queued and written from a separate thread
#DEFINES += QS_LOG_SEPARATE_THREAD # messages are queued and written from a separate thread
#DEFINES += QS_LOG_WIN_PRINTF_CONSOLE # Use fprintf instead of OutputDebugString on Windows
#DEFINES += QS_LOG_WIN_PRINTF_CONSOLE # Use fprintf instead of OutputDebugString on Windows
...
...
sbkpay/control.cpp
View file @
566f0949
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include "QsLog.h"
#include "QsLog.h"
#include "jsonfactory.h"
#include "jsonfactory.h"
#include "rspfactory.h"
#include "rspfactory.h"
#include "xmlreader.h"
#include <QtConcurrent>
#include <QtConcurrent>
#include <QSettings>
#include <QSettings>
...
@@ -19,6 +20,9 @@ typedef int (__stdcall *GetValue) (char *, char *);
...
@@ -19,6 +20,9 @@ typedef int (__stdcall *GetValue) (char *, char *);
typedef
int
(
__stdcall
*
GetRSACret
)(
int
,
const
char
*
,
const
char
*
);
typedef
int
(
__stdcall
*
GetRSACret
)(
int
,
const
char
*
,
const
char
*
);
typedef
int
(
__stdcall
*
SKBAPISend
)(
const
char
*
indata
,
const
char
*
guid
,
char
*
outdata
,
char
*
errMsg
,
const
char
*
mode
);
typedef
int
(
__stdcall
*
SKBAPISend
)(
const
char
*
indata
,
const
char
*
guid
,
char
*
outdata
,
char
*
errMsg
,
const
char
*
mode
);
typedef
int
(
__stdcall
*
AddSign
)(
char
*
,
char
*
);
typedef
int
(
__stdcall
*
AddSign
)(
char
*
,
char
*
);
typedef
int
(
__stdcall
*
GetMac
)(
char
*
);
typedef
int
(
__stdcall
*
GetRealMac
)(
char
*
);
typedef
int
(
__stdcall
*
SetRSACret
)(
char
*
);
void
Control
::
GetProcPath
(
char
*
pathBuf
)
void
Control
::
GetProcPath
(
char
*
pathBuf
)
{
{
...
@@ -50,8 +54,10 @@ void Control::Start(const char *indata, char *outdata)
...
@@ -50,8 +54,10 @@ void Control::Start(const char *indata, char *outdata)
if
(
_widget
==
NULL
)
if
(
_widget
==
NULL
)
_widget
=
new
HostWidget
();
_widget
=
new
HostWidget
();
QLOG_INFO
()
<<
"In data: "
<<
QString
::
fromUtf8
(
indata
);
QJsonParseError
parseError
;
QJsonParseError
parseError
;
QJsonDocument
inDataDoc
=
QJsonDocument
::
fromJson
(
QString
::
from
Local8Bit
(
indata
).
toUtf8
(),
&
parseError
);
QJsonDocument
inDataDoc
=
QJsonDocument
::
fromJson
(
QString
::
from
Utf8
(
indata
).
toUtf8
(),
&
parseError
);
if
(
parseError
.
error
==
QJsonParseError
::
NoError
)
{
if
(
parseError
.
error
==
QJsonParseError
::
NoError
)
{
_posReqJsonObj
=
inDataDoc
.
object
();
_posReqJsonObj
=
inDataDoc
.
object
();
...
@@ -98,22 +104,29 @@ void Control::Start(const char *indata, char *outdata)
...
@@ -98,22 +104,29 @@ void Control::Start(const char *indata, char *outdata)
_widget
=
NULL
;
_widget
=
NULL
;
_lock
.
unlock
();
_lock
.
unlock
();
memcpy
(
outdata
,
(
char
*
)(
&
_response
),
sizeof
(
struct
AlipayResponse
));
// memcpy(outdata, (char *)(&_response), sizeof(struct AlipayResponse));
outdata
[
sizeof
(
struct
AlipayResponse
)]
=
0
;
// outdata[sizeof(struct AlipayResponse)] = 0;
QByteArray
responseArray
=
QJsonDocument
(
_responseJsonObj
).
toJson
(
QJsonDocument
::
Compact
);
memcpy
(
outdata
,
responseArray
.
data
(),
responseArray
.
size
());
QLOG_INFO
()
<<
"return data to pos : "
<<
outdata
;
QLOG_INFO
()
<<
"return data to pos : "
<<
outdata
;
}
}
void
Control
::
SetResPonseWithMessage
(
QString
code
,
const
QString
&
message
)
void
Control
::
SetResPonseWithMessage
(
QString
code
,
const
QString
&
message
)
{
{
FMTool
::
SetString
(
_response
.
ResponseCode
,
3
,
code
);
// FMTool::SetString(_response.ResponseCode, 3, code);
FMTool
::
SetString
(
_response
.
ResponseMsg
,
40
,
message
);
// FMTool::SetString(_response.ResponseMsg, 40, message);
_responseJsonObj
[
JSON_KEY_STATUSCODE
]
=
code
;
_responseJsonObj
[
JSON_KEY_MESSAGE
]
=
message
;
}
}
void
Control
::
InitModel
()
void
Control
::
InitModel
()
{
{
memset
(
&
_request
,
' '
,
sizeof
(
struct
AlipayRequest
));
// memset(&_request, ' ', sizeof(struct AlipayRequest));
memset
(
&
_response
,
' '
,
sizeof
(
struct
AlipayResponse
));
// memset(&_response, ' ', sizeof(struct AlipayResponse));
_posReqJsonObj
=
QJsonObject
();
_responseJsonObj
=
QJsonObject
();
}
}
bool
Control
::
SendMessageToPayMent
(
const
QJsonObject
&
json
,
QByteArray
&
outdata
,
QString
&
error
)
bool
Control
::
SendMessageToPayMent
(
const
QJsonObject
&
json
,
QByteArray
&
outdata
,
QString
&
error
)
...
@@ -210,24 +223,21 @@ bool Control::SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata,
...
@@ -210,24 +223,21 @@ bool Control::SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata,
"</ns0:AP>"
"</ns0:AP>"
"</ns0:OLTP>"
);
"</ns0:OLTP>"
);
QString
nsTo
=
"CS00400004"
;
QString
nsTo
=
"CS00400004"
;
int
type
=
FMTool
::
GetJsonValue
(
_posReqJsonObj
,
JSON_KEY_REQTYPE
).
toInt
(
);
int
type
=
FMTool
::
GetJsonValue
(
json
,
JSON_KEY_REQTYPE
).
toInt
(
-
1
);
if
(
type
==
SPCC_sign
)
{
if
(
type
==
-
1
)
{
nsTo
=
"CS00400003"
;
nsTo
=
"CS00400003"
;
}
}
QString
date
=
QDate
::
currentDate
().
toString
(
"yyMMdd"
);
QString
date
=
QDate
::
currentDate
().
toString
(
"yyMMdd"
);
QString
time
=
QTime
::
currentTime
().
toString
(
"hhmmss"
);
QString
time
=
QTime
::
currentTime
().
toString
(
"hhmmss"
);
QString
storeId
=
FMTool
::
GetJsonValue
(
_posReqJsonObj
,
JSON_KEY_STOREID
).
toString
();
QString
storeId
=
FMTool
::
GetJsonValue
(
json
,
JSON_KEY_STOREID
).
toString
();
QString
posId
=
FMTool
::
GetJsonValue
(
_posReqJsonObj
,
JSON_KEY_STATIONID
).
toString
();
QString
posId
=
FMTool
::
GetJsonValue
(
json
,
JSON_KEY_STATIONID
).
toString
();
qsrand
(
QDateTime
::
currentMSecsSinceEpoch
());
qsrand
(
QDateTime
::
currentMSecsSinceEpoch
());
QString
termino
=
QString
::
fromUtf8
(
"%1%2%3%4%5"
).
arg
(
date
).
arg
(
storeId
).
arg
(
posId
).
arg
(
qrand
()
%
90
+
10
).
arg
(
time
);
QString
termino
=
QString
::
fromUtf8
(
"%1%2%3%4%5"
).
arg
(
date
).
arg
(
storeId
,
6
,
'0'
).
arg
(
posId
,
6
,
'0'
).
arg
(
qrand
()
%
90
+
10
).
arg
(
time
);
QByteArray
jsonArray
=
QJsonDocument
(
json
).
toJson
(
QJsonDocument
::
Compact
);
QByteArray
jsonArray
=
QJsonDocument
(
json
).
toJson
(
QJsonDocument
::
Compact
);
char
signStr
[
MAX_BUF_LEN
]
=
{
0
};
GetSPCCSign
(
jsonArray
.
data
(),
signStr
);
QLOG_INFO
()
<<
"Sign str: "
<<
signStr
;
reqXmlStr
=
reqXmlStr
.
arg
(
termino
).
arg
(
nsTo
).
arg
(
date
).
arg
(
time
).
arg
(
QString
::
fromUtf8
(
jsonArray
));
reqXmlStr
=
reqXmlStr
.
arg
(
termino
).
arg
(
nsTo
).
arg
(
QDate
::
currentDate
().
toString
(
"yyyyMMdd"
)
).
arg
(
time
).
arg
(
QString
::
fromUtf8
(
jsonArray
));
char
in
[
MAX_BUF_LEN
]
=
{
0
};
char
in
[
MAX_BUF_LEN
]
=
{
0
};
char
out
[
MAX_BUF_LEN
]
=
{
0
};
char
out
[
MAX_BUF_LEN
]
=
{
0
};
...
@@ -238,14 +248,72 @@ bool Control::SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata,
...
@@ -238,14 +248,72 @@ bool Control::SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata,
strcpy
(
in
,
reqXmlStr
.
toUtf8
().
data
());
strcpy
(
in
,
reqXmlStr
.
toUtf8
().
data
());
QLOG_INFO
()
<<
"Request StarbucksAPI XML data: "
<<
in
;
QLOG_INFO
()
<<
"Request StarbucksAPI XML data: "
<<
in
;
#define SBKTEST
#ifdef SBKTEST
int
result
=
skbSend
(
in
,
guid
,
out
,
errMsg
,
mode
);
int
result
=
skbSend
(
in
,
guid
,
out
,
errMsg
,
mode
);
#else
QLOG_DEBUG
()
<<
"============ Read debug data. ==============="
;
QFile
f
(
qApp
->
applicationDirPath
()
+
"/test/1.txt"
);
f
.
open
(
QIODevice
::
ReadOnly
);
strcpy
(
out
,
f
.
readAll
().
data
());
int
result
=
0
;
#endif //! End def SBKTEST
QLOG_DEBUG
()
<<
"StarbucksAPI return to UTF-8: "
<<
QString
::
fromUtf8
(
out
);
QLOG_DEBUG
()
<<
"StarbucksAPI return to GBK: "
<<
QString
::
fromLocal8Bit
(
out
);
QString
outXMlString
=
QString
::
fromUtf8
(
out
);
QLOG_INFO
()
<<
"OLTP return: "
<<
result
<<
" data: "
<<
outXMlString
;
if
(
result
!=
0
)
{
if
(
result
!=
0
)
{
error
=
QString
(
errMsg
);
error
=
"OLTP return error:
\n
"
+
QString
::
fromUtf8
(
errMsg
);
QLOG_ERROR
()
<<
"SKBSend return: "
<<
result
<<
" errMsg: "
<<
errMsg
<<
" data: "
<<
out
;
QLOG_ERROR
()
<<
error
;
return
QByteArray
();
return
QByteArray
();
}
else
{
QString
statcode
;
bool
isOk
=
FMTool
::
SearchXMLNodeString
(
outXMlString
,
"ns0:STATCODE"
,
statcode
);
if
(
!
isOk
)
{
error
=
"Can't find xml node: ns0:STATCODE"
;
QLOG_ERROR
()
<<
error
;
return
QByteArray
();
}
if
(
statcode
.
compare
(
"0000"
)
!=
0
)
{
error
=
"OLTP return STATCODE is: "
+
statcode
;
QLOG_ERROR
()
<<
error
;
return
QByteArray
();
}
QString
returnStr
;
isOk
=
FMTool
::
SearchXMLNodeString
(
outXMlString
,
"ns0:AP"
,
returnStr
);
if
(
!
isOk
)
{
error
=
"Can't find xml node: ns0:AP"
;
QLOG_ERROR
()
<<
error
;
return
QByteArray
();
}
return
returnStr
.
toUtf8
();
// XMLReader reader;
// if(!reader.parser(QString::fromUtf8(out))) {
// error = "OLTP return xml parser error: " + reader.errorString;
// QLOG_ERROR() << error;
// return QByteArray();
// } else {
// QList<QDomNode> outElements = reader.findElements("ns0:AP");
// if(outElements.length() != 1) {
// error = "OLTP return xml can't find ns0:AP";
// return QByteArray();
// } else {
// QDomNode node = outElements.first().firstChild();
// QString text = node.nodeValue();
// QLOG_INFO() << "OLTP JSON: " << text;
// return text.toUtf8();
// }
// }
}
}
QLOG_INFO
()
<<
"SKBSend return: "
<<
result
<<
" data: "
<<
out
;
return
QByteArray
(
out
);
return
QByteArray
(
out
);
});
});
...
@@ -278,6 +346,9 @@ bool Control::SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata,
...
@@ -278,6 +346,9 @@ bool Control::SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata,
bool
Control
::
GetRSA
(
QString
&
error
)
bool
Control
::
GetRSA
(
QString
&
error
)
{
{
QJsonObject
json
;
JsonFactory
::
GetJsonWithType
(
sign
,
json
,
_posReqJsonObj
,
QStringList
());
char
mod
[
MAX_PATH
]
=
{
0
};
char
mod
[
MAX_PATH
]
=
{
0
};
GetProcPath
(
mod
);
GetProcPath
(
mod
);
...
@@ -289,31 +360,54 @@ bool Control::GetRSA(QString &error)
...
@@ -289,31 +360,54 @@ bool Control::GetRSA(QString &error)
if
(
lib
.
load
())
if
(
lib
.
load
())
{
{
json
[
"mac"
]
=
GetMacString
();
GetRSACret
getrsacret
=
(
GetRSACret
)
lib
.
resolve
(
"_GetRSACret@12"
);
QByteArray
out
;
if
(
!
SendMessageToSBKAPI
(
json
,
out
,
error
))
{
if
(
getrsacret
!=
NULL
)
QLOG_ERROR
()
<<
"GetRSA error: "
<<
error
;
{
return
false
;
QEventLoop
loop
;
QtConcurrent
::
run
(
[
this
,
&
loop
,
&
rlt
,
&
error
,
getrsacret
]()
{
int
i
=
FMTool
::
GetString
(
_request
.
PlatNo
,
4
).
toInt
();
QString
storeID
=
FMTool
::
GetString
(
_request
.
StoreNo
,
20
);
QString
PosNO
=
FMTool
::
GetString
(
_request
.
DeviceNo
,
6
);
rlt
=
getrsacret
(
i
,
storeID
.
toLatin1
().
data
(),
PosNO
.
toLatin1
().
data
());
if
(
!
rlt
)
error
=
QString
::
fromLocal8Bit
(
"获取服务端返回数据失败"
);
loop
.
exit
();
});
loop
.
exec
();
}
}
else
{
SetRSACret
setRsaCret
=
(
SetRSACret
)
lib
.
resolve
(
"SetRSACret"
);
QLOG_ERROR
()
<<
"get function (GetRSACret) failed"
;
if
(
setRsaCret
!=
NULL
)
{
if
(
setRsaCret
(
out
.
data
()))
{
QLOG_INFO
()
<<
"setRSACret return success. "
;
return
true
;
}
else
{
error
=
"setRSACret return error."
;
QLOG_ERROR
()
<<
error
;
return
false
;
}
}
else
{
QLOG_ERROR
()
<<
"get function (SetRSACret) failed"
;
error
=
QString
::
fromLocal8Bit
(
"加载基础组件(fun)失败"
);
error
=
QString
::
fromLocal8Bit
(
"加载基础组件(fun)失败"
);
}
}
// GetRSACret getrsacret = (GetRSACret)lib.resolve("_GetRSACret@12");
// if(getrsacret != NULL)
// {
// QEventLoop loop;
// QtConcurrent::run( [ this, &loop, &rlt, &error, getrsacret]()
// {
// int i = FMTool::GetString(_request.PlatNo, 4).toInt();
// QString storeID = FMTool::GetString(_request.StoreNo, 20);
// QString PosNO = FMTool::GetString(_request.DeviceNo, 6);
// rlt = getrsacret(i, storeID.toLatin1().data(), PosNO.toLatin1().data());
// if(!rlt)
// error = QString::fromLocal8Bit("获取服务端返回数据失败");
// loop.exit();
// });
// loop.exec();
// }
// else
// {
// QLOG_ERROR() << "get function (GetRSACret) failed";
// error = QString::fromLocal8Bit("加载基础组件(fun)失败");
// }
}
}
else
else
{
{
...
@@ -323,6 +417,55 @@ bool Control::GetRSA(QString &error)
...
@@ -323,6 +417,55 @@ bool Control::GetRSA(QString &error)
return
rlt
;
return
rlt
;
}
}
QString
Control
::
GetMacString
(
bool
isSign
)
{
char
mod
[
MAX_PATH
]
=
{
0
};
GetProcPath
(
mod
);
QLibrary
lib
(
QString
(
mod
)
+
"
\\
"
+
"FreemudWrapper.dll"
);
if
(
lib
.
load
())
{
if
(
isSign
)
{
GetMac
getMac
=
(
GetMac
)
lib
.
resolve
(
"GetMac"
);
if
(
getMac
!=
NULL
)
{
char
mac
[
128
]
=
{
0
};
if
(
getMac
(
mac
)
==
1
)
{
QString
macStr
=
QString
::
fromUtf8
(
mac
);
QLOG_INFO
()
<<
"Get mac success: "
<<
macStr
;
return
macStr
;
}
else
{
QLOG_ERROR
()
<<
"Get mac failed."
;
}
}
else
{
QLOG_ERROR
()
<<
"get function (GetMac) failed"
;
}
}
else
{
GetRealMac
getMac
=
(
GetRealMac
)
lib
.
resolve
(
"GetRealMac"
);
if
(
getMac
!=
NULL
)
{
char
mac
[
128
]
=
{
0
};
if
(
getMac
(
mac
)
==
1
)
{
QString
macStr
=
QString
::
fromUtf8
(
mac
);
QLOG_INFO
()
<<
"Get mac success: "
<<
macStr
;
return
macStr
;
}
else
{
QLOG_ERROR
()
<<
"Get real mac failed."
;
}
}
else
{
QLOG_ERROR
()
<<
"get function (GetRealMac) failed"
;
}
}
}
else
{
QLOG_ERROR
()
<<
"load dll failed"
;
}
return
""
;
}
void
Control
::
RequestSign
()
void
Control
::
RequestSign
()
{
{
QString
error
;
QString
error
;
...
@@ -341,18 +484,20 @@ void Control::RequestSign()
...
@@ -341,18 +484,20 @@ void Control::RequestSign()
bool
Control
::
GetJson
(
ReqType
type
,
QJsonObject
&
json
,
const
QByteArray
array
,
QString
&
error
)
bool
Control
::
GetJson
(
ReqType
type
,
QJsonObject
&
json
,
const
QByteArray
array
,
QString
&
error
)
{
{
QJsonDocument
jsonDocument
=
QJsonDocument
::
fromJson
(
array
.
data
());
QJsonParseError
parseError
;
QJsonDocument
jsonDocument
=
QJsonDocument
::
fromJson
(
array
.
data
(),
&
parseError
);
if
(
jsonDocument
.
isNull
()
)
if
(
jsonDocument
.
isNull
()
)
{
{
QLOG_ERROR
()
<<
"server return not json"
;
QLOG_ERROR
()
<<
"server return not json"
<<
parseError
.
errorString
()
;
error
=
QString
::
fromLocal8Bit
(
"服务端返回数据异常"
);
error
=
QString
::
fromLocal8Bit
(
"服务端返回数据异常"
);
return
false
;
return
false
;
}
}
json
=
jsonDocument
.
object
();
json
=
jsonDocument
.
object
();
RspFactory
::
GetResPonseJson
(
type
,
_response
,
json
);
// RspFactory::GetResPonseJson(type, _response, json);
RspFactory
::
GetResPonseJson
(
type
,
_responseJsonObj
,
json
);
if
(
json
.
contains
(
JSON_KEY_MESSAGE
))
if
(
json
.
contains
(
JSON_KEY_MESSAGE
))
error
=
json
[
JSON_KEY_MESSAGE
].
toString
();
error
=
json
[
JSON_KEY_MESSAGE
].
toString
();
...
@@ -373,12 +518,22 @@ void Control::Request(ReqType type, QStringList list)
...
@@ -373,12 +518,22 @@ void Control::Request(ReqType type, QStringList list)
// bool rlt = SendMessageToPayMent(json, outdata, error);
// bool rlt = SendMessageToPayMent(json, outdata, error);
JsonFactory
::
GetJsonWithType
(
type
,
json
,
_posReqJsonObj
,
list
);
JsonFactory
::
GetJsonWithType
(
type
,
json
,
_posReqJsonObj
,
list
);
json
[
"ver"
]
=
1
;
json
[
"mac"
]
=
GetMacString
(
false
);
QByteArray
jsonArray
=
QJsonDocument
(
json
).
toJson
(
QJsonDocument
::
Compact
);
char
signStr
[
MAX_BUF_LEN
]
=
{
0
};
GetSPCCSign
(
jsonArray
.
data
(),
signStr
);
json
[
"sign"
]
=
QString
::
fromLocal8Bit
(
signStr
);
QLOG_INFO
()
<<
"Sign str: "
<<
signStr
;
bool
rlt
=
SendMessageToSBKAPI
(
json
,
outdata
,
error
);
bool
rlt
=
SendMessageToSBKAPI
(
json
,
outdata
,
error
);
if
(
rlt
)
if
(
rlt
)
rlt
=
Control
::
GetJson
(
type
,
rtjson
,
outdata
,
error
);
rlt
=
Control
::
GetJson
(
type
,
rtjson
,
outdata
,
error
);
else
if
(
!
rlt
)
SetResPonseWithMessage
(
"23"
,
error
);
SetResPonseWithMessage
(
"23"
,
error
);
...
...
sbkpay/control.h
View file @
566f0949
...
@@ -48,6 +48,8 @@ private:
...
@@ -48,6 +48,8 @@ private:
void
GetSPCCSign
(
char
*
in
,
char
*
out
);
void
GetSPCCSign
(
char
*
in
,
char
*
out
);
QString
GetMacString
(
bool
isSign
=
true
);
public
slots
:
public
slots
:
void
RequestWithType
(
ReqType
type
,
QStringList
list
);
void
RequestWithType
(
ReqType
type
,
QStringList
list
);
...
...
sbkpay/fmtool.h
View file @
566f0949
...
@@ -163,6 +163,25 @@ public:
...
@@ -163,6 +163,25 @@ public:
}
}
return
QJsonValue
();
return
QJsonValue
();
}
}
static
bool
SearchXMLNodeString
(
const
QString
&
xmlStr
,
const
QString
&
nodeName
,
QString
&
nodeStr
)
{
QRegularExpression
regExp
(
QString
(
"<%1>([
\\
s
\\
S]+)</%1>"
).
arg
(
nodeName
));
int
index
=
0
;
QRegularExpressionMatch
match
;
do
{
match
=
regExp
.
match
(
xmlStr
,
index
);
if
(
match
.
hasMatch
())
{
index
=
match
.
capturedEnd
();
nodeStr
=
match
.
captured
(
1
).
trimmed
();
return
true
;
}
else
{
break
;
}
}
while
(
index
<
xmlStr
.
length
());
return
false
;
}
};
};
...
...
sbkpay/hostwidget.cpp
View file @
566f0949
...
@@ -86,30 +86,7 @@ void HostWidget::keyPressEvent(QKeyEvent *ke)
...
@@ -86,30 +86,7 @@ void HostWidget::keyPressEvent(QKeyEvent *ke)
{
{
if
(
ke
->
key
()
==
Qt
::
Key_Return
&&
_curr_show_widget
==
ui
->
pay
)
if
(
ke
->
key
()
==
Qt
::
Key_Return
&&
_curr_show_widget
==
ui
->
pay
)
{
{
if
(
!
_need_exit
)
ShowPayWidget
();
{
ui
->
btn_pay_exit
->
hide
();
ui
->
label_pay_money
->
hide
();
_label_pay_timer
->
start
(
60
,
QString
::
fromLocal8Bit
(
"%1 秒"
));
QStringList
list
;
list
.
append
(
ui
->
lineEdit_pay_code
->
text
());
QLOG_INFO
()
<<
list
;
if
(
_type
==
pay
)
{
ui
->
label_pay_title
->
setText
(
QString
::
fromLocal8Bit
(
"支付宝支付中..."
));
emit
RequestWithType
(
pay
,
list
);
}
else
{
ui
->
label_pay_title
->
setText
(
QString
::
fromLocal8Bit
(
"支付宝退款中..."
));
emit
RequestWithType
(
refund
,
list
);
}
}
else
emit
Exits
();
}
}
else
else
{
{
...
@@ -117,6 +94,34 @@ void HostWidget::keyPressEvent(QKeyEvent *ke)
...
@@ -117,6 +94,34 @@ void HostWidget::keyPressEvent(QKeyEvent *ke)
}
}
}
}
void
HostWidget
::
ShowPayWidget
()
{
if
(
!
_need_exit
)
{
ui
->
btn_pay_exit
->
hide
();
ui
->
label_pay_money
->
hide
();
_label_pay_timer
->
start
(
60
,
QString
::
fromLocal8Bit
(
"%1 秒"
));
QStringList
list
;
list
.
append
(
ui
->
lineEdit_pay_code
->
text
());
QLOG_INFO
()
<<
list
;
if
(
_type
==
pay
)
{
ui
->
label_pay_title
->
setText
(
QString
::
fromLocal8Bit
(
"支付宝支付中..."
));
emit
RequestWithType
(
pay
,
list
);
}
else
{
ui
->
label_pay_title
->
setText
(
QString
::
fromLocal8Bit
(
"支付宝退款中..."
));
emit
RequestWithType
(
refund
,
list
);
}
}
else
emit
Exits
();
}
void
HostWidget
::
ShowWithRequest
(
AlipayRequest
request
)
void
HostWidget
::
ShowWithRequest
(
AlipayRequest
request
)
{
{
QString
reqtype
;
QString
reqtype
;
...
@@ -157,6 +162,8 @@ void HostWidget::ShowWithRequest(QJsonObject requestObj)
...
@@ -157,6 +162,8 @@ void HostWidget::ShowWithRequest(QJsonObject requestObj)
{
{
int
reqtype
=
FMTool
::
GetJsonValue
(
requestObj
,
JSON_KEY_REQTYPE
).
toInt
();
int
reqtype
=
FMTool
::
GetJsonValue
(
requestObj
,
JSON_KEY_REQTYPE
).
toInt
();
_posReqJsonObj
=
requestObj
;
switch
(
reqtype
)
{
switch
(
reqtype
)
{
case
manage
:
case
manage
:
{
{
...
@@ -188,6 +195,7 @@ void HostWidget::ShowWithRequest(QJsonObject requestObj)
...
@@ -188,6 +195,7 @@ void HostWidget::ShowWithRequest(QJsonObject requestObj)
case
SPCC_sign
:
{
case
SPCC_sign
:
{
ShowWidget
(
ui
->
Manager
);
ShowWidget
(
ui
->
Manager
);
_curr_show_widget
=
ui
->
Manager
;
_curr_show_widget
=
ui
->
Manager
;
on_btn_mananger_register_clicked
();
break
;
break
;
}
}
case
SPCC_manage
:
{
case
SPCC_manage
:
{
...
@@ -210,9 +218,12 @@ void HostWidget::ShowWithRequest(QJsonObject requestObj)
...
@@ -210,9 +218,12 @@ void HostWidget::ShowWithRequest(QJsonObject requestObj)
ShowWidget
(
ui
->
pay
);
ShowWidget
(
ui
->
pay
);
_curr_show_widget
=
ui
->
pay
;
_curr_show_widget
=
ui
->
pay
;
double
Amount
=
FMTool
::
GetJsonValue
(
requestObj
,
JSON_KEY_TRANSAMOUNT
).
toInt
()
/
100.0
;
double
Amount
=
FMTool
::
GetJsonValue
(
requestObj
,
JSON_KEY_TRANSAMOUNT
).
toInt
()
/
100.0
;
QString
FmId
=
FMTool
::
GetJsonValue
(
requestObj
,
JSON_KEY_FMID
).
toString
();
ui
->
label_pay_title
->
setText
(
QString
::
fromLocal8Bit
(
"请扫描退款凭证号"
));
ui
->
label_pay_title
->
setText
(
QString
::
fromLocal8Bit
(
"请扫描退款凭证号"
));
ui
->
btn_pay_exit
->
setText
(
QString
::
fromLocal8Bit
(
"取消退款"
));
ui
->
btn_pay_exit
->
setText
(
QString
::
fromLocal8Bit
(
"取消退款"
));
ui
->
label_pay_money
->
setText
(
QString
::
fromLocal8Bit
(
"退款 ¥ %1"
).
arg
(
Amount
));
ui
->
label_pay_money
->
setText
(
QString
::
fromLocal8Bit
(
"退款 ¥ %1"
).
arg
(
Amount
));
ui
->
lineEdit_pay_code
->
setText
(
FmId
);
ShowPayWidget
();
break
;
break
;
}
}
default
:
default
:
...
@@ -298,7 +309,8 @@ void HostWidget::on_btn_mananger_register_clicked()
...
@@ -298,7 +309,8 @@ void HostWidget::on_btn_mananger_register_clicked()
ui
->
btn_sign_sign
->
hide
();
ui
->
btn_sign_sign
->
hide
();
ui
->
label_sign_title
->
setText
(
QString
::
fromLocal8Bit
(
"签到中..."
));
ui
->
label_sign_title
->
setText
(
QString
::
fromLocal8Bit
(
"签到中..."
));
ui
->
label_sign_msg
->
setText
(
""
);
ui
->
label_sign_msg
->
setText
(
""
);
ui
->
label_sign_storeid
->
setText
(
FMTool
::
GetString
(
_data
.
StoreNo
,
20
));
// ui->label_sign_storeid->setText(FMTool::GetString(_data.StoreNo, 20));
ui
->
label_sign_storeid
->
setText
(
FMTool
::
GetJsonValue
(
_posReqJsonObj
,
JSON_KEY_STOREID
).
toString
());
emit
RequestWithType
(
sign
,
list
);
emit
RequestWithType
(
sign
,
list
);
}
}
...
...
sbkpay/hostwidget.h
View file @
566f0949
...
@@ -64,6 +64,8 @@ private:
...
@@ -64,6 +64,8 @@ private:
void
InitWidget
();
void
InitWidget
();
void
ShowPayWidget
();
private
:
private
:
Ui
::
HostWidget
*
ui
;
Ui
::
HostWidget
*
ui
;
...
@@ -72,6 +74,7 @@ private:
...
@@ -72,6 +74,7 @@ private:
QWidget
*
_curr_show_widget
;
QWidget
*
_curr_show_widget
;
AlipayRequest
_data
;
AlipayRequest
_data
;
QJsonObject
_posReqJsonObj
;
LabelsTimer
*
_label_pay_timer
;
LabelsTimer
*
_label_pay_timer
;
...
...
sbkpay/jsonfactory.h
View file @
566f0949
...
@@ -32,11 +32,14 @@ public:
...
@@ -32,11 +32,14 @@ public:
static
bool
GetJsonWithType
(
ReqType
type
,
QJsonObject
&
json
,
const
QJsonObject
&
reqJson
,
QStringList
list
)
static
bool
GetJsonWithType
(
ReqType
type
,
QJsonObject
&
json
,
const
QJsonObject
&
reqJson
,
QStringList
list
)
{
{
switch
(
type
)
{
switch
(
type
)
{
case
sign
:
return
GetSignJson
(
json
,
reqJson
,
list
);
case
pay
:
case
pay
:
return
GetPayJson
(
json
,
reqJson
,
list
);
return
GetPayJson
(
json
,
reqJson
,
list
);
case
refund
:
case
refund
:
return
GetRefundJosn
(
json
,
reqJson
,
list
);
return
GetRefundJosn
(
json
,
reqJson
,
list
);
default
:
default
:
json
=
reqJson
;
break
;
break
;
}
}
}
}
...
@@ -65,6 +68,15 @@ public:
...
@@ -65,6 +68,15 @@ public:
}
}
private
:
private
:
static
bool
GetSignJson
(
QJsonObject
&
json
,
const
QJsonObject
&
reqJson
,
QStringList
l
)
{
json
[
JSON_KEY_VER
]
=
reqJson
[
JSON_KEY_VER
];
json
[
JSON_KEY_PARTNERID
]
=
reqJson
[
JSON_KEY_PARTNERID
];
json
[
JSON_KEY_STOREID
]
=
reqJson
[
JSON_KEY_STOREID
];
json
[
JSON_KEY_STATIONID
]
=
reqJson
[
JSON_KEY_STATIONID
];
return
true
;
}
//支付
//支付
static
bool
GetPayJson
(
QJsonObject
&
json
,
const
AlipayRequest
&
request
,
QStringList
list
)
static
bool
GetPayJson
(
QJsonObject
&
json
,
const
AlipayRequest
&
request
,
QStringList
list
)
{
{
...
...
sbkpay/main.cpp
View file @
566f0949
...
@@ -288,7 +288,7 @@ int main(int argc, char *argv[])
...
@@ -288,7 +288,7 @@ int main(int argc, char *argv[])
// control.Start(as, b);
// control.Start(as, b);
char
spccIn
[
MAX_BUF_LEN
]
=
"{
\"
reqType
\"
:353,
\"
storeId
\"
:
\"
1713
\"
,
\"
stationId
\"
:
\"
1
\"
,
\"
partnerId
\"
:1443,
\"
operatorId
\"
:
\"
sssaw
\"
,
\"
transId
\"
:
\"
52342342323806
\"
,
\"
transAmount
\"
:8000,
\"
partnerOrderId
\"
:
\"
909911039993720192019
\"
,
\"
businessDate
\"
:
\"
20170508
\"
,
\"
products
\"
:[{
\"
pid
\"
:
\"
123
\"
,
\"
name
\"
:
\"
中杯拿铁
\"
,
\"
price
\"
:321,
\"
salesType
\"
:
\"
NORMAL
\"
}]}"
;
char
spccIn
[
MAX_BUF_LEN
]
=
"{
\"
fmId
\"
:
\"
0123456789012345678
\"
,
\"
reqType
\"
:353,
\"
storeId
\"
:
\"
1713
\"
,
\"
stationId
\"
:
\"
1
\"
,
\"
partnerId
\"
:1443,
\"
operatorId
\"
:
\"
sssaw
\"
,
\"
transId
\"
:
\"
52342342323806
\"
,
\"
transAmount
\"
:8000,
\"
partnerOrderId
\"
:
\"
909911039993720192019
\"
,
\"
businessDate
\"
:
\"
20170508
\"
,
\"
products
\"
:[{
\"
pid
\"
:
\"
123
\"
,
\"
name
\"
:
\"
中杯拿铁
\"
,
\"
price
\"
:321,
\"
salesType
\"
:
\"
NORMAL
\"
}]}"
;
control
.
Start
(
spccIn
,
b
);
control
.
Start
(
spccIn
,
b
);
return
a
.
exec
();
return
a
.
exec
();
...
...
sbkpay/rspfactory.h
View file @
566f0949
...
@@ -33,6 +33,23 @@ public:
...
@@ -33,6 +33,23 @@ public:
return
false
;
return
false
;
}
}
static
bool
GetResPonseJson
(
ReqType
type
,
QJsonObject
&
response
,
const
QJsonObject
&
json
)
{
if
(
json
.
isEmpty
())
return
false
;
if
(
type
==
sign
)
return
GetSignResponse
(
response
,
json
);
if
(
type
==
pay
)
return
GetPayResponse
(
response
,
json
);
if
(
type
==
refund
)
return
GetRefundResponse
(
response
,
json
);
return
false
;
}
static
bool
GetResPonseWithError
(
AlipayResponse
&
response
,
QString
errorcode
,
QString
message
)
static
bool
GetResPonseWithError
(
AlipayResponse
&
response
,
QString
errorcode
,
QString
message
)
{
{
if
(
errorcode
.
isEmpty
()
||
message
.
isEmpty
())
if
(
errorcode
.
isEmpty
()
||
message
.
isEmpty
())
...
@@ -50,6 +67,12 @@ public:
...
@@ -50,6 +67,12 @@ public:
private
:
private
:
#endif
#endif
static
bool
GetSignResponse
(
QJsonObject
&
response
,
const
QJsonObject
&
json
)
{
response
=
json
;
return
true
;
}
static
bool
GetPayResponse
(
AlipayResponse
&
response
,
const
QJsonObject
&
json
)
static
bool
GetPayResponse
(
AlipayResponse
&
response
,
const
QJsonObject
&
json
)
{
{
FMTool
::
SetString
(
response
.
ResponseCode
,
3
,
QString
::
number
(
json
[
JSON_KEY_STATUSCODE
].
toInt
()));
FMTool
::
SetString
(
response
.
ResponseCode
,
3
,
QString
::
number
(
json
[
JSON_KEY_STATUSCODE
].
toInt
()));
...
@@ -62,6 +85,20 @@ private:
...
@@ -62,6 +85,20 @@ private:
return
true
;
return
true
;
}
}
static
bool
GetPayResponse
(
QJsonObject
&
response
,
const
QJsonObject
&
json
)
{
response
=
json
;
// FMTool::SetString(response.ResponseCode, 3, QString::number(json[JSON_KEY_STATUSCODE].toInt()));
// FMTool::SetString(response.ResponseMsg, 40, json[JSON_KEY_MESSAGE].toString());
// FMTool::SetString(response.CardTraceNo, 40, json[JSON_KEY_FMID].toString());
// FMTool::SetString(response.NeedPrint, 2, QString("01"));
// if(json[JSON_KEY_STATUSCODE].toInt() == 100)
// return SetPinter(response, json);
return
true
;
}
static
bool
GetRefundResponse
(
AlipayResponse
&
response
,
const
QJsonObject
&
json
)
static
bool
GetRefundResponse
(
AlipayResponse
&
response
,
const
QJsonObject
&
json
)
{
{
FMTool
::
SetString
(
response
.
ResponseCode
,
3
,
QString
::
number
(
json
[
JSON_KEY_STATUSCODE
].
toInt
()));
FMTool
::
SetString
(
response
.
ResponseCode
,
3
,
QString
::
number
(
json
[
JSON_KEY_STATUSCODE
].
toInt
()));
...
@@ -69,12 +106,27 @@ private:
...
@@ -69,12 +106,27 @@ private:
FMTool
::
SetString
(
response
.
CardTraceNo
,
40
,
json
[
JSON_KEY_FMID
].
toString
());
FMTool
::
SetString
(
response
.
CardTraceNo
,
40
,
json
[
JSON_KEY_FMID
].
toString
());
FMTool
::
SetString
(
response
.
NeedPrint
,
2
,
QString
(
"01"
));
FMTool
::
SetString
(
response
.
NeedPrint
,
2
,
QString
(
"01"
));
if
(
json
[
JSON_KEY_STATUSCODE
].
toInt
()
==
100
)
//
if(json[JSON_KEY_STATUSCODE].toInt() == 100)
return
SetPinter
(
response
,
json
);
//
return SetPinter(response, json);
return
true
;
return
true
;
}
}
static
bool
GetRefundResponse
(
QJsonObject
&
response
,
const
QJsonObject
&
json
)
{
response
=
json
;
// FMTool::SetString(response.ResponseCode, 3, QString::number(json[JSON_KEY_STATUSCODE].toInt()));
// FMTool::SetString(response.ResponseMsg, 40, json[JSON_KEY_MESSAGE].toString());
// FMTool::SetString(response.CardTraceNo, 40, json[JSON_KEY_FMID].toString());
// FMTool::SetString(response.NeedPrint, 2, QString("01"));
// if(json[JSON_KEY_STATUSCODE].toInt() == 100)
// return SetPinter(response, json);
return
true
;
}
static
bool
GetDayEndResponse
(
AlipayResponse
&
response
,
const
QJsonObject
&
json
)
static
bool
GetDayEndResponse
(
AlipayResponse
&
response
,
const
QJsonObject
&
json
)
{
{
FMTool
::
SetString
(
response
.
ResponseCode
,
3
,
QString
::
number
(
json
[
JSON_KEY_STATUSCODE
].
toInt
()));
FMTool
::
SetString
(
response
.
ResponseCode
,
3
,
QString
::
number
(
json
[
JSON_KEY_STATUSCODE
].
toInt
()));
...
...
sbkpay/sbkpay.pro
View file @
566f0949
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
#
#
#-------------------------------------------------
#-------------------------------------------------
QT
+=
core
gui
concurrent
QT
+=
core
gui
concurrent
xml
greaterThan
(
QT_MAJOR_VERSION
,
4
)
:
QT
+=
widgets
greaterThan
(
QT_MAJOR_VERSION
,
4
)
:
QT
+=
widgets
...
@@ -13,7 +13,9 @@ TARGET = sbkpay
...
@@ -13,7 +13,9 @@ TARGET = sbkpay
include
(
"./QsLog/QsLog.pri"
)
include
(
"./QsLog/QsLog.pri"
)
CONFIG
+=
C
++
11
SBKDLL
CONFIG
+=
C
++
11
#CONFIG += SBKTEST
#CONFIG += SBKDLL
include
(
$$
PWD
/
qtwinmigrate
/
src
/
qtwinmigrate
.
pri
)
include
(
$$
PWD
/
qtwinmigrate
/
src
/
qtwinmigrate
.
pri
)
...
@@ -35,7 +37,8 @@ release {
...
@@ -35,7 +37,8 @@ release {
SOURCES
+=
main
.
cpp
\
SOURCES
+=
main
.
cpp
\
hostwidget
.
cpp
\
hostwidget
.
cpp
\
control
.
cpp
\
control
.
cpp
\
labelstimer
.
cpp
labelstimer
.
cpp
\
xmlreader
.
cpp
HEADERS
+=
hostwidget
.
h
\
HEADERS
+=
hostwidget
.
h
\
fmp_window
.
h
\
fmp_window
.
h
\
...
@@ -48,7 +51,8 @@ HEADERS += hostwidget.h \
...
@@ -48,7 +51,8 @@ HEADERS += hostwidget.h \
jsonfactory
.
h
\
jsonfactory
.
h
\
labelstimer
.
h
\
labelstimer
.
h
\
rspfactory
.
h
\
rspfactory
.
h
\
reqfactory
.
h
reqfactory
.
h
\
xmlreader
.
h
FORMS
+=
hostwidget
.
ui
FORMS
+=
hostwidget
.
ui
...
...
sbkpay/sbkpay.pro.user
View file @
566f0949
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator
3.5.1, 2017-08-14T12:31:22
. -->
<!-- Written by QtCreator
4.3.1, 2017-08-19T15:59:53
. -->
<qtcreator>
<qtcreator>
<data>
<data>
<variable>
EnvironmentId
</variable>
<variable>
EnvironmentId
</variable>
<value
type=
"QByteArray"
>
{
45ff7264-c067-4213-ad04-937bad1dfb10
}
</value>
<value
type=
"QByteArray"
>
{
ca824a60-ba93-49e5-b668-ae93bbb68724
}
</value>
</data>
</data>
<data>
<data>
<variable>
ProjectExplorer.Project.ActiveTarget
</variable>
<variable>
ProjectExplorer.Project.ActiveTarget
</variable>
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
<value
type=
"bool"
key=
"EditorConfiguration.ScrollWheelZooming"
>
true
</value>
<value
type=
"bool"
key=
"EditorConfiguration.ScrollWheelZooming"
>
true
</value>
<value
type=
"bool"
key=
"EditorConfiguration.ShowMargin"
>
false
</value>
<value
type=
"bool"
key=
"EditorConfiguration.ShowMargin"
>
false
</value>
<value
type=
"int"
key=
"EditorConfiguration.SmartBackspaceBehavior"
>
0
</value>
<value
type=
"int"
key=
"EditorConfiguration.SmartBackspaceBehavior"
>
0
</value>
<value
type=
"bool"
key=
"EditorConfiguration.SmartSelectionChanging"
>
true
</value>
<value
type=
"bool"
key=
"EditorConfiguration.SpacesForTabs"
>
true
</value>
<value
type=
"bool"
key=
"EditorConfiguration.SpacesForTabs"
>
true
</value>
<value
type=
"int"
key=
"EditorConfiguration.TabKeyBehavior"
>
0
</value>
<value
type=
"int"
key=
"EditorConfiguration.TabKeyBehavior"
>
0
</value>
<value
type=
"int"
key=
"EditorConfiguration.TabSize"
>
8
</value>
<value
type=
"int"
key=
"EditorConfiguration.TabSize"
>
8
</value>
...
@@ -58,22 +59,21 @@
...
@@ -58,22 +59,21 @@
<data>
<data>
<variable>
ProjectExplorer.Project.Target.0
</variable>
<variable>
ProjectExplorer.Project.Target.0
</variable>
<valuemap
type=
"QVariantMap"
>
<valuemap
type=
"QVariantMap"
>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Desktop Qt 5.5.1 MSVC2010 32bit
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Qt5.5.1 MSVC2010
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
>
Desktop Qt 5.5.1 MSVC2010 32bit
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
>
Qt5.5.1 MSVC2010
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
qt.55.win32_msvc2010_kit
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
{373b91dc-3ee0-4b8c-ab5f-13bc6628cb59}
</value>
<value
type=
"int"
key=
"ProjectExplorer.Target.ActiveBuildConfiguration"
>
1
</value>
<value
type=
"int"
key=
"ProjectExplorer.Target.ActiveBuildConfiguration"
>
0
</value>
<value
type=
"int"
key=
"ProjectExplorer.Target.ActiveDeployConfiguration"
>
0
</value>
<value
type=
"int"
key=
"ProjectExplorer.Target.ActiveDeployConfiguration"
>
0
</value>
<value
type=
"int"
key=
"ProjectExplorer.Target.ActiveRunConfiguration"
>
0
</value>
<value
type=
"int"
key=
"ProjectExplorer.Target.ActiveRunConfiguration"
>
0
</value>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.Target.BuildConfiguration.0"
>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.Target.BuildConfiguration.0"
>
<value
type=
"QString"
key=
"ProjectExplorer.BuildConfiguration.BuildDirectory"
>
D:/gitcode/sbkpay/build-sbkpay-Desktop_Qt_5_5_1_MSVC2010_32bit
-Debug
</value>
<value
type=
"QString"
key=
"ProjectExplorer.BuildConfiguration.BuildDirectory"
>
E:/Qt/sbkpay/build-sbkpay-Qt5_5_1_MSVC2010
-Debug
</value>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.BuildConfiguration.BuildStepList.0"
>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.BuildConfiguration.BuildStepList.0"
>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.BuildStepList.Step.0"
>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.BuildStepList.Step.0"
>
<value
type=
"bool"
key=
"ProjectExplorer.BuildStep.Enabled"
>
true
</value>
<value
type=
"bool"
key=
"ProjectExplorer.BuildStep.Enabled"
>
true
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
qmake
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
qmake
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
QtProjectManager.QMakeBuildStep
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
QtProjectManager.QMakeBuildStep
</value>
<value
type=
"bool"
key=
"QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary"
>
false
</value>
<value
type=
"bool"
key=
"QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary"
>
true
</value>
<value
type=
"bool"
key=
"QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto"
>
true
</value>
<value
type=
"QString"
key=
"QtProjectManager.QMakeBuildStep.QMakeArguments"
></value>
<value
type=
"QString"
key=
"QtProjectManager.QMakeBuildStep.QMakeArguments"
></value>
<value
type=
"bool"
key=
"QtProjectManager.QMakeBuildStep.QMakeForced"
>
false
</value>
<value
type=
"bool"
key=
"QtProjectManager.QMakeBuildStep.QMakeForced"
>
false
</value>
<value
type=
"bool"
key=
"QtProjectManager.QMakeBuildStep.SeparateDebugInfo"
>
false
</value>
<value
type=
"bool"
key=
"QtProjectManager.QMakeBuildStep.SeparateDebugInfo"
>
false
</value>
...
@@ -120,7 +120,7 @@
...
@@ -120,7 +120,7 @@
<value
type=
"bool"
key=
"Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild"
>
true
</value>
<value
type=
"bool"
key=
"Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild"
>
true
</value>
</valuemap>
</valuemap>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.Target.BuildConfiguration.1"
>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.Target.BuildConfiguration.1"
>
<value
type=
"QString"
key=
"ProjectExplorer.BuildConfiguration.BuildDirectory"
>
D:/gitcode/sbkpay/build-sbkpay-Desktop_Qt_5_5_1_MSVC2010_32bit
-Release
</value>
<value
type=
"QString"
key=
"ProjectExplorer.BuildConfiguration.BuildDirectory"
>
E:/Qt/sbkpay/build-sbkpay-Qt5_5_1_MSVC2010
-Release
</value>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.BuildConfiguration.BuildStepList.0"
>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.BuildConfiguration.BuildStepList.0"
>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.BuildStepList.Step.0"
>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.BuildStepList.Step.0"
>
<value
type=
"bool"
key=
"ProjectExplorer.BuildStep.Enabled"
>
true
</value>
<value
type=
"bool"
key=
"ProjectExplorer.BuildStep.Enabled"
>
true
</value>
...
@@ -128,7 +128,6 @@
...
@@ -128,7 +128,6 @@
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
QtProjectManager.QMakeBuildStep
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
QtProjectManager.QMakeBuildStep
</value>
<value
type=
"bool"
key=
"QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary"
>
false
</value>
<value
type=
"bool"
key=
"QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary"
>
false
</value>
<value
type=
"bool"
key=
"QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto"
>
true
</value>
<value
type=
"QString"
key=
"QtProjectManager.QMakeBuildStep.QMakeArguments"
></value>
<value
type=
"QString"
key=
"QtProjectManager.QMakeBuildStep.QMakeArguments"
></value>
<value
type=
"bool"
key=
"QtProjectManager.QMakeBuildStep.QMakeForced"
>
false
</value>
<value
type=
"bool"
key=
"QtProjectManager.QMakeBuildStep.QMakeForced"
>
false
</value>
<value
type=
"bool"
key=
"QtProjectManager.QMakeBuildStep.SeparateDebugInfo"
>
false
</value>
<value
type=
"bool"
key=
"QtProjectManager.QMakeBuildStep.SeparateDebugInfo"
>
false
</value>
...
@@ -174,7 +173,61 @@
...
@@ -174,7 +173,61 @@
<value
type=
"int"
key=
"Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration"
>
0
</value>
<value
type=
"int"
key=
"Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration"
>
0
</value>
<value
type=
"bool"
key=
"Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild"
>
true
</value>
<value
type=
"bool"
key=
"Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild"
>
true
</value>
</valuemap>
</valuemap>
<value
type=
"int"
key=
"ProjectExplorer.Target.BuildConfigurationCount"
>
2
</value>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.Target.BuildConfiguration.2"
>
<value
type=
"QString"
key=
"ProjectExplorer.BuildConfiguration.BuildDirectory"
>
E:/Qt/sbkpay/build-sbkpay-Qt5_5_1_MSVC2010-Profile
</value>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.BuildConfiguration.BuildStepList.0"
>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.BuildStepList.Step.0"
>
<value
type=
"bool"
key=
"ProjectExplorer.BuildStep.Enabled"
>
true
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
qmake
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
QtProjectManager.QMakeBuildStep
</value>
<value
type=
"bool"
key=
"QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary"
>
true
</value>
<value
type=
"QString"
key=
"QtProjectManager.QMakeBuildStep.QMakeArguments"
></value>
<value
type=
"bool"
key=
"QtProjectManager.QMakeBuildStep.QMakeForced"
>
false
</value>
<value
type=
"bool"
key=
"QtProjectManager.QMakeBuildStep.SeparateDebugInfo"
>
true
</value>
<value
type=
"bool"
key=
"QtProjectManager.QMakeBuildStep.UseQtQuickCompiler"
>
false
</value>
</valuemap>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.BuildStepList.Step.1"
>
<value
type=
"bool"
key=
"ProjectExplorer.BuildStep.Enabled"
>
true
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Make
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
Qt4ProjectManager.MakeStep
</value>
<valuelist
type=
"QVariantList"
key=
"Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"
/>
<value
type=
"bool"
key=
"Qt4ProjectManager.MakeStep.Clean"
>
false
</value>
<value
type=
"QString"
key=
"Qt4ProjectManager.MakeStep.MakeArguments"
></value>
<value
type=
"QString"
key=
"Qt4ProjectManager.MakeStep.MakeCommand"
></value>
</valuemap>
<value
type=
"int"
key=
"ProjectExplorer.BuildStepList.StepsCount"
>
2
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
构建
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
ProjectExplorer.BuildSteps.Build
</value>
</valuemap>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.BuildConfiguration.BuildStepList.1"
>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.BuildStepList.Step.0"
>
<value
type=
"bool"
key=
"ProjectExplorer.BuildStep.Enabled"
>
true
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Make
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
Qt4ProjectManager.MakeStep
</value>
<valuelist
type=
"QVariantList"
key=
"Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"
/>
<value
type=
"bool"
key=
"Qt4ProjectManager.MakeStep.Clean"
>
true
</value>
<value
type=
"QString"
key=
"Qt4ProjectManager.MakeStep.MakeArguments"
>
clean
</value>
<value
type=
"QString"
key=
"Qt4ProjectManager.MakeStep.MakeCommand"
></value>
</valuemap>
<value
type=
"int"
key=
"ProjectExplorer.BuildStepList.StepsCount"
>
1
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
清理
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
ProjectExplorer.BuildSteps.Clean
</value>
</valuemap>
<value
type=
"int"
key=
"ProjectExplorer.BuildConfiguration.BuildStepListCount"
>
2
</value>
<value
type=
"bool"
key=
"ProjectExplorer.BuildConfiguration.ClearSystemEnvironment"
>
false
</value>
<valuelist
type=
"QVariantList"
key=
"ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"
/>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Profile
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
Qt4ProjectManager.Qt4BuildConfiguration
</value>
<value
type=
"int"
key=
"Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration"
>
0
</value>
<value
type=
"bool"
key=
"Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild"
>
true
</value>
</valuemap>
<value
type=
"int"
key=
"ProjectExplorer.Target.BuildConfigurationCount"
>
3
</value>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.Target.DeployConfiguration.0"
>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.Target.DeployConfiguration.0"
>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.BuildConfiguration.BuildStepList.0"
>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.BuildConfiguration.BuildStepList.0"
>
<value
type=
"int"
key=
"ProjectExplorer.BuildStepList.StepsCount"
>
0
</value>
<value
type=
"int"
key=
"ProjectExplorer.BuildStepList.StepsCount"
>
0
</value>
...
@@ -190,6 +243,11 @@
...
@@ -190,6 +243,11 @@
<value
type=
"int"
key=
"ProjectExplorer.Target.DeployConfigurationCount"
>
1
</value>
<value
type=
"int"
key=
"ProjectExplorer.Target.DeployConfigurationCount"
>
1
</value>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.Target.PluginSettings"
/>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.Target.PluginSettings"
/>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.Target.RunConfiguration.0"
>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.Target.RunConfiguration.0"
>
<value
type=
"bool"
key=
"Analyzer.QmlProfiler.AggregateTraces"
>
false
</value>
<value
type=
"bool"
key=
"Analyzer.QmlProfiler.FlushEnabled"
>
false
</value>
<value
type=
"uint"
key=
"Analyzer.QmlProfiler.FlushInterval"
>
1000
</value>
<value
type=
"QString"
key=
"Analyzer.QmlProfiler.LastTraceFile"
></value>
<value
type=
"bool"
key=
"Analyzer.QmlProfiler.Settings.UseGlobalSettings"
>
true
</value>
<valuelist
type=
"QVariantList"
key=
"Analyzer.Valgrind.AddedSuppressionFiles"
/>
<valuelist
type=
"QVariantList"
key=
"Analyzer.Valgrind.AddedSuppressionFiles"
/>
<value
type=
"bool"
key=
"Analyzer.Valgrind.Callgrind.CollectBusEvents"
>
false
</value>
<value
type=
"bool"
key=
"Analyzer.Valgrind.Callgrind.CollectBusEvents"
>
false
</value>
<value
type=
"bool"
key=
"Analyzer.Valgrind.Callgrind.CollectSystime"
>
false
</value>
<value
type=
"bool"
key=
"Analyzer.Valgrind.Callgrind.CollectSystime"
>
false
</value>
...
@@ -226,12 +284,15 @@
...
@@ -226,12 +284,15 @@
</valuelist>
</valuelist>
<value
type=
"int"
key=
"PE.EnvironmentAspect.Base"
>
2
</value>
<value
type=
"int"
key=
"PE.EnvironmentAspect.Base"
>
2
</value>
<valuelist
type=
"QVariantList"
key=
"PE.EnvironmentAspect.Changes"
/>
<valuelist
type=
"QVariantList"
key=
"PE.EnvironmentAspect.Changes"
/>
<value
type=
"QString"
key=
"ProjectExplorer.CustomExecutableRunConfiguration.Arguments"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
sbkpay
</value>
<value
type=
"QString"
key=
"ProjectExplorer.CustomExecutableRunConfiguration.Executable"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory"
>
%{buildDir}
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
自定义执行档
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
ProjectExplorer.CustomExecutableRunConfiguration
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
Qt4ProjectManager.Qt4RunConfiguration:E:/Qt/sbkpay/sbkpay/sbkpay.pro
</value>
<value
type=
"bool"
key=
"QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath"
>
true
</value>
<value
type=
"QString"
key=
"Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"
></value>
<value
type=
"QString"
key=
"Qt4ProjectManager.Qt4RunConfiguration.ProFile"
>
sbkpay.pro
</value>
<value
type=
"bool"
key=
"Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix"
>
false
</value>
<value
type=
"QString"
key=
"Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"
></value>
<value
type=
"QString"
key=
"Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default"
>
E:/Qt/sbkpay/build-sbkpay-Qt5_5_1_MSVC2010-Debug
</value>
<value
type=
"uint"
key=
"RunConfiguration.QmlDebugServerPort"
>
3768
</value>
<value
type=
"uint"
key=
"RunConfiguration.QmlDebugServerPort"
>
3768
</value>
<value
type=
"bool"
key=
"RunConfiguration.UseCppDebugger"
>
false
</value>
<value
type=
"bool"
key=
"RunConfiguration.UseCppDebugger"
>
false
</value>
<value
type=
"bool"
key=
"RunConfiguration.UseCppDebuggerAuto"
>
true
</value>
<value
type=
"bool"
key=
"RunConfiguration.UseCppDebuggerAuto"
>
true
</value>
...
...
sbkpay/xmlreader.cpp
0 → 100644
View file @
566f0949
#include "xmlreader.h"
#include <QDebug>
#include <QFile>
#include <QDomNodeList>
XMLReader
::
XMLReader
(
QObject
*
parent
)
:
QObject
(
parent
)
{
}
XMLReader
::~
XMLReader
()
{
}
bool
XMLReader
::
parserFile
(
const
QString
&
xmlFile
,
QDomNode
&
root
)
{
QFile
f
(
xmlFile
);
if
(
!
f
.
open
(
QIODevice
::
ReadOnly
))
{
errorString
=
QString
(
"Open file: %1 failed.
\n
%2"
).
arg
(
xmlFile
).
arg
(
f
.
errorString
());
return
false
;
}
int
errorLine
,
errorColumn
;
if
(
!
xmlDoc
.
setContent
(
&
f
,
&
errorString
,
&
errorLine
,
&
errorColumn
))
{
errorString
+=
QString
(
" Line: %1, Column: %2"
).
arg
(
errorLine
).
arg
(
errorColumn
);
return
false
;
}
root
=
xmlDoc
.
firstChild
();
return
true
;
}
bool
XMLReader
::
parser
(
const
QString
&
xmlString
)
{
int
errorLine
,
errorColumn
;
if
(
!
xmlDoc
.
setContent
(
xmlString
,
&
errorString
,
&
errorLine
,
&
errorColumn
))
{
errorString
+=
QString
(
" Line: %1, Column: %2"
).
arg
(
errorLine
).
arg
(
errorColumn
);
return
false
;
}
return
true
;
}
QList
<
QDomNode
>
XMLReader
::
findElements
(
const
QString
&
name
)
{
QList
<
QDomNode
>
nodeList
;
QDomNodeList
domNodeList
=
xmlDoc
.
elementsByTagName
(
name
);
for
(
int
i
=
0
;
i
<
domNodeList
.
length
();
i
++
)
{
nodeList
.
append
(
domNodeList
.
at
(
i
));
}
return
nodeList
;
}
QList
<
QDomNode
>
XMLReader
::
findElementsByAttr
(
const
QString
&
name
,
const
Attributes
&
attr
)
{
QList
<
QDomNode
>
nodeList
=
findElements
(
name
);
foreach
(
QDomNode
node
,
nodeList
)
{
foreach
(
QString
attrName
,
attr
.
keys
())
{
QString
attrValue
=
attr
[
attrName
];
if
(
!
checkAttributeValue
(
node
,
attrName
,
attrValue
))
{
nodeList
.
removeOne
(
node
);
break
;
}
}
}
return
nodeList
;
}
QMap
<
QString
,
QList
<
QDomNode
>
>
XMLReader
::
groupElementsByAttr
(
const
QString
&
nodeName
,
const
QString
&
attrName
)
{
QMap
<
QString
,
QList
<
QDomNode
>
>
nodeMap
;
QList
<
QDomNode
>
nodeList
=
findElements
(
nodeName
);
foreach
(
QDomNode
node
,
nodeList
)
{
QString
attrValue
=
getAttributeValue
(
node
,
attrName
);
if
(
nodeMap
.
contains
(
attrValue
))
{
nodeMap
[
attrValue
].
append
(
node
);
}
else
{
QList
<
QDomNode
>
tempNodeList
;
tempNodeList
.
append
(
node
);
nodeMap
[
attrValue
]
=
tempNodeList
;
}
}
return
nodeMap
;
}
Attributes
XMLReader
::
getAttributes
(
const
QDomNode
&
node
)
{
Attributes
attrs
;
QDomNamedNodeMap
attrNodeMap
=
node
.
attributes
();
for
(
int
i
=
0
;
i
<
attrNodeMap
.
length
();
i
++
)
{
QDomNode
attrNode
=
attrNodeMap
.
item
(
i
);
if
(
attrNode
.
isAttr
())
{
attrs
[
attrNode
.
nodeName
()]
=
attrNode
.
nodeValue
();
}
}
return
attrs
;
}
QString
XMLReader
::
getAttributeValue
(
const
QDomNode
&
node
,
const
QString
&
attrName
)
{
QString
value
;
if
(
!
node
.
hasAttributes
())
{
errorString
=
QString
(
"Node: %1 don't has any attrs."
).
arg
(
node
.
nodeName
());;
}
else
{
QDomNamedNodeMap
attrs
=
node
.
attributes
();
if
(
!
attrs
.
contains
(
attrName
))
{
errorString
=
QString
(
"Node: %1 don't has attr: %2."
).
arg
(
node
.
nodeName
()).
arg
(
attrName
);
}
else
{
QDomNode
attr
=
attrs
.
namedItem
(
attrName
);
value
=
attr
.
toAttr
().
value
();
}
}
return
value
;
}
bool
XMLReader
::
checkAttributeValue
(
const
QDomNode
&
node
,
const
QString
&
attrName
,
const
QString
&
attrValue
)
{
QString
value
=
getAttributeValue
(
node
,
attrName
);
return
(
value
==
attrValue
);
}
sbkpay/xmlreader.h
0 → 100644
View file @
566f0949
#ifndef XMLREADER_H
#define XMLREADER_H
#include <QObject>
#include <QDomDocument>
#include <QDomElement>
typedef
QMap
<
QString
,
QString
>
Attributes
;
class
XMLReader
:
public
QObject
{
Q_OBJECT
public
:
explicit
XMLReader
(
QObject
*
parent
=
nullptr
);
~
XMLReader
();
bool
parser
(
const
QString
&
xmlString
);
bool
parserFile
(
const
QString
&
xmlFile
,
QDomNode
&
root
);
QList
<
QDomNode
>
findElements
(
const
QString
&
name
);
QList
<
QDomNode
>
findElementsByAttr
(
const
QString
&
name
,
const
Attributes
&
attr
);
QMap
<
QString
,
QList
<
QDomNode
>>
groupElementsByAttr
(
const
QString
&
nodeName
,
const
QString
&
attrName
);
Attributes
getAttributes
(
const
QDomNode
&
node
);
QString
getAttributeValue
(
const
QDomNode
&
node
,
const
QString
&
attrName
);
bool
checkAttributeValue
(
const
QDomNode
&
node
,
const
QString
&
attrName
,
const
QString
&
attrValue
);
QString
errorString
;
QDomDocument
xmlDoc
;
signals
:
public
slots
:
private
:
};
#endif // XMLREADER_H
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