summaryrefslogtreecommitdiffstats
path: root/akregator/src/akregator_part.h
blob: 66abcae5a815cd2d9d3ea8453046a9dbd86088ba (plain)
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/*
    This file is part of Akregator.

    Copyright (C) 2004 Stanislav Karchebny <Stanislav.Karchebny@kdemail.net>
                  2005 Frank Osterfeld <frank.osterfeld at kdemail.net>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

    As a special exception, permission is given to link this program
    with any edition of TQt, and distribute the resulting executable,
    without including the source code for TQt in the source distribution.
*/

#ifndef _AKREGATORPART_H_
#define _AKREGATORPART_H_

#include <tdeparts/browserextension.h>
#include <tdeparts/part.h>
#include <kurl.h>

#include "config.h"

#include "akregator_partiface.h"

class TQDomDocument;
class TQTimer;

class TDEAboutData;
class TDEConfig;
class KURL;

namespace Akregator
{
    namespace Backend
    {
        class Storage;
    }

    typedef KParts::ReadOnlyPart MyBasePart;

    class ActionManagerImpl;
    class View;
    class Part;
    class Feed;
    class Article;
    class TrayIcon;

    class BrowserExtension : public KParts::BrowserExtension
    {
        Q_OBJECT
  

        public:
            BrowserExtension(Part *p, const char *name );
        public slots:
            void saveSettings();
        private:
            Part *m_part;
    };

    /**
     This is a RSS Aggregator "Part". It does all the real work.
     It is also embeddable into other applications (e.g. for use in Kontact).
     */
    class Part : public MyBasePart, virtual public AkregatorPartIface
    {
        Q_OBJECT
  
        public:
           typedef MyBasePart inherited;

            /** Default constructor.*/
            Part(TQWidget *parentWidget, const char *widgetName,
                          TQObject *parent, const char *name, const TQStringList&);

	        /** Destructor. */
            virtual ~Part();

            /** Create TDEAboutData for this KPart. */
            static TDEAboutData *createAboutData();

            /**
             Opens feedlist
             @param url URL to feedlist
             */
            virtual bool openURL(const KURL& url);

            /** Opens standard feedlist */
            virtual void openStandardFeedList();

            virtual void fetchFeedUrl(const TQString&);

            /** Fetch all feeds in the feed tree */
            virtual void fetchAllFeeds();

            /**
             Add a feed to a group.
             @param urls The URL(s) of the feed(s) to add.
             @param group The name of the folder into which the feed is added.
             If the group does not exist, it is created.  The feed is added as the last member
             of the group.
             */
            virtual void addFeedsToGroup(const TQStringList& urls, const TQString& group);

            virtual void addFeed();

            /**
             This method is called when this app is restored.  The TDEConfig
             object points to the session management config file that was saved
             with @ref saveProperties
             Calls AkregatorView's saveProperties.
             */
            virtual void readProperties(TDEConfig* config);

            /** This method is called when it is time for the app to save its
             properties for session management purposes.
             Calls AkregatorView's readProperties. */
            virtual void saveProperties(TDEConfig* config);

            /** merges a nested part's GUI into the gui of this part
            @return true iff merging was successful, i.e. the GUI factory was not NULL */
            virtual bool mergePart(KParts::Part*);

            void loadTagSet(const TQString& path);
            void saveTagSet(const TQString& path);

        public slots:
            /** Used to save settings after changing them from configuration dialog. Calls AkregatorPart's saveSettings. */
            virtual void saveSettings();

            /** Saves the standard feed list to it's default location */
            void slotSaveFeedList();

            void fileImport();
            void fileExport();
            void fileGetFeeds();

            void fileSendLink() { fileSendArticle(); }
            void fileSendFile() { fileSendArticle(true); }
            void fileSendArticle(bool attach=false);

            /** Shows configuration dialog */
            void showOptions();
            void showKNotifyOptions();

        signals:
            void showPart();
            void signalSettingsChanged();


        protected:

        /** @return Whether the tray icon is enabled or not */
            virtual bool isTrayIconEnabled() const;

            /** loads all Akregator plugins */
            void loadPlugins();

            /** This must be implemented by each part */
            virtual bool openFile();

            void importFile(const KURL& url);
            void exportFile(const KURL& url);

            /** FIXME: hack to get the tray icon working */
            TQWidget* getMainWindow();

            virtual KParts::Part *hitTest(TQWidget *widget, const TQPoint &globalPos);

            /** reimplemented to load/unload the merged parts on selection/deselection */
            virtual void partActivateEvent(KParts::PartActivateEvent* event);

        protected slots:
            void slotOnShutdown();
            void slotSettingsChanged();

        private: // methods

            bool copyFile(const TQString& backup);

            /** fills the font settings with system fonts, if fonts are not set */
            void initFonts();

            /** creates an OPML file containing the initial feeds (KDE feeds) */
            static TQDomDocument createDefaultFeedList();

            bool tryToLock(const TQString& backendName);

         private: // attributes

            class ApplyFiltersInterceptor;
            ApplyFiltersInterceptor* m_applyFiltersInterceptor;
            TQString m_standardFeedList;
            TQString m_tagSetPath;
            bool m_standardListLoaded;
            bool m_shuttingDown;

            KParts::BrowserExtension *m_extension;
            KParts::Part* m_mergedPart;
            View* m_view;

            TQTimer* m_autosaveTimer;
            /** did we backup the feed list already? */
            bool m_backedUpList;
            Backend::Storage* m_storage;
            ActionManagerImpl* m_actionManager;
    };
}

#endif // _AKREGATORPART_H_