KVIrc  4.9.2
DeveloperAPIs
KviApplication.h
Go to the documentation of this file.
1 #ifndef _KVI_APP_H_
2 #define _KVI_APP_H_
3 
4 //=============================================================================
5 //
6 // File : KviApplication.h
7 // Creation date : Sun Jun 18 2000 12:40:00 CEST by Szymon Stefanek
8 //
9 // This file is part of the KVIrc IRC client distribution
10 // Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net)
11 //
12 // This program is FREE software. You can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the HOPE that it will be USEFUL,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 // See the GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program. If not, write to the Free Software Foundation,
24 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 //
26 //=============================================================================
27 
28 #include "kvi_settings.h"
29 #include "KviCString.h"
30 #include "KviQString.h"
31 #include "KviTalApplication.h"
32 #include "KviPointerList.h"
33 #include "KviTimeUtils.h"
34 #include "KviPointerHashTable.h" // ?
35 
36 #include <QFont>
37 #include <QStringList>
38 
39 #ifdef COMPILE_KDE_SUPPORT
40 #include <KAboutData>
41 #endif
42 
43 #ifdef COMPILE_ON_WINDOWS
44 // The brain damaged MSVC compiler can't instantiate templates without this
45 #include "KviMainWindow.h"
46 #include "KviWindow.h"
47 #else // !COMPILE_ON_WINDOWS
48 class KviMainWindow;
49 class KviWindow;
50 #endif // !COMPILE_ON_WINDOWS
51 
52 #ifndef COMPILE_NO_IPC
53 class KviIpcSentinel;
54 #endif // !COMPILE_NO_IPC
55 
56 class QMenu;
57 class KviTalListBox;
58 class KviConsoleWindow;
60 class KviRegisteredUser;
61 class KviIrcConnection;
63 class QPixmap;
64 class QTextCodec;
65 class QDomElement;
66 class QStringList;
67 
69 {
71  QString szRemoteUrl;
72  QString szNick;
73  QString szUser;
74  QString szHost;
76 
83 {
85  QString szIcon;
86  QString szMessage;
87  unsigned int uMessageLifetime;
89 
91 {
92  QStringList lMessages;
94 
95 #ifdef Unsorted
96 #undef Unsorted
97 #endif
98 #ifdef None
99 #undef None
100 #endif
101 
103 {
104  friend class KviMainWindow;
105  friend class KviWindow;
106  friend class SetupWizard; // this resides in a module!
107  Q_OBJECT
108 public:
109  // FIXME: "Plugins" and "ConfigPlugins" should become "Modules" and "ConfigModules"
111  {
138  EasyPlugins
139  };
140 
141  KviApplication(int & argc, char ** argv);
142  ~KviApplication();
143 
144 public:
145  // setup stuff (accessed from KviMain.cpp: consider private otherwise)
146  QString m_szConfigFile; // setup
147  bool m_bCreateConfig; // setup
149 
150 protected:
151 #ifdef COMPILE_KDE_SUPPORT
152  KAboutData * m_pAboutData;
153 #endif
154  // directories
160 #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
161  bool m_bPortable;
162 #endif
168 #ifdef COMPILE_PSEUDO_TRANSPARENCY
169  bool m_bUpdatePseudoTransparencyPending;
170 #endif
171 #ifndef COMPILE_NO_IPC
173 #endif
175 
176 public:
177  void setup(); // THIS SHOULD BE PRIVATE! (but is accessed from KviMain.cpp)
178 
179 #ifdef COMPILE_KDE_SUPPORT
180  void setAboutData(KAboutData * pAboutData)
181  {
182  m_pAboutData = pAboutData;
183  };
184  KAboutData * aboutData() { return m_pAboutData; };
185 #endif
186 
187 #ifndef COMPILE_NO_IPC
188  void ipcMessage(char * message);
189 #endif
190 
191  static int getGloballyUniqueId(); // returns an unique integer identifier across the application
192 
193  bool firstTimeRun() const { return m_bFirstTimeRun; };
194  bool kviClosingDown() const { return m_bClosingDown; };
195  void setKviClosingDown() { m_bClosingDown = true; };
196 
197  bool supportsCompositing();
198 
199  void setupBegin();
200  void setupFinish();
201 
202  /*
203  Unused
204  inline void emitRecentUrlsChanged() { emit(recentUrlsChanged()); };
205  */
206 
207  // KviApplication.cpp (Saving options)
208  void saveIrcServerDataBase();
209  void saveProxyDataBase();
210  void saveRecentEntries();
211  void saveAppEvents();
212  void saveRawEvents();
213  void saveMediaTypes();
214  void saveRegisteredUsers();
215  void saveSharedFiles();
216  void savePopups();
217  void saveAliases();
218  void saveNickServ();
219  void saveIdentityProfiles();
220  void saveDefaultScripts();
221  void saveTextIcons();
222  void saveRegisteredChannels();
223  void saveInputHistory();
224  void saveAvatarCache();
225  void saveToolBars();
226  void saveActions();
227  void saveScriptAddons();
228  void saveIdentities();
229 
230  // KviOptions.cpp : Options saving and loading (kvi.main.conf))
231  void loadOptions();
232  void saveOptions();
233 
234  void listAvailableOptions(KviWindow * wnd);
235  bool getOptionString(const QString & optName, QString & buffer);
236  bool setOptionValue(const QString & optName, const QString & value);
237  bool setCommonOptionValue(const QString & optName, const QString & value);
238 
239  void optionResetUpdate(int flags);
240 
241  // KviApplication_filesystem.cpp : Filesystem thingies
242  void getGlobalKvircDirectory(QString & szData, KvircSubdir dir, const QString & appendFile = QString());
243  void getLocalKvircDirectory(QString & szData, KvircSubdir dir, const QString & appendFile = QString(), bool bCreateIfNeeded = true);
244 
245  void getTmpFileName(QString & szBuffer, const QString & szEndingFileName = QString());
246  void getChannelDumpLogFileName(QString & str);
247 
248  static QTextCodec * defaultTextCodec();
249  static QTextCodec * defaultSrvCodec();
250 
251  bool findImageInImageSearchPath(QString & szRetPath, const QString & filename);
252 
253  bool findImage(QString & szRetPath, const QString & filename);
254  bool findImageThemeOnlyCompat(QString & szRetPath, const QString & filename); // temporary compat, will be removed soon (do not use)
255  bool findSmallIcon(QString & szRetPath, const QString & filename);
256  // tries to map the full path filename to one of the KVIrc's mapped directories
257  // if it doesn't succeed it just returns the complete filename in szRetPath
258  //bool mapImageFile(KviCString &szRetPath,const char * filename);
259  bool mapImageFile(QString & szRetPath, const QString & filename);
260 
261  //void getDefaultDccSaveFilePath(KviCString &path,const char *filename);
262  void completeDirectory(const QString & word, KviPointerList<QString> * matches);
263  //
264  // Returns a config path suitable for reading (at least)
265  // First lookups the user local config directory,
266  // if no config file is found, it searches in the global one
267  // returns false if no config file has been found
268  // If bNoFail is true, the buffer is filled with the file name even
269  // if no config file has been found: in this case the local config
270  // directory is used
271  //
272  bool getReadOnlyConfigPath(QString & buffer, const char * config_name, KvircSubdir sbd = Config, bool bNoFail = false);
273 
283  bool findAudioFile(QString & szRetPath, const QString & szFileName);
284 
285  // KviApplication.cpp : Window stuff
286  KviWindow * findWindow(const QString & windowId);
287  KviWindow * findWindowByCaption(const QString & windowCaption, int iContextId = -1);
288  KviConsoleWindow * findConsole(unsigned int ircContextId);
289  KviConsoleWindow * findConsole(QString & servr, QString & nick);
290  KviConsoleWindow * topmostConnectedConsole();
291  KviConsoleWindow * activeConsole();
292  bool windowExists(KviWindow * wnd);
293  bool connectionExists(KviIrcConnection * cnn);
294  unsigned int windowCount();
295 
296  // KviApplication.cpp : Utilities
297  void resetAvatarForMatchingUsers(KviRegisteredUser * u);
298  void restartNotifyLists();
299  void restartLagMeters();
300  void triggerUpdateGui();
301 #ifdef COMPILE_PSEUDO_TRANSPARENCY
302  void triggerUpdatePseudoTransparency();
303 #endif
304 
305  // KviApplication.cpp : DCC (and CTCP AVATAR & SOUND) related stuff
306  void setAvatarOnFileReceived(KviConsoleWindow * pConsole, const QString & szRemoteUrl, const QString & szNick, const QString & szUser, const QString & szHost);
307  KviPendingAvatarChange * findPendingAvatarChange(KviConsoleWindow * pConsole, const QString & szNick, const QString & szRemoteUrl);
308  void fileDownloadTerminated(bool bSuccess, const QString & szRemoteUrl, const QString & szLocalFileName, const QString & szNick = QString(), const QString & szError = QString(), bool bQuiet = false);
309 
310  void setAvatarFromOptions();
311 
312  // uMessageLifetime is in seconds! and 0 means "forever"
313  void notifierMessage(KviWindow * pWnd, int iIconId, const QString & szMsg, unsigned int uMessageLifetime);
314 
315  void addRecentNickname(const QString & newNick);
316  void addRecentChannel(const QString & chan, const QString & net);
317 
318  QStringList * recentChannelsForNetwork(const QString & net);
319 
321  {
322  return m_pRecentChannelDict;
323  }
324 
325  void addRecentServer(const QString & server);
326  void fillRecentServersPopup(QMenu * m);
327  void fillRecentNicknamesPopup(QMenu * m, KviConsoleWindow * pConsole);
328  void fillRecentChannelsPopup(QMenu * m, KviConsoleWindow * pConsole);
329  //
330  void autoConnectToServers();
331 
332  void checkSuggestRestoreDefaultScript();
333 
334  void loadDefaultScript(QString szItem = QString());
335  QStyle * themedStyle();
336 
337 protected:
338  void buildRecentChannels();
339  void saveRecentChannels();
340  // KviApplication.cpp : KviWindow global database
341  void registerWindow(KviWindow * wnd);
342  void unregisterWindow(KviWindow * wnd);
343  void frameDestructorCallback();
344  void heartbeat(kvi_time_t tNow);
345  virtual void timerEvent(QTimerEvent * e);
346 
347 private:
348  // KviApplication_setup.cpp : Setup stuff
349  void loadDirectories();
350  void findGlobalKvircDirectory();
351  bool findLocalKvircDirectory();
352  bool checkGlobalKvircDirectory(const QString);
353  bool checkLocalKvircDirectory(const QString & szSpecificPath);
354  bool checkLocalKvircDirectory(); // check the m_szLocalKvircDirectory path
355  bool checkFileAssociations();
356  void setupFileAssociations();
357 
358  bool checkUriAssociations(const char * proto);
359  void setupUriAssociations(const char * proto);
360 
361  void saveKvircDirectory();
362 
363  // KviApplication.cpp : GUI stuff
364  void updateApplicationFont();
365 
366  // KviApplication.cpp : parts of setup()
367  void loadRecentEntries();
368 #ifndef COMPILE_NO_IPC
369  void createIpcSentinel();
370  void destroyIpcSentinel();
371 #endif // COMPILE_NO_IPC
372  void createFrame();
373 
374 #ifdef COMPILE_PSEUDO_TRANSPARENCY
375  void createGlobalBackgrounds(QPixmap * pix);
376  void destroyPseudoTransparency();
377 #endif //COMPILE_PSEUDO_TRANSPARENCY
378 public slots:
379  // KviApplication.cpp : Slots
380  void saveConfiguration();
381  void updateGui();
382  void updatePseudoTransparency();
383  void restoreDefaultScript();
384  void addRecentUrl(const QString & text);
385  void showParentFrame();
386 signals:
387  void reloadImages();
388  void updateNotifier();
389  void recentUrlsChanged();
390 };
391 
392 #ifndef _KVI_APP_CPP_
395 #endif
396 
397 #endif //_KVI_APP_H_
KviIpcSentinel * m_pIpcSentinel
Definition: KviApplication.h:172
void saveAliases(const QString &szFileName)
Definition: KviKvs.cpp:82
Definition: KviApplication.h:124
Definition: KviMainWindow.h:60
Definition: KviConsoleWindow.h:75
#define KVIRC_API
Definition: kvi_settings.h:128
void saveAppEvents(const QString &szFileName)
Definition: KviKvs.cpp:97
Definition: KviApplication.h:136
Definition: KviApplication.h:121
bool firstTimeRun() const
Definition: KviApplication.h:193
#define m
Definition: detector.cpp:77
KviPointerList< KviPendingAvatarChange > * m_pPendingAvatarChanges
Definition: KviApplication.h:165
int m_iHeartbeatTimerId
Definition: KviApplication.h:157
bool m_bSetupDone
Definition: KviApplication.h:166
An abstraction of a connection to an IRC server.
Definition: KviIrcConnection.h:95
Definition: KviApplication.h:90
Definition: KviConfigurationFile.h:48
bool kviClosingDown() const
Definition: KviApplication.h:194
bool m_bFirstTimeRun
Definition: KviApplication.h:158
Definition: KviApplication.h:68
Definition: KviApplication.h:130
Definition: KviApplication.h:114
QString szMessage
Definition: KviApplication.h:86
KviPointerHashTable< QString, QStringList > * recentChannels() const
Definition: KviApplication.h:320
struct _KviNotifierMessageParam KviNotifierMessageParam
KviConsoleWindow * pConsole
Definition: KviApplication.h:70
KviWindow * m_pActiveWindow
Definition: KviApplication.h:163
Definition: KviApplication.h:120
Definition: KviRegisteredUser.h:35
Definition: KviApplication.h:132
virtual void saveConfiguration()=0
Saves configuration to disk.
void setKviClosingDown()
Definition: KviApplication.h:195
Definition: KviApplication.h:116
Definition: KviApplication.h:125
QString m_szExecAfterStartup
Definition: KviApplication.h:148
#define kvi_time_t
Definition: KviTimeUtils.h:43
KVIRC_API KviIrcServerDataBase * g_pServerDataBase
Definition: KviApplication.cpp:154
#define e
Definition: detector.cpp:69
QString m_szConfigFile
Definition: KviApplication.h:146
Definition: KviApplication.h:127
QString szRemoteUrl
Definition: KviApplication.h:71
QString szNick
Definition: KviApplication.h:72
Defines a struct which holds information about the notifier message.
Definition: KviApplication.h:82
defined(COMPILE_KDE4_SUPPORT)
Definition: KviTalApplication.h:53
Pointer Hash Table.
QString szUser
Definition: KviApplication.h:73
struct _KviPendingAvatarChange KviPendingAvatarChange
Definition: KviApplication.h:112
void savePopups(const QString &szFileName)
Definition: KviKvs.cpp:67
KviPointerHashTable< QString, QStringList > * m_pRecentChannelDict
Definition: KviApplication.h:167
QString szHost
Definition: libkvisetup.cpp:45
bool m_bUpdateGuiPending
Definition: KviApplication.h:164
QString m_szLocalKvircDir
Definition: KviApplication.h:156
Definition: KviApplication.h:119
Definition: KviApplication.h:115
Time management.
Definition: KviApplication.h:113
Definition: KviApplication.h:131
Definition: SetupWizard.h:62
void saveScriptAddons(const QString &szFileName)
Definition: KviKvs.cpp:127
Definition: KviApplication.h:135
C++ Template based double linked pointer list class.
Base class for all windows in KVIrc.
Definition: KviWindow.h:74
A template double linked list of pointers.
Definition: KviPointerList.h:55
Definition: KviApplication.h:122
QString szHost
Definition: KviApplication.h:74
Definition: KviApplication.h:102
Definition: KviApplication.h:123
Toolkit Abstraction Level class.
QFont m_fntDefaultFont
Definition: KviApplication.h:174
KVIRC_API KviApplication * g_pApp
Definition: KviApplication.cpp:151
Definition: KviIpcSentinel.h:50
QString szIcon
Definition: KviApplication.h:85
Contains the KviWindow class.
#define u
Definition: detector.cpp:85
Definition: KviApplication.h:117
QStringList lMessages
Definition: KviApplication.h:92
Definition: KviApplication.h:133
bool m_bClosingDown
Definition: KviApplication.h:159
char szBuffer[4096]
Definition: winamp.cpp:77
Definition: KviApplication.h:129
QString m_szGlobalKvircDir
Definition: KviApplication.h:155
Definition: KviApplication.h:128
Definition: KviApplication.h:126
void saveRawEvents(const QString &szFileName)
Definition: KviKvs.cpp:112
This file contains compile time settings.
Definition: KviApplication.h:137
Definition: KviApplication.h:118
Irc server database handling class.
Definition: KviIrcServerDataBase.h:63
bool m_bCreateConfig
Definition: KviApplication.h:147
struct _KviDBusNotifierMessageQueue KviDBusNotifierMessageQueue
unsigned int uMessageLifetime
Definition: KviApplication.h:87
Definition: KviApplication.h:134
Helper functions for the QString class.
KviWindow * pWindow
Definition: KviApplication.h:84
KvircSubdir
Definition: KviApplication.h:110