File: IntegrationManager.h

package info (click to toggle)
libappimage 1.0.4-5-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,360 kB
  • sloc: cpp: 4,678; ansic: 1,325; sh: 170; python: 27; makefile: 19
file content (108 lines) | stat: -rw-r--r-- 4,246 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#pragma once

// system
#include <string>
#include <memory>
#include <iostream>

// local
#include <appimage/desktop_integration/exceptions.h>
#include <appimage/core/AppImage.h>
#include <appimage/config.h>

namespace appimage {
    namespace desktop_integration {
        class IntegrationManager {
        public:
            /**
             * Instantiate an Integration manager that will use as XDG_DATA_HOME the one pointed by the system
             * configuration.
             */
            explicit IntegrationManager();

            /**
             * Instantiate an Integration manager that will use as XDG_DATA_HOME the one pointed by the <xdgDataHome>
             */
            explicit IntegrationManager(const std::string& xdgDataHome);

            /**
            * Creates an IntegrationManager instance from <other> IntegrationManager
            * @param other
            */
            IntegrationManager(const IntegrationManager& other);

            /**
             * Copy the <other> instance data into the current one.
             * @param other
             * @return
             */
            IntegrationManager& operator=(const IntegrationManager& other);

            virtual ~IntegrationManager();

            /**
             * @brief Register an AppImage in the system
             *
             * Extract the application main desktop entry, icons and mime type packages. Modifies their content to
             * properly match the AppImage file location and deploy them into the use XDG_DATA_HOME appending a
             * prefix to each file. Such prefix is composed as "<vendor id>_<appimage_path_md5>_<old_file_name>"
             *
             * @param appImage
             */
            void registerAppImage(const core::AppImage& appImage) const;

            /**
             * @brief Unregister an AppImage in the system
             *
             * Remove all files created by the registerAppImage function. The files are identified by matching the
             * AppImageId contained in their names. The Id is made from the MD5 checksum of the <appImagePath>.
             * @param appImagePath
             */
            void unregisterAppImage(const std::string& appImagePath) const;

            /**
             * @brief Check whether the AppImage pointed by <appImagePath> has been registered in the system.
             *
             * Explore XDG_DATA_HOME/applications looking for Destkop Entries files with a file name that matches
             * the current AppImage Id (MD5 checksum of the <appImagePath>)
             *
             * @param appImagePath
             * @return true if the AppImage is registered, false otherwise.
             */
            bool isARegisteredAppImage(const std::string& appImagePath) const;

            /**
             * @brief Check whether the author of an AppImage doesn't want it to be integrated.
             *
             * An AppImage is considered that shall not be integrated if fulfill any of the following conditions:
             *  - The AppImage's desktop file has set X-AppImage-Integrate=false.
             *  - The AppImage's desktop file has set Terminal=true.
             *
             * @param appImage
             * @return false if any of the conditions are meet, true otherwise
             */
            bool shallAppImageBeRegistered(const core::AppImage& appImage) const;

#ifdef LIBAPPIMAGE_THUMBNAILER_ENABLED
            /**
             * @brief Generate thumbnails according to the FreeDesktop Thumbnail Managing Standard
             * See: https://specifications.freedesktop.org/thumbnail-spec/0.8.0/index.html
             * @param appImage
             */
            void generateThumbnails(const core::AppImage& appImage) const;

            /**
             * @brief Remove thumbnails according to the FreeDesktop Thumbnail Managing Standard
             * See: https://specifications.freedesktop.org/thumbnail-spec/0.8.0/index.html
             * @param appImagePath
             */
            void removeThumbnails(const std::string& appImagePath) const;

#endif

        private:
            class Private;
            std::shared_ptr<Private> d;   // opaque pointer
        };
    }
}