Skip to content

Commit

Permalink
Merge branch 'use_standard_logging' into 'master'
Browse files Browse the repository at this point in the history
Use standard logging. JB#53698

See merge request mer-core/commhistory-daemon!52
  • Loading branch information
pvuorela committed Mar 31, 2021
2 parents 8e9cdc9 + f5ad02f commit d5a8e20
Show file tree
Hide file tree
Showing 25 changed files with 410 additions and 443 deletions.
48 changes: 24 additions & 24 deletions src/accountoperationsobserver.cpp
Expand Up @@ -36,16 +36,16 @@ AccountOperationsObserver::AccountOperationsObserver(Tp::AccountManagerPtr accou
m_pGroupModel(0),
m_AccountManager(accountManager)
{
DEBUG() << Q_FUNC_INFO << "START";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "START";

if (!m_AccountManager.isNull()) {
if (!m_AccountManager->isReady()) {
DEBUG() << Q_FUNC_INFO << "Account manager is not ready. Making it ready...";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "Account manager is not ready. Making it ready...";
connect(m_AccountManager->becomeReady(),
SIGNAL(finished(Tp::PendingOperation *)),
SLOT(slotAccountManagerReady(Tp::PendingOperation *)));
} else {
DEBUG() << Q_FUNC_INFO << "Account manager is already ready.";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "Account manager is already ready.";
connectToAccounts();
}
} else {
Expand All @@ -58,12 +58,12 @@ AccountOperationsObserver::AccountOperationsObserver(Tp::AccountManagerPtr accou
SLOT(removeNotifications(QString)),
Qt::UniqueConnection);

DEBUG() << Q_FUNC_INFO << "END";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "END";
}

void AccountOperationsObserver::connectToAccounts()
{
DEBUG() << Q_FUNC_INFO << "START";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "START";

// First of all we must connect to listen removed()-signals of the accounts created in the future:
connect(m_AccountManager.data(),
Expand All @@ -76,14 +76,14 @@ void AccountOperationsObserver::connectToAccounts()
slotConnectToSignals(account);
}

DEBUG() << Q_FUNC_INFO << "END";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "END";
}

// S L O T S

void AccountOperationsObserver::slotAccountManagerReady(Tp::PendingOperation *op)
{
DEBUG() << Q_FUNC_INFO << "START";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "START";

if (op->isError()) {
qWarning() << "Account manager cannot become ready:" << op->errorName() << "-" << op->errorMessage();
Expand All @@ -92,12 +92,12 @@ void AccountOperationsObserver::slotAccountManagerReady(Tp::PendingOperation *op

connectToAccounts();

DEBUG() << Q_FUNC_INFO << "END";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "END";
}

void AccountOperationsObserver::slotConnectToSignals(const Tp::AccountPtr &account)
{
DEBUG() << Q_FUNC_INFO << "START";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "START";

if (!account.isNull()) {
m_accounts.insert(account->objectPath(), account);
Expand All @@ -114,12 +114,12 @@ void AccountOperationsObserver::slotConnectToSignals(const Tp::AccountPtr &accou
Qt::UniqueConnection);
}

DEBUG() << Q_FUNC_INFO << "END";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "END";
}

void AccountOperationsObserver::slotAccountStateChanged(bool isEnabled)
{
DEBUG() << Q_FUNC_INFO << isEnabled;
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << isEnabled;

if (!isEnabled) {

Expand All @@ -131,13 +131,13 @@ void AccountOperationsObserver::slotAccountStateChanged(bool isEnabled)

void AccountOperationsObserver::slotAccountRemoved()
{
DEBUG() << Q_FUNC_INFO << "START";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "START";

Tp::Account *account = qobject_cast<Tp::Account *>(sender());

if (account) {
QString accountPath = account->objectPath();
DEBUG() << Q_FUNC_INFO << "Account " << accountPath << " removed.";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "Account " << accountPath << " removed.";

m_accounts.remove(accountPath);

Expand Down Expand Up @@ -183,12 +183,12 @@ void AccountOperationsObserver::slotAccountRemoved()
}
}

DEBUG() << Q_FUNC_INFO << "END";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "END";
}

void AccountOperationsObserver::slotDeleteConversations()
{
DEBUG() << Q_FUNC_INFO << "START";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "START";

if (!m_pGroupModel)
return;
Expand All @@ -203,7 +203,7 @@ void AccountOperationsObserver::slotDeleteConversations()
int groupId = group.id();
QString localId = group.localUid();
if (localId == accountPath) {
DEBUG() << Q_FUNC_INFO << "Group " << groupId << " to be deleted";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "Group " << groupId << " to be deleted";
groupsToBeDeleted.append(groupId);
}
}
Expand All @@ -221,12 +221,12 @@ void AccountOperationsObserver::slotDeleteConversations()

m_accountPathsForConvs.clear();

DEBUG() << Q_FUNC_INFO << "END";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "END";
}

void AccountOperationsObserver::slotDeleteCalls()
{
DEBUG() << Q_FUNC_INFO << "START";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "START";

CommHistory::CallModel *callModel = qobject_cast<CommHistory::CallModel *>(sender());

Expand All @@ -241,7 +241,7 @@ void AccountOperationsObserver::slotDeleteCalls()
QModelIndex index = callModel->index(i,0);
if (index.isValid()) {
CommHistory::Event callEvent = callModel->event(index);
DEBUG() << Q_FUNC_INFO << "Call " << callEvent.id() << " to be deleted";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "Call " << callEvent.id() << " to be deleted";
callsToBeDeleted.append(callEvent);
}
}
Expand All @@ -255,14 +255,14 @@ void AccountOperationsObserver::slotDeleteCalls()

if (callsToBeDeleted.isEmpty()) {
QString accountPath = m_accountPathsForCalls.key(callModel);
DEBUG() << Q_FUNC_INFO << "No calls to be deleted for " << accountPath << ". We can delete the CallModel.";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "No calls to be deleted for " << accountPath << ". We can delete the CallModel.";
m_accountPathsForCalls.take(accountPath)->deleteLater();

// delete notifcations of this account
emit removeAccountNotifications(accountPath);
}

DEBUG() << Q_FUNC_INFO << "END";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "END";
}

void AccountOperationsObserver::slotRowsRemoved(const QModelIndex& index, int start, int end)
Expand All @@ -271,7 +271,7 @@ void AccountOperationsObserver::slotRowsRemoved(const QModelIndex& index, int st
Q_UNUSED(start)
Q_UNUSED(end)

DEBUG() << Q_FUNC_INFO << "start: " << start << " end: " << end;
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "start: " << start << " end: " << end;

CommHistory::CallModel *callModel = qobject_cast<CommHistory::CallModel *>(sender());

Expand All @@ -281,13 +281,13 @@ void AccountOperationsObserver::slotRowsRemoved(const QModelIndex& index, int st
}

if (callModel->rowCount() == 0) {
DEBUG() << Q_FUNC_INFO << "Last event in CallModel deleted. We can delete the model.";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "Last event in CallModel deleted. We can delete the model.";
QString accountPath = m_accountPathsForCalls.key(callModel);
m_accountPathsForCalls.take(accountPath)->deleteLater();

// delete notifcations of this account
emit removeAccountNotifications(accountPath);
}

DEBUG() << Q_FUNC_INFO << "END";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "END";
}
6 changes: 3 additions & 3 deletions src/accountpresenceservice.cpp
Expand Up @@ -59,7 +59,7 @@ AccountPresenceService::AccountPresenceService(Tp::AccountManagerPtr manager, QO
if (!QDBusConnection::sessionBus().registerObject(ACCOUNT_PRESENCE_OBJECT_PATH, this)) {
qWarning() << "Object registration failed!";
} else {
if(!QDBusConnection::sessionBus().registerService(ACCOUNT_PRESENCE_SERVICE_NAME)) {
if (!QDBusConnection::sessionBus().registerService(ACCOUNT_PRESENCE_SERVICE_NAME)) {
qWarning() << "Unable to register account presence service!"
<< QDBusConnection::sessionBus().lastError();
} else {
Expand All @@ -69,7 +69,7 @@ AccountPresenceService::AccountPresenceService(Tp::AccountManagerPtr manager, QO

if (!m_accountManager->isReady()) {
// Wait for the account manager to become ready
DEBUG() << "Waiting for account manager to become ready";
qCDebug(lcCommhistoryd) << "Waiting for account manager to become ready";
Tp::PendingReady *pr = m_accountManager->becomeReady(Tp::AccountManager::FeatureCore);
Q_ASSERT(pr);
connect(pr, SIGNAL(finished(Tp::PendingOperation *)),
Expand Down Expand Up @@ -138,7 +138,7 @@ void AccountPresenceService::setAccountPresenceWithMessage(const QString &accoun
void AccountPresenceService::accountManagerReady(Tp::PendingOperation *)
{
if (m_accountManager->isReady()) {
DEBUG() << "Account manager is now ready";
qCDebug(lcCommhistoryd) << "Account manager is now ready";

// Process any updates that were previously deferred
if (m_globalUpdatePresent) {
Expand Down
24 changes: 12 additions & 12 deletions src/channellistener.cpp
Expand Up @@ -52,7 +52,7 @@ ChannelListener::ChannelListener(const Tp::AccountPtr &account,

void ChannelListener::slotChannelReady(Tp::PendingOperation* operation)
{
DEBUG() << __PRETTY_FUNCTION__ << channel();
qCDebug(lcCommhistoryd) << __PRETTY_FUNCTION__ << channel();

if (!checkIfError(operation) && m_Channel) {
m_Direction = m_Channel->isRequested() ?
Expand All @@ -70,19 +70,19 @@ bool ChannelListener::checkIfError(Tp::PendingOperation* operation)
{
bool error = true;

if( operation && !operation->isError() ) {
if (operation && !operation->isError()) {
error = false;
} else if( operation ) {
finishedWithError( operation->errorName(),
operation->errorMessage() );
} else if (operation) {
finishedWithError(operation->errorName(),
operation->errorMessage());
}
return error;
}

void ChannelListener::invalidated(Tp::DBusProxy *proxy,
const QString &errorName, const QString &errorMessage)
{
DEBUG() << __PRETTY_FUNCTION__ << proxy->objectPath();
qCDebug(lcCommhistoryd) << __PRETTY_FUNCTION__ << proxy->objectPath();

Q_UNUSED(proxy)
finishedWithError(errorName, errorMessage);
Expand All @@ -91,7 +91,7 @@ void ChannelListener::invalidated(Tp::DBusProxy *proxy,
void ChannelListener::finishedWithError(const QString& errorName,
const QString& errorMessage)
{
if( !m_InvocationContext.isNull() ) {
if (!m_InvocationContext.isNull()) {
m_InvocationContext->setFinishedWithError(errorName, errorMessage);
}
closed();
Expand All @@ -104,15 +104,15 @@ ChannelListener::~ChannelListener()
QString ChannelListener::channel() const
{
QString channel;
if(!m_Channel.isNull()) {
if (!m_Channel.isNull()) {
channel = m_Channel->objectPath();
}
return channel;
}

void ChannelListener::closed()
{
DEBUG() << "channelClosed";
qCDebug(lcCommhistoryd) << "channelClosed";
emit channelClosed(this);
}

Expand All @@ -134,7 +134,7 @@ void ChannelListener::makeChannelReady(const Tp::Features &features)

void ChannelListener::invocationContextFinished()
{
if(!m_InvocationContext.isNull()) {
if (!m_InvocationContext.isNull()) {
m_InvocationContext->setFinished();
}
}
Expand All @@ -146,7 +146,7 @@ void ChannelListener::invocationContextError()

CommHistory::EventModel& ChannelListener::eventModel()
{
if(!m_pEventModel){
if (!m_pEventModel) {
m_pEventModel = new CommHistory::EventModel(this);
}

Expand All @@ -170,5 +170,5 @@ QString ChannelListener::targetId() const

void ChannelListener::channelReady()
{
DEBUG() << Q_FUNC_INFO << "not implemented";
qCDebug(lcCommhistoryd) << Q_FUNC_INFO << "not implemented";
}
4 changes: 2 additions & 2 deletions src/commhistoryservice.cpp
Expand Up @@ -46,10 +46,10 @@ CommHistoryService::CommHistoryService( QObject* parent )
}

if (parent) {
if(!QDBusConnection::sessionBus().registerObject(COMM_HISTORY_DAEMON_OBJECT_PATH, this)) {
if (!QDBusConnection::sessionBus().registerObject(COMM_HISTORY_DAEMON_OBJECT_PATH, this)) {
qWarning() << "Object registration failed!";
} else {
if(!QDBusConnection::sessionBus().registerService(COMM_HISTORY_DAEMON_SERVICE_NAME)) {
if (!QDBusConnection::sessionBus().registerService(COMM_HISTORY_DAEMON_SERVICE_NAME)) {
qWarning() << "Unable to register commhistory service!"
<< QDBusConnection::sessionBus().lastError();
} else {
Expand Down

0 comments on commit d5a8e20

Please sign in to comment.