Commit caf8f24c authored by Martin Straka's avatar Martin Straka

Refactoring some header files

parent a7069b20
......@@ -694,7 +694,6 @@ bool Files::parseAndShowXmlData(enum MsgInfo::ZfoType type, QString *idStr,
qDebug("%s()", __func__);
QXmlStreamReader xml;
XmlLayer xmlLayer;
MsgEnvelope msg;
QList<AttachmentData> fileList;
QList<Messages::Event> eventList;
......@@ -716,7 +715,7 @@ bool Files::parseAndShowXmlData(enum MsgInfo::ZfoType type, QString *idStr,
}
if (token == QXmlStreamReader::StartElement) {
if (xml.name() == "dmDm") {
xmlLayer.completeMessageParse(xml, msg, fileList);
XmlLayer::completeMessageParse(xml, msg, fileList);
}
}
}
......@@ -732,7 +731,7 @@ bool Files::parseAndShowXmlData(enum MsgInfo::ZfoType type, QString *idStr,
}
if (token == QXmlStreamReader::StartElement) {
if (xml.name() == "dmEvent") {
eventList.append(xmlLayer.parseEvent(xml));
eventList.append(XmlLayer::parseEvent(xml));
}
}
}
......
......@@ -34,10 +34,6 @@ DbWrapper::DbWrapper(QObject *parent)
{
}
DbWrapper::~DbWrapper(void)
{
}
QString DbWrapper::createAccountInfoStringForQml(
const DbWrapper::AccountInfo &accountInfo)
{
......
......@@ -32,14 +32,12 @@
/*
* Class DbWrapper updates data from http response to database.
* Class is initialised and used in the XmlLayer class (xml_layer.h)
* Class is initialised and used in the ISDS wrapper class (isds_wrapper.h)
*/
class DbWrapper : public QObject {
Q_OBJECT
public:
DbWrapper(QObject *parent = Q_NULLPTR);
~DbWrapper(void);
/*!
* @brief Holds information about an account and owner of databox.
......@@ -101,6 +99,11 @@ public:
QString _pwdExpDate;
};
/*!
* @brief Constructor.
*/
DbWrapper(QObject *parent = Q_NULLPTR);
/*!
* @brief Create account info text for QML.
*
......@@ -114,11 +117,11 @@ public:
/*!
* @brief Insert messagelist to db.
*
* @param[in] userName - account username string.
* @param[in] messageType - message type.
* @param[in] messages - list of message envelopes.
* @param[out] messageChangedStatusList -
* list of message ids where message status has changed.
* @param[in] userName Account username string.
* @param[in] messageType Message type.
* @param[in] messages List of message envelopes.
* @param[out] messageChangedStatusList List of message ids
* where message status has changed.
* @param[out] txt Error description if something fails.
* @param[out] listOfNewMsgIds List of new message Ids for complete
* message downloading.
......@@ -133,10 +136,10 @@ public:
/*!
* @brief Insert complete message to db.
*
* @param[in] userName - account username string.
* @param[in] msg - message envelope data.
* @param[in] fileList - list of files.
* @param[out] txt - error description if something fails.
* @param[in] userName Account username string.
* @param[in] msg Message envelope data.
* @param[in] fileList List of files.
* @param[out] txt Error description if something fails.
* @return true if success.
*/
bool insertCompleteMessageToDb(const QString &userName,
......@@ -146,8 +149,8 @@ public:
/*!
* @brief Insert password expiration date to db.
*
* @param[in] userName - account username string.
* @param[in] expirDate - password expiration date string.
* @param[in] userName Account username string.
* @param[in] expirDate Password expiration date string.
* @return true if success.
*/
bool insertPwdExpirationToDb(const QString &userName,
......@@ -156,7 +159,7 @@ public:
/*!
* @brief Insert account info to db.
*
* @param[in] accountInfo - account info struct.
* @param[in] accountInfo Account info struct.
* @return true if success.
*/
bool insertAccountInfoToDb(const DbWrapper::AccountInfo &accountInfo);
......@@ -164,7 +167,7 @@ public:
/*!
* @brief Insert user info to db.
*
* @param[in] userInfo - user info struct.
* @param[in] userInfo User info struct.
* @return true if success.
*/
bool insertUserInfoToDb(const DbWrapper::UserInfo &userInfo);
......@@ -172,11 +175,11 @@ public:
/*!
* @brief Update author info to db.
*
* @param[in] userName - account username string.
* @param[in] userType - author type string.
* @param[in] authorName - author name string.
* @param[in] msgId - message ID.
* @param[out] txt - error description if something fails.
* @param[in] userName Account username string.
* @param[in] userType Author type string.
* @param[in] authorName Author name string.
* @param[in] msgId Message ID.
* @param[out] txt Error description if something fails.
* @return true if success.
*/
bool updateAuthorInfo(const QString &userName, const QString &userType,
......@@ -185,10 +188,10 @@ public:
/*!
* @brief Insert or update delivery info to db.
*
* @param[in] userName - account username string.
* @param[in] eventList - event list.
* @param[in] msgId - message ID.
* @param[out] txt - error description if something fails.
* @param[in] userName Account username string.
* @param[in] eventList Event list.
* @param[in] msgId Message ID.
* @param[out] txt Error description if something fails.
* @return true if success.
*/
bool insertMesasgeDeliveryInfoToDb(const QString &userName,
......
......@@ -33,10 +33,6 @@ IsdsSession::IsdsSession(QObject *parent) : QObject(parent),
{
}
IsdsSession::~IsdsSession()
{
}
bool IsdsSession::createIsdsCtx(const QString &userName)
{
qDebug("%s()", __func__);
......@@ -58,12 +54,12 @@ bool IsdsSession::createIsdsCtx(const QString &userName)
isdsCtx.account_name = acntData.accountName();
isdsCtx.login_method = acntData.loginMethod();
isdsCtx.is_logged = false;
isdsCtx.last_isds_msg = "";
isdsCtx.last_isds_msg = QString();
isdsCtx.timeout = ISDS_TIMEOUT;
isdsCtx.url = getUrlFromLoginMethod(
acntData.loginMethod(), acntData.isTestAccount());
isdsCtx.password = acntData.password();
isdsCtx.pass_phrase = "";
isdsCtx.pass_phrase = QString();
isdsCtx.last_http_code = 0;
isdsCtxMap.insert(userName, isdsCtx);
return true;
......@@ -86,7 +82,7 @@ bool IsdsSession::setCertDataToCtx(IsdsContext &ctx, const QString &certPath)
QFile certFile(certPath);
if (!certFile.open(QIODevice::ReadOnly)) {
qDebug()<< "Error: cannot open certificate from" << certPath;
qCritical()<< "Error: cannot open certificate from" << certPath;
ctx.last_isds_msg = tr("Cannot open certificate");
return false;
}
......@@ -113,13 +109,13 @@ bool IsdsSession::setCertDataToCtx(IsdsContext &ctx, const QString &certPath)
ctx.certificate = cert;
ctx.key = key;
} else {
qDebug()<< "Error: cannot parse certificate from"
qCritical()<< "Error: cannot parse certificate from"
<< certPath;
ctx.last_isds_msg = tr("Cannot parse certificate");
return false;
}
} else {
qDebug()<< "Error: unknown certificate format" << certPath;
qCritical()<< "Error: unknown certificate format" << certPath;
ctx.last_isds_msg = tr("Unknown certificate format");
return false;
}
......
......@@ -45,10 +45,11 @@ class IsdsSession : public QObject {
Q_OBJECT
public:
/*
* Isds context structure for account.
* Holds data for connection to ISDS like url, username and password,
* certificate or cookie, etc...
/*!
* @brief Holds isds context structure for account. Holds data for
* connection to ISDS like url, login method, username and
* password, certificate, cookie, otp, etc...
*/
struct IsdsContext {
QString login_method; /* login method */
......@@ -66,8 +67,10 @@ public:
int last_http_code; /* last http status code */
};
explicit IsdsSession (QObject* parent = 0);
~IsdsSession();
/*!
* @brief Constructor.
*/
explicit IsdsSession (QObject* parent = Q_NULLPTR);
/*!
* @brief Holds isds context for all accounts (username = key)
......
......@@ -525,7 +525,7 @@ void IsdsWrapper::sendMessage(const QString &userName, qint64 dmID,
fDb = globFileDbsPtr->accessFileDb(globSet.dbsLocation, userName,
AccountListModel::globAccounts[userName].storeToDisk());
if (fDb == NULL) {
qDebug() << "ERROR: File database cannot open!" << userName;
qCritical() << "ERROR: File database cannot open!" << userName;
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Error"), tr("Cannot access file database."),
tr("Internal error"));
......@@ -802,7 +802,7 @@ void IsdsWrapper::sendMessageFinished(const QString &userName,
success, errTxt, dbIDRecipient, dmRecipient, msgId));
if (!m_transactIds.remove(transactId)) {
qDebug() << "Was not able to remove a transaction identifier from list of unfinished transactions.";
qCritical() << "Was not able to remove a transaction identifier from list of unfinished transactions.";
}
if (!m_transactIds.isEmpty()) {
......
......@@ -44,7 +44,14 @@ class IsdsWrapper : public QObject {
Q_OBJECT
public:
/*!
* @brief Constructor.
*/
explicit IsdsWrapper(QObject *parent = Q_NULLPTR);
/*!
* @brief Destructor.
*/
~IsdsWrapper(void);
/*!
......@@ -73,10 +80,10 @@ public:
* @brief Downloads complete message.
*
* @param[in,out] msgModelVariant QVariant holding message model
* to be altered.
* @param[in] userName Account username string.
* @param[in] messageType Message orientation.
* @param[in] msgId Message ID.
* to be altered.
* @param[in] userName Account username string.
* @param[in] messageType Message orientation.
* @param[in] msgId Message ID.
*/
Q_INVOKABLE
void downloadMessage(const QVariant &msgModelVariant,
......@@ -220,7 +227,7 @@ public:
*
* @param[in,out] acntModelVariant QVariant holding account model
* to be altered.
* @param[in] userName Account username string.
* @param[in] userName Account username string.
*/
Q_INVOKABLE
void syncOneAccount(const QVariant &acntModelVariant,
......@@ -233,7 +240,7 @@ public:
* to be altered.
* @param[in,out] msgModelVariant QVariant holding message model
* to be altered.
* @param[in] userName Account username string.
* @param[in] userName Account username string.
*/
Q_INVOKABLE
void syncSingleAccountReceived(const QVariant &acntModelVariant,
......@@ -246,7 +253,7 @@ public:
* to be altered.
* @param[in,out] msgModelVariant QVariant holding message model
* to be altered.
* @param[in] userName Account username string.
* @param[in] userName Account username string.
*/
Q_INVOKABLE
void syncSingleAccountSent(const QVariant &acntModelVariant,
......@@ -493,9 +500,9 @@ private:
* @brief Downloads complete message.
*
* @param[in,out] messageModel Message model to be altered.
* @param[in] userName Account username string.
* @param[in] messageType Message orientation.
* @param[in] msgId Message ID.
* @param[in] userName Account username string.
* @param[in] messageType Message orientation.
* @param[in] msgId Message ID.
*/
void downloadMessage(MessageListModel *messageModel,
const QString &userName, enum Messages::MessageType messageType,
......@@ -557,7 +564,7 @@ private:
* to be altered.
* @param[in,out] msgModelVariant QVariant holding message model
* to be altered.
* @param[in] userName Account username string.
* @param[in] userName Account username string.
*/
void syncSingleAccount(const QVariant &acntModelVariant,
const QVariant &msgModelVariant, const QString &userName,
......
......@@ -40,7 +40,6 @@ class NetLayer : public QObject {
Q_OBJECT
public:
/*!
* @brief Constructor.
*/
......
......@@ -39,10 +39,6 @@ XmlLayer::XmlLayer(QObject *parent)
{
}
XmlLayer::~XmlLayer(void)
{
}
QByteArray XmlLayer::xmlCreateDownloadMessageSoapRequest(qint64 msgId,
enum Messages::MessageType msgDirect)
{
......@@ -524,8 +520,6 @@ bool XmlLayer::completeMessageParse(QXmlStreamReader &xml,
/* Parse other parts of xml response */
while (!(xml.tokenType() == QXmlStreamReader::EndElement
&& xml.name() == "dmReturnedMessage")) {
//qDebug() << xml.name() << xml.text() <<
// xml.error() << xml.errorString();
if (xml.error() != QXmlStreamReader::NoError) {
return false;
}
......
......@@ -40,9 +40,10 @@ class XmlLayer : public QObject {
Q_OBJECT
public:
/*!
* @brief Constructor.
*/
XmlLayer(QObject *parent = Q_NULLPTR);
~XmlLayer(void);
/*!
* @brief Create download message soap request.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment