aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-03-08 22:13:21 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-03-08 22:13:21 +0000
commite37339840f3e79625230b8aed23405eaa5a78533 (patch)
tree053dd992ea8b8b42b0a8c648e5ab7ac5c50b8611 /source
parent8a67791b0cbb94a4c57923aa2d5f2a4c045ef21d (diff)
downloadqxmpp-e37339840f3e79625230b8aed23405eaa5a78533.tar.gz
fixup
Diffstat (limited to 'source')
-rw-r--r--source/QXmppClient.cpp2
-rw-r--r--source/QXmppLogger.cpp12
-rw-r--r--source/QXmppLogger.h17
-rw-r--r--source/QXmppReconnectionManager.cpp2
-rw-r--r--source/QXmppStream.cpp29
-rw-r--r--source/QXmppStream.h1
6 files changed, 32 insertions, 31 deletions
diff --git a/source/QXmppClient.cpp b/source/QXmppClient.cpp
index 4f2c0275..6e0c87a2 100644
--- a/source/QXmppClient.cpp
+++ b/source/QXmppClient.cpp
@@ -187,7 +187,7 @@ void QXmppClient::connectToServer(const QString& host,
else
{
qWarning("QXmppClient::connectToServer: Invalid bareJid");
- logger()->debug("Invalid bareJid");
+ logger()->log(QXmppLogger::WarningMessage, "Invalid bareJid");
}
}
diff --git a/source/QXmppLogger.cpp b/source/QXmppLogger.cpp
index a4a75fe3..f35253e8 100644
--- a/source/QXmppLogger.cpp
+++ b/source/QXmppLogger.cpp
@@ -57,17 +57,7 @@ QXmppLogger::LoggingType QXmppLogger::loggingType()
return m_loggingType;
}
-void QXmppLogger::debug(const QString &str)
-{
- log(QtDebugMsg, str);
-}
-
-void QXmppLogger::warning(const QString &str)
-{
- log(QtWarningMsg, str);
-}
-
-void QXmppLogger::log(QtMsgType type, const QString& str)
+void QXmppLogger::log(QXmppLogger::MessageType type, const QString& str)
{
switch(m_loggingType)
{
diff --git a/source/QXmppLogger.h b/source/QXmppLogger.h
index 7847cfa3..245b644e 100644
--- a/source/QXmppLogger.h
+++ b/source/QXmppLogger.h
@@ -39,23 +39,28 @@ public:
STDOUT
};
+ enum MessageType
+ {
+ DebugMessage = 0, ///< Debugging message
+ InformationMessage, ///< Informational message
+ WarningMessage, ///< Warning message
+ ReceivedMessage, ///< Message received from server
+ SentMessage, ///< Message sent to server
+ };
+
QXmppLogger(QObject *parent = 0);
static QXmppLogger* getLogger();
QXmppLogger::LoggingType loggingType();
void setLoggingType(QXmppLogger::LoggingType);
- void debug(const QString& str);
- void warning(const QString &str);
+ virtual void log(QXmppLogger::MessageType type, const QString& str);
// deprecated accessors, use the form without "get" instead
QXmppLogger::LoggingType Q_DECL_DEPRECATED getLoggingType();
signals:
- void message(QtMsgType type, const QString &str);
-
-protected:
- virtual void log(QtMsgType type, const QString& str);
+ void message(QXmppLogger::MessageType type, const QString &str);
private:
static QXmppLogger* m_logger;
diff --git a/source/QXmppReconnectionManager.cpp b/source/QXmppReconnectionManager.cpp
index 20ddbb69..8c0fbaa8 100644
--- a/source/QXmppReconnectionManager.cpp
+++ b/source/QXmppReconnectionManager.cpp
@@ -83,7 +83,7 @@ void QXmppReconnectionManager::reconnect()
{
if(m_client)
{
- m_client->logger()->debug("QXmppReconnectionManager::reconnect()");
+ m_client->logger()->log(QXmppLogger::DebugMessage, "QXmppReconnectionManager::reconnect()");
emit reconnectingNow();
m_client->connectToServer(m_client->getConfiguration());
}
diff --git a/source/QXmppStream.cpp b/source/QXmppStream.cpp
index 987ae7f7..1ab78ee4 100644
--- a/source/QXmppStream.cpp
+++ b/source/QXmppStream.cpp
@@ -169,7 +169,7 @@ QXmppConfiguration& QXmppStream::getConfiguration()
void QXmppStream::connect()
{
- debug(QString("Connecting to: %1:%2").arg(getConfiguration().
+ info(QString("Connecting to: %1:%2").arg(getConfiguration().
host()).arg(getConfiguration().port()));
// prepare for connection
@@ -192,14 +192,14 @@ void QXmppStream::socketSslErrors(const QList<QSslError> & error)
void QXmppStream::socketHostFound()
{
- warning("Host found");
+ debug("Host found");
emit hostFound();
}
void QXmppStream::socketConnected()
{
flushDataBuffer();
- debug("Connected");
+ info("Connected");
emit connected();
sendStartStream();
}
@@ -207,7 +207,7 @@ void QXmppStream::socketConnected()
void QXmppStream::socketDisconnected()
{
flushDataBuffer();
- debug("Disconnected");
+ info("Disconnected");
emit disconnected();
}
@@ -226,8 +226,8 @@ void QXmppStream::socketError(QAbstractSocket::SocketError ee)
void QXmppStream::socketReadReady()
{
- QByteArray data = m_socket.readAll();
- debug("SERVER [COULD BE PARTIAL DATA]:" + data.left(20));
+ const QByteArray data = m_socket.readAll();
+ //debug("SERVER [COULD BE PARTIAL DATA]:" + data.left(20));
parser(data);
}
@@ -242,12 +242,17 @@ void QXmppStream::sendNonSASLAuthQuery( const QString &to )
void QXmppStream::debug(const QString &data)
{
- m_client->logger()->debug(data);
+ m_client->logger()->log(QXmppLogger::DebugMessage, data);
+}
+
+void QXmppStream::info(const QString &data)
+{
+ m_client->logger()->log(QXmppLogger::InformationMessage, data);
}
void QXmppStream::warning(const QString &data)
{
- m_client->logger()->warning(data);
+ m_client->logger()->log(QXmppLogger::WarningMessage, data);
}
void QXmppStream::parser(const QByteArray& data)
@@ -272,7 +277,7 @@ void QXmppStream::parser(const QByteArray& data)
if(doc.setContent(completeXml, true))
{
- debug("SERVER:" + m_dataBuffer);
+ m_client->logger()->log(QXmppLogger::ReceivedMessage, m_dataBuffer);
flushDataBuffer();
QDomElement nodeRecv = doc.documentElement().firstChildElement();
@@ -301,7 +306,7 @@ void QXmppStream::parser(const QByteArray& data)
{
QString ns = nodeRecv.namespaceURI();
- //debug("Namespace: " + ns + " Tag: " + nodeRecv.tagName() );
+ debug("Namespace: " + ns + " Tag: " + nodeRecv.tagName() );
if(m_client->handleStreamElement(nodeRecv))
{
// already handled by client, do nothing
@@ -389,7 +394,7 @@ void QXmppStream::parser(const QByteArray& data)
break;
}
default:
- debug("Desired SASL Auth mechanism not available trying the available ones");
+ info("Desired SASL Auth mechanism not available trying the available ones");
if(mechanisms.contains("DIGEST-MD5"))
sendAuthDigestMD5();
else if(mechanisms.contains("PLAIN"))
@@ -775,7 +780,7 @@ void QXmppStream::sendStartStream()
void QXmppStream::sendToServer(const QByteArray& packet)
{
- debug("CLIENT: " + packet);
+ m_client->logger()->log(QXmppLogger::SentMessage, packet);
m_socket.write( packet );
}
diff --git a/source/QXmppStream.h b/source/QXmppStream.h
index dbe37b2f..f3e90e45 100644
--- a/source/QXmppStream.h
+++ b/source/QXmppStream.h
@@ -144,6 +144,7 @@ private:
QXmppConfiguration& getConfiguration();
void debug(const QString&);
+ void info(const QString&);
void warning(const QString&);
void parser(const QByteArray&);
void sendStartStream();