Bug 397487 - Cannot disable activity tracking and history not deleted
Summary: Cannot disable activity tracking and history not deleted
Status: RESOLVED FIXED
Alias: None
Product: kactivitymanagerd
Classification: Plasma
Component: general (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Andreas Bontozoglou
URL:
Keywords:
: 478665 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-08-15 13:26 UTC by daniel roi
Modified: 2024-07-17 15:23 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description daniel roi 2018-08-15 13:26:30 UTC
I have no use for kactivitymanager, I wanted to disable it but there is no way to do that in the settings menu. An option would be appreciated.

The privacy settings also do not seem to be working, e.g.:

1) open sample file abcde.doc

2) from KDE's system settings > desktop behavior > activities > privacy, choose "do not remember", click "clear recent history" > forget everything, then "apply"

3) I expect the db to be clean now, but if I grep abcde.doc in my .local/share/kactivitymanagerd/resources/ directory, database-wal matches. If I delete the file and logout/login again, it's gone but I also lose the favorites icons in the applications menu.

Note: I didn't choose a version in the bug report because the one I'm using was not in the list (5.13.4).
Comment 1 daniel roi 2019-04-09 15:51:55 UTC
Any news about this bug?
Comment 2 p d 2022-07-28 17:36:11 UTC
Workaround:

Create a script in cron that does this:

#!/bin/bash
sqlite3 ~/.local/share/kactivitymanagerd/resources/database 'delete from ResourceInfo; pragma wal_checkpoint(TRUNCATE); vacuum;'
sqlite3 ~/.local/share/kactivitymanagerd/resources/test-backup/database 'delete from ResourceInfo; pragma wal_checkpoint(TRUNCATE); vacuum;'
sqlite3 ~/.local/share/kactivitymanagerd/resources/working-backup/database 'delete from ResourceInfo; pragma wal_checkpoint(TRUNCATE); vacuum;'

Create a script in ~/.config/plasma-workspace/shutdown/ that does this:

#!/bin/bash
rm ~/.local/share/kactivitymanagerd/resources*/database-wal
Comment 3 serfreeman1337 2023-05-29 09:00:03 UTC
Can someone please take a look at this?
https://invent.kde.org/plasma/kactivitymanagerd/-/blob/master/src/service/plugins/sqlite/StatsPlugin.cpp#L66

I think that saveResourceMimetype and saveResourceTitle functions are lacking conditional check like addEvents does:
    if (m_blockAll || m_whatToRemember == NoApplications) {
        return;
    }

https://invent.kde.org/plasma/kactivitymanagerd/-/blob/master/src/service/plugins/sqlite/StatsPlugin.cpp#L351
Comment 4 Andreas Bontozoglou 2023-08-21 17:12:34 UTC
So, reading a bit the source code here:

- Both saveResourceMimetype and saveResourceTitle call insertResourceInfo and then do an update
- None of them have the "if" to check config
- Both are also used as slots (linked to Resources signals)
- Both have a callpath that leads to addEvent: detectResourceInfo <- openResourceEvent <- addEvents which is protected based on user settings

So, _I think_ that the only way mimeType and title can leak is if the slot is called directly. However, these seem to be connected to the `m_resources` signals (Resources class) which in turn seem to only be exposed in dbus `kactivitymanagerd/src/common/dbus/org.kde.ActivityManager.Resources.xml` and not called anywhere directly.


What I do see though is that StatsPlugin has:

```
    enum WhatToRemember {
        AllApplications = 0,
        SpecificApplications = 1,
        NoApplications = 2,
    };
```

but when I set the settings to "Do not remember" the config has:

```
$ grep what ~/.config/kactivitymanagerd-pluginsrc
what-to-remember=1
```

Similarly, when I set the setting to "Only for specific applications" I get:

```
$ grep what ~/.config/kactivitymanagerd-pluginsrc
what-to-remember=2
```

The values look flipped to me! I am struggling to locate the code that updates this config (lost somewhere in https://invent.kde.org/plasma/plasma-desktop/-/tree/master/kcms/recentFiles). Can anyone point me to where kactivitymanagerd-pluginsrc is written?
Comment 5 Bug Janitor Service 2023-08-22 16:57:06 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/1677
Comment 6 Méven Car 2023-08-28 13:40:06 UTC
Git commit 5f1b83a69d8e462e4e27ca5bdefa8e3155be2817 by Méven Car, on behalf of Andreas Bontozoglou.
Committed on 28/08/2023 at 15:39.
Pushed by meven into branch 'master'.

RecentFiles kcm: whattoremember: Make the value visible in the UI match the value saved

In this commit:

1. Setting the property `kcfg_property=kcfg_value` on the QGroupBox. This should force
   the KConfigDialogManager to use that to retrieve that value that needs to be stored.
2. Introducing RecentFilesKcm::whatToRememberWidgetChanged which figures out the correct
   value of "what-to-remember" and sets it under the property `kcfg_value` and triggers
   the Save/Reset buttons.
3. Linking the above slot to the `QAbstractButton::clicked` signals of the radio buttons

M  +7    -0    kcms/recentFiles/CMakeLists.txt
M  +36   -2    kcms/recentFiles/kcm_recentFiles.cpp
M  +1    -0    kcms/recentFiles/kcm_recentFiles.h

https://invent.kde.org/plasma/plasma-desktop/-/commit/5f1b83a69d8e462e4e27ca5bdefa8e3155be2817
Comment 7 serfreeman1337 2023-08-29 08:14:36 UTC
(In reply to Andreas Bontozoglou from comment #4)
> However, these seem to be connected to the `m_resources`
> signals (Resources class) which in turn seem to only be exposed in dbus
> `kactivitymanagerd/src/common/dbus/org.kde.ActivityManager.Resources.xml`
> and not called anywhere directly.
So it's called directly via dbus somewhere else. Here is debug log with print statements for addEvents, saveResourceTitle, saveResourceMimetype whenever I open any file in dolphin:
> kactivitymanagerd[107123]: !!! saveResourceMimetype !!! uri [ "file:///home/serfreeman1337/kde/src/log/latest/kactivitymanagerd/build.log" ], mimetype [ "text/x-log" ], autoMimetype [ false ]
> kactivitymanagerd[107123]: !!! addEvents !! m_blockAll [ false ], m_whatToRemember [ 2 ]
saveResourceMimetype's called before addEvents.

Re-opening this, since it was not solved by previous commit.

STEPS TO REPRODUCE
1. In settings, set Workspace Behavior > Recent Files > Do not remember.
2. In dolphin, open any file.
3. Check ResourceInfo table with the following command: 

sqlite3 ~/.local/share/kactivitymanagerd/resources/database "SELECT * FROM ResourceInfo;"

OBSERVED RESULT
Information about just opened file has been filled in ResourceInfo, 
even though "Remember opened documents" is set to "Do not remember".

EXPECTED RESULT
No information about recent documents should be stored when "Remember opened documents" is set to "Do not remember".

Easy way to solve this should be simply adding conditional checks for saveResourceMimetype and saveResourceTitle.
Other way is to track down what is calling dbus signal and solve it there.
Comment 8 Andreas Bontozoglou 2023-08-29 09:44:16 UTC
(In reply to serfreeman1337 from comment #7)

I believe that fixing the config value is a prerequisite to fixing this bug since the user needs to be able to set recent files settings to "Do not remember". That said, indeed the bug is not completely fixed - I will make another MR soon
Comment 9 Bug Janitor Service 2023-08-29 09:55:54 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kactivitymanagerd/-/merge_requests/52
Comment 10 Andreas Bontozoglou 2023-08-30 16:55:36 UTC
Git commit 5e193ac52d6a1fdfba8a8ed5da504fb8ac7e3cd4 by Andreas Bontozoglou.
Committed on 29/08/2023 at 11:46.
Pushed by meven into branch 'master'.

plugins/sqlite: Skipping insert/update when m_blockAll or m_whatToRemember==NoApplications

Adding an if-statement in both `saveResourceTitle` and `saveResourceMimetype`
to skip inserting/updating the sqlite database (ResourceInfo table) if the
user has configured kamd/recentFiles with "Do not remember".

M  +8    -0    src/service/plugins/sqlite/StatsPlugin.cpp

https://invent.kde.org/plasma/kactivitymanagerd/-/commit/5e193ac52d6a1fdfba8a8ed5da504fb8ac7e3cd4
Comment 11 Méven 2023-09-06 06:55:34 UTC
Git commit 257acb4cdebd0aa10c50d547e919b451cbf7151e by Méven Car, on behalf of Andreas Bontozoglou.
Committed on 04/09/2023 at 09:22.
Pushed by meven into branch 'Plasma/5.27'.

plugins/sqlite: Skipping insert/update when m_blockAll or m_whatToRemember==NoApplications

Adding an if-statement in both `saveResourceTitle` and `saveResourceMimetype`
to skip inserting/updating the sqlite database (ResourceInfo table) if the
user has configured kamd/recentFiles with "Do not remember".
(cherry picked from commit 5e193ac52d6a1fdfba8a8ed5da504fb8ac7e3cd4)

M  +8    -0    src/service/plugins/sqlite/StatsPlugin.cpp

https://invent.kde.org/plasma/kactivitymanagerd/-/commit/257acb4cdebd0aa10c50d547e919b451cbf7151e
Comment 12 Méven Car 2023-09-09 09:47:20 UTC
Git commit b57bf61d8d18cc4b7319b1af5514a8466761d321 by Méven Car, on behalf of Andreas Bontozoglou.
Committed on 09/09/2023 at 11:04.
Pushed by meven into branch 'Plasma/5.27'.

RecentFiles kcm: whattoremember: Make the value visible in the UI match the value saved

In this commit:

1. Setting the property `kcfg_property=kcfg_value` on the QGroupBox. This should force
   the KConfigDialogManager to use that to retrieve that value that needs to be stored.
2. Introducing RecentFilesKcm::whatToRememberWidgetChanged which figures out the correct
   value of "what-to-remember" and sets it under the property `kcfg_value` and triggers
   the Save/Reset buttons.
3. Linking the above slot to the `QAbstractButton::clicked` signals of the radio buttons
(cherry picked from commit 5f1b83a69d8e462e4e27ca5bdefa8e3155be2817)

M  +7    -0    kcms/recentFiles/CMakeLists.txt
M  +36   -2    kcms/recentFiles/kcm_recentFiles.cpp
M  +1    -0    kcms/recentFiles/kcm_recentFiles.h

https://invent.kde.org/plasma/plasma-desktop/-/commit/b57bf61d8d18cc4b7319b1af5514a8466761d321
Comment 13 p d 2023-09-22 22:56:05 UTC
It still doesn't work. Now, the settings "Do not remember" in "Recent files" doesn't save, and when I close that section of the KDE settings, it resets to "For all applications".
Comment 14 serfreeman1337 2023-09-23 06:29:31 UTC
UI settings page is broken, yes. It isn't reflects current value when you re-open it.
But it still sets correct "what-to-remember" param in  "~/.config/kactivitymanagerd-pluginsrc" and  "ResourceInfo" no longer filled when "Do not remember" is set.
Comment 15 Bug Janitor Service 2023-11-28 13:27:37 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/1883
Comment 16 Méven 2023-11-28 13:30:55 UTC
Git commit c641ae122fdf90e890e845aa1d8cb4ba8c42a8f2 by Méven Car, on behalf of Andreas Bontozoglou.
Committed on 28/11/2023 at 14:26.
Pushed by meven into branch 'master'.

kcms/recentFiles: Restoring radio button state on load

M  +5    -0    kcms/recentFiles/kcm_recentFiles.cpp

https://invent.kde.org/plasma/plasma-desktop/-/commit/c641ae122fdf90e890e845aa1d8cb4ba8c42a8f2
Comment 17 Thomas Bertels 2024-07-17 15:23:21 UTC
*** Bug 478665 has been marked as a duplicate of this bug. ***