> 2014-06-27 23:35 GMT+02:00 Sandro Knauß <[email protected]>:
>  Hey,have you cleaned the build dir/ delete it? Sometimes this helps :)
CMake
>  creates a Cache of what and where somthing was found. And if you rerun
cmake,
>  than not everthing is checked again. That's why sometimes deleting the
build
>  dir helps :)

Yes, I tried a lot of things.

2014-06-28 10:42 GMT+02:00 Daniel Vrátil <[email protected]>:

> On Friday 27 of June 2014 00:21:07 David Edmundson wrote:
> > Filters won't help, the logging is done by an observer in a separate
> > process.
> >
> > See c0a2104a590e9e68226f836d22ff6e645f3e33d3 in telepathy-logger, it
> > might do what we want.
> >
> > Dan, can you comment here?
>
> Unfortunately this has been committed after 0.8.0 and there was no new
> release
> since then, so distros don't have it.
>
> Maybe you could try asking on telepathy ml what are their release plans for
> telepathy-logger.
>
> I think I had a patch for telepathy-logger-qt somewhere to add support for
> the
> API, but I can't find it. Should be easy to write again though, since it
> just
> needs updating spec/Logger.xml.
>
> Dan
>

telepathy-logger stores ignorelist using gsettings and doesn't seem to give
access to it through dbus interfaces.
I added simple patches to enable it in both telepathy-logger-qt and in
KTp::Logger.
I can't get it working. Every call to disableForEntity ends with crash:

GLib-CRITICAL **: g_variant_new_string: assertion 'g_utf8_validate (string,
-1, NULL)' failed
GLib-CRITICAL **: g_variant_ref_sink: assertion 'value != NULL' failed

enableForEntity and isDisabledForEntity do not cause any errors.
Maybe I do not understand properly glib, hence my problems.

Still this is not entirely the feature we need. If I understand it
correctly, when I intend do disable logging for a conversation  I have to
disable it for both sides of it. As a consequence I would turn off logging
of every message I create,  even during unencrypted conversation with
different contacts.
I would like to know if it is what we would like to see in KTp and if it
works properly before I ask on telepathy ml.
diff --git a/KTp/Logger/abstract-logger-plugin.h b/KTp/Logger/abstract-logger-plugin.h
index 6db98d4..48d3854 100644
--- a/KTp/Logger/abstract-logger-plugin.h
+++ b/KTp/Logger/abstract-logger-plugin.h
@@ -156,6 +156,30 @@ class KTP_EXPORT AbstractLoggerPlugin : public QObject
      */
     virtual bool logsExist(const Tp::AccountPtr &account, const KTp::LogEntity &contact) = 0;
 
+    /**
+     * Disables logging for given @p account and @p contact
+     *
+     * @param account Account to disable
+     * @param contact Contact to disable
+     */
+    virtual void disableLoggingForEntity(const Tp::AccountPtr &account, const KTp::LogEntity &contact) = 0;
+
+    /**
+     * Enables logging for given @p account and @p contact
+     *
+     * @param account Account to enable
+     * @param contact Contact to enable
+     */
+    virtual void enableLoggingForEntity(const Tp::AccountPtr &account, const KTp::LogEntity &contact) = 0;
+
+    /**
+     * Checks if logging is disabled for given @p account and @p contact
+     *
+     * @param account Account to query
+     * @param contact Contact to query
+     */
+    virtual bool isLoggingDisabledForEntity(const Tp::AccountPtr &account, const KTp::LogEntity &contact) = 0;
+
   private:
     class Private;
     Private * const d;
diff --git a/KTp/Logger/log-manager.cpp b/KTp/Logger/log-manager.cpp
index 7ce4a12..97b9716 100644
--- a/KTp/Logger/log-manager.cpp
+++ b/KTp/Logger/log-manager.cpp
@@ -168,5 +168,40 @@ bool LogManager::logsExist(const Tp::AccountPtr &account, const KTp::LogEntity &
     return false;
 }
 
+void LogManager::disableLoggingForEntity(const Tp::AccountPtr &account, const KTp::LogEntity &contact)
+{
+    Q_FOREACH (KTp::AbstractLoggerPlugin *plugin, d->plugins) {
+        if (!plugin->handlesAccount(account)) {
+            continue;
+        }
+
+        plugin->disableLoggingForEntity(account, contact);
+    }
+}
+
+void LogManager::enableLoggingForEntity(const Tp::AccountPtr &account, const KTp::LogEntity &contact) 
+{
+    Q_FOREACH (KTp::AbstractLoggerPlugin *plugin, d->plugins) {
+        if (!plugin->handlesAccount(account)) {
+            continue;
+        }
+
+        plugin->enableLoggingForEntity(account, contact);
+    }
+}
+
+bool LogManager::isLoggingDisabledForEntity(const Tp::AccountPtr &account, const KTp::LogEntity &contact)
+{
+    bool isDisabled = false;
+    Q_FOREACH (KTp::AbstractLoggerPlugin *plugin, d->plugins) {
+        if (!plugin->handlesAccount(account)) {
+            continue;
+        }
+
+        isDisabled |= plugin->isLoggingDisabledForEntity(account, contact);
+    }
+
+    return isDisabled;
+}
 
 using namespace KTp;
diff --git a/KTp/Logger/log-manager.h b/KTp/Logger/log-manager.h
index c5f92d6..b0651aa 100644
--- a/KTp/Logger/log-manager.h
+++ b/KTp/Logger/log-manager.h
@@ -139,6 +139,30 @@ class KTP_EXPORT LogManager : public AbstractLoggerPlugin
     bool logsExist(const Tp::AccountPtr &account, const KTp::LogEntity &contact);
 
     /**
+     * Disables logging for given @p account and @p contact
+     *
+     * @param account Account to disable
+     * @param contact Contact to disable
+     */
+    void disableLoggingForEntity(const Tp::AccountPtr &account, const KTp::LogEntity &contact);
+
+    /**
+     * Enables logging for given @p account and @p contact
+     *
+     * @param account Account to enable
+     * @param contact Contact to enable
+     */
+    void enableLoggingForEntity(const Tp::AccountPtr &account, const KTp::LogEntity &contact);
+
+    /**
+     * Checks if logging is disabled for given @p account and @p contact
+     *
+     * @param account Account to query
+     * @param contact Contact to query
+     */
+    bool isLoggingDisabledForEntity(const Tp::AccountPtr &account, const KTp::LogEntity &contact);
+
+    /**
      * Destructor.
      */
     virtual ~LogManager();
diff --git a/KTp/Logger/plugins/tplogger/tp-logger-plugin.cpp b/KTp/Logger/plugins/tplogger/tp-logger-plugin.cpp
index 8c0cb16..8c1b3fb 100644
--- a/KTp/Logger/plugins/tplogger/tp-logger-plugin.cpp
+++ b/KTp/Logger/plugins/tplogger/tp-logger-plugin.cpp
@@ -100,6 +100,24 @@ bool TpLoggerPlugin::logsExist(const Tp::AccountPtr &account, const KTp::LogEnti
     return manager->exists(account, Utils::toTplEntity(contact), Tpl::EventTypeMaskText);
 }
 
+void TpLoggerPlugin::disableLoggingForEntity(const Tp::AccountPtr &account, const KTp::LogEntity &contact) 
+{
+    Tpl::LogManagerPtr manager = Tpl::LogManager::instance();
+    manager->disableForEntity(account, Utils::toTplEntity(contact));
+}
+
+void TpLoggerPlugin::enableLoggingForEntity(const Tp::AccountPtr &account, const KTp::LogEntity &contact)
+{
+    Tpl::LogManagerPtr manager = Tpl::LogManager::instance();
+    manager->enableForEntity(account, Utils::toTplEntity(contact));
+}
+
+bool TpLoggerPlugin::isLoggingDisabledForEntity(const Tp::AccountPtr &account, const KTp::LogEntity &contact)
+{
+    Tpl::LogManagerPtr manager = Tpl::LogManager::instance();
+    return manager->isDisabledForEntity(account, Utils::toTplEntity(contact));
+}
+
 
 K_PLUGIN_FACTORY(TpLoggerPluginFactory, registerPlugin<TpLoggerPlugin>();)
 K_EXPORT_PLUGIN(TpLoggerPluginFactory("ktp_logger_plugin_tpLogger"))
diff --git a/KTp/Logger/plugins/tplogger/tp-logger-plugin.h b/KTp/Logger/plugins/tplogger/tp-logger-plugin.h
index 346c233..060fa8d 100644
--- a/KTp/Logger/plugins/tplogger/tp-logger-plugin.h
+++ b/KTp/Logger/plugins/tplogger/tp-logger-plugin.h
@@ -46,6 +46,10 @@ class TpLoggerPlugin : public KTp::AbstractLoggerPlugin
     KTp::PendingLoggerSearch* search(const QString &term);
     bool logsExist(const Tp::AccountPtr &account, const KTp::LogEntity &contact);
 
+    void disableLoggingForEntity(const Tp::AccountPtr &account, const KTp::LogEntity &contact);
+    void enableLoggingForEntity(const Tp::AccountPtr &account, const KTp::LogEntity &contact);
+    bool isLoggingDisabledForEntity(const Tp::AccountPtr &account, const KTp::LogEntity &contact);
+
     void setAccountManager(const Tp::AccountManagerPtr &accountManager);
 
 
diff --git a/TelepathyLoggerQt4/log-manager.cpp b/TelepathyLoggerQt4/log-manager.cpp
index 7aadc4d..cdfbb6a 100644
--- a/TelepathyLoggerQt4/log-manager.cpp
+++ b/TelepathyLoggerQt4/log-manager.cpp
@@ -141,3 +141,39 @@ LogWalkerPtr LogManager::queryWalkFilteredEvents(const Tp::AccountPtr& account,
                                 filterFunctionUserData);
     return LogWalkerPtr::wrap(tpWalker, false);
 }
+
+void LogManager::disableForEntity(const Tp::AccountPtr &account, const EntityPtr &entity) 
+{
+
+    TpAccount *tpAccount = Utils::instance()->tpAccount(account);
+    if (!tpAccount) {
+        qWarning() << "Invalid account";
+        return;
+    }
+
+    tpl_log_manager_disable_for_entity(LogManagerPtr(this), tpAccount, entity);
+}
+
+void LogManager::enableForEntity(const Tp::AccountPtr &account, const EntityPtr &entity) 
+{
+
+    TpAccount *tpAccount = Utils::instance()->tpAccount(account);
+    if (!tpAccount) {
+        qWarning() << "Invalid account";
+        return;
+    }
+    tpl_log_manager_enable_for_entity(LogManagerPtr(this), tpAccount, entity);
+}
+
+bool LogManager::isDisabledForEntity(const Tp::AccountPtr &account, const EntityPtr &entity) 
+{
+
+    TpAccount *tpAccount = Utils::instance()->tpAccount(account);
+    if (!tpAccount) {
+        qWarning() << "Invalid account";
+        return false; // TODO optional bool would be better here
+    }
+
+    return tpl_log_manager_is_disabled_for_entity(LogManagerPtr(this), tpAccount, entity);
+}
+
diff --git a/TelepathyLoggerQt4/log-manager.h b/TelepathyLoggerQt4/log-manager.h
index 60a0e8c..08f55b8 100644
--- a/TelepathyLoggerQt4/log-manager.h
+++ b/TelepathyLoggerQt4/log-manager.h
@@ -178,6 +178,30 @@ public:
         const Tpl::EntityPtr &entity, EventTypeMask typeMask, LogEventFilter filterFunction,
         void *filterFunctionUserData = 0);
 
+    /**
+     * \brief Disables logging for given \p account and \p entity
+     *
+     * \param account
+     * \param entity
+     */
+    void disableForEntity(const Tp::AccountPtr &account, const EntityPtr &entity);
+
+    /**
+     * \brief Enables logging for given \p account and \p entity
+     *
+     * \param account
+     * \param entity
+     */
+    void enableForEntity(const Tp::AccountPtr &account, const EntityPtr &entity);
+
+    /**
+     * \brief Checks if logging is disabled for given \p account and \p entity
+     *
+     * \param account
+     * \param entity
+     */
+    bool isDisabledForEntity(const Tp::AccountPtr &account, const EntityPtr &entity);
+
 private:
     QTELEPATHYLOGGERQT4_WRAPPER(LogManager)
 };
_______________________________________________
KDE-Telepathy mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-telepathy

Reply via email to