• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

  • tdecore
tdeapplication.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
3  Copyright (C) 1998, 1999, 2000 KDE Team
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19  */
20 
21 #include "config.h"
22 
23 #ifdef HAVE_XCOMPOSITE
24 #define COMPOSITE
25 #endif
26 
27 // #ifdef QTRANSLATOR_H
28 // #error qtranslator.h was already included
29 // #endif // QTRANSLATOR_H
30 //
31 // #ifdef TQTRANSLATOR_H
32 // #error tqtranslator.h was already included
33 // #endif // TQTRANSLATOR_H
34 
35 #undef QT_NO_TRANSLATION
36 #undef TQT_NO_TRANSLATION
37 #include <tqtranslator.h>
38 
39 // FIXME
40 // FOR BINARY COMPATIBILITY ONLY
41 // REMOVE WHEN PRACTICAL!
42 #define TDEAPPLICATION_BINARY_COMPAT_HACK 1
43 #include "tdeapplication.h"
44 #undef TDEAPPLICATION_BINARY_COMPAT_HACK
45 
46 #define QT_NO_TRANSLATION
47 #define TQT_NO_TRANSLATION
48 #include <tqdir.h>
49 #include <tqptrcollection.h>
50 #include <tqwidgetlist.h>
51 #include <tqstrlist.h>
52 #include <tqfile.h>
53 #include <tqmessagebox.h>
54 #include <tqtextstream.h>
55 #include <tqregexp.h>
56 #include <tqlineedit.h>
57 #include <tqtextedit.h>
58 #include <tqsessionmanager.h>
59 #include <tqptrlist.h>
60 #include <tqtimer.h>
61 #include <tqstylesheet.h>
62 #include <tqpixmapcache.h>
63 #include <tqtooltip.h>
64 #include <tqstylefactory.h>
65 #include <tqmetaobject.h>
66 #include <tqimage.h>
67 #ifndef QT_NO_SQL
68 #include <tqsqlpropertymap.h>
69 #endif
70 
71 #include <tdeglobal.h>
72 #include <kstandarddirs.h>
73 #include <kdebug.h>
74 #include <tdelocale.h>
75 #include <tdestyle.h>
76 #include <kiconloader.h>
77 #include <kclipboard.h>
78 #include <tdeconfig.h>
79 #include <ksimpleconfig.h>
80 #include <tdecmdlineargs.h>
81 #include <tdeaboutdata.h>
82 #include <tdeglobalsettings.h>
83 #include <kcrash.h>
84 #include <kdatastream.h>
85 #include <klibloader.h>
86 #include <kmimesourcefactory.h>
87 #include <tdestdaccel.h>
88 #include <tdeaccel.h>
89 #include "kcheckaccelerators.h"
90 #include <tqptrdict.h>
91 #include <kmacroexpander.h>
92 #include <kshell.h>
93 #include <kprotocolinfo.h>
94 #include <kkeynative.h>
95 #include <kmdcodec.h>
96 #include <kglobalaccel.h>
97 
98 #if defined Q_WS_X11
99 #include <tdestartupinfo.h>
100 #endif
101 
102 #include <dcopclient.h>
103 #include <dcopref.h>
104 
105 #include <sys/types.h>
106 #ifdef HAVE_SYS_STAT_H
107 #include <sys/stat.h>
108 #endif
109 #include <sys/wait.h>
110 #include <grp.h>
111 #include <sys/types.h>
112 
113 #ifndef Q_WS_WIN
114 #include "twin.h"
115 #endif
116 
117 #include <fcntl.h>
118 #include <stdlib.h> // getenv(), srand(), rand()
119 #include <signal.h>
120 #include <unistd.h>
121 #include <time.h>
122 #include <sys/time.h>
123 #include <errno.h>
124 #include <string.h>
125 #include <netdb.h>
126 #if defined Q_WS_X11
127 //#ifndef Q_WS_QWS //FIXME(E): NetWM should talk to QWS...
128 #include <netwm.h>
129 #endif
130 
131 #include "kprocctrl.h"
132 
133 #ifdef HAVE_PATHS_H
134 #include <paths.h>
135 #endif
136 
137 #ifdef Q_WS_X11
138 #include <X11/Xlib.h>
139 #ifdef COMPOSITE
140 #include <X11/extensions/Xrender.h>
141 #include <X11/extensions/Xcomposite.h>
142 #include <dlfcn.h>
143 #endif
144 #include <X11/Xutil.h>
145 #include <X11/Xatom.h>
146 #include <X11/SM/SMlib.h>
147 #include <fixx11h.h>
148 #endif
149 
150 #include <pwd.h>
151 
152 #ifndef Q_WS_WIN
153 #include <KDE-ICE/ICElib.h>
154 #else
155 typedef void* IceIOErrorHandler;
156 #include <windows.h>
157 //KDE4: remove
158 #define Button1Mask (1<<8)
159 #define Button2Mask (1<<9)
160 #define Button3Mask (1<<10)
161 #endif
162 
163 #ifdef Q_WS_X11
164 #define DISPLAY "DISPLAY"
165 #elif defined(Q_WS_QWS)
166 #define DISPLAY "QWS_DISPLAY"
167 #endif
168 
169 #if defined Q_WS_X11
170 #include <kipc.h>
171 #endif
172 
173 #ifdef Q_WS_MACX
174 #include <Carbon/Carbon.h>
175 #include <tqimage.h>
176 #endif
177 
178 #if defined Q_WS_X11
179 #include <sys/ioctl.h>
180 #ifdef __linux__
181 #include <linux/vt.h>
182 #endif
183 extern "C" {
184 extern int getfd(const char *fnam);
185 }
186 #endif
187 
188 #include "kappdcopiface.h"
189 
190 // exported for tdm kfrontend
191 KDE_EXPORT bool kde_have_kipc = true; // magic hook to disable kipc in tdm
192 bool kde_kiosk_exception = false; // flag to disable kiosk restrictions
193 bool kde_kiosk_admin = false;
194 
195 TDEApplication* TDEApplication::KApp = 0L;
196 bool TDEApplication::loadedByKdeinit = false;
197 DCOPClient *TDEApplication::s_DCOPClient = 0L;
198 bool TDEApplication::s_dcopClientNeedsPostInit = false;
199 
200 #ifdef Q_WS_X11
201 static Atom atom_DesktopWindow;
202 static Atom atom_NetSupported;
203 #endif
204 
205 #if defined(Q_WS_X11) && defined(COMPOSITE)
206 static int composite_event, composite_error, composite_opcode;
207 static bool x11_composite_error_generated;
208 static int x11_error(Display *dpy, XErrorEvent *ev) {
209  if (ev->request_code == composite_opcode && ev->minor_code == X_CompositeRedirectSubwindows)
210  {
211  x11_composite_error_generated = true;
212  return 0;
213  }
214  return 1;
215 }
216 #endif
217 
218 // duplicated from patched Qt, so that there won't be unresolved symbols if Qt gets
219 // replaced by unpatched one
220 TDECORE_EXPORT bool tqt_qclipboard_bailout_hack = false;
221 
222 template class TQPtrList<KSessionManaged>;
223 
224 #ifdef Q_WS_X11
225 extern "C" {
226 static int kde_xio_errhandler( Display * dpy )
227 {
228  return kapp->xioErrhandler( dpy );
229 }
230 
231 static int kde_x_errhandler( Display *dpy, XErrorEvent *err )
232 {
233  return kapp->xErrhandler( dpy, err );
234 }
235 
236 }
237 
238 extern "C" {
239 static void kde_ice_ioerrorhandler( IceConn conn )
240 {
241  if(kapp)
242  kapp->iceIOErrorHandler( conn );
243  // else ignore the error for now
244 }
245 }
246 #endif
247 
248 #ifdef Q_WS_WIN
249 void TDEApplication_init_windows(bool GUIenabled);
250 
251 class QAssistantClient;
252 #endif
253 
254 #ifdef Q_WS_X11
255 // --------------------------------------------------------------------------------------
256 // Get the VT number X is running on
257 // (code taken from GDM, daemon/getvt.c, GPLv2+)
258 // --------------------------------------------------------------------------------------
259 int get_x_vtnum(Display *dpy)
260 {
261  Atom prop;
262  Atom actualtype;
263  int actualformat;
264  unsigned long nitems;
265  unsigned long bytes_after;
266  unsigned char *buf;
267  int num;
268 
269  prop = XInternAtom (dpy, "XFree86_VT", False);
270  if (prop == None)
271  return -1;
272 
273  if (XGetWindowProperty (dpy, DefaultRootWindow (dpy), prop, 0, 1,
274  False, AnyPropertyType, &actualtype, &actualformat,
275  &nitems, &bytes_after, &buf)) {
276  return -1;
277  }
278 
279  if (nitems != 1) {
280  XFree (buf);
281  return -1;
282  }
283 
284  switch (actualtype) {
285  case XA_CARDINAL:
286  case XA_INTEGER:
287  case XA_WINDOW:
288  switch (actualformat) {
289  case 8:
290  num = (*(uint8_t *)(void *)buf);
291  break;
292  case 16:
293  num = (*(uint16_t *)(void *)buf);
294  break;
295  case 32:
296  num = (*(uint32_t *)(void *)buf);
297  break;
298  default:
299  XFree (buf);
300  return -1;
301  }
302  break;
303  default:
304  XFree (buf);
305  return -1;
306  }
307 
308  XFree (buf);
309 
310  return num;
311 }
312 // --------------------------------------------------------------------------------------
313 #endif // Q_WS_X11
314 
315 /*
316  Private data to make keeping binary compatibility easier
317  */
318 class TDEApplicationPrivate
319 {
320 public:
321  TDEApplicationPrivate()
322  : actionRestrictions( false ),
323  refCount( 1 ),
324  oldIceIOErrorHandler( 0 ),
325  checkAccelerators( 0 ),
326  overrideStyle( TQString::null ),
327  startup_id( "0" ),
328  app_started_timer( NULL ),
329  m_KAppDCOPInterface( 0L ),
330  session_save( false )
331 #ifdef Q_WS_X11
332  ,oldXErrorHandler( NULL )
333  ,oldXIOErrorHandler( NULL )
334 #elif defined Q_WS_WIN
335  ,qassistantclient( 0 )
336 #endif
337  {
338  }
339 
340  ~TDEApplicationPrivate()
341  {
342 #ifdef Q_WS_WIN
343  delete qassistantclient;
344 #endif
345  }
346 
347 
348  bool actionRestrictions : 1;
349  bool guiEnabled : 1;
356  int refCount;
357  IceIOErrorHandler oldIceIOErrorHandler;
358  KCheckAccelerators* checkAccelerators;
359  TQString overrideStyle;
360  TQString geometry_arg;
361  TQCString startup_id;
362  TQTimer* app_started_timer;
363  KAppDCOPInterface *m_KAppDCOPInterface;
364  bool session_save;
365 #ifdef Q_WS_X11
366  int (*oldXErrorHandler)(Display*,XErrorEvent*);
367  int (*oldXIOErrorHandler)(Display*);
368 #elif defined Q_WS_WIN
369  QAssistantClient* qassistantclient;
370 #endif
371 
372  class URLActionRule
373  {
374  public:
375 #define checkExactMatch(s, b) \
376  if (s.isEmpty()) b = true; \
377  else if (s[s.length()-1] == '!') \
378  { b = false; s.truncate(s.length()-1); } \
379  else b = true;
380 #define checkStartWildCard(s, b) \
381  if (s.isEmpty()) b = true; \
382  else if (s[0] == '*') \
383  { b = true; s = s.mid(1); } \
384  else b = false;
385 #define checkEqual(s, b) \
386  b = (s == "=");
387 
388  URLActionRule(const TQString &act,
389  const TQString &bProt, const TQString &bHost, const TQString &bPath,
390  const TQString &dProt, const TQString &dHost, const TQString &dPath,
391  bool perm)
392  : action(act),
393  baseProt(bProt), baseHost(bHost), basePath(bPath),
394  destProt(dProt), destHost(dHost), destPath(dPath),
395  permission(perm)
396  {
397  checkExactMatch(baseProt, baseProtWildCard);
398  checkStartWildCard(baseHost, baseHostWildCard);
399  checkExactMatch(basePath, basePathWildCard);
400  checkExactMatch(destProt, destProtWildCard);
401  checkStartWildCard(destHost, destHostWildCard);
402  checkExactMatch(destPath, destPathWildCard);
403  checkEqual(destProt, destProtEqual);
404  checkEqual(destHost, destHostEqual);
405  }
406 
407  bool baseMatch(const KURL &url, const TQString &protClass)
408  {
409  if (baseProtWildCard)
410  {
411  if ( !baseProt.isEmpty() && !url.protocol().startsWith(baseProt) &&
412  (protClass.isEmpty() || (protClass != baseProt)) )
413  return false;
414  }
415  else
416  {
417  if ( (url.protocol() != baseProt) &&
418  (protClass.isEmpty() || (protClass != baseProt)) )
419  return false;
420  }
421  if (baseHostWildCard)
422  {
423  if (!baseHost.isEmpty() && !url.host().endsWith(baseHost))
424  return false;
425  }
426  else
427  {
428  if (url.host() != baseHost)
429  return false;
430  }
431  if (basePathWildCard)
432  {
433  if (!basePath.isEmpty() && !url.path().startsWith(basePath))
434  return false;
435  }
436  else
437  {
438  if (url.path() != basePath)
439  return false;
440  }
441  return true;
442  }
443 
444  bool destMatch(const KURL &url, const TQString &protClass, const KURL &base, const TQString &baseClass)
445  {
446  if (destProtEqual)
447  {
448  if ( (url.protocol() != base.protocol()) &&
449  (protClass.isEmpty() || baseClass.isEmpty() || protClass != baseClass) )
450  return false;
451  }
452  else if (destProtWildCard)
453  {
454  if ( !destProt.isEmpty() && !url.protocol().startsWith(destProt) &&
455  (protClass.isEmpty() || (protClass != destProt)) )
456  return false;
457  }
458  else
459  {
460  if ( (url.protocol() != destProt) &&
461  (protClass.isEmpty() || (protClass != destProt)) )
462  return false;
463  }
464  if (destHostWildCard)
465  {
466  if (!destHost.isEmpty() && !url.host().endsWith(destHost))
467  return false;
468  }
469  else if (destHostEqual)
470  {
471  if (url.host() != base.host())
472  return false;
473  }
474  else
475  {
476  if (url.host() != destHost)
477  return false;
478  }
479  if (destPathWildCard)
480  {
481  if (!destPath.isEmpty() && !url.path().startsWith(destPath))
482  return false;
483  }
484  else
485  {
486  if (url.path() != destPath)
487  return false;
488  }
489  return true;
490  }
491 
492  TQString action;
493  TQString baseProt;
494  TQString baseHost;
495  TQString basePath;
496  TQString destProt;
497  TQString destHost;
498  TQString destPath;
499  bool baseProtWildCard : 1;
500  bool baseHostWildCard : 1;
501  bool basePathWildCard : 1;
502  bool destProtWildCard : 1;
503  bool destHostWildCard : 1;
504  bool destPathWildCard : 1;
505  bool destProtEqual : 1;
506  bool destHostEqual : 1;
507  bool permission;
508  };
509  TQPtrList<URLActionRule> urlActionRestrictions;
510 
511  TQString sessionKey;
512  TQString pSessionConfigFile;
513 };
514 
515 
516 static TQPtrList<TQWidget>*x11Filter = 0;
517 static bool autoDcopRegistration = true;
518 
519 void TDEApplication::installX11EventFilter( TQWidget* filter )
520 {
521  if ( !filter )
522  return;
523  if (!x11Filter)
524  x11Filter = new TQPtrList<TQWidget>;
525  connect ( filter, TQT_SIGNAL( destroyed() ), this, TQT_SLOT( x11FilterDestroyed() ) );
526  x11Filter->append( filter );
527 }
528 
529 void TDEApplication::x11FilterDestroyed()
530 {
531  removeX11EventFilter( static_cast< const TQWidget* >( sender()));
532 }
533 
534 void TDEApplication::removeX11EventFilter( const TQWidget* filter )
535 {
536  if ( !x11Filter || !filter )
537  return;
538  x11Filter->removeRef( filter );
539  if ( x11Filter->isEmpty() ) {
540  delete x11Filter;
541  x11Filter = 0;
542  }
543 }
544 
545 // FIXME: remove this when we've get a better method of
546 // customizing accelerator handling -- hopefully in Qt.
547 // For now, this is set whenever an accelerator is overridden
548 // in TDEAccelEventHandler so that the AccelOverride isn't sent twice. -- ellis, 19/10/02
549 extern bool kde_g_bKillAccelOverride;
550 
551 bool TDEApplication::notify(TQObject *receiver, TQEvent *event)
552 {
553  TQEvent::Type t = event->type();
554  if (kde_g_bKillAccelOverride)
555  {
556  kde_g_bKillAccelOverride = false;
557  // Indicate that the accelerator has been overridden.
558  if (t == TQEvent::AccelOverride)
559  {
560  TQT_TQKEYEVENT(event)->accept();
561  return true;
562  }
563  else
564  kdWarning(125) << "kde_g_bKillAccelOverride set, but received an event other than AccelOverride." << endl;
565  }
566 
567  if ((t == TQEvent::AccelOverride) || (t == TQEvent::KeyPress))
568  {
569  static const TDEShortcut& _selectAll = TDEStdAccel::selectAll();
570  TQLineEdit *edit = ::tqqt_cast<TQLineEdit *>(receiver);
571  if (edit)
572  {
573  // We have a keypress for a lineedit...
574  TQKeyEvent *kevent = TQT_TQKEYEVENT(event);
575  KKey key(kevent);
576  if (_selectAll.contains(key))
577  {
578  if (t == TQEvent::KeyPress)
579  {
580  edit->selectAll();
581  return true;
582  }
583  else
584  {
585  kevent->accept();
586  }
587  }
588  // Ctrl-U deletes from start of line.
589  if (key == KKey(Qt::CTRL + Qt::Key_U))
590  {
591  if (t == TQEvent::KeyPress)
592  {
593  if (!edit->isReadOnly())
594  {
595  TQString t(edit->text());
596  t = t.mid(edit->cursorPosition());
597  edit->validateAndSet(t, 0, 0, 0);
598  }
599  return true;
600  }
601  else
602  {
603  kevent->accept();
604  }
605 
606  }
607  }
608  TQTextEdit *medit = ::tqqt_cast<TQTextEdit *>(receiver);
609  if (medit)
610  {
611  // We have a keypress for a multilineedit...
612  TQKeyEvent *kevent = TQT_TQKEYEVENT(event);
613  if (_selectAll.contains(KKey(kevent)))
614  {
615  if (t == TQEvent::KeyPress)
616  {
617  medit->selectAll();
618  return true;
619  }
620  else
621  {
622  kevent->accept();
623  }
624  }
625  }
626  }
627  if( t == TQEvent::Show && receiver->isWidgetType())
628  {
629  TQWidget* w = TQT_TQWIDGET( receiver );
630 #if defined Q_WS_X11
631  if( w->isTopLevel() && !startupId().isEmpty() && !TQT_TQSHOWEVENT(event)->spontaneous()) // TODO better done using window group leader?
632  TDEStartupInfo::setWindowStartupId( w->winId(), startupId());
633 #endif
634  if( w->isTopLevel() && !w->testWFlags( WX11BypassWM ) && !w->isPopup() && !event->spontaneous())
635  {
636  if( d->app_started_timer == NULL )
637  {
638  d->app_started_timer = new TQTimer( this, "app_started_timer" );
639  connect( d->app_started_timer, TQT_SIGNAL( timeout()), TQT_SLOT( checkAppStartedSlot()));
640  }
641  if( !d->app_started_timer->isActive())
642  d->app_started_timer->start( 0, true );
643  }
644  if( w->isTopLevel() && ( w->icon() == NULL || w->icon()->isNull()))
645  {
646  // icon() cannot be null pixmap, it'll be the "unknown" icon - so check if there is this application icon
647  static TQPixmap* ic = NULL;
648  if( ic == NULL )
649  ic = new TQPixmap( TDEGlobal::iconLoader()->loadIcon( iconName(),
650  TDEIcon::NoGroup, 0, TDEIcon::DefaultState, NULL, true ));
651  if( !ic->isNull())
652  {
653  w->setIcon( *ic );
654 #if defined Q_WS_X11
655  KWin::setIcons( w->winId(), *ic, miniIcon());
656 #endif
657  }
658  }
659  }
660  return TQApplication::notify(receiver, event);
661 }
662 
663 void TDEApplication::checkAppStartedSlot()
664 {
665 #if defined Q_WS_X11
666  TDEStartupInfo::handleAutoAppStartedSending();
667 #endif
668 }
669 
670 // the help class for session management communication
671 static TQPtrList<KSessionManaged>* sessionClients()
672 {
673  static TQPtrList<KSessionManaged>* session_clients = 0L;
674  if ( !session_clients )
675  session_clients = new TQPtrList<KSessionManaged>;
676  return session_clients;
677 }
678 
679 /*
680  Auxiliary function to calculate a a session config name used for the
681  instance specific config object.
682  Syntax: "session/<appname>_<sessionId>"
683  */
684 TQString TDEApplication::sessionConfigName() const
685 {
686  TQString sessKey = sessionKey();
687  if ( sessKey.isEmpty() && !d->sessionKey.isEmpty() )
688  sessKey = d->sessionKey;
689  return TQString("session/%1_%2_%3").arg(name()).arg(sessionId()).arg(sessKey);
690 }
691 
692 #ifdef Q_WS_X11
693 static SmcConn mySmcConnection = 0;
694 static SmcConn tmpSmcConnection = 0;
695 #else
696 // FIXME(E): Implement for Qt Embedded
697 // Possibly "steal" XFree86's libSM?
698 #endif
699 static TQTime* smModificationTime = 0;
700 
701 TDEApplication::TDEApplication( int& argc, char** argv, const TQCString& rAppName,
702  bool allowStyles, bool GUIenabled, bool SMenabled ) :
703  TQApplication( argc, argv, GUIenabled, SMenabled ), TDEInstance(rAppName),
704 #ifdef Q_WS_X11
705  display(0L),
706  argb_visual(false),
707 #endif
708  d (new TDEApplicationPrivate())
709 {
710  aIconPixmap.pm.icon = 0L;
711  aIconPixmap.pm.miniIcon = 0L;
712  read_app_startup_id();
713  if (!GUIenabled)
714  allowStyles = false;
715  useStyles = allowStyles;
716  Q_ASSERT (!rAppName.isEmpty());
717  setName(rAppName);
718 
719  installSigpipeHandler();
720  TDECmdLineArgs::initIgnore(argc, argv, rAppName.data());
721  parseCommandLine( );
722  init(GUIenabled);
723  d->m_KAppDCOPInterface = new KAppDCOPInterface(this);
724 }
725 
726 // FIXME
727 // FOR BINARY COMPATIBILITY ONLY
728 // REMOVE WHEN PRACTICAL!
729 TDEApplication::TDEApplication( int& argc, char** argv, const TQCString& rAppName,
730  bool allowStyles, bool GUIenabled ) :
731  TQApplication( argc, argv, GUIenabled ), TDEInstance(rAppName),
732 #ifdef Q_WS_X11
733  display(0L),
734  argb_visual(false),
735 #endif
736  d (new TDEApplicationPrivate())
737 {
738  aIconPixmap.pm.icon = 0L;
739  aIconPixmap.pm.miniIcon = 0L;
740  read_app_startup_id();
741  if (!GUIenabled)
742  allowStyles = false;
743  useStyles = allowStyles;
744  Q_ASSERT (!rAppName.isEmpty());
745  setName(rAppName);
746 
747  installSigpipeHandler();
748  TDECmdLineArgs::initIgnore(argc, argv, rAppName.data());
749  parseCommandLine( );
750  init(GUIenabled);
751  d->m_KAppDCOPInterface = new KAppDCOPInterface(this);
752 }
753 
754 TDEApplication::TDEApplication( bool allowStyles, bool GUIenabled, bool SMenabled ) :
755 // TQApplication( *TDECmdLineArgs::tqt_argc(), *TDECmdLineArgs::tqt_argv(), TRUE ), // Qt4 requires that there always be a GUI
756  TQApplication( *TDECmdLineArgs::tqt_argc(), *TDECmdLineArgs::tqt_argv(), GUIenabled, SMenabled ), // We need to be able to run command line apps
757  TDEInstance( TDECmdLineArgs::about),
758 #ifdef Q_WS_X11
759  display(0L),
760  argb_visual(false),
761 #endif
762  d (new TDEApplicationPrivate)
763 {
764  aIconPixmap.pm.icon = 0L;
765  aIconPixmap.pm.miniIcon = 0L;
766  read_app_startup_id();
767  if (!GUIenabled)
768  allowStyles = false;
769  useStyles = allowStyles;
770  setName( instanceName() );
771 
772  installSigpipeHandler();
773  parseCommandLine( );
774  init(GUIenabled);
775  d->m_KAppDCOPInterface = new KAppDCOPInterface(this);
776 }
777 
778 // FIXME
779 // FOR BINARY COMPATIBILITY ONLY
780 // REMOVE WHEN PRACTICAL!
781 TDEApplication::TDEApplication( bool allowStyles, bool GUIenabled ) :
782 // TQApplication( *TDECmdLineArgs::tqt_argc(), *TDECmdLineArgs::tqt_argv(), TRUE ), // Qt4 requires that there always be a GUI
783  TQApplication( *TDECmdLineArgs::tqt_argc(), *TDECmdLineArgs::tqt_argv(), GUIenabled ), // We need to be able to run command line apps
784  TDEInstance( TDECmdLineArgs::about),
785 #ifdef Q_WS_X11
786  display(0L),
787  argb_visual(false),
788 #endif
789  d (new TDEApplicationPrivate)
790 {
791  aIconPixmap.pm.icon = 0L;
792  aIconPixmap.pm.miniIcon = 0L;
793  read_app_startup_id();
794  if (!GUIenabled)
795  allowStyles = false;
796  useStyles = allowStyles;
797  setName( instanceName() );
798 
799  installSigpipeHandler();
800  parseCommandLine( );
801  init(GUIenabled);
802  d->m_KAppDCOPInterface = new KAppDCOPInterface(this);
803 }
804 
805 #ifdef Q_WS_X11
806 TDEApplication::TDEApplication( Display *dpy, bool allowStyles ) :
807  TQApplication( dpy, *TDECmdLineArgs::tqt_argc(), *TDECmdLineArgs::tqt_argv(),
808  getX11RGBAVisual(dpy), getX11RGBAColormap(dpy) ),
809  TDEInstance( TDECmdLineArgs::about), display(0L), d (new TDEApplicationPrivate)
810 {
811  aIconPixmap.pm.icon = 0L;
812  aIconPixmap.pm.miniIcon = 0L;
813  read_app_startup_id();
814  useStyles = allowStyles;
815  setName( instanceName() );
816  installSigpipeHandler();
817  parseCommandLine( );
818  init( true );
819  d->m_KAppDCOPInterface = new KAppDCOPInterface(this);
820 }
821 
822 TDEApplication::TDEApplication( Display *dpy, bool disable_argb, Qt::HANDLE visual, Qt::HANDLE colormap, bool allowStyles ) :
823  TQApplication( dpy, *TDECmdLineArgs::tqt_argc(), *TDECmdLineArgs::tqt_argv(),
824  disable_argb?visual:getX11RGBAVisual(dpy), disable_argb?colormap:getX11RGBAColormap(dpy) ),
825  TDEInstance( TDECmdLineArgs::about), display(0L), d (new TDEApplicationPrivate)
826 {
827  aIconPixmap.pm.icon = 0L;
828  aIconPixmap.pm.miniIcon = 0L;
829  read_app_startup_id();
830  useStyles = allowStyles;
831  if (disable_argb) argb_visual = false;
832  setName( instanceName() );
833  installSigpipeHandler();
834  parseCommandLine( );
835  init( true );
836  d->m_KAppDCOPInterface = new KAppDCOPInterface(this);
837 }
838 
839 TDEApplication::TDEApplication( Display *dpy, Qt::HANDLE visual, Qt::HANDLE colormap,
840  bool allowStyles ) :
841  TQApplication( dpy, *TDECmdLineArgs::tqt_argc(), *TDECmdLineArgs::tqt_argv(),
842  visual?visual:getX11RGBAVisual(dpy), colormap?colormap:getX11RGBAColormap(dpy) ),
843  TDEInstance( TDECmdLineArgs::about), display(0L), d (new TDEApplicationPrivate)
844 {
845  if ((visual) && (colormap))
846  getX11RGBAInformation(dpy);
847  aIconPixmap.pm.icon = 0L;
848  aIconPixmap.pm.miniIcon = 0L;
849  read_app_startup_id();
850  useStyles = allowStyles;
851  setName( instanceName() );
852  installSigpipeHandler();
853  parseCommandLine( );
854  init( true );
855  d->m_KAppDCOPInterface = new KAppDCOPInterface(this);
856 }
857 
858 TDEApplication::TDEApplication( Display *dpy, Qt::HANDLE visual, Qt::HANDLE colormap,
859  bool allowStyles, TDEInstance * _instance ) :
860  TQApplication( dpy, *TDECmdLineArgs::tqt_argc(), *TDECmdLineArgs::tqt_argv(),
861  visual?visual:getX11RGBAVisual(dpy), colormap?colormap:getX11RGBAColormap(dpy) ),
862  TDEInstance( _instance ), display(0L), d (new TDEApplicationPrivate)
863 {
864  if ((visual) && (colormap))
865  getX11RGBAInformation(dpy);
866  aIconPixmap.pm.icon = 0L;
867  aIconPixmap.pm.miniIcon = 0L;
868  read_app_startup_id();
869  useStyles = allowStyles;
870  setName( instanceName() );
871  installSigpipeHandler();
872  parseCommandLine( );
873  init( true );
874  d->m_KAppDCOPInterface = new KAppDCOPInterface(this);
875 }
876 #endif
877 
878 TDEApplication::TDEApplication( bool allowStyles, bool GUIenabled, TDEInstance* _instance ) :
879  TQApplication( *TDECmdLineArgs::tqt_argc(), *TDECmdLineArgs::tqt_argv(),
880  GUIenabled ),
881  TDEInstance( _instance ),
882 #ifdef Q_WS_X11
883  display(0L),
884 #endif
885  argb_visual(false),
886  d (new TDEApplicationPrivate)
887 {
888  aIconPixmap.pm.icon = 0L;
889  aIconPixmap.pm.miniIcon = 0L;
890  read_app_startup_id();
891  if (!GUIenabled)
892  allowStyles = false;
893  useStyles = allowStyles;
894  setName( instanceName() );
895 
896  installSigpipeHandler();
897  parseCommandLine( );
898  init(GUIenabled);
899  d->m_KAppDCOPInterface = new KAppDCOPInterface(this);
900 }
901 
902 #ifdef Q_WS_X11
903 TDEApplication::TDEApplication(Display *display, int& argc, char** argv, const TQCString& rAppName,
904  bool allowStyles, bool GUIenabled ) :
905  TQApplication( display ), TDEInstance(rAppName),
906  display(0L),
907  argb_visual(false),
908  d (new TDEApplicationPrivate())
909 {
910  aIconPixmap.pm.icon = 0L;
911  aIconPixmap.pm.miniIcon = 0L;
912  read_app_startup_id();
913  if (!GUIenabled)
914  allowStyles = false;
915  useStyles = allowStyles;
916 
917  Q_ASSERT (!rAppName.isEmpty());
918  setName(rAppName);
919 
920  installSigpipeHandler();
921  TDECmdLineArgs::initIgnore(argc, argv, rAppName.data());
922  parseCommandLine( );
923  init(GUIenabled);
924  d->m_KAppDCOPInterface = new KAppDCOPInterface(this);
925 }
926 #endif
927 
928 int TDEApplication::xioErrhandler( Display* dpy )
929 {
930  if(kapp)
931  {
932  emit shutDown();
933 #ifdef Q_WS_X11
934  d->oldXIOErrorHandler( dpy );
935 #else
936  Q_UNUSED(dpy);
937 #endif
938  }
939  exit( 1 );
940  return 0;
941 }
942 
943 int TDEApplication::xErrhandler( Display* dpy, void* err_ )
944 { // no idea how to make forward decl. for XErrorEvent
945 #ifdef Q_WS_X11
946  XErrorEvent* err = static_cast< XErrorEvent* >( err_ );
947  if(kapp)
948  {
949  // add KDE specific stuff here
950  d->oldXErrorHandler( dpy, err );
951  }
952 #endif
953  return 0;
954 }
955 
956 void TDEApplication::iceIOErrorHandler( _IceConn *conn )
957 {
958  emit shutDown();
959 
960 #ifdef Q_WS_X11
961  if ( d->oldIceIOErrorHandler != NULL )
962  (*d->oldIceIOErrorHandler)( conn );
963 #endif
964  exit( 1 );
965 }
966 
967 class KDETranslator : public TQTranslator
968 {
969 public:
970  KDETranslator(TQObject *parent) : TQTranslator(parent, "kdetranslator") {}
971  virtual TQTranslatorMessage findMessage(const char* context,
972  const char *sourceText,
973  const char* message) const
974  {
975  TQTranslatorMessage res;
976  res.setTranslation(TDEGlobal::locale()->translateQt(context, sourceText, message));
977  return res;
978  }
979 };
980 
981 void TDEApplication::init(bool GUIenabled)
982 {
983  d->guiEnabled = GUIenabled;
984  if ((getuid() != geteuid()) ||
985  (getgid() != getegid()) )
986  {
987  // man permissions are not exploitable and better than
988  // world writable directories
989  struct group *man = getgrnam("man");
990  if ( !man || man->gr_gid != getegid() ){
991  fprintf(stderr, "The TDE libraries are not designed to run with suid privileges.\n");
992  ::exit(127);
993  }
994  }
995 
996  TDEProcessController::ref();
997 
998  (void) TDEClipboardSynchronizer::self();
999 
1000  TQApplication::setDesktopSettingsAware( false );
1001 
1002  KApp = this;
1003 
1004 
1005 #ifdef Q_WS_X11 //FIXME(E)
1006  // create all required atoms in _one_ roundtrip to the X server
1007  if ( GUIenabled ) {
1008  const int max = 20;
1009  Atom* atoms[max];
1010  char* names[max];
1011  Atom atoms_return[max];
1012  int n = 0;
1013 
1014  atoms[n] = &kipcCommAtom;
1015  names[n++] = (char *) "KIPC_COMM_ATOM";
1016 
1017  atoms[n] = &atom_DesktopWindow;
1018  names[n++] = (char *) "KDE_DESKTOP_WINDOW";
1019 
1020  atoms[n] = &atom_NetSupported;
1021  names[n++] = (char *) "_NET_SUPPORTED";
1022 
1023  XInternAtoms( tqt_xdisplay(), names, n, false, atoms_return );
1024 
1025  for (int i = 0; i < n; i++ )
1026  *atoms[i] = atoms_return[i];
1027  }
1028 #endif
1029 
1030  dcopAutoRegistration();
1031  dcopClientPostInit();
1032 
1033  smw = 0;
1034 
1035  // Initial KIPC event mask.
1036 #if defined Q_WS_X11
1037  kipcEventMask = (1 << KIPC::StyleChanged) | (1 << KIPC::PaletteChanged) |
1038  (1 << KIPC::FontChanged) | (1 << KIPC::BackgroundChanged) |
1039  (1 << KIPC::ToolbarStyleChanged) | (1 << KIPC::SettingsChanged) |
1040  (1 << KIPC::ClipboardConfigChanged) | (1 << KIPC::BlockShortcuts);
1041 #endif
1042 
1043  // Trigger creation of locale.
1044  (void) TDEGlobal::locale();
1045 
1046  TDEConfig* config = TDEGlobal::config();
1047  d->actionRestrictions = config->hasGroup("KDE Action Restrictions" ) && !kde_kiosk_exception;
1048  // For brain-dead configurations where the user's local config file is not writable.
1049  // * We use kdialog to warn the user, so we better not generate warnings from
1050  // kdialog itself.
1051  // * Don't warn if we run with a read-only $HOME
1052  TQCString readOnly = getenv("TDE_HOME_READONLY");
1053  if (readOnly.isEmpty() && (tqstrcmp(name(), "kdialog") != 0))
1054  {
1055  TDEConfigGroupSaver saver(config, "KDE Action Restrictions");
1056  if (config->readBoolEntry("warn_unwritable_config",true))
1057  config->checkConfigFilesWritable(true);
1058  }
1059 
1060  if (GUIenabled)
1061  {
1062 #ifdef Q_WS_X11
1063  // this is important since we fork() to launch the help (Matthias)
1064  fcntl(ConnectionNumber(tqt_xdisplay()), F_SETFD, FD_CLOEXEC);
1065  // set up the fancy (=robust and error ignoring ) KDE xio error handlers (Matthias)
1066  d->oldXErrorHandler = XSetErrorHandler( kde_x_errhandler );
1067  d->oldXIOErrorHandler = XSetIOErrorHandler( kde_xio_errhandler );
1068 #endif
1069 
1070  connect( this, TQT_SIGNAL( aboutToQuit() ), this, TQT_SIGNAL( shutDown() ) );
1071 
1072 #ifdef Q_WS_X11 //FIXME(E)
1073  display = desktop()->x11Display();
1074 #endif
1075 
1076  {
1077  TQStringList plugins = TDEGlobal::dirs()->resourceDirs( "qtplugins" );
1078  TQStringList::Iterator it = plugins.begin();
1079  while (it != plugins.end()) {
1080  addLibraryPath( *it );
1081  ++it;
1082  }
1083 
1084  }
1085  tdedisplaySetStyle();
1086  tdedisplaySetFont();
1087 // tdedisplaySetPalette(); done by tdedisplaySetStyle
1088  propagateSettings(SETTINGS_QT);
1089 
1090  // Set default mime-source factory
1091  // XXX: This is a hack. Make our factory the default factory, but add the
1092  // previous default factory to the list of factories. Why? When the default
1093  // factory can't resolve something, it iterates in the list of factories.
1094  // But it TQWhatsThis only uses the default factory. So if there was already
1095  // a default factory (which happens when using an image library using uic),
1096  // we prefer KDE's factory and so we put that old default factory in the
1097  // list and use KDE as the default. This may speed up things as well.
1098  TQMimeSourceFactory* oldDefaultFactory = TQMimeSourceFactory::takeDefaultFactory();
1099  TQMimeSourceFactory::setDefaultFactory( mimeSourceFactory() );
1100  if ( oldDefaultFactory ) {
1101  TQMimeSourceFactory::addFactory( oldDefaultFactory );
1102  }
1103 
1104  d->checkAccelerators = new KCheckAccelerators( TQT_TQOBJECT(this) );
1105  }
1106 
1107 #ifdef Q_WS_MACX
1108  if (GUIenabled) {
1109  TQPixmap pixmap = TDEGlobal::iconLoader()->loadIcon( TDECmdLineArgs::appName(),
1110  TDEIcon::NoGroup, TDEIcon::SizeLarge, TDEIcon::DefaultState, 0L, false );
1111  if (!pixmap.isNull()) {
1112  TQImage i = pixmap.convertToImage().convertDepth(32).smoothScale(40, 40);
1113  for(int y = 0; y < i.height(); y++) {
1114  uchar *l = i.scanLine(y);
1115  for(int x = 0; x < i.width(); x+=4)
1116  *(l+x) = 255;
1117  }
1118  CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
1119  CGDataProviderRef dp = CGDataProviderCreateWithData(NULL,
1120  i.bits(), i.numBytes(), NULL);
1121  CGImageRef ir = CGImageCreate(i.width(), i.height(), 8, 32, i.bytesPerLine(),
1122  cs, kCGImageAlphaNoneSkipFirst, dp,
1123  0, 0, kCGRenderingIntentDefault);
1124  //cleanup
1125  SetApplicationDockTileImage(ir);
1126  CGImageRelease(ir);
1127  CGColorSpaceRelease(cs);
1128  CGDataProviderRelease(dp);
1129  }
1130  }
1131 #endif
1132 
1133 
1134  // save and restore the RTL setting, as installTranslator calls qt_detectRTLLanguage,
1135  // which makes it impossible to use the -reverse cmdline switch with KDE apps
1136  bool rtl = reverseLayout();
1137  installTranslator(new KDETranslator(TQT_TQOBJECT(this)));
1138  setReverseLayout( rtl );
1139  if (i18n( "_: Dear Translator! Translate this string to the string 'LTR' in "
1140  "left-to-right languages (as english) or to 'RTL' in right-to-left "
1141  "languages (such as Hebrew and Arabic) to get proper widget layout." ) == "RTL")
1142  setReverseLayout( !rtl );
1143 
1144  // install appdata resource type
1145  TDEGlobal::dirs()->addResourceType("appdata", TDEStandardDirs::kde_default("data")
1146  + TQString::fromLatin1(name()) + '/');
1147  pSessionConfig = 0L;
1148  bSessionManagement = true;
1149 
1150 #ifdef Q_WS_X11
1151  // register a communication window for desktop changes (Matthias)
1152  if (GUIenabled && kde_have_kipc )
1153  {
1154  smw = new TQWidget(0,0);
1155  long data = 1;
1156  XChangeProperty(tqt_xdisplay(), smw->winId(),
1157  atom_DesktopWindow, atom_DesktopWindow,
1158  32, PropModeReplace, (unsigned char *)&data, 1);
1159  }
1160  d->oldIceIOErrorHandler = IceSetIOErrorHandler( kde_ice_ioerrorhandler );
1161 #elif defined(Q_WS_WIN)
1162  TDEApplication_init_windows(GUIenabled);
1163 #else
1164  // FIXME(E): Implement for Qt Embedded
1165 #endif
1166 }
1167 
1168 static int my_system (const char *command) {
1169  int pid, status;
1170 
1171  pid = fork();
1172  if (pid == -1)
1173  return -1;
1174  if (pid == 0) {
1175  const char* shell = "/bin/sh";
1176  execl(shell, shell, "-c", command, (void *)0);
1177  ::_exit(127);
1178  }
1179  do {
1180  if (waitpid(pid, &status, 0) == -1) {
1181  if (errno != EINTR)
1182  return -1;
1183  } else
1184  return status;
1185  } while(1);
1186 }
1187 
1188 
1189 DCOPClient *TDEApplication::dcopClient()
1190 {
1191  if (s_DCOPClient)
1192  return s_DCOPClient;
1193 
1194  s_DCOPClient = new DCOPClient();
1195  TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs("tde");
1196  if (args && args->isSet("dcopserver"))
1197  {
1198  s_DCOPClient->setServerAddress( args->getOption("dcopserver"));
1199  }
1200  if( kapp ) {
1201  connect(s_DCOPClient, TQT_SIGNAL(attachFailed(const TQString &)),
1202  kapp, TQT_SLOT(dcopFailure(const TQString &)));
1203  connect(s_DCOPClient, TQT_SIGNAL(blockUserInput(bool) ),
1204  kapp, TQT_SLOT(dcopBlockUserInput(bool)) );
1205  }
1206  else
1207  s_dcopClientNeedsPostInit = true;
1208 
1209  DCOPClient::setMainClient( s_DCOPClient );
1210  return s_DCOPClient;
1211 }
1212 
1213 void TDEApplication::dcopClientPostInit()
1214 {
1215  if( s_dcopClientNeedsPostInit )
1216  {
1217  s_dcopClientNeedsPostInit = false;
1218  connect(s_DCOPClient, TQT_SIGNAL(blockUserInput(bool) ),
1219  TQT_SLOT(dcopBlockUserInput(bool)) );
1220  s_DCOPClient->bindToApp(); // Make sure we get events from the DCOPClient.
1221  }
1222 }
1223 
1224 void TDEApplication::dcopAutoRegistration()
1225 {
1226  if (autoDcopRegistration)
1227  {
1228  ( void ) dcopClient();
1229  if( dcopClient()->appId().isEmpty())
1230  dcopClient()->registerAs(name());
1231  }
1232 }
1233 
1234 void TDEApplication::disableAutoDcopRegistration()
1235 {
1236  autoDcopRegistration = false;
1237 }
1238 
1239 TDEConfig* TDEApplication::sessionConfig()
1240 {
1241  if (pSessionConfig)
1242  return pSessionConfig;
1243 
1244  // create an instance specific config object
1245  pSessionConfig = new TDEConfig( sessionConfigName(), false, false);
1246  return pSessionConfig;
1247 }
1248 
1249 void TDEApplication::ref()
1250 {
1251  d->refCount++;
1252  //kdDebug() << "[tdecore-tdeapplication] TDEApplication::ref() : refCount = " << d->refCount << endl;
1253 }
1254 
1255 void TDEApplication::deref()
1256 {
1257  d->refCount--;
1258  //kdDebug() << "[tdecore-tdeapplication] TDEApplication::deref() : refCount = " << d->refCount << endl;
1259  if ( d->refCount <= 0 )
1260  quit();
1261 }
1262 
1263 KSessionManaged::KSessionManaged()
1264 {
1265  sessionClients()->remove( this );
1266  sessionClients()->append( this );
1267 }
1268 
1269 KSessionManaged::~KSessionManaged()
1270 {
1271  sessionClients()->remove( this );
1272 }
1273 
1274 bool KSessionManaged::saveState(TQSessionManager&)
1275 {
1276  return true;
1277 }
1278 
1279 bool KSessionManaged::commitData(TQSessionManager&)
1280 {
1281  return true;
1282 }
1283 
1284 
1285 void TDEApplication::disableSessionManagement() {
1286  bSessionManagement = false;
1287 }
1288 
1289 void TDEApplication::enableSessionManagement() {
1290  bSessionManagement = true;
1291 #ifdef Q_WS_X11
1292  // Session management support in Qt/TDE is awfully broken.
1293  // If konqueror disables session management right after its startup,
1294  // and enables it later (preloading stuff), it won't be properly
1295  // saved on session shutdown.
1296  // I'm not actually sure why it doesn't work, but saveState()
1297  // doesn't seem to be called on session shutdown, possibly
1298  // because disabling session management after konqueror startup
1299  // disabled it somehow. Forcing saveState() here for this application
1300  // seems to fix it.
1301  if( mySmcConnection ) {
1302  SmcRequestSaveYourself( mySmcConnection, SmSaveLocal, False,
1303  SmInteractStyleAny,
1304  False, False );
1305 
1306  // flush the request
1307  IceFlush(SmcGetIceConnection(mySmcConnection));
1308  }
1309 #endif
1310 }
1311 
1312 
1313 bool TDEApplication::requestShutDown(
1314  ShutdownConfirm confirm, ShutdownType sdtype, ShutdownMode sdmode )
1315 {
1316 #ifdef Q_WS_X11
1317  TQApplication::syncX();
1318  /* use ksmserver's dcop interface if necessary */
1319  if ( confirm == ShutdownConfirmYes ||
1320  sdtype != ShutdownTypeDefault ||
1321  sdmode != ShutdownModeDefault )
1322  {
1323  TQByteArray data;
1324  TQDataStream arg(data, IO_WriteOnly);
1325  arg << (int)confirm << (int)sdtype << (int)sdmode;
1326  return dcopClient()->send( "ksmserver", "ksmserver",
1327  "logout(int,int,int)", data );
1328  }
1329 
1330  if ( mySmcConnection ) {
1331  // we already have a connection to the session manager, use it.
1332  SmcRequestSaveYourself( mySmcConnection, SmSaveBoth, True,
1333  SmInteractStyleAny,
1334  confirm == ShutdownConfirmNo, True );
1335 
1336  // flush the request
1337  IceFlush(SmcGetIceConnection(mySmcConnection));
1338  return true;
1339  }
1340 
1341  // open a temporary connection, if possible
1342 
1343  propagateSessionManager();
1344  TQCString smEnv = ::getenv("SESSION_MANAGER");
1345  if (smEnv.isEmpty())
1346  return false;
1347 
1348  if (! tmpSmcConnection) {
1349  char cerror[256];
1350  char* myId = 0;
1351  char* prevId = 0;
1352  SmcCallbacks cb;
1353  tmpSmcConnection = SmcOpenConnection( 0, 0, 1, 0,
1354  0, &cb,
1355  prevId,
1356  &myId,
1357  255,
1358  cerror );
1359  ::free( myId ); // it was allocated by C
1360  if (!tmpSmcConnection )
1361  return false;
1362  }
1363 
1364  SmcRequestSaveYourself( tmpSmcConnection, SmSaveBoth, True,
1365  SmInteractStyleAny, False, True );
1366 
1367  // flush the request
1368  IceFlush(SmcGetIceConnection(tmpSmcConnection));
1369  return true;
1370 #else
1371  // FIXME(E): Implement for Qt Embedded
1372  return false;
1373 #endif
1374 }
1375 
1376 void TDEApplication::propagateSessionManager()
1377 {
1378 #ifdef Q_WS_X11
1379  TQCString fName = TQFile::encodeName(locateLocal("socket", "KSMserver"));
1380  TQCString display = ::getenv(DISPLAY);
1381  // strip the screen number from the display
1382  display.replace(TQRegExp("\\.[0-9]+$"), "");
1383  int i;
1384  while( (i = display.find(':')) >= 0)
1385  display[i] = '_';
1386 
1387  fName += "_"+display;
1388  TQCString smEnv = ::getenv("SESSION_MANAGER");
1389  bool check = smEnv.isEmpty();
1390  if ( !check && smModificationTime ) {
1391  TQFileInfo info( fName );
1392  TQTime current = TQT_TQTIME_OBJECT(info.lastModified().time());
1393  check = current > *smModificationTime;
1394  }
1395  if ( check ) {
1396  delete smModificationTime;
1397  TQFile f( fName );
1398  if ( !f.open( IO_ReadOnly ) )
1399  return;
1400  TQFileInfo info ( f );
1401  smModificationTime = new TQTime( TQT_TQTIME_OBJECT(info.lastModified().time()) );
1402  TQTextStream t(&f);
1403  t.setEncoding( TQTextStream::Latin1 );
1404  TQString s = t.readLine();
1405  f.close();
1406  ::setenv( "SESSION_MANAGER", s.latin1(), true );
1407  }
1408 #endif
1409 }
1410 
1411 void TDEApplication::commitData( TQSessionManager& sm )
1412 {
1413  d->session_save = true;
1414  bool canceled = false;
1415  for (KSessionManaged* it = sessionClients()->first();
1416  it && !canceled;
1417  it = sessionClients()->next() ) {
1418  canceled = !it->commitData( sm );
1419  }
1420  if ( canceled )
1421  sm.cancel();
1422 
1423  if ( sm.allowsInteraction() ) {
1424  TQWidgetList done;
1425  TQWidgetList *list = TQApplication::topLevelWidgets();
1426  bool canceled = false;
1427  TQWidget* w = list->first();
1428  while ( !canceled && w ) {
1429  if ( !w->testWState( WState_ForceHide ) && !w->inherits("TDEMainWindow") ) {
1430  TQCloseEvent e;
1431  sendEvent( w, &e );
1432  canceled = !e.isAccepted();
1433  if ( !canceled )
1434  done.append( w );
1435  delete list; // one never knows...
1436  list = TQApplication::topLevelWidgets();
1437  w = list->first();
1438  } else {
1439  w = list->next();
1440  }
1441  while ( w && done.containsRef( w ) )
1442  w = list->next();
1443  }
1444  delete list;
1445  }
1446 
1447 
1448  if ( !bSessionManagement )
1449  sm.setRestartHint( TQSessionManager::RestartNever );
1450  else
1451  sm.setRestartHint( TQSessionManager::RestartIfRunning );
1452  d->session_save = false;
1453 }
1454 
1455 static void checkRestartVersion( TQSessionManager& sm )
1456 {
1457  Display* dpy = tqt_xdisplay();
1458  Atom type;
1459  int format;
1460  unsigned long nitems, after;
1461  unsigned char* data;
1462  if( XGetWindowProperty( dpy, RootWindow( dpy, 0 ), XInternAtom( dpy, "TDE_FULL_SESSION", False ),
1463  0, 1, False, AnyPropertyType, &type, &format, &nitems, &after, &data ) == Success ) {
1464  if( data != NULL )
1465  XFree( data );
1466  if( type == XA_STRING && format == 8 ) { // session set, check if TDE_SESSION_VERSION is not set (meaning KDE3)
1467  if( XGetWindowProperty( dpy, RootWindow( dpy, 0 ), XInternAtom( dpy, "TDE_SESSION_VERSION", False ),
1468  0, 1, False, AnyPropertyType, &type, &format, &nitems, &after, &data ) == Success ) {
1469  if( data != NULL )
1470  XFree( data ); // KDE4 or newer
1471  if( type == None )
1472  return; // we run in our native session, no need to wrap
1473  } else {
1474  return; // we run in our native session, no need to wrap
1475  }
1476  }
1477  }
1478  TQString wrapper = TDEStandardDirs::findExe( "trinity" );
1479  TQStringList restartCommand = sm.restartCommand();
1480  restartCommand.prepend( wrapper );
1481  sm.setRestartCommand( restartCommand );
1482 }
1483 
1484 void TDEApplication::saveState( TQSessionManager& sm )
1485 {
1486  d->session_save = true;
1487 #ifdef Q_WS_X11
1488  static bool firstTime = true;
1489  mySmcConnection = (SmcConn) sm.handle();
1490 
1491  if ( !bSessionManagement ) {
1492  sm.setRestartHint( TQSessionManager::RestartNever );
1493  d->session_save = false;
1494  return;
1495  }
1496  else
1497  sm.setRestartHint( TQSessionManager::RestartIfRunning );
1498 
1499  if ( firstTime ) {
1500  firstTime = false;
1501  d->session_save = false;
1502  return; // no need to save the state.
1503  }
1504 
1505  // remove former session config if still existing, we want a new
1506  // and fresh one. Note that we do not delete the config file here,
1507  // this is done by the session manager when it executes the
1508  // discard commands. In fact it would be harmful to remove the
1509  // file here, as the session might be stored under a different
1510  // name, meaning the user still might need it eventually.
1511  if ( pSessionConfig ) {
1512  delete pSessionConfig;
1513  pSessionConfig = 0;
1514  }
1515 
1516  // tell the session manager about our new lifecycle
1517  TQStringList restartCommand = sm.restartCommand();
1518 
1519  TQCString multiHead = getenv("TDE_MULTIHEAD");
1520  if (multiHead.lower() == "true") {
1521  // if multihead is enabled, we save our -display argument so that
1522  // we are restored onto the correct head... one problem with this
1523  // is that the display is hard coded, which means we cannot restore
1524  // to a different display (ie. if we are in a university lab and try,
1525  // try to restore a multihead session, our apps could be started on
1526  // someone else's display instead of our own)
1527  TQCString displayname = getenv(DISPLAY);
1528  if (! displayname.isNull()) {
1529  // only store the command if we actually have a DISPLAY
1530  // environment variable
1531  restartCommand.append("-display");
1532  restartCommand.append(displayname);
1533  }
1534  sm.setRestartCommand( restartCommand );
1535  }
1536 
1537  checkRestartVersion( sm );
1538 
1539  // finally: do session management
1540  emit saveYourself(); // for compatibility
1541  bool canceled = false;
1542  for (KSessionManaged* it = sessionClients()->first();
1543  it && !canceled;
1544  it = sessionClients()->next() ) {
1545  canceled = !it->saveState( sm );
1546  }
1547 
1548  // if we created a new session config object, register a proper discard command
1549  if ( pSessionConfig ) {
1550  pSessionConfig->sync();
1551  TQStringList discard;
1552  discard << "rm" << locateLocal("config", sessionConfigName());
1553  sm.setDiscardCommand( discard );
1554  } else {
1555  sm.setDiscardCommand( TQStringList("") );
1556  }
1557 
1558  if ( canceled )
1559  sm.cancel();
1560 #else
1561  // FIXME(E): Implement for Qt Embedded
1562 #endif
1563  d->session_save = false;
1564 }
1565 
1566 bool TDEApplication::sessionSaving() const
1567 {
1568  return d->session_save;
1569 }
1570 
1571 void TDEApplication::startKdeinit()
1572 {
1573 #ifndef Q_WS_WIN //TODO
1574  TDEInstance inst( "starttdeinitlock" );
1575  TDELockFile lock( locateLocal( "tmp", "starttdeinitlock", &inst ));
1576  if( lock.lock( TDELockFile::LockNoBlock ) != TDELockFile::LockOK ) {
1577  lock.lock();
1578  DCOPClient cl;
1579  if( cl.attach())
1580  return; // whoever held the lock has already started dcopserver
1581  }
1582  // Try to launch tdeinit.
1583  TQString srv = TDEStandardDirs::findExe(TQString::fromLatin1("tdeinit"));
1584  if (srv.isEmpty())
1585  srv = TDEStandardDirs::findExe(TQString::fromLatin1("tdeinit"), TDEGlobal::dirs()->kfsstnd_defaultbindir());
1586  if (srv.isEmpty())
1587  return;
1588  if (kapp && (Tty != kapp->type()))
1589  setOverrideCursor( tqwaitCursor );
1590  my_system(TQFile::encodeName(srv)+" --suicide"+" --new-startup");
1591  if (kapp && (Tty != kapp->type()))
1592  restoreOverrideCursor();
1593 #endif
1594 }
1595 
1596 void TDEApplication::dcopFailure(const TQString &msg)
1597 {
1598  static int failureCount = 0;
1599  failureCount++;
1600  if (failureCount == 1)
1601  {
1602  startKdeinit();
1603  return;
1604  }
1605  if (failureCount == 2)
1606  {
1607 #ifdef Q_WS_WIN
1608  TDEGlobal::config()->setGroup("General");
1609  if (TDEGlobal::config()->readBoolEntry("ignoreDCOPFailures", false))
1610  return;
1611 #endif
1612  TQString msgStr(i18n("There was an error setting up inter-process "
1613  "communications for TDE. The message returned "
1614  "by the system was:\n\n"));
1615  msgStr += msg;
1616  msgStr += i18n("\n\nPlease check that the \"dcopserver\" program is running!");
1617 
1618  if (Tty != kapp->type())
1619  {
1620  TQMessageBox::critical
1621  (
1622  kapp->mainWidget(),
1623  i18n("DCOP communications error (%1)").arg(kapp->caption()),
1624  msgStr,
1625  i18n("&OK")
1626  );
1627  }
1628  else
1629  {
1630  fprintf(stderr, "%s\n", msgStr.local8Bit().data());
1631  }
1632 
1633  return;
1634  }
1635 }
1636 
1637 static const TDECmdLineOptions qt_options[] =
1638 {
1639  //FIXME: Check if other options are specific to Qt/X11
1640 #ifdef Q_WS_X11
1641  { "display <displayname>", I18N_NOOP("Use the X-server display 'displayname'"), 0},
1642 #else
1643  { "display <displayname>", I18N_NOOP("Use the QWS display 'displayname'"), 0},
1644 #endif
1645  { "session <sessionId>", I18N_NOOP("Restore the application for the given 'sessionId'"), 0},
1646  { "cmap", I18N_NOOP("Causes the application to install a private color\nmap on an 8-bit display"), 0},
1647  { "ncols <count>", I18N_NOOP("Limits the number of colors allocated in the color\ncube on an 8-bit display, if the application is\nusing the TQApplication::ManyColor color\nspecification"), 0},
1648  { "nograb", I18N_NOOP("tells TQt to never grab the mouse or the keyboard"), 0},
1649  { "dograb", I18N_NOOP("running under a debugger can cause an implicit\n-nograb, use -dograb to override"), 0},
1650  { "sync", I18N_NOOP("switches to synchronous mode for debugging"), 0},
1651  { "fn", 0, 0},
1652  { "font <fontname>", I18N_NOOP("defines the application font"), 0},
1653  { "bg", 0, 0},
1654  { "background <color>", I18N_NOOP("sets the default background color and an\napplication palette (light and dark shades are\ncalculated)"), 0},
1655  { "fg", 0, 0},
1656  { "foreground <color>", I18N_NOOP("sets the default foreground color"), 0},
1657  { "btn", 0, 0},
1658  { "button <color>", I18N_NOOP("sets the default button color"), 0},
1659  { "name <name>", I18N_NOOP("sets the application name"), 0},
1660  { "title <title>", I18N_NOOP("sets the application title (caption)"), 0},
1661 #ifdef Q_WS_X11
1662  { "visual TrueColor", I18N_NOOP("forces the application to use a TrueColor visual on\nan 8-bit display"), 0},
1663  { "inputstyle <inputstyle>", I18N_NOOP("sets XIM (X Input Method) input style. Possible\nvalues are onthespot, overthespot, offthespot and\nroot"), 0 },
1664  { "im <XIM server>", I18N_NOOP("set XIM server"),0},
1665  { "noxim", I18N_NOOP("disable XIM"), 0 },
1666 #endif
1667 #ifdef Q_WS_QWS
1668  { "qws", I18N_NOOP("forces the application to run as QWS Server"), 0},
1669 #endif
1670  { "reverse", I18N_NOOP("mirrors the whole layout of widgets"), 0},
1671  TDECmdLineLastOption
1672 };
1673 
1674 static const TDECmdLineOptions kde_options[] =
1675 {
1676  { "caption <caption>", I18N_NOOP("Use 'caption' as name in the titlebar"), 0},
1677  { "icon <icon>", I18N_NOOP("Use 'icon' as the application icon"), 0},
1678  { "miniicon <icon>", I18N_NOOP("Use 'icon' as the icon in the titlebar"), 0},
1679  { "config <filename>", I18N_NOOP("Use alternative configuration file"), 0},
1680  { "dcopserver <server>", I18N_NOOP("Use the DCOP Server specified by 'server'"), 0},
1681  { "nocrashhandler", I18N_NOOP("Disable crash handler, to get core dumps"), 0},
1682  { "waitforwm", I18N_NOOP("Waits for a WM_NET compatible windowmanager"), 0},
1683  { "style <style>", I18N_NOOP("sets the application GUI style"), 0},
1684  { "geometry <geometry>", I18N_NOOP("sets the client geometry of the main widget - see man X for the argument format"), 0},
1685  { "smkey <sessionKey>", 0, 0}, // this option is obsolete and exists only to allow smooth upgrades from sessions
1686  // saved under Qt 3.0.x -- Qt 3.1.x includes the session key now automatically in
1687  // the session id (Simon)
1688  TDECmdLineLastOption
1689 };
1690 
1691 void
1692 TDEApplication::addCmdLineOptions()
1693 {
1694  TDECmdLineArgs::addCmdLineOptions(qt_options, "Qt", "qt");
1695  TDECmdLineArgs::addCmdLineOptions(kde_options, "TDE", "tde");
1696 }
1697 
1698 void TDEApplication::parseCommandLine( )
1699 {
1700  TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs("tde");
1701 
1702  if ( !args ) return;
1703 
1704  if (args->isSet("config"))
1705  {
1706  TQString config = TQString::fromLocal8Bit(args->getOption("config"));
1707  setConfigName(config);
1708  }
1709 
1710  if (args->isSet("style"))
1711  {
1712 
1713  TQStringList plugins = TDEGlobal::dirs()->resourceDirs( "qtplugins" );
1714  TQStringList::Iterator itp = plugins.begin();
1715  while (itp != plugins.end()) {
1716  addLibraryPath( *itp );
1717  ++itp;
1718  }
1719 
1720  TQStringList styles = TQStyleFactory::keys();
1721  TQString reqStyle(args->getOption("style").lower());
1722 
1723  TQStringList list = libraryPaths();
1724  TQStringList::Iterator it = list.begin();
1725  while( it != list.end() ) {
1726  ++it;
1727  }
1728 
1729  for (TQStringList::ConstIterator it = styles.begin(); it != styles.end(); ++it) {
1730  if ((*it).lower() == reqStyle)
1731  {
1732  d->overrideStyle = *it;
1733  break;
1734  }
1735  }
1736 
1737  if (d->overrideStyle.isEmpty())
1738  fprintf(stderr, "%s", TQString(i18n("The style %1 was not found\n").arg(reqStyle)).local8Bit().data());
1739  }
1740 
1741  if (args->isSet("caption"))
1742  {
1743  aCaption = TQString::fromLocal8Bit(args->getOption("caption"));
1744  }
1745 
1746  if (args->isSet("miniicon"))
1747  {
1748  const char *tmp = args->getOption("miniicon");
1749  if (!aIconPixmap.pm.miniIcon) {
1750  aIconPixmap.pm.miniIcon = new TQPixmap;
1751  }
1752  *aIconPixmap.pm.miniIcon = SmallIcon(tmp);
1753  aMiniIconName = tmp;
1754  }
1755 
1756  if (args->isSet("icon"))
1757  {
1758  const char *tmp = args->getOption("icon");
1759  if (!aIconPixmap.pm.icon) {
1760  aIconPixmap.pm.icon = new TQPixmap;
1761  }
1762  *aIconPixmap.pm.icon = DesktopIcon( tmp );
1763  aIconName = tmp;
1764  if (!aIconPixmap.pm.miniIcon) {
1765  aIconPixmap.pm.miniIcon = new TQPixmap;
1766  }
1767  if (aIconPixmap.pm.miniIcon->isNull())
1768  {
1769  *aIconPixmap.pm.miniIcon = SmallIcon( tmp );
1770  aMiniIconName = tmp;
1771  }
1772  }
1773 
1774  bool nocrashhandler = (getenv("TDE_DEBUG") != NULL);
1775  if (!nocrashhandler && args->isSet("crashhandler"))
1776  {
1777  // set default crash handler / set emergency save function to nothing
1778  TDECrash::setCrashHandler(TDECrash::defaultCrashHandler);
1779  TDECrash::setEmergencySaveFunction(NULL);
1780 
1781  TDECrash::setApplicationName(TQString(args->appName()));
1782  }
1783 
1784 #ifdef Q_WS_X11
1785  if ( args->isSet( "waitforwm" ) ) {
1786  Atom type;
1787  (void) desktop(); // trigger desktop creation, we need PropertyNotify events for the root window
1788  int format;
1789  unsigned long length, after;
1790  unsigned char *data;
1791  while ( XGetWindowProperty( tqt_xdisplay(), tqt_xrootwin(), atom_NetSupported,
1792  0, 1, false, AnyPropertyType, &type, &format,
1793  &length, &after, &data ) != Success || !length ) {
1794  if ( data )
1795  XFree( data );
1796  XEvent event;
1797  XWindowEvent( tqt_xdisplay(), tqt_xrootwin(), PropertyChangeMask, &event );
1798  }
1799  if ( data )
1800  XFree( data );
1801  }
1802 #else
1803  // FIXME(E): Implement for Qt Embedded
1804 #endif
1805 
1806  if (args->isSet("geometry"))
1807  {
1808  d->geometry_arg = args->getOption("geometry");
1809  }
1810 
1811  if (args->isSet("smkey"))
1812  {
1813  d->sessionKey = args->getOption("smkey");
1814  }
1815 
1816 }
1817 
1818 TQString TDEApplication::geometryArgument() const
1819 {
1820  return d->geometry_arg;
1821 }
1822 
1823 TQPixmap TDEApplication::icon() const
1824 {
1825  if( !aIconPixmap.pm.icon) {
1826  aIconPixmap.pm.icon = new TQPixmap;
1827  }
1828  if( aIconPixmap.pm.icon->isNull()) {
1829  *aIconPixmap.pm.icon = DesktopIcon( instanceName() );
1830  }
1831  return *aIconPixmap.pm.icon;
1832 }
1833 
1834 TQString TDEApplication::iconName() const
1835 {
1836  return aIconName.isNull() ? (TQString)instanceName() : aIconName;
1837 }
1838 
1839 TQPixmap TDEApplication::miniIcon() const
1840 {
1841  if (!aIconPixmap.pm.miniIcon) {
1842  aIconPixmap.pm.miniIcon = new TQPixmap;
1843  }
1844  if (aIconPixmap.pm.miniIcon->isNull()) {
1845  *aIconPixmap.pm.miniIcon = SmallIcon( instanceName() );
1846  }
1847  return *aIconPixmap.pm.miniIcon;
1848 }
1849 
1850 TQString TDEApplication::miniIconName() const
1851 {
1852  return aMiniIconName.isNull() ? (TQString)instanceName() : aMiniIconName;
1853 }
1854 
1855 extern void kDebugCleanup();
1856 
1857 TDEApplication::~TDEApplication()
1858 {
1859  delete aIconPixmap.pm.miniIcon;
1860  aIconPixmap.pm.miniIcon = 0L;
1861  delete aIconPixmap.pm.icon;
1862  aIconPixmap.pm.icon = 0L;
1863  delete d->m_KAppDCOPInterface;
1864 
1865  // First call the static deleters and then call KLibLoader::cleanup()
1866  // The static deleters may delete libraries for which they need KLibLoader.
1867  // KLibLoader will take care of the remaining ones.
1868  TDEGlobal::deleteStaticDeleters();
1869  KLibLoader::cleanUp();
1870 
1871  delete smw;
1872 
1873  // close down IPC
1874  delete s_DCOPClient;
1875  s_DCOPClient = 0L;
1876 
1877  TDEProcessController::deref();
1878 
1879 #ifdef Q_WS_X11
1880  if ( d->oldXErrorHandler != NULL )
1881  XSetErrorHandler( d->oldXErrorHandler );
1882  if ( d->oldXIOErrorHandler != NULL )
1883  XSetIOErrorHandler( d->oldXIOErrorHandler );
1884  if ( d->oldIceIOErrorHandler != NULL )
1885  IceSetIOErrorHandler( d->oldIceIOErrorHandler );
1886 #endif
1887 
1888  delete d;
1889  KApp = 0;
1890 
1891 #ifdef Q_WS_X11
1892  mySmcConnection = 0;
1893  delete smModificationTime;
1894  smModificationTime = 0;
1895 
1896  // close the temporary smc connection
1897  if (tmpSmcConnection) {
1898  SmcCloseConnection( tmpSmcConnection, 0, 0 );
1899  tmpSmcConnection = 0;
1900  }
1901 #else
1902  // FIXME(E): Implement for Qt Embedded
1903 #endif
1904 }
1905 
1906 
1907 #ifdef Q_WS_X11
1908 class KAppX11HackWidget: public TQWidget
1909 {
1910 public:
1911  bool publicx11Event( XEvent * e) { return x11Event( e ); }
1912 };
1913 #endif
1914 
1915 #if defined(Q_WS_X11) && defined(COMPOSITE)
1916 bool TDEApplication::isCompositionManagerAvailable() {
1917  bool have_manager = false;
1918 
1919  char *filename;
1920  const char *pidfile = "compton-tde.available";
1921  char uidstr[sizeof(uid_t)*8+1];
1922  sprintf(uidstr, "%d", getuid());
1923  int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
1924  filename = (char*)malloc(n*sizeof(char)+1);
1925  memset(filename,0,n);
1926  strcat(filename, P_tmpdir);
1927  strcat(filename, "/.");
1928  strcat(filename, uidstr);
1929  strcat(filename, "-");
1930  strcat(filename, pidfile);
1931 
1932  // Now that we did all that by way of introduction...read the file!
1933  FILE *pFile;
1934  pFile = fopen(filename, "r");
1935  if (pFile) {
1936  have_manager = true;
1937  fclose(pFile);
1938  }
1939 
1940  free(filename);
1941  filename = NULL;
1942 
1943  return have_manager;
1944 }
1945 
1946 bool TDEApplication::detectCompositionManagerAvailable(bool force_available, bool available) {
1947  bool compositing_manager_available;
1948  if (force_available) {
1949  compositing_manager_available = available;
1950  }
1951  else {
1952  // See if compositing has been enabled
1953  TDECmdLineArgs *qtargs = TDECmdLineArgs::parsedArgs("qt");
1954  char *displayname = 0;
1955  if ( qtargs->isSet("display"))
1956  displayname = qtargs->getOption( "display" ).data();
1957 
1958  Display *dpy = XOpenDisplay( displayname );
1959 
1960  x11_composite_error_generated = false;
1961  compositing_manager_available = false;
1962  XSetErrorHandler(x11_error);
1963  if (!XQueryExtension (dpy, COMPOSITE_NAME, &composite_opcode, &composite_event, &composite_error)) {
1964  XSetErrorHandler(NULL);
1965  compositing_manager_available = false;
1966  }
1967  else {
1968  if (available) { // FIXME This variable does double duty to avoid breaking the ABI for R14.0. In reality it should be called perform_deep_check
1969  Window root_window = XDefaultRootWindow(dpy);
1970  XCompositeRedirectSubwindows(dpy, root_window, CompositeRedirectManual);
1971  XSync(dpy, false);
1972  if (x11_composite_error_generated == true) {
1973  compositing_manager_available = true;
1974  }
1975  else {
1976  XCompositeUnredirectSubwindows(dpy, root_window, CompositeRedirectManual);
1977  compositing_manager_available = false;
1978  }
1979  XSetErrorHandler(NULL);
1980  XCloseDisplay(dpy);
1981  }
1982  else {
1983  compositing_manager_available = true;
1984  }
1985  }
1986  }
1987 
1988  char *filename;
1989  const char *pidfile = "compton-tde.available";
1990  char uidstr[sizeof(uid_t)*8+1];
1991  sprintf(uidstr, "%d", getuid());
1992  int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
1993  filename = (char*)malloc(n*sizeof(char)+1);
1994  memset(filename,0,n);
1995  strcat(filename, P_tmpdir);
1996  strcat(filename, "/.");
1997  strcat(filename, uidstr);
1998  strcat(filename, "-");
1999  strcat(filename, pidfile);
2000 
2001  /* now that we did all that by way of introduction...create or remove the file! */
2002  if (compositing_manager_available) {
2003  FILE *pFile;
2004  char buffer[255];
2005  sprintf(buffer, "available");
2006  pFile = fopen(filename, "w");
2007  if (pFile) {
2008  fwrite(buffer,1,strlen(buffer), pFile);
2009  fclose(pFile);
2010  }
2011  }
2012  else {
2013  unlink(filename);
2014  }
2015 
2016  free(filename);
2017  filename = NULL;
2018 
2019  return compositing_manager_available;
2020 }
2021 
2022 Display* TDEApplication::openX11RGBADisplay() {
2023  TDECmdLineArgs *qtargs = TDECmdLineArgs::parsedArgs("qt");
2024  char *display = 0;
2025  if ( qtargs->isSet("display"))
2026  display = qtargs->getOption( "display" ).data();
2027 
2028  Display *dpy = XOpenDisplay( display );
2029  if ( !dpy ) {
2030  kdError() << "cannot connect to X server " << display << endl;
2031  exit( 1 );
2032  }
2033 
2034  return dpy;
2035 }
2036 
2037 Qt::HANDLE TDEApplication::getX11RGBAVisual(Display *dpy) {
2038  getX11RGBAInformation(dpy);
2039  if (TDEApplication::isCompositionManagerAvailable() == true) {
2040  return argb_x11_visual;
2041  }
2042  else {
2043  return (Qt::HANDLE)NULL;
2044  }
2045 }
2046 
2047 Qt::HANDLE TDEApplication::getX11RGBAColormap(Display *dpy) {
2048  getX11RGBAInformation(dpy);
2049  if (TDEApplication::isCompositionManagerAvailable() == true) {
2050  return argb_x11_colormap;
2051  }
2052  else {
2053  return (Qt::HANDLE)NULL;
2054  }
2055 }
2056 
2057 bool TDEApplication::isX11CompositionAvailable() {
2058  return (argb_visual & isCompositionManagerAvailable());
2059 }
2060 
2061 void TDEApplication::getX11RGBAInformation(Display *dpy) {
2062  if ( !dpy ) {
2063  argb_visual = false;
2064  return;
2065  }
2066 
2067  int screen = DefaultScreen( dpy );
2068  Colormap colormap = 0;
2069  Visual *visual = 0;
2070  int event_base, error_base;
2071 
2072  if ( XRenderQueryExtension( dpy, &event_base, &error_base ) ) {
2073  int nvi;
2074  XVisualInfo templ;
2075  templ.screen = screen;
2076  templ.depth = 32;
2077  templ.c_class = TrueColor;
2078  XVisualInfo *xvi = XGetVisualInfo( dpy, VisualScreenMask | VisualDepthMask
2079  | VisualClassMask, &templ, &nvi );
2080 
2081  for ( int i = 0; i < nvi; i++ ) {
2082  XRenderPictFormat *format = XRenderFindVisualFormat( dpy, xvi[i].visual );
2083  if ( format->type == PictTypeDirect && format->direct.alphaMask ) {
2084  visual = xvi[i].visual;
2085  colormap = XCreateColormap( dpy, RootWindow( dpy, screen ), visual, AllocNone );
2086  kdDebug() << "[tdecore-tdeapplication] Found visual with alpha support" << endl;
2087  argb_visual = true;
2088  break;
2089  }
2090  }
2091  }
2092 
2093  if( argb_visual ) {
2094  argb_x11_visual = Qt::HANDLE( visual );
2095  argb_x11_colormap = Qt::HANDLE( colormap );
2096  argb_visual = true;
2097  return;
2098  }
2099  argb_visual = false;
2100  return;
2101 }
2102 #else
2103 void TDEApplication::getX11RGBAInformation(Display *dpy) {
2104 }
2105 
2106 bool TDEApplication::isCompositionManagerAvailable() {
2107  return false;
2108 }
2109 
2110 bool TDEApplication::detectCompositionManagerAvailable(bool force_available, bool available) {
2111  char *filename;
2112  const char *pidfile = "compton-tde.available";
2113  char uidstr[sizeof(uid_t)*8+1];
2114  sprintf(uidstr, "%d", getuid());
2115  int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
2116  filename = (char*)malloc(n*sizeof(char)+1);
2117  memset(filename,0,n);
2118  strcat(filename, P_tmpdir);
2119  strcat(filename, "/.");
2120  strcat(filename, uidstr);
2121  strcat(filename, "-");
2122  strcat(filename, pidfile);
2123 
2124  /* now that we did all that by way of introduction...create or remove the file! */
2125  if (force_available) {
2126  FILE *pFile;
2127  char buffer[255];
2128  sprintf(buffer, "available");
2129  pFile = fopen(filename, "w");
2130  if (pFile) {
2131  fwrite(buffer,1,strlen(buffer), pFile);
2132  fclose(pFile);
2133  }
2134  }
2135  else {
2136  unlink(filename);
2137  }
2138 
2139  free(filename);
2140  filename = NULL;
2141 
2142  return false;
2143 }
2144 
2145 Display* TDEApplication::openX11RGBADisplay() {
2146  return 0;
2147 }
2148 
2149 Qt::HANDLE TDEApplication::getX11RGBAVisual(Display *dpy) {
2150  return 0;
2151 }
2152 
2153 Qt::HANDLE TDEApplication::getX11RGBAColormap(Display *dpy) {
2154  return 0;
2155 }
2156 
2157 bool TDEApplication::isX11CompositionAvailable() {
2158  return false;
2159 }
2160 #endif
2161 
2162 static bool kapp_block_user_input = false;
2163 
2164 void TDEApplication::dcopBlockUserInput( bool b )
2165 {
2166  kapp_block_user_input = b;
2167 }
2168 
2169 #ifdef Q_WS_X11
2170 bool TDEApplication::x11EventFilter( XEvent *_event )
2171 {
2172  if ( kapp_block_user_input ) {
2173  switch ( _event->type ) {
2174  case ButtonPress:
2175  case ButtonRelease:
2176  case XKeyPress:
2177  case XKeyRelease:
2178  case MotionNotify:
2179  case EnterNotify:
2180  case LeaveNotify:
2181  return true;
2182  default:
2183  break;
2184  }
2185  }
2186 
2187  if (x11Filter) {
2188  for (TQWidget *w=x11Filter->first(); w; w=x11Filter->next()) {
2189  if (((KAppX11HackWidget*) w)->publicx11Event(_event))
2190  return true;
2191  }
2192  }
2193 
2194  if ((_event->type == ClientMessage) &&
2195  (_event->xclient.message_type == kipcCommAtom))
2196  {
2197  XClientMessageEvent *cme = (XClientMessageEvent *) _event;
2198 
2199  int id = cme->data.l[0];
2200  int arg = cme->data.l[1];
2201  if ((id < 32) && (kipcEventMask & (1 << id)))
2202  {
2203  switch (id)
2204  {
2205  case KIPC::StyleChanged:
2206  TDEGlobal::config()->reparseConfiguration();
2207  tdedisplaySetStyle();
2208  break;
2209 
2210  case KIPC::ToolbarStyleChanged:
2211  TDEGlobal::config()->reparseConfiguration();
2212  if (useStyles)
2213  emit toolbarAppearanceChanged(arg);
2214  break;
2215 
2216  case KIPC::PaletteChanged:
2217  TDEGlobal::config()->reparseConfiguration();
2218  tdedisplaySetPalette();
2219  break;
2220 
2221  case KIPC::FontChanged:
2222  TDEGlobal::config()->reparseConfiguration();
2223  TDEGlobalSettings::rereadFontSettings();
2224  tdedisplaySetFont();
2225  break;
2226 
2227  case KIPC::BackgroundChanged:
2228  emit backgroundChanged(arg);
2229  break;
2230 
2231  case KIPC::SettingsChanged:
2232  TDEGlobal::config()->reparseConfiguration();
2233  if (arg == SETTINGS_PATHS)
2234  TDEGlobalSettings::rereadPathSettings();
2235  else if (arg == SETTINGS_MOUSE)
2236  TDEGlobalSettings::rereadMouseSettings();
2237  propagateSettings((SettingsCategory)arg);
2238  break;
2239 
2240  case KIPC::IconChanged:
2241  TQPixmapCache::clear();
2242  TDEGlobal::config()->reparseConfiguration();
2243  TDEGlobal::instance()->newIconLoader();
2244  emit updateIconLoaders();
2245  emit iconChanged(arg);
2246  break;
2247 
2248  case KIPC::ClipboardConfigChanged:
2249  TDEClipboardSynchronizer::newConfiguration(arg);
2250  break;
2251 
2252  case KIPC::BlockShortcuts:
2253  TDEGlobalAccel::blockShortcuts(arg);
2254  emit kipcMessage(id, arg); // some apps may do additional things
2255  break;
2256  }
2257  }
2258  else if (id >= 32)
2259  {
2260  emit kipcMessage(id, arg);
2261  }
2262  return true;
2263  }
2264  return false;
2265 }
2266 #endif // Q_WS_X11
2267 
2268 void TDEApplication::updateUserTimestamp( unsigned long time )
2269 {
2270 #if defined Q_WS_X11
2271  Display *display = tqt_xdisplay();
2272  if (!display) {
2273  return;
2274  }
2275  if( time == 0 )
2276  { // get current X timestamp
2277  Window w = XCreateSimpleWindow( display, tqt_xrootwin(), 0, 0, 1, 1, 0, 0, 0 );
2278  XSelectInput( tqt_xdisplay(), w, PropertyChangeMask );
2279  unsigned char data[ 1 ];
2280  XChangeProperty( display, w, XA_ATOM, XA_ATOM, 8, PropModeAppend, data, 1 );
2281  XEvent ev;
2282  XWindowEvent( display, w, PropertyChangeMask, &ev );
2283  time = ev.xproperty.time;
2284  XDestroyWindow( display, w );
2285  }
2286  if( GET_QT_X_USER_TIME() == 0
2287  || NET::timestampCompare( time, GET_QT_X_USER_TIME() ) > 0 ) // check time > tqt_x_user_time
2288  SET_QT_X_USER_TIME(time);
2289 #endif
2290 }
2291 
2292 unsigned long TDEApplication::userTimestamp() const
2293 {
2294 #if defined Q_WS_X11
2295  return GET_QT_X_USER_TIME();
2296 #else
2297  return 0;
2298 #endif
2299 }
2300 
2301 void TDEApplication::updateRemoteUserTimestamp( const TQCString& dcopId, unsigned long time )
2302 {
2303 #if defined Q_WS_X11
2304  if( time == 0 )
2305  time = GET_QT_X_USER_TIME();
2306  DCOPRef( dcopId, "MainApplication-Interface" ).call( "updateUserTimestamp", time );
2307 #endif
2308 }
2309 
2310 void TDEApplication::invokeEditSlot( const char *slot )
2311 {
2312  TQObject *object = TQT_TQOBJECT(focusWidget());
2313  if( !object )
2314  return;
2315 
2316  TQMetaObject *meta = object->metaObject();
2317 
2318  int idx = meta->findSlot( slot + 1, true );
2319  if( idx < 0 )
2320  return;
2321 
2322  object->tqt_invoke( idx, 0 );
2323 }
2324 
2325 void TDEApplication::addKipcEventMask(int id)
2326 {
2327  if (id >= 32)
2328  {
2329  kdDebug(101) << "[tdecore-tdeapplication] Cannot use KIPC event mask for message IDs >= 32\n";
2330  return;
2331  }
2332  kipcEventMask |= (1 << id);
2333 }
2334 
2335 void TDEApplication::removeKipcEventMask(int id)
2336 {
2337  if (id >= 32)
2338  {
2339  kdDebug(101) << "[tdecore-tdeapplication] Cannot use KIPC event mask for message IDs >= 32\n";
2340  return;
2341  }
2342  kipcEventMask &= ~(1 << id);
2343 }
2344 
2345 void TDEApplication::enableStyles()
2346 {
2347  if (!useStyles)
2348  {
2349  useStyles = true;
2350  applyGUIStyle();
2351  }
2352 }
2353 
2354 void TDEApplication::disableStyles()
2355 {
2356  useStyles = false;
2357 }
2358 
2359 void TDEApplication::applyGUIStyle()
2360 {
2361  if ( !useStyles ) return;
2362 
2363  TDEConfigGroup pConfig (TDEGlobal::config(), "General");
2364  TQString defaultStyle = TDEStyle::defaultStyle();
2365  TQString styleStr = pConfig.readEntry("widgetStyle", defaultStyle);
2366 
2367  if (d->overrideStyle.isEmpty()) {
2368  // ### add check whether we already use the correct style to return then
2369  // (workaround for Qt misbehavior to avoid double style initialization)
2370 
2371  TQStyle* sp = TQStyleFactory::create( styleStr );
2372 
2373  // If there is no default style available, try falling back any available style
2374  if ( !sp && styleStr != defaultStyle)
2375  sp = TQStyleFactory::create( defaultStyle );
2376  if ( !sp )
2377  sp = TQStyleFactory::create( *(TQStyleFactory::keys().begin()) );
2378  setStyle(sp);
2379  }
2380  else
2381  setStyle(d->overrideStyle);
2382  // Reread palette from config file.
2383  tdedisplaySetPalette();
2384 }
2385 
2386 TQString TDEApplication::caption() const
2387 {
2388  // Caption set from command line ?
2389  if( !aCaption.isNull() )
2390  return aCaption;
2391  else
2392  // We have some about data ?
2393  if ( TDEGlobal::instance()->aboutData() )
2394  return TDEGlobal::instance()->aboutData()->programName();
2395  else
2396  // Last resort : application name
2397  return name();
2398 }
2399 
2400 
2401 //
2402 // 1999-09-20: Espen Sand
2403 // An attempt to simplify consistent captions.
2404 //
2405 TQString TDEApplication::makeStdCaption( const TQString &userCaption,
2406  bool withAppName, bool modified ) const
2407 {
2408  TQString s = userCaption.isEmpty() ? caption() : userCaption;
2409 
2410  // If the document is modified, add '[modified]'.
2411  if (modified)
2412  s += TQString::fromUtf8(" [") + i18n("modified") + TQString::fromUtf8("]");
2413 
2414  if ( !userCaption.isEmpty() ) {
2415  // Add the application name if:
2416  // User asked for it, it's not a duplication and the app name (caption()) is not empty
2417  if ( withAppName && !caption().isNull() && !userCaption.endsWith(caption()) )
2418  s += TQString::fromUtf8(" - ") + caption();
2419  }
2420 
2421  return s;
2422 }
2423 
2424 TQPalette TDEApplication::createApplicationPalette()
2425 {
2426  TDEConfig *config = TDEGlobal::config();
2427  TDEConfigGroupSaver saver( config, "General" );
2428  return createApplicationPalette( config, TDEGlobalSettings::contrast() );
2429 }
2430 
2431 TQPalette TDEApplication::createApplicationPalette( TDEConfig *config, int contrast_ )
2432 {
2433  TQColor trinity4Background( 239, 239, 239 );
2434  TQColor trinity4Blue( 103,141,178 );
2435 
2436  TQColor trinity4Button;
2437  if ( TQPixmap::defaultDepth() > 8 )
2438  trinity4Button.setRgb( 221, 223, 228 );
2439  else
2440  trinity4Button.setRgb( 220, 220, 220 );
2441 
2442  TQColor trinity4Link( 0, 0, 238 );
2443  TQColor trinity4VisitedLink( 82, 24, 139 );
2444 
2445  TQColor background = config->readColorEntry( "background", &trinity4Background );
2446  TQColor foreground = config->readColorEntry( "foreground", tqblackptr );
2447  TQColor button = config->readColorEntry( "buttonBackground", &trinity4Button );
2448  TQColor buttonText = config->readColorEntry( "buttonForeground", tqblackptr );
2449  TQColor highlight = config->readColorEntry( "selectBackground", &trinity4Blue );
2450  TQColor highlightedText = config->readColorEntry( "selectForeground", tqwhiteptr );
2451  TQColor base = config->readColorEntry( "windowBackground", tqwhiteptr );
2452  TQColor baseText = config->readColorEntry( "windowForeground", tqblackptr );
2453  TQColor link = config->readColorEntry( "linkColor", &trinity4Link );
2454  TQColor visitedLink = config->readColorEntry( "visitedLinkColor", &trinity4VisitedLink );
2455 
2456  int highlightVal, lowlightVal;
2457  highlightVal = 100 + (2*contrast_+4)*16/10;
2458  lowlightVal = 100 + (2*contrast_+4)*10;
2459 
2460  TQColor disfg = foreground;
2461 
2462  int h, s, v;
2463  disfg.hsv( &h, &s, &v );
2464  if (v > 128)
2465  // dark bg, light fg - need a darker disabled fg
2466  disfg = disfg.dark(lowlightVal);
2467  else if (disfg != Qt::black)
2468  // light bg, dark fg - need a lighter disabled fg - but only if !black
2469  disfg = disfg.light(highlightVal);
2470  else
2471  // black fg - use darkgray disabled fg
2472  disfg = Qt::darkGray;
2473 
2474 
2475  TQColorGroup disabledgrp(disfg, background,
2476  background.light(highlightVal),
2477  background.dark(lowlightVal),
2478  background.dark(120),
2479  background.dark(120), base);
2480 
2481  TQColorGroup colgrp(foreground, background, background.light(highlightVal),
2482  background.dark(lowlightVal),
2483  background.dark(120),
2484  baseText, base);
2485 
2486  int inlowlightVal = lowlightVal-25;
2487  if(inlowlightVal < 120)
2488  inlowlightVal = 120;
2489 
2490  colgrp.setColor(TQColorGroup::Highlight, highlight);
2491  colgrp.setColor(TQColorGroup::HighlightedText, highlightedText);
2492  colgrp.setColor(TQColorGroup::Button, button);
2493  colgrp.setColor(TQColorGroup::ButtonText, buttonText);
2494  colgrp.setColor(TQColorGroup::Midlight, background.light(110));
2495  colgrp.setColor(TQColorGroup::Link, link);
2496  colgrp.setColor(TQColorGroup::LinkVisited, visitedLink);
2497 
2498  disabledgrp.setColor(TQColorGroup::Button, button);
2499 
2500  TQColor disbtntext = buttonText;
2501  disbtntext.hsv( &h, &s, &v );
2502  if (v > 128)
2503  // dark button, light buttonText - need a darker disabled buttonText
2504  disbtntext = disbtntext.dark(lowlightVal);
2505  else if (disbtntext != Qt::black)
2506  // light buttonText, dark button - need a lighter disabled buttonText - but only if !black
2507  disbtntext = disbtntext.light(highlightVal);
2508  else
2509  // black button - use darkgray disabled buttonText
2510  disbtntext = Qt::darkGray;
2511 
2512  disabledgrp.setColor(TQColorGroup::ButtonText, disbtntext);
2513  disabledgrp.setColor(TQColorGroup::Midlight, background.light(110));
2514  disabledgrp.setColor(TQColorGroup::Highlight, highlight.dark(120));
2515  disabledgrp.setColor(TQColorGroup::Link, link);
2516  disabledgrp.setColor(TQColorGroup::LinkVisited, visitedLink);
2517 
2518  return TQPalette(colgrp, disabledgrp, colgrp);
2519 }
2520 
2521 
2522 void TDEApplication::tdedisplaySetPalette()
2523 {
2524 #ifdef Q_WS_MACX
2525  //Can I have this on other platforms, please!? --Sam
2526  {
2527  TDEConfig *config = TDEGlobal::config();
2528  TDEConfigGroupSaver saver( config, "General" );
2529  bool do_not_set_palette = FALSE;
2530  if(config->readBoolEntry("nopaletteChange", &do_not_set_palette))
2531  return;
2532  }
2533 #endif
2534  TQApplication::setPalette( createApplicationPalette(), true);
2535  emit tdedisplayPaletteChanged();
2536  emit appearanceChanged();
2537 }
2538 
2539 
2540 void TDEApplication::tdedisplaySetFont()
2541 {
2542  TQApplication::setFont(TDEGlobalSettings::generalFont(), true);
2543  TQApplication::setFont(TDEGlobalSettings::menuFont(), true, TQMENUBAR_OBJECT_NAME_STRING);
2544  TQApplication::setFont(TDEGlobalSettings::menuFont(), true, TQPOPUPMENU_OBJECT_NAME_STRING);
2545  TQApplication::setFont(TDEGlobalSettings::menuFont(), true, "TDEPopupTitle");
2546 
2547  // "patch" standard TQStyleSheet to follow our fonts
2548  TQStyleSheet* sheet = TQStyleSheet::defaultSheet();
2549  sheet->item ("pre")->setFontFamily (TDEGlobalSettings::fixedFont().family());
2550  sheet->item ("code")->setFontFamily (TDEGlobalSettings::fixedFont().family());
2551  sheet->item ("tt")->setFontFamily (TDEGlobalSettings::fixedFont().family());
2552 
2553  emit tdedisplayFontChanged();
2554  emit appearanceChanged();
2555 }
2556 
2557 
2558 void TDEApplication::tdedisplaySetStyle()
2559 {
2560  if (useStyles)
2561  {
2562  applyGUIStyle();
2563  emit tdedisplayStyleChanged();
2564  emit appearanceChanged();
2565  }
2566 }
2567 
2568 
2569 void TDEApplication::propagateSettings(SettingsCategory arg)
2570 {
2571  TDEConfigBase* config = TDEGlobal::config();
2572  TDEConfigGroupSaver saver( config, "KDE" );
2573 
2574 #ifdef QT_HAVE_MAX_IMAGE_SIZE
2575  TQSize maxImageSize(4096, 4096);
2576  maxImageSize = config->readSizeEntry("MaxImageSize", &maxImageSize);
2577  TQImage::setMaxImageSize(maxImageSize);
2578 #endif
2579 
2580  int num = config->readNumEntry("CursorBlinkRate", TQApplication::cursorFlashTime());
2581  if ((num != 0) && (num < 200))
2582  num = 200;
2583  if (num > 2000)
2584  num = 2000;
2585  TQApplication::setCursorFlashTime(num);
2586  num = config->readNumEntry("DoubleClickInterval", TQApplication::doubleClickInterval());
2587  TQApplication::setDoubleClickInterval(num);
2588  num = config->readNumEntry("StartDragTime", TQApplication::startDragTime());
2589  TQApplication::setStartDragTime(num);
2590  num = config->readNumEntry("StartDragDist", TQApplication::startDragDistance());
2591  TQApplication::setStartDragDistance(num);
2592  num = config->readNumEntry("WheelScrollLines", TQApplication::wheelScrollLines());
2593  TQApplication::setWheelScrollLines(num);
2594 
2595  bool b = config->readBoolEntry("EffectAnimateMenu", false);
2596  TQApplication::setEffectEnabled( Qt::UI_AnimateMenu, b);
2597  b = config->readBoolEntry("EffectFadeMenu", false);
2598  TQApplication::setEffectEnabled( Qt::UI_FadeMenu, b);
2599  b = config->readBoolEntry("EffectAnimateCombo", false);
2600  TQApplication::setEffectEnabled( Qt::UI_AnimateCombo, b);
2601  b = config->readBoolEntry("EffectAnimateTooltip", false);
2602  TQApplication::setEffectEnabled( Qt::UI_AnimateTooltip, b);
2603  b = config->readBoolEntry("EffectFadeTooltip", false);
2604  TQApplication::setEffectEnabled( Qt::UI_FadeTooltip, b);
2605  b = !config->readBoolEntry("EffectNoTooltip", false);
2606  TQToolTip::setGloballyEnabled( b );
2607 
2608  emit settingsChanged(arg);
2609 }
2610 
2611 void TDEApplication::installKDEPropertyMap()
2612 {
2613 #ifndef QT_NO_SQL
2614  static bool installed = false;
2615  if (installed) return;
2616  installed = true;
2623  // TQSqlPropertyMap takes ownership of the new default map.
2624  TQSqlPropertyMap *kdeMap = new TQSqlPropertyMap;
2625  kdeMap->insert( "KColorButton", "color" );
2626  kdeMap->insert( "KComboBox", "currentItem" );
2627  kdeMap->insert( "KDatePicker", "date" );
2628  kdeMap->insert( "KDateWidget", "date" );
2629  kdeMap->insert( "KDateTimeWidget", "dateTime" );
2630  kdeMap->insert( "KEditListBox", "items" );
2631  kdeMap->insert( "TDEFontCombo", "family" );
2632  kdeMap->insert( "TDEFontRequester", "font" );
2633  kdeMap->insert( "TDEFontChooser", "font" );
2634  kdeMap->insert( "KHistoryCombo", "currentItem" );
2635  kdeMap->insert( "TDEListBox", "currentItem" );
2636  kdeMap->insert( "KLineEdit", "text" );
2637  kdeMap->insert( "KRestrictedLine", "text" );
2638  kdeMap->insert( "KSqueezedTextLabel", "text" );
2639  kdeMap->insert( "KTextBrowser", "source" );
2640  kdeMap->insert( "KTextEdit", "text" );
2641  kdeMap->insert( "KURLRequester", "url" );
2642  kdeMap->insert( "KPasswordEdit", "password" );
2643  kdeMap->insert( "KIntNumInput", "value" );
2644  kdeMap->insert( "KIntSpinBox", "value" );
2645  kdeMap->insert( "KDoubleNumInput", "value" );
2646  // Temp til fixed in QT then enable ifdef with the correct version num
2647  kdeMap->insert( TQGROUPBOX_OBJECT_NAME_STRING, "checked" );
2648  kdeMap->insert( TQTABWIDGET_OBJECT_NAME_STRING, "currentPage" );
2649  TQSqlPropertyMap::installDefaultMap( kdeMap );
2650 #endif
2651 }
2652 
2653 void TDEApplication::invokeHelp( const TQString& anchor,
2654  const TQString& _appname) const
2655 {
2656  return invokeHelp( anchor, _appname, "" );
2657 }
2658 
2659 #ifndef Q_WS_WIN
2660 // for win32 we're using simple help tools like Qt Assistant,
2661 // see kapplication_win.cpp
2662 void TDEApplication::invokeHelp( const TQString& anchor,
2663  const TQString& _appname,
2664  const TQCString& startup_id ) const
2665 {
2666  TQString url;
2667  TQString appname;
2668  if (_appname.isEmpty())
2669  appname = name();
2670  else
2671  appname = _appname;
2672 
2673  if (!anchor.isEmpty())
2674  url = TQString("help:/%1?anchor=%2").arg(appname).arg(anchor);
2675  else
2676  url = TQString("help:/%1/index.html").arg(appname);
2677 
2678  TQString error;
2679  if ( !dcopClient()->isApplicationRegistered("khelpcenter") )
2680  {
2681  if (startServiceByDesktopName("khelpcenter", url, &error, 0, 0, startup_id, false))
2682  {
2683  if (Tty != kapp->type())
2684  TQMessageBox::critical(kapp->mainWidget(), i18n("Could not Launch Help Center"),
2685  i18n("Could not launch the TDE Help Center:\n\n%1").arg(error), i18n("&OK"));
2686  else
2687  kdWarning() << "Could not launch help:\n" << error << endl;
2688  return;
2689  }
2690  }
2691  else
2692  DCOPRef( "khelpcenter", "KHelpCenterIface" ).send( "openUrl", url, startup_id );
2693 }
2694 #endif
2695 
2696 void TDEApplication::invokeHTMLHelp( const TQString& _filename, const TQString& topic ) const
2697 {
2698  kdWarning() << "invoking HTML help is deprecated! use docbook and invokeHelp!\n";
2699 
2700  TQString filename;
2701 
2702  if( _filename.isEmpty() )
2703  filename = TQString(name()) + "/index.html";
2704  else
2705  filename = _filename;
2706 
2707  TQString url;
2708  if (!topic.isEmpty())
2709  url = TQString("help:/%1#%2").arg(filename).arg(topic);
2710  else
2711  url = TQString("help:/%1").arg(filename);
2712 
2713  TQString error;
2714  if ( !dcopClient()->isApplicationRegistered("khelpcenter") )
2715  {
2716  if (startServiceByDesktopName("khelpcenter", url, &error, 0, 0, "", false))
2717  {
2718  if (Tty != kapp->type())
2719  TQMessageBox::critical(kapp->mainWidget(), i18n("Could not Launch Help Center"),
2720  i18n("Could not launch the TDE Help Center:\n\n%1").arg(error), i18n("&OK"));
2721  else
2722  kdWarning() << "Could not launch help:\n" << error << endl;
2723  return;
2724  }
2725  }
2726  else
2727  DCOPRef( "khelpcenter", "KHelpCenterIface" ).send( "openUrl", url );
2728 }
2729 
2730 
2731 void TDEApplication::invokeMailer(const TQString &address, const TQString &subject)
2732 {
2733  return invokeMailer(address,subject,"");
2734 }
2735 
2736 void TDEApplication::invokeMailer(const TQString &address, const TQString &subject, const TQCString& startup_id)
2737 {
2738  invokeMailer(address, TQString::null, TQString::null, subject, TQString::null, TQString::null,
2739  TQStringList(), startup_id );
2740 }
2741 
2742 void TDEApplication::invokeMailer(const KURL &mailtoURL)
2743 {
2744  return invokeMailer( mailtoURL, "" );
2745 }
2746 
2747 void TDEApplication::invokeMailer(const KURL &mailtoURL, const TQCString& startup_id )
2748 {
2749  return invokeMailer( mailtoURL, startup_id, false);
2750 }
2751 
2752 void TDEApplication::invokeMailer(const KURL &mailtoURL, const TQCString& startup_id, bool allowAttachments )
2753 {
2754  TQString address = KURL::decode_string(mailtoURL.path()), subject, cc, bcc, body;
2755  TQStringList queries = TQStringList::split('&', mailtoURL.query().mid(1));
2756  TQStringList attachURLs;
2757  for (TQStringList::Iterator it = queries.begin(); it != queries.end(); ++it)
2758  {
2759  TQString q = (*it).lower();
2760  if (q.startsWith("subject="))
2761  subject = KURL::decode_string((*it).mid(8));
2762  else
2763  if (q.startsWith("cc="))
2764  cc = cc.isEmpty()? KURL::decode_string((*it).mid(3)): cc + ',' + KURL::decode_string((*it).mid(3));
2765  else
2766  if (q.startsWith("bcc="))
2767  bcc = bcc.isEmpty()? KURL::decode_string((*it).mid(4)): bcc + ',' + KURL::decode_string((*it).mid(4));
2768  else
2769  if (q.startsWith("body="))
2770  body = KURL::decode_string((*it).mid(5));
2771  else
2772  if (allowAttachments && q.startsWith("attach="))
2773  attachURLs.push_back(KURL::decode_string((*it).mid(7)));
2774  else
2775  if (allowAttachments && q.startsWith("attachment="))
2776  attachURLs.push_back(KURL::decode_string((*it).mid(11)));
2777  else
2778  if (q.startsWith("to="))
2779  address = address.isEmpty()? KURL::decode_string((*it).mid(3)): address + ',' + KURL::decode_string((*it).mid(3));
2780  }
2781 
2782  invokeMailer( address, cc, bcc, subject, body, TQString::null, attachURLs, startup_id );
2783 }
2784 
2785 void TDEApplication::invokeMailer(const TQString &to, const TQString &cc, const TQString &bcc,
2786  const TQString &subject, const TQString &body,
2787  const TQString & messageFile, const TQStringList &attachURLs)
2788 {
2789  return invokeMailer(to,cc,bcc,subject,body,messageFile,attachURLs,"");
2790 }
2791 
2792 #ifndef Q_WS_WIN
2793 // on win32, for invoking browser we're using win32 API
2794 // see kapplication_win.cpp
2795 
2796 static TQStringList splitEmailAddressList( const TQString & aStr )
2797 {
2798  // This is a copy of KPIM::splitEmailAddrList().
2799  // Features:
2800  // - always ignores quoted characters
2801  // - ignores everything (including parentheses and commas)
2802  // inside quoted strings
2803  // - supports nested comments
2804  // - ignores everything (including double quotes and commas)
2805  // inside comments
2806 
2807  TQStringList list;
2808 
2809  if (aStr.isEmpty())
2810  return list;
2811 
2812  TQString addr;
2813  uint addrstart = 0;
2814  int commentlevel = 0;
2815  bool insidequote = false;
2816 
2817  for (uint index=0; index<aStr.length(); index++) {
2818  // the following conversion to latin1 is o.k. because
2819  // we can safely ignore all non-latin1 characters
2820  switch (aStr[index].latin1()) {
2821  case '"' : // start or end of quoted string
2822  if (commentlevel == 0)
2823  insidequote = !insidequote;
2824  break;
2825  case '(' : // start of comment
2826  if (!insidequote)
2827  commentlevel++;
2828  break;
2829  case ')' : // end of comment
2830  if (!insidequote) {
2831  if (commentlevel > 0)
2832  commentlevel--;
2833  else {
2834  //kdDebug() << "[tdecore-tdeapplication] Error in address splitting: Unmatched ')'"
2835  // << endl;
2836  return list;
2837  }
2838  }
2839  break;
2840  case '\\' : // quoted character
2841  index++; // ignore the quoted character
2842  break;
2843  case ',' :
2844  if (!insidequote && (commentlevel == 0)) {
2845  addr = aStr.mid(addrstart, index-addrstart);
2846  if (!addr.isEmpty())
2847  list += addr.simplifyWhiteSpace();
2848  addrstart = index+1;
2849  }
2850  break;
2851  }
2852  }
2853  // append the last address to the list
2854  if (!insidequote && (commentlevel == 0)) {
2855  addr = aStr.mid(addrstart, aStr.length()-addrstart);
2856  if (!addr.isEmpty())
2857  list += addr.simplifyWhiteSpace();
2858  }
2859  //else
2860  // kdDebug() << "[tdecore-tdeapplication] Error in address splitting: "
2861  // << "Unexpected end of address list"
2862  // << endl;
2863 
2864  return list;
2865 }
2866 
2867 void TDEApplication::invokeMailer(const TQString &_to, const TQString &_cc, const TQString &_bcc,
2868  const TQString &subject, const TQString &body,
2869  const TQString & /*messageFile TODO*/, const TQStringList &attachURLs,
2870  const TQCString& startup_id )
2871 {
2872  TDEConfig config("emaildefaults");
2873 
2874  config.setGroup("Defaults");
2875  TQString group = config.readEntry("Profile","Default");
2876 
2877  config.setGroup( TQString("PROFILE_%1").arg(group) );
2878  TQString command = config.readPathEntry("EmailClient");
2879 
2880  TQString to, cc, bcc;
2881  if (command.isEmpty() || command == TQString::fromLatin1("kmail")
2882  || command.endsWith("/kmail"))
2883  {
2884  command = TQString::fromLatin1("kmail --composer -s %s -c %c -b %b --body %B --attach %A -- %t");
2885  if ( !_to.isEmpty() )
2886  {
2887  // put the whole address lists into RFC2047 encoded blobs; technically
2888  // this isn't correct, but KMail understands it nonetheless
2889  to = TQString( "=?utf8?b?%1?=" )
2890  .arg( TQString(KCodecs::base64Encode( _to.utf8(), false )) );
2891  }
2892  if ( !_cc.isEmpty() )
2893  cc = TQString( "=?utf8?b?%1?=" )
2894  .arg( TQString(KCodecs::base64Encode( _cc.utf8(), false )) );
2895  if ( !_bcc.isEmpty() )
2896  bcc = TQString( "=?utf8?b?%1?=" )
2897  .arg( TQString(KCodecs::base64Encode( _bcc.utf8(), false )) );
2898  } else {
2899  to = _to;
2900  cc = _cc;
2901  bcc = _bcc;
2902  if( !command.contains( '%' ))
2903  command += " %u";
2904  }
2905 
2906  if (config.readBoolEntry("TerminalClient", false))
2907  {
2908  TDEConfigGroup confGroup( TDEGlobal::config(), "General" );
2909  TQString preferredTerminal = confGroup.readPathEntry("TerminalApplication", "konsole");
2910  command = preferredTerminal + " -e " + command;
2911  }
2912 
2913  TQStringList cmdTokens = KShell::splitArgs(command);
2914  TQString cmd = cmdTokens[0];
2915  cmdTokens.remove(cmdTokens.begin());
2916 
2917  KURL url;
2918  TQStringList qry;
2919  if (!to.isEmpty())
2920  {
2921  TQStringList tos = splitEmailAddressList( to );
2922  url.setPath( tos.first() );
2923  tos.remove( tos.begin() );
2924  for (TQStringList::ConstIterator it = tos.begin(); it != tos.end(); ++it)
2925  qry.append( "to=" + KURL::encode_string( *it ) );
2926  }
2927  const TQStringList ccs = splitEmailAddressList( cc );
2928  for (TQStringList::ConstIterator it = ccs.begin(); it != ccs.end(); ++it)
2929  qry.append( "cc=" + KURL::encode_string( *it ) );
2930  const TQStringList bccs = splitEmailAddressList( bcc );
2931  for (TQStringList::ConstIterator it = bccs.begin(); it != bccs.end(); ++it)
2932  qry.append( "bcc=" + KURL::encode_string( *it ) );
2933  for (TQStringList::ConstIterator it = attachURLs.begin(); it != attachURLs.end(); ++it)
2934  qry.append( "attach=" + KURL::encode_string( *it ) );
2935  if (!subject.isEmpty())
2936  qry.append( "subject=" + KURL::encode_string( subject ) );
2937  if (!body.isEmpty())
2938  qry.append( "body=" + KURL::encode_string( body ) );
2939  url.setQuery( qry.join( "&" ) );
2940  if ( ! (to.isEmpty() && qry.isEmpty()) )
2941  url.setProtocol("mailto");
2942 
2943  TQMap<TQChar, TQString> keyMap;
2944  keyMap.insert('t', to);
2945  keyMap.insert('s', subject);
2946  keyMap.insert('c', cc);
2947  keyMap.insert('b', bcc);
2948  keyMap.insert('B', body);
2949  keyMap.insert('u', url.url());
2950 
2951  TQString attachlist = attachURLs.join(",");
2952  attachlist.prepend('\'');
2953  attachlist.append('\'');
2954  keyMap.insert('A', attachlist);
2955 
2956  for (TQStringList::Iterator it = cmdTokens.begin(); it != cmdTokens.end(); )
2957  {
2958  if (*it == "%A")
2959  {
2960  if (it == cmdTokens.begin()) // better safe than sorry ...
2961  continue;
2962  TQStringList::ConstIterator urlit = attachURLs.begin();
2963  TQStringList::ConstIterator urlend = attachURLs.end();
2964  if ( urlit != urlend )
2965  {
2966  TQStringList::Iterator previt = it;
2967  --previt;
2968  *it = *urlit;
2969  ++it;
2970  while ( ++urlit != urlend )
2971  {
2972  cmdTokens.insert( it, *previt );
2973  cmdTokens.insert( it, *urlit );
2974  }
2975  } else {
2976  --it;
2977  it = cmdTokens.remove( cmdTokens.remove( it ) );
2978  }
2979  } else {
2980  *it = KMacroExpander::expandMacros(*it, keyMap);
2981  ++it;
2982  }
2983  }
2984 
2985  TQString error;
2986  // TODO this should check if cmd has a .desktop file, and use data from it, together
2987  // with sending more ASN data
2988  if (tdeinitExec(cmd, cmdTokens, &error, NULL, startup_id )) {
2989  if (Tty != kapp->type()) {
2990  TQMessageBox::critical(kapp->mainWidget(), i18n("Could not Launch Mail Client"),
2991  i18n("Could not launch the mail client:\n\n%1").arg(error), i18n("&OK"));
2992  }
2993  else {
2994  kdWarning() << "Could not launch mail client:\n" << error << endl;
2995  }
2996  }
2997 }
2998 #endif
2999 
3000 void TDEApplication::invokeBrowser( const TQString &url )
3001 {
3002  return invokeBrowser( url, "" );
3003 }
3004 
3005 #ifndef Q_WS_WIN
3006 // on win32, for invoking browser we're using win32 API
3007 // see kapplication_win.cpp
3008 void TDEApplication::invokeBrowser( const TQString &url, const TQCString& startup_id )
3009 {
3010  TQString error;
3011 
3012  if (startServiceByDesktopName("kfmclient", url, &error, 0, 0, startup_id, false))
3013  {
3014  if (Tty != kapp->type())
3015  TQMessageBox::critical(kapp->mainWidget(), i18n("Could not Launch Browser"),
3016  i18n("Could not launch the browser:\n\n%1").arg(error), i18n("&OK"));
3017  else
3018  kdWarning() << "Could not launch browser:\n" << error << endl;
3019  return;
3020  }
3021 }
3022 #endif
3023 
3024 void TDEApplication::cut()
3025 {
3026  invokeEditSlot( TQT_SLOT( cut() ) );
3027 }
3028 
3029 void TDEApplication::copy()
3030 {
3031  invokeEditSlot( TQT_SLOT( copy() ) );
3032 }
3033 
3034 void TDEApplication::paste()
3035 {
3036  invokeEditSlot( TQT_SLOT( paste() ) );
3037 }
3038 
3039 void TDEApplication::clear()
3040 {
3041  invokeEditSlot( TQT_SLOT( clear() ) );
3042 }
3043 
3044 void TDEApplication::selectAll()
3045 {
3046  invokeEditSlot( TQT_SLOT( selectAll() ) );
3047 }
3048 
3049 void TDEApplication::broadcastKeyCode(unsigned int keyCode)
3050 {
3051  emit coreFakeKeyPress(keyCode);
3052 }
3053 
3054 TQCString
3055 TDEApplication::launcher()
3056 {
3057  return "tdelauncher";
3058 }
3059 
3060 static int
3061 startServiceInternal( const TQCString &function,
3062  const TQString& _name, const TQStringList &URLs,
3063  TQString *error, TQCString *dcopService, int *pid, const TQCString& startup_id, bool noWait )
3064 {
3065  struct serviceResult
3066  {
3067  int result;
3068  TQCString dcopName;
3069  TQString error;
3070  pid_t pid;
3071  };
3072 
3073  // Register app as able to send DCOP messages
3074  DCOPClient *dcopClient;
3075  if (kapp)
3076  dcopClient = kapp->dcopClient();
3077  else
3078  dcopClient = new DCOPClient;
3079 
3080  if (!dcopClient->isAttached())
3081  {
3082  if (!dcopClient->attach())
3083  {
3084  if (error)
3085  *error = i18n("Could not register with DCOP.\n");
3086  if (!kapp)
3087  delete dcopClient;
3088 
3089  return -1;
3090  }
3091  }
3092  TQByteArray params;
3093  TQDataStream stream(params, IO_WriteOnly);
3094  stream << _name << URLs;
3095  TQCString replyType;
3096  TQByteArray replyData;
3097  TQCString _launcher = TDEApplication::launcher();
3098  TQValueList<TQCString> envs;
3099 #ifdef Q_WS_X11
3100  if (tqt_xdisplay()) {
3101  TQCString dpystring(XDisplayString(tqt_xdisplay()));
3102  envs.append( TQCString("DISPLAY=") + dpystring );
3103  } else if( getenv( "DISPLAY" )) {
3104  TQCString dpystring( getenv( "DISPLAY" ));
3105  envs.append( TQCString("DISPLAY=") + dpystring );
3106  }
3107 #endif
3108  stream << envs;
3109 #if defined Q_WS_X11
3110  // make sure there is id, so that user timestamp exists
3111  stream << ( startup_id.isEmpty() ? TDEStartupInfo::createNewStartupId() : startup_id );
3112 #endif
3113  if( function.left( 12 ) != "tdeinit_exec" )
3114  stream << noWait;
3115 
3116  if (!dcopClient->call(_launcher, _launcher,
3117  function, params, replyType, replyData))
3118  {
3119  if (error)
3120  *error = i18n("TDELauncher could not be reached via DCOP.\n");
3121  if (!kapp)
3122  delete dcopClient;
3123  return -1;
3124  }
3125  if (!kapp)
3126  delete dcopClient;
3127 
3128  if (noWait)
3129  return 0;
3130 
3131  TQDataStream stream2(replyData, IO_ReadOnly);
3132  serviceResult result;
3133  stream2 >> result.result >> result.dcopName >> result.error >> result.pid;
3134  if (dcopService)
3135  *dcopService = result.dcopName;
3136  if (error)
3137  *error = result.error;
3138  if (pid)
3139  *pid = result.pid;
3140  return result.result;
3141 }
3142 
3143 int
3144 TDEApplication::startServiceByName( const TQString& _name, const TQString &URL,
3145  TQString *error, TQCString *dcopService, int *pid, const TQCString& startup_id, bool noWait )
3146 {
3147  TQStringList URLs;
3148  if (!URL.isEmpty())
3149  URLs.append(URL);
3150  return startServiceInternal(
3151  "start_service_by_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3152  _name, URLs, error, dcopService, pid, startup_id, noWait);
3153 }
3154 
3155 int
3156 TDEApplication::startServiceByName( const TQString& _name, const TQStringList &URLs,
3157  TQString *error, TQCString *dcopService, int *pid, const TQCString& startup_id, bool noWait )
3158 {
3159  return startServiceInternal(
3160  "start_service_by_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3161  _name, URLs, error, dcopService, pid, startup_id, noWait);
3162 }
3163 
3164 int
3165 TDEApplication::startServiceByDesktopPath( const TQString& _name, const TQString &URL,
3166  TQString *error, TQCString *dcopService, int *pid, const TQCString& startup_id, bool noWait )
3167 {
3168  TQStringList URLs;
3169  if (!URL.isEmpty())
3170  URLs.append(URL);
3171  return startServiceInternal(
3172  "start_service_by_desktop_path(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3173  _name, URLs, error, dcopService, pid, startup_id, noWait);
3174 }
3175 
3176 int
3177 TDEApplication::startServiceByDesktopPath( const TQString& _name, const TQStringList &URLs,
3178  TQString *error, TQCString *dcopService, int *pid, const TQCString& startup_id, bool noWait )
3179 {
3180  return startServiceInternal(
3181  "start_service_by_desktop_path(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3182  _name, URLs, error, dcopService, pid, startup_id, noWait);
3183 }
3184 
3185 int
3186 TDEApplication::startServiceByDesktopName( const TQString& _name, const TQString &URL,
3187  TQString *error, TQCString *dcopService, int *pid, const TQCString& startup_id, bool noWait )
3188 {
3189  TQStringList URLs;
3190  if (!URL.isEmpty())
3191  URLs.append(URL);
3192  return startServiceInternal(
3193  "start_service_by_desktop_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3194  _name, URLs, error, dcopService, pid, startup_id, noWait);
3195 }
3196 
3197 int
3198 TDEApplication::startServiceByDesktopName( const TQString& _name, const TQStringList &URLs,
3199  TQString *error, TQCString *dcopService, int *pid, const TQCString& startup_id, bool noWait )
3200 {
3201  return startServiceInternal(
3202  "start_service_by_desktop_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3203  _name, URLs, error, dcopService, pid, startup_id, noWait);
3204 }
3205 
3206 int
3207 TDEApplication::tdeinitExec( const TQString& name, const TQStringList &args,
3208  TQString *error, int *pid )
3209 {
3210  return tdeinitExec( name, args, error, pid, "" );
3211 }
3212 
3213 int
3214 TDEApplication::tdeinitExec( const TQString& name, const TQStringList &args,
3215  TQString *error, int *pid, const TQCString& startup_id )
3216 {
3217  return startServiceInternal("tdeinit_exec(TQString,TQStringList,TQValueList<TQCString>,TQCString)",
3218  name, args, error, 0, pid, startup_id, false);
3219 }
3220 
3221 int
3222 TDEApplication::tdeinitExecWait( const TQString& name, const TQStringList &args,
3223  TQString *error, int *pid )
3224 {
3225  return tdeinitExecWait( name, args, error, pid, "" );
3226 }
3227 
3228 int
3229 TDEApplication::tdeinitExecWait( const TQString& name, const TQStringList &args,
3230  TQString *error, int *pid, const TQCString& startup_id )
3231 {
3232  return startServiceInternal("tdeinit_exec_wait(TQString,TQStringList,TQValueList<TQCString>,TQCString)",
3233  name, args, error, 0, pid, startup_id, false);
3234 }
3235 
3236 TQString TDEApplication::tempSaveName( const TQString& pFilename ) const
3237 {
3238  TQString aFilename;
3239 
3240  if( TQDir::isRelativePath(pFilename) )
3241  {
3242  kdWarning(101) << "Relative filename passed to TDEApplication::tempSaveName" << endl;
3243  aFilename = TQFileInfo( TQDir( "." ), pFilename ).absFilePath();
3244  }
3245  else
3246  aFilename = pFilename;
3247 
3248  TQDir aAutosaveDir( TQDir::homeDirPath() + "/autosave/" );
3249  if( !aAutosaveDir.exists() )
3250  {
3251  if( !aAutosaveDir.mkdir( aAutosaveDir.absPath() ) )
3252  {
3253  // Last chance: use temp dir
3254  aAutosaveDir.setPath( TDEGlobal::dirs()->saveLocation("tmp") );
3255  }
3256  }
3257 
3258  aFilename.replace( "/", "\\!" ).prepend( "#" ).append( "#" ).prepend( "/" ).prepend( aAutosaveDir.absPath() );
3259 
3260  return aFilename;
3261 }
3262 
3263 
3264 TQString TDEApplication::checkRecoverFile( const TQString& pFilename,
3265  bool& bRecover ) const
3266 {
3267  TQString aFilename;
3268 
3269  if( TQDir::isRelativePath(pFilename) )
3270  {
3271  kdWarning(101) << "Relative filename passed to TDEApplication::tempSaveName" << endl;
3272  aFilename = TQFileInfo( TQDir( "." ), pFilename ).absFilePath();
3273  }
3274  else
3275  aFilename = pFilename;
3276 
3277  TQDir aAutosaveDir( TQDir::homeDirPath() + "/autosave/" );
3278  if( !aAutosaveDir.exists() )
3279  {
3280  if( !aAutosaveDir.mkdir( aAutosaveDir.absPath() ) )
3281  {
3282  // Last chance: use temp dir
3283  aAutosaveDir.setPath( TDEGlobal::dirs()->saveLocation("tmp") );
3284  }
3285  }
3286 
3287  aFilename.replace( "/", "\\!" ).prepend( "#" ).append( "#" ).prepend( "/" ).prepend( aAutosaveDir.absPath() );
3288 
3289  if( TQFile( aFilename ).exists() )
3290  {
3291  bRecover = true;
3292  return aFilename;
3293  }
3294  else
3295  {
3296  bRecover = false;
3297  return pFilename;
3298  }
3299 }
3300 
3301 
3302 bool checkAccess(const TQString& pathname, int mode)
3303 {
3304  int accessOK = access( TQFile::encodeName(pathname), mode );
3305  if ( accessOK == 0 )
3306  return true; // OK, I can really access the file
3307 
3308  // else
3309  // if we want to write the file would be created. Check, if the
3310  // user may write to the directory to create the file.
3311  if ( (mode & W_OK) == 0 )
3312  return false; // Check for write access is not part of mode => bail out
3313 
3314 
3315  if (!access( TQFile::encodeName(pathname), F_OK)) // if it already exists
3316  return false;
3317 
3318  //strip the filename (everything until '/' from the end
3319  TQString dirName(pathname);
3320  int pos = dirName.findRev('/');
3321  if ( pos == -1 )
3322  return false; // No path in argument. This is evil, we won't allow this
3323  else if ( pos == 0 ) // don't turn e.g. /root into an empty string
3324  pos = 1;
3325 
3326  dirName.truncate(pos); // strip everything starting from the last '/'
3327 
3328  accessOK = access( TQFile::encodeName(dirName), W_OK );
3329  // -?- Can I write to the accessed diretory
3330  if ( accessOK == 0 )
3331  return true; // Yes
3332  else
3333  return false; // No
3334 }
3335 
3336 void TDEApplication::setTopWidget( TQWidget *topWidget )
3337 {
3338  if( !topWidget )
3339  return;
3340 
3341  // set the specified caption
3342  if ( !topWidget->inherits("TDEMainWindow") ) { // TDEMainWindow does this already for us
3343  topWidget->setCaption( caption() );
3344  }
3345 
3346  // set the specified icons
3347  topWidget->setIcon( icon() ); //standard X11
3348 #if defined Q_WS_X11
3349 //#ifdef Q_WS_X11 // FIXME(E): Implement for Qt/Embedded
3350  KWin::setIcons(topWidget->winId(), icon(), miniIcon() ); // NET_WM hints for KWin
3351 
3352  // set the app startup notification window property
3353  TDEStartupInfo::setWindowStartupId( topWidget->winId(), startupId());
3354 #endif
3355 }
3356 
3357 TQCString TDEApplication::startupId() const
3358 {
3359  return d->startup_id;
3360 }
3361 
3362 void TDEApplication::setStartupId( const TQCString& startup_id )
3363 {
3364  if( startup_id == d->startup_id )
3365  return;
3366 #if defined Q_WS_X11
3367  TDEStartupInfo::handleAutoAppStartedSending(); // finish old startup notification if needed
3368 #endif
3369  if( startup_id.isEmpty())
3370  d->startup_id = "0";
3371  else
3372  {
3373  d->startup_id = startup_id;
3374 #if defined Q_WS_X11
3375  TDEStartupInfoId id;
3376  id.initId( startup_id );
3377  long timestamp = id.timestamp();
3378  if( timestamp != 0 )
3379  updateUserTimestamp( timestamp );
3380 #endif
3381  }
3382 }
3383 
3384 // read the startup notification env variable, save it and unset it in order
3385 // not to propagate it to processes started from this app
3386 void TDEApplication::read_app_startup_id()
3387 {
3388 #if defined Q_WS_X11
3389  TDEStartupInfoId id = TDEStartupInfo::currentStartupIdEnv();
3390  TDEStartupInfo::resetStartupEnv();
3391  d->startup_id = id.id();
3392 #endif
3393 }
3394 
3395 int TDEApplication::random()
3396 {
3397  static bool init = false;
3398  if (!init)
3399  {
3400  unsigned int seed;
3401  init = true;
3402  int fd = open("/dev/urandom", O_RDONLY);
3403  if (fd < 0 || ::read(fd, &seed, sizeof(seed)) != sizeof(seed))
3404  {
3405  // No /dev/urandom... try something else.
3406  srand(getpid());
3407  seed = rand()+time(0);
3408  }
3409  if (fd >= 0) close(fd);
3410  srand(seed);
3411  }
3412  return rand();
3413 }
3414 
3415 TQString TDEApplication::randomString(int length)
3416 {
3417  if (length <=0 ) return TQString::null;
3418 
3419  TQString str; str.setLength( length );
3420  int i = 0;
3421  while (length--)
3422  {
3423  int r=random() % 62;
3424  r+=48;
3425  if (r>57) r+=7;
3426  if (r>90) r+=6;
3427  str[i++] = char(r);
3428  // so what if I work backwards?
3429  }
3430  return str;
3431 }
3432 
3433 bool TDEApplication::authorize(const TQString &genericAction)
3434 {
3435  if (!d->actionRestrictions)
3436  return true;
3437 
3438  TDEConfig *config = TDEGlobal::config();
3439  TDEConfigGroupSaver saver( config, "KDE Action Restrictions" );
3440  return config->readBoolEntry(genericAction, true);
3441 }
3442 
3443 bool TDEApplication::authorizeTDEAction(const char *action)
3444 {
3445  if (!d->actionRestrictions || !action)
3446  return true;
3447 
3448  static const TQString &action_prefix = TDEGlobal::staticQString( "action/" );
3449 
3450  return authorize(action_prefix + action);
3451 }
3452 
3453 bool TDEApplication::authorizeControlModule(const TQString &menuId)
3454 {
3455  if (menuId.isEmpty() || kde_kiosk_exception)
3456  return true;
3457  TDEConfig *config = TDEGlobal::config();
3458  TDEConfigGroupSaver saver( config, "TDE Control Module Restrictions" );
3459  return config->readBoolEntry(menuId, true);
3460 }
3461 
3462 TQStringList TDEApplication::authorizeControlModules(const TQStringList &menuIds)
3463 {
3464  TDEConfig *config = TDEGlobal::config();
3465  TDEConfigGroupSaver saver( config, "TDE Control Module Restrictions" );
3466  TQStringList result;
3467  for(TQStringList::ConstIterator it = menuIds.begin();
3468  it != menuIds.end(); ++it)
3469  {
3470  if (config->readBoolEntry(*it, true))
3471  result.append(*it);
3472  }
3473  return result;
3474 }
3475 
3476 void TDEApplication::initUrlActionRestrictions()
3477 {
3478  d->urlActionRestrictions.setAutoDelete(true);
3479  d->urlActionRestrictions.clear();
3480  d->urlActionRestrictions.append( new TDEApplicationPrivate::URLActionRule
3481  ("open", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, true));
3482  d->urlActionRestrictions.append( new TDEApplicationPrivate::URLActionRule
3483  ("list", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, true));
3484 // TEST:
3485 // d->urlActionRestrictions.append( new TDEApplicationPrivate::URLActionRule
3486 // ("list", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, false));
3487 // d->urlActionRestrictions.append( new TDEApplicationPrivate::URLActionRule
3488 // ("list", TQString::null, TQString::null, TQString::null, "file", TQString::null, TQDir::homeDirPath(), true));
3489  d->urlActionRestrictions.append( new TDEApplicationPrivate::URLActionRule
3490  ("link", TQString::null, TQString::null, TQString::null, ":internet", TQString::null, TQString::null, true));
3491  d->urlActionRestrictions.append( new TDEApplicationPrivate::URLActionRule
3492  ("redirect", TQString::null, TQString::null, TQString::null, ":internet", TQString::null, TQString::null, true));
3493 
3494  // We allow redirections to file: but not from internet protocols, redirecting to file:
3495  // is very popular among io-slaves and we don't want to break them
3496  d->urlActionRestrictions.append( new TDEApplicationPrivate::URLActionRule
3497  ("redirect", TQString::null, TQString::null, TQString::null, "file", TQString::null, TQString::null, true));
3498  d->urlActionRestrictions.append( new TDEApplicationPrivate::URLActionRule
3499  ("redirect", ":internet", TQString::null, TQString::null, "file", TQString::null, TQString::null, false));
3500 
3501  // local protocols may redirect everywhere
3502  d->urlActionRestrictions.append( new TDEApplicationPrivate::URLActionRule
3503  ("redirect", ":local", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, true));
3504 
3505  // Anyone may redirect to about:
3506  d->urlActionRestrictions.append( new TDEApplicationPrivate::URLActionRule
3507  ("redirect", TQString::null, TQString::null, TQString::null, "about", TQString::null, TQString::null, true));
3508 
3509  // Anyone may redirect to itself, cq. within it's own group
3510  d->urlActionRestrictions.append( new TDEApplicationPrivate::URLActionRule
3511  ("redirect", TQString::null, TQString::null, TQString::null, "=", TQString::null, TQString::null, true));
3512 
3513  TDEConfig *config = TDEGlobal::config();
3514  TDEConfigGroupSaver saver( config, "KDE URL Restrictions" );
3515  int count = config->readNumEntry("rule_count");
3516  TQString keyFormat = TQString("rule_%1");
3517  for(int i = 1; i <= count; i++)
3518  {
3519  TQString key = keyFormat.arg(i);
3520  TQStringList rule = config->readListEntry(key);
3521  if (rule.count() != 8)
3522  continue;
3523  TQString action = rule[0];
3524  TQString refProt = rule[1];
3525  TQString refHost = rule[2];
3526  TQString refPath = rule[3];
3527  TQString urlProt = rule[4];
3528  TQString urlHost = rule[5];
3529  TQString urlPath = rule[6];
3530  TQString strEnabled = rule[7].lower();
3531 
3532  bool bEnabled = (strEnabled == "true");
3533 
3534  if (refPath.startsWith("$HOME"))
3535  refPath.replace(0, 5, TQDir::homeDirPath());
3536  else if (refPath.startsWith("~"))
3537  refPath.replace(0, 1, TQDir::homeDirPath());
3538  if (urlPath.startsWith("$HOME"))
3539  urlPath.replace(0, 5, TQDir::homeDirPath());
3540  else if (urlPath.startsWith("~"))
3541  urlPath.replace(0, 1, TQDir::homeDirPath());
3542 
3543  if (refPath.startsWith("$TMP"))
3544  refPath.replace(0, 4, TDEGlobal::dirs()->saveLocation("tmp"));
3545  if (urlPath.startsWith("$TMP"))
3546  urlPath.replace(0, 4, TDEGlobal::dirs()->saveLocation("tmp"));
3547 
3548  d->urlActionRestrictions.append(new TDEApplicationPrivate::URLActionRule
3549  ( action, refProt, refHost, refPath, urlProt, urlHost, urlPath, bEnabled));
3550  }
3551 }
3552 
3553 void TDEApplication::allowURLAction(const TQString &action, const KURL &_baseURL, const KURL &_destURL)
3554 {
3555  if (authorizeURLAction(action, _baseURL, _destURL))
3556  return;
3557 
3558  d->urlActionRestrictions.append(new TDEApplicationPrivate::URLActionRule
3559  ( action, _baseURL.protocol(), _baseURL.host(), _baseURL.path(-1),
3560  _destURL.protocol(), _destURL.host(), _destURL.path(-1), true));
3561 }
3562 
3563 bool TDEApplication::authorizeURLAction(const TQString &action, const KURL &_baseURL, const KURL &_destURL)
3564 {
3565  if (_destURL.isEmpty())
3566  return true;
3567 
3568  bool result = false;
3569  if (d->urlActionRestrictions.isEmpty())
3570  initUrlActionRestrictions();
3571 
3572  KURL baseURL(_baseURL);
3573  baseURL.setPath(TQDir::cleanDirPath(baseURL.path()));
3574  TQString baseClass = KProtocolInfo::protocolClass(baseURL.protocol());
3575  KURL destURL(_destURL);
3576  destURL.setPath(TQDir::cleanDirPath(destURL.path()));
3577  TQString destClass = KProtocolInfo::protocolClass(destURL.protocol());
3578 
3579  for(TDEApplicationPrivate::URLActionRule *rule = d->urlActionRestrictions.first();
3580  rule; rule = d->urlActionRestrictions.next())
3581  {
3582  if ((result != rule->permission) && // No need to check if it doesn't make a difference
3583  (action == rule->action) &&
3584  rule->baseMatch(baseURL, baseClass) &&
3585  rule->destMatch(destURL, destClass, baseURL, baseClass))
3586  {
3587  result = rule->permission;
3588  }
3589  }
3590  return result;
3591 }
3592 
3593 
3594 uint TDEApplication::keyboardModifiers()
3595 {
3596 #ifdef Q_WS_X11
3597  Window root;
3598  Window child;
3599  int root_x, root_y, win_x, win_y;
3600  uint keybstate;
3601  XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
3602  &root_x, &root_y, &win_x, &win_y, &keybstate );
3603  return keybstate & 0x00ff;
3604 #elif defined W_WS_MACX
3605  return GetCurrentEventKeyModifiers() & 0x00ff;
3606 #else
3607  //TODO for win32
3608  return 0;
3609 #endif
3610 }
3611 
3612 uint TDEApplication::mouseState()
3613 {
3614  uint mousestate;
3615 #ifdef Q_WS_X11
3616  Window root;
3617  Window child;
3618  int root_x, root_y, win_x, win_y;
3619  XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
3620  &root_x, &root_y, &win_x, &win_y, &mousestate );
3621 #elif defined(Q_WS_WIN)
3622  const bool mousebtn_swapped = GetSystemMetrics(SM_SWAPBUTTON);
3623  if (GetAsyncKeyState(VK_LBUTTON))
3624  mousestate |= (mousebtn_swapped ? Button3Mask : Button1Mask);
3625  if (GetAsyncKeyState(VK_MBUTTON))
3626  mousestate |= Button2Mask;
3627  if (GetAsyncKeyState(VK_RBUTTON))
3628  mousestate |= (mousebtn_swapped ? Button1Mask : Button3Mask);
3629 #elif defined(Q_WS_MACX)
3630  mousestate = GetCurrentEventButtonState();
3631 #else
3632  //TODO: other platforms
3633 #endif
3634  return mousestate & 0xff00;
3635 }
3636 
3637 TQ_ButtonState TDEApplication::keyboardMouseState()
3638 {
3639  int ret = 0;
3640 #ifdef Q_WS_X11
3641  Window root;
3642  Window child;
3643  int root_x, root_y, win_x, win_y;
3644  uint state;
3645  XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
3646  &root_x, &root_y, &win_x, &win_y, &state );
3647  // transform the same way like Qt's qt_x11_translateButtonState()
3648  if( state & Button1Mask )
3649  ret |= TQ_LeftButton;
3650  if( state & Button2Mask )
3651  ret |= TQ_MidButton;
3652  if( state & Button3Mask )
3653  ret |= TQ_RightButton;
3654  if( state & ShiftMask )
3655  ret |= TQ_ShiftButton;
3656  if( state & ControlMask )
3657  ret |= TQ_ControlButton;
3658  if( state & KKeyNative::modX( KKey::ALT ))
3659  ret |= TQ_AltButton;
3660  if( state & KKeyNative::modX( KKey::WIN ))
3661  ret |= TQ_MetaButton;
3662 #elif defined(Q_WS_WIN)
3663  const bool mousebtn_swapped = GetSystemMetrics(SM_SWAPBUTTON);
3664  if (GetAsyncKeyState(VK_LBUTTON))
3665  ret |= (mousebtn_swapped ? RightButton : LeftButton);
3666  if (GetAsyncKeyState(VK_MBUTTON))
3667  ret |= TQ_MidButton;
3668  if (GetAsyncKeyState(VK_RBUTTON))
3669  ret |= (mousebtn_swapped ? TQ_LeftButton : TQ_RightButton);
3670  if (GetAsyncKeyState(VK_SHIFT))
3671  ret |= TQ_ShiftButton;
3672  if (GetAsyncKeyState(VK_CONTROL))
3673  ret |= TQ_ControlButton;
3674  if (GetAsyncKeyState(VK_MENU))
3675  ret |= TQ_AltButton;
3676  if (GetAsyncKeyState(VK_LWIN) || GetAsyncKeyState(VK_RWIN))
3677  ret |= TQ_MetaButton;
3678 #else
3679  //TODO: other platforms
3680 #endif
3681  return static_cast< ButtonState >( ret );
3682 }
3683 
3684 #if defined Q_WS_X11
3685 int TDEApplication::currentX11VT()
3686 {
3687  return get_x_vtnum(TQPaintDevice::x11AppDisplay());
3688 }
3689 #else // Q_WS_X11
3690 int TDEApplication::currentX11VT()
3691 {
3692  return -1;
3693 }
3694 #endif // Q_WS_X11
3695 
3696 void TDEApplication::installSigpipeHandler()
3697 {
3698 #ifdef Q_OS_UNIX
3699  struct sigaction act;
3700  act.sa_handler = SIG_IGN;
3701  sigemptyset( &act.sa_mask );
3702  act.sa_flags = 0;
3703  sigaction( SIGPIPE, &act, 0 );
3704 #endif
3705 }
3706 
3707 void TDEApplication::sigpipeHandler(int)
3708 {
3709  int saved_errno = errno;
3710  // Using kdDebug from a signal handler is not a good idea.
3711 #ifndef NDEBUG
3712  char msg[1000];
3713  sprintf(msg, "*** SIGPIPE *** (ignored, pid = %ld)\n", (long) getpid());
3714  if (write(2, msg, strlen(msg)) < 0) {
3715  // ERROR
3716  }
3717 #endif
3718 
3719  // Do nothing.
3720  errno = saved_errno;
3721 }
3722 
3723 bool TDEApplication::guiEnabled()
3724 {
3725  return kapp && kapp->d->guiEnabled;
3726 }
3727 
3728 void TDEApplication::virtual_hook( int id, void* data )
3729 { TDEInstance::virtual_hook( id, data ); }
3730 
3731 void KSessionManaged::virtual_hook( int, void* )
3732 { /*BASE::virtual_hook( id, data );*/ }
3733 
3734 #include "tdeapplication.moc"
KURL::setQuery
void setQuery(const TQString &_txt, int encoding_hint=0)
Sets the encoded query of the URL.
Definition: kurl.cpp:2047
TDEConfig::reparseConfiguration
virtual void reparseConfiguration()
Clears all internal data structures and then reread configuration information from disk...
Definition: tdeconfig.cpp:161
TDEApplication::miniIcon
TQPixmap miniIcon() const
Returns the mini-icon for the application as a TQPixmap.
TDEConfig
Access KDE Configuration entries.
Definition: tdeconfig.h:43
DCOPClient::setServerAddress
static void setServerAddress(const TQCString &addr)
TDEApplication::broadcastKeyCode
void broadcastKeyCode(unsigned int keyCode)
Broadcast a received keycode to all listening KDE applications The primary use for this feature is to...
Definition: tdeapplication.cpp:3049
TDEApplication::clear
void clear()
If the widget with focus provides a clear() slot, call that slot.
Definition: tdeapplication.cpp:3039
TDEApplication::KApp
static TDEApplication * KApp
Current application object.
Definition: tdeapplication.h:1283
KURL
Represents and parses a URL.
Definition: kurl.h:127
TDEApplication::startServiceByDesktopPath
static int startServiceByDesktopPath(const TQString &_name, const TQString &URL, TQString *error=0, TQCString *dcopService=0, int *pid=0, const TQCString &startup_id="", bool noWait=false)
Starts a service based on the desktop path of the service.
Definition: tdeapplication.cpp:3165
TDECmdLineArgs
A class for command-line argument handling.
Definition: tdecmdlineargs.h:222
TDEApplication::cut
void cut()
If the widget with focus provides a cut() slot, call that slot.
Definition: tdeapplication.cpp:3024
TDEApplication::invokeHTMLHelp
void invokeHTMLHelp(const TQString &aFilename, const TQString &aTopic=TQString::null) const KDE_DEPRECATED
Definition: tdeapplication.cpp:2696
TDEApplication::invokeEditSlot
void invokeEditSlot(const char *slot)
This method is used internally to determine which edit slots are implemented by the widget that has t...
Definition: tdeapplication.cpp:2310
TDEApplication::saveState
void saveState(TQSessionManager &sm)
Reimplemented for internal purposes, mainly the highlevel handling of session management with KSessio...
Definition: tdeapplication.cpp:1484
TDEIcon::DefaultState
The default state.
Definition: kicontheme.h:130
KSessionManaged::commitData
virtual bool commitData(TQSessionManager &sm)
See TQApplication::commitData() for documentation.
Definition: tdeapplication.cpp:1279
TDEStandardDirs::kde_default
static TQString kde_default(const char *type)
This returns a default relative path for the standard KDE resource types.
Definition: kstandarddirs.cpp:1036
TDEApplication::dcopClient
static DCOPClient * dcopClient()
Returns a pointer to a DCOPClient for the application.
Definition: tdeapplication.cpp:1189
TDEApplication::iconChanged
void iconChanged(int group)
Emitted when the global icon settings have been changed.
TDEApplication::installX11EventFilter
void installX11EventFilter(TQWidget *filter)
Installs widget filter as global X11 event filter.
Definition: tdeapplication.cpp:519
TDEApplication::copy
void copy()
If the widget with focus provides a copy() slot, call that slot.
Definition: tdeapplication.cpp:3029
TDEApplication::startServiceByName
static int startServiceByName(const TQString &_name, const TQString &URL, TQString *error=0, TQCString *dcopService=0, int *pid=0, const TQCString &startup_id="", bool noWait=false)
Starts a service based on the (translated) name of the service.
Definition: tdeapplication.cpp:3144
TDEApplication::selectAll
void selectAll()
If the widget with focus provides a selectAll() slot, call that slot.
Definition: tdeapplication.cpp:3044
TDECrash::setCrashHandler
static void setCrashHandler(HandlerType handler=defaultCrashHandler)
Install a function to be called in case a SIGSEGV is caught.
Definition: kcrash.cpp:86
TDEStdAccel::selectAll
const TDEShortcut & selectAll()
Reload.
Definition: tdestdaccel.cpp:313
TDEConfigGroupSaver
Helper class to facilitate working with TDEConfig / KSimpleConfig groups.
Definition: tdeconfigbase.h:2082
TDEApplication::authorizeTDEAction
bool authorizeTDEAction(const char *action)
Returns whether a certain TDEAction is authorized.
Definition: tdeapplication.cpp:3443
TDEStdAccel::key
int key(StdAccel id)
Definition: tdestdaccel.cpp:383
TDEApplication::ShutdownType
ShutdownType
The possible values for the sdtype parameter of requestShutDown().
Definition: tdeapplication.h:359
TDEConfigBase::setGroup
void setGroup(const TQString &group)
Specifies the group in which keys will be read and written.
Definition: tdeconfigbase.cpp:79
TDEApplication::appearanceChanged
void appearanceChanged()
Emitted when TDEApplication has changed either its GUI style, its font or its palette in response to ...
KMacroExpander::expandMacros
TQString expandMacros(const TQString &ostr, const TQMap< TQChar, TQString > &map, TQChar c)
Perform safe macro expansion (substitution) on a string.
Definition: kmacroexpander.cpp:520
TDEApplication::isX11CompositionAvailable
bool isX11CompositionAvailable()
Returns whether or not X11 composition is available.
Definition: tdeapplication.cpp:2157
DCOPClient::attach
bool attach()
TDEApplication::invokeHelp
void invokeHelp(const TQString &anchor, const TQString &appname, const TQCString &startup_id) const
Invokes the KHelpCenter HTML help viewer from docbook sources.
Definition: kapplication_win.cpp:77
KURL::query
TQString query() const
Returns the encoded query of the URL.
Definition: kurl.cpp:2094
TDEShortcut::contains
bool contains(const KKey &key) const
Checks whether this shortcut contains a sequence that starts with the given key.
Definition: tdeshortcut.cpp:532
TDEGlobal::iconLoader
static TDEIconLoader * iconLoader()
Returns an iconloader object.
Definition: tdeglobal.cpp:79
TDEStandardDirs::resourceDirs
TQStringList resourceDirs(const char *type) const
This function is used internally by almost all other function as it serves and fills the directories ...
Definition: kstandarddirs.cpp:795
TDEApplication::userTimestamp
unsigned long userTimestamp() const
Returns the last user action timestamp or 0 if no user activity has taken place yet.
Definition: tdeapplication.cpp:2292
TDEApplication::backgroundChanged
void backgroundChanged(int desk)
Emitted when the desktop background has been changed by kcmdisplay.
DCOPClient::send
bool send(const TQCString &remApp, const TQCString &remObj, const TQCString &remFun, const TQByteArray &data)
KURL::protocol
TQString protocol() const
Returns the protocol for the URL.
Definition: kurl.h:367
TDECmdLineArgs::addCmdLineOptions
static void addCmdLineOptions(const TDECmdLineOptions *options, const char *name=0, const char *id=0, const char *afterId=0)
Add options to your application.
Definition: tdecmdlineargs.cpp:206
DCOPRef
TDEApplication::getX11RGBAVisual
Qt::HANDLE getX11RGBAVisual(Display *dpy)
Returns the X11 display visual.
Definition: tdeapplication.cpp:2149
TDEApplication::kipcMessage
void kipcMessage(int id, int data)
Emitted when a KIPC user message has been received.
TDEInstance::aboutData
const TDEAboutData * aboutData() const
Returns the about data of this instance Warning, can be 0L.
Definition: kinstance.cpp:314
TDEApplication::ShutdownModeDefault
Select previous mode or the default if it's the first time.
Definition: tdeapplication.h:385
TDECmdLineArgs::appName
static const char * appName()
Get the appname according to argv[0].
Definition: tdecmdlineargs.cpp:199
TDEApplication::ShutdownTypeDefault
Select previous action or the default if it's the first time.
Definition: tdeapplication.h:363
TDEApplication::startupId
TQCString startupId() const
Returns the app startup notification identifier for this running application.
Definition: tdeapplication.cpp:3357
TDEConfigBase::readListEntry
int readListEntry(const TQString &pKey, TQStrList &list, char sep= ',') const
Reads a list of strings.
Definition: tdeconfigbase.cpp:491
TDEClipboardSynchronizer::self
static TDEClipboardSynchronizer * self()
Returns the TDEClipboardSynchronizer singleton object.
Definition: kclipboard.cpp:97
TDEApplication::allowURLAction
void allowURLAction(const TQString &action, const KURL &_baseURL, const KURL &_destURL)
Allow a certain URL action.
Definition: tdeapplication.cpp:3553
TDEApplication::deref
void deref()
Tells TDEApplication that one operation such as those described in ref() just finished.
Definition: tdeapplication.cpp:1255
TDEStandardDirs::addResourceType
bool addResourceType(const char *type, const TQString &relativename)
Adds suffixes for types.
Definition: kstandarddirs.cpp:255
TDEApplication::isCompositionManagerAvailable
static bool isCompositionManagerAvailable()
Gets the availability of a composition manager such as kompmgr Note that at least one application mus...
Definition: tdeapplication.cpp:2106
TDEApplication::keyboardMouseState
static ButtonState keyboardMouseState()
Returns the state of the currently pressed keyboard modifiers (e.g.
Definition: tdeapplication.cpp:3637
TDELocale::i18n
TQString i18n(const char *text)
Definition: tdelocale.cpp:1976
KURL::isEmpty
bool isEmpty() const
Tests if the KURL is empty.
Definition: kurl.cpp:652
TDEApplication::currentX11VT
static int currentX11VT()
Returns the VT that the current X server is running on, or -1 if this information is unavailable...
Definition: tdeapplication.cpp:3690
TDECrash::setEmergencySaveFunction
static void setEmergencySaveFunction(HandlerType saveFunction=(HandlerType) 0)
Installs a function which should try to save the applications data.
Definition: kcrash.cpp:70
KIPC::BlockShortcuts
Definition: kipc.h:59
DCOPClient
TDEApplication::tdeinitExec
static int tdeinitExec(const TQString &name, const TQStringList &args, TQString *error, int *pid, const TQCString &startup_id)
Starts a program via tdeinit.
Definition: tdeapplication.cpp:3214
TDEApplication
Controls and provides information to all KDE applications.
Definition: tdeapplication.h:96
TDEIcon::NoGroup
No group.
Definition: kicontheme.h:90
TDEApplication::shutDown
void shutDown()
Your application is killed.
TDEApplication::addKipcEventMask
void addKipcEventMask(int id)
Adds a message type to the KIPC event mask.
Definition: tdeapplication.cpp:2325
TDEApplication::startServiceByDesktopName
static int startServiceByDesktopName(const TQString &_name, const TQString &URL, TQString *error=0, TQCString *dcopService=0, int *pid=0, const TQCString &startup_id="", bool noWait=false)
Starts a service based on the desktop name of the service.
Definition: tdeapplication.cpp:3186
TDECmdLineArgs::getOption
TQCString getOption(const char *option) const
Read out a string option.
Definition: tdecmdlineargs.cpp:1119
TDEApplication::commitData
void commitData(TQSessionManager &sm)
Reimplemented for internal purposes, mainly the highlevel handling of session management with KSessio...
Definition: tdeapplication.cpp:1411
TDELocale::I18N_NOOP
#define I18N_NOOP(x)
Definition: tdelocale.h:51
DCOPRef::send
bool send(const TQCString &fun)
TDEConfigBase::checkConfigFilesWritable
bool checkConfigFilesWritable(bool warnUser)
Check whether the config files are writable.
Definition: tdeconfigbase.cpp:1952
TDEApplication::disableAutoDcopRegistration
static void disableAutoDcopRegistration()
Disable automatic dcop registration Must be called before creating a TDEApplication instance to have ...
Definition: tdeapplication.cpp:1234
TDEApplication::geometryArgument
TQString geometryArgument() const
Returns the argument to –geometry if any, so the geometry can be set wherever necessary.
Definition: tdeapplication.cpp:1818
KURL::host
TQString host() const
Returns the decoded hostname included in the URL.
Definition: kurl.h:477
KSessionManaged::saveState
virtual bool saveState(TQSessionManager &sm)
See TQApplication::saveState() for documentation.
Definition: tdeapplication.cpp:1274
TDEProcessController::deref
static void deref()
Destroy the instance if one exists and it is not referenced any more.
Definition: kprocctrl.cpp:48
TDEApplication::setTopWidget
void setTopWidget(TQWidget *topWidget)
Sets the top widget of the application.
Definition: tdeapplication.cpp:3336
TDEConfigBase
KDE Configuration Management abstract base class.
Definition: tdeconfigbase.h:70
TDEApplication::updateRemoteUserTimestamp
void updateRemoteUserTimestamp(const TQCString &dcopId, unsigned long time=0)
Updates the last user action timestamp in the application registered to DCOP with dcopId to the given...
Definition: tdeapplication.cpp:2301
TDEGlobal::dirs
static TDEStandardDirs * dirs()
Returns the application standard dirs object.
Definition: tdeglobal.cpp:58
TDEApplication::ShutdownConfirm
ShutdownConfirm
The possible values for the confirm parameter of requestShutDown().
Definition: tdeapplication.h:341
TDEInstance::newIconLoader
void newIconLoader() const
Re-allocate the global iconloader.
Definition: kinstance.cpp:307
TDEConfigGroup
A TDEConfigBase derived class for one specific group in a TDEConfig object.
Definition: tdeconfigbase.h:2126
TDEApplication::tdedisplayPaletteChanged
void tdedisplayPaletteChanged()
Emitted when TDEApplication has changed its palette due to a KControl request.
TDEApplication::getX11RGBAColormap
Qt::HANDLE getX11RGBAColormap(Display *dpy)
Returns the X11 display colormap.
Definition: tdeapplication.cpp:2153
TDEProcessController::ref
static void ref()
Create an instance if none exists yet.
Definition: kprocctrl.cpp:39
TDEApplication::ShutdownMode
ShutdownMode
The possible values for the sdmode parameter of requestShutDown().
Definition: tdeapplication.h:381
tdelocale.h
TDEIcon::SizeLarge
large sized icons for the panel
Definition: kicontheme.h:120
TDEApplication::TDEApplication
TDEApplication(bool allowStyles=true, bool GUIenabled=true, bool SMenabled=true)
This constructor takes aboutData and command line arguments from TDECmdLineArgs.
Definition: tdeapplication.cpp:754
TDEGlobal::instance
static TDEInstance * instance()
Returns the global instance.
Definition: tdeglobal.cpp:102
TDEApplication::tdedisplayFontChanged
void tdedisplayFontChanged()
Emitted when TDEApplication has changed its font in response to a KControl request.
TDECmdLineArgs::parsedArgs
static TDECmdLineArgs * parsedArgs(const char *id=0)
Access parsed arguments.
Definition: tdecmdlineargs.cpp:310
TDEApplication::enableSessionManagement
void enableSessionManagement()
Enables again session management for this application, formerly disabled by calling disableSessionMan...
Definition: tdeapplication.cpp:1289
TDEApplication::invokeMailer
void invokeMailer(const TQString &address, const TQString &subject, const TQCString &startup_id)
Convenience method; invokes the standard email application.
Definition: tdeapplication.cpp:2736
TDEInstance::mimeSourceFactory
KMimeSourceFactory * mimeSourceFactory() const
Returns the KMimeSourceFactory of the instance.
Definition: kinstance.cpp:326
TDEApplication::createApplicationPalette
static TQPalette createApplicationPalette()
Used to obtain the TQPalette that will be used to set the application palette.
Definition: tdeapplication.cpp:2424
TDEApplication::authorizeControlModule
bool authorizeControlModule(const TQString &menuId)
Returns whether access to a certain control module is authorized.
Definition: tdeapplication.cpp:3453
TDEAboutData::programName
TQString programName() const
Returns the translated program name.
Definition: tdeaboutdata.cpp:252
TDEGlobalSettings::generalFont
static TQFont generalFont()
Returns the default general font.
Definition: tdeglobalsettings.cpp:470
TDEStandardDirs::findExe
static TQString findExe(const TQString &appname, const TQString &pathstr=TQString::null, bool ignoreExecBit=false)
Finds the executable in the system path.
Definition: kstandarddirs.cpp:932
KURL::setPath
void setPath(const TQString &path)
Sets the decoded path of the URL.
Definition: kurl.cpp:2025
TDEConfigBase::readBoolEntry
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
Reads a boolean entry.
Definition: tdeconfigbase.cpp:772
DCOPClient::registerAs
TQCString registerAs(const TQCString &appId, bool addPID=true)
TDEApplication::installSigpipeHandler
static void installSigpipeHandler()
Installs a handler for the SIGPIPE signal.
Definition: tdeapplication.cpp:3696
TDEApplication::randomString
static TQString randomString(int length)
Generates a random string.
Definition: tdeapplication.cpp:3415
DCOPClient::setMainClient
static void setMainClient(DCOPClient *mainClient)
TDEGlobal::checkAccess
bool checkAccess(const TQString &pathname, int mode)
Definition: tdeapplication.cpp:3302
TDEApplication::tempSaveName
TQString tempSaveName(const TQString &pFilename) const
Get a file name in order to make a temporary copy of your document.
Definition: tdeapplication.cpp:3236
DCOPRef::call
DCOPReply call(const TQCString &fun)
TDEIconLoader::loadIcon
TQPixmap loadIcon(const TQString &name, TDEIcon::Group group, int size=0, int state=TDEIcon::DefaultState, TQString *path_store=0L, bool canReturnNull=false) const
Loads an icon.
Definition: kiconloader.cpp:583
DCOPClient::appId
TQCString appId() const
TDEApplication::updateUserTimestamp
void updateUserTimestamp(unsigned long time=0)
Updates the last user action timestamp to the given time, or to the current time, if 0 is given...
Definition: tdeapplication.cpp:2268
TDEConfigBase::readSizeEntry
TQSize readSizeEntry(const TQString &pKey, const TQSize *pDefault=0L) const
Reads a TQSize entry.
Definition: tdeconfigbase.cpp:945
TDEApplication::mouseState
static uint mouseState() KDE_DEPRECATED
Definition: tdeapplication.cpp:3612
TDEApplication::checkRecoverFile
TQString checkRecoverFile(const TQString &pFilename, bool &bRecover) const
Check whether an auto-save file exists for the document you want to open.
Definition: tdeapplication.cpp:3264
TDEApplication::ShutdownConfirmYes
Always confirm, ask even if the user turned it off.
Definition: tdeapplication.h:353
TDEApplication::tdedisplayStyleChanged
void tdedisplayStyleChanged()
Emitted when TDEApplication has changed its GUI style in response to a KControl request.
TDEApplication::invokeBrowser
void invokeBrowser(const TQString &url, const TQCString &startup_id)
Invokes the standard browser.
Definition: kapplication_win.cpp:93
TDEApplication::removeKipcEventMask
void removeKipcEventMask(int id)
Removes a message type from the KIPC event mask.
Definition: tdeapplication.cpp:2335
TDEApplication::iconName
TQString iconName() const
Returns the name of the application icon.
Definition: tdeapplication.cpp:1834
TDEApplication::requestShutDown
bool requestShutDown(ShutdownConfirm confirm=ShutdownConfirmDefault, ShutdownType sdtype=ShutdownTypeDefault, ShutdownMode sdmode=ShutdownModeDefault)
Asks the session manager to shut the session down.
Definition: tdeapplication.cpp:1313
TDEInstance::instanceName
TQCString instanceName() const
Returns the name of the instance.
Definition: kinstance.cpp:320
KStdAction::action
TDEAction * action(StdAction act_enum, const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0L)
KStdAction::name
const char * name(StdAction id)
TDEGlobal::staticQString
static const TQString & staticQString(const char *str)
Creates a static TQString.
Definition: tdeglobal.cpp:148
TDECrash::defaultCrashHandler
static void defaultCrashHandler(int signal)
The default crash handler.
Definition: kcrash.cpp:119
TDEGlobal::deleteStaticDeleters
static void deleteStaticDeleters()
Calls KStaticDeleterBase::destructObject() on all registered static deleters and unregisters them all...
Definition: tdeglobal.cpp:205
TDEGlobalSettings::contrast
static int contrast()
Returns the contrast for borders.
Definition: tdeglobalsettings.cpp:363
KURL::encode_string
static TQString encode_string(const TQString &str, int encoding_hint=0)
Encodes a string for use in URLs.
Definition: kurl.cpp:2106
TDELockFile::LockNoBlock
Return immediately, do not wait for the lock to become available.
Definition: klockfile.h:74
TDEInstance::config
TDEConfig * config() const
Returns the general config object ("appnamerc").
Definition: kinstance.cpp:210
TDEApplication::random
static int random()
Generates a uniform random number.
Definition: tdeapplication.cpp:3395
TDEApplication::installKDEPropertyMap
void installKDEPropertyMap()
Install a Qt SQL property map with entries for all KDE widgets Call this in any application using KDE...
Definition: tdeapplication.cpp:2611
TDEGlobal::locale
static TDELocale * locale()
Returns the global locale object.
Definition: tdeglobal.cpp:108
TDELockFile
The TDELockFile class provides NFS safe lockfiles.
Definition: klockfile.h:33
TDEApplication::paste
void paste()
If the widget with focus provides a paste() slot, call that slot.
Definition: tdeapplication.cpp:3034
KKey
A KKey object represents a single key with possible modifiers (Shift, Ctrl, Alt, Win).
Definition: tdeshortcut.h:40
TDEShortcut
The TDEShortcut class is used to represent a keyboard shortcut to an action.
Definition: tdeshortcut.h:543
TDEApplication::detectCompositionManagerAvailable
bool detectCompositionManagerAvailable(bool force_available=false, bool available=true)
Detects the availability of a composition manager such as kompmgr Note that calling this method will ...
Definition: tdeapplication.cpp:2110
KCodecs::base64Encode
static TQCString base64Encode(const TQByteArray &in, bool insertLFs=false)
Encodes the given data using the base64 algorithm.
Definition: kmdcodec.cpp:373
TDEGlobalSettings::menuFont
static TQFont menuFont()
Returns the default menu font.
Definition: tdeglobalsettings.cpp:518
TDEApplication::authorize
bool authorize(const TQString &genericAction)
Returns whether a certain action is authorized.
Definition: tdeapplication.cpp:3433
KURL::decode_string
static TQString decode_string(const TQString &str, int encoding_hint=0)
Decodes a string as used in URLs.
Definition: kurl.cpp:2101
TDEStandardDirs::saveLocation
TQString saveLocation(const char *type, const TQString &suffix=TQString::null, bool create=true) const
Finds a location to save files into for the given type in the user's home directory.
Definition: kstandarddirs.cpp:1099
TDEApplication::miniIconName
TQString miniIconName() const
Returns the name of the mini-icon for the application.
Definition: tdeapplication.cpp:1850
TDEApplication::authorizeControlModules
TQStringList authorizeControlModules(const TQStringList &menuIds)
Returns whether access to a certain control modules is authorized.
Definition: tdeapplication.cpp:3462
TDEApplication::icon
TQPixmap icon() const
Returns a TQPixmap with the application icon.
TDEConfigBase::readColorEntry
TQColor readColorEntry(const TQString &pKey, const TQColor *pDefault=0L) const
Reads a TQColor entry.
Definition: tdeconfigbase.cpp:971
TDEApplication::removeX11EventFilter
void removeX11EventFilter(const TQWidget *filter)
Removes global X11 event filter previously installed by installX11EventFilter().
Definition: tdeapplication.cpp:534
TDEConfigBase::hasGroup
bool hasGroup(const TQString &group) const
Returns true if the specified group is known about.
Definition: tdeconfigbase.cpp:152
DCOPClient::isAttached
bool isAttached() const
TDEApplication::caption
TQString caption() const
Returns a text for the window caption.
Definition: tdeapplication.cpp:2386
TDEInstance::setConfigName
void setConfigName(const TQString &name)
Set name of default config file.
Definition: kinstance.cpp:268
TDEApplication::disableStyles
void disableStyles()
Disables style plugins.
Definition: tdeapplication.cpp:2354
TDEApplication::SettingsCategory
SettingsCategory
Valid values for the settingsChanged signal.
Definition: tdeapplication.h:1394
TDEApplication::enableStyles
void enableStyles()
Enables style plugins.
Definition: tdeapplication.cpp:2345
TDEApplication::disableSessionManagement
void disableSessionManagement()
Disables session management for this application.
Definition: tdeapplication.cpp:1285
TDEConfigBase::readPathEntry
TQString readPathEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads a path.
Definition: tdeconfigbase.cpp:609
TDEApplication::sessionSaving
bool sessionSaving() const
Returns true if the application is currently saving its session data (most probably before KDE logout...
Definition: tdeapplication.cpp:1566
NET::timestampCompare
static int timestampCompare(unsigned long time1, unsigned long time2)
Compares two X timestamps, taking into account wrapping and 64bit architectures.
TDEApplication::addCmdLineOptions
static void addCmdLineOptions()
Add Qt and KDE command line options to TDECmdLineArgs.
Definition: tdeapplication.cpp:1692
KURL::url
TQString url(int _trailing=0, int encoding_hint=0) const
Returns the URL as string, with all escape sequences intact, encoded in a given charset.
Definition: kurl.cpp:1499
KURL::path
TQString path() const
Returns the current decoded path.
Definition: kurl.h:532
TDECmdLineArgs::isSet
bool isSet(const char *option) const
Read out a boolean option or check for the presence of string option.
Definition: tdecmdlineargs.cpp:1181
TDEApplication::propagateSessionManager
void propagateSessionManager()
Propagates the network address of the session manager in the SESSION_MANAGER environment variable so ...
Definition: tdeapplication.cpp:1376
TDEApplication::makeStdCaption
TQString makeStdCaption(const TQString &userCaption, bool withAppName=true, bool modified=false) const
Builds a caption that contains the application name along with the userCaption using a standard layou...
Definition: tdeapplication.cpp:2405
TDEGlobalSettings::fixedFont
static TQFont fixedFont()
Returns the default fixed font.
Definition: tdeglobalsettings.cpp:486
TDEGlobal::config
static TDEConfig * config()
Returns the general config object.
Definition: tdeglobal.cpp:65
endl
kndbgstream & endl(kndbgstream &s)
Does nothing.
Definition: kdebug.h:583
TDEApplication::tdeinitExecWait
static int tdeinitExecWait(const TQString &name, const TQStringList &args, TQString *error, int *pid, const TQCString &startup_id)
Starts a program via tdeinit and wait for it to finish.
Definition: tdeapplication.cpp:3229
TDEApplication::launcher
static TQCString launcher()
Returns the DCOP name of the service launcher.
Definition: tdeapplication.cpp:3055
TDEApplication::sessionConfig
TDEConfig * sessionConfig()
Returns the application session config object.
Definition: tdeapplication.cpp:1239
KAppDCOPInterface
This is the main interface to the TDEApplication.
Definition: kappdcopiface.h:37
TDEConfigBase::readEntry
TQString readEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads the value of an entry specified by pKey in the current group.
Definition: tdeconfigbase.cpp:221
TDELockFile::LockOK
Lock was acquired successfully.
Definition: klockfile.h:52
TDEApplication::ref
void ref()
Tells TDEApplication about one more operation that should be finished before the application exits...
Definition: tdeapplication.cpp:1249
TDEApplication::authorizeURLAction
bool authorizeURLAction(const TQString &action, const KURL &baseURL, const KURL &destURL)
Returns whether a certain URL related action is authorized.
Definition: tdeapplication.cpp:3563
KShell::splitArgs
TQStringList splitArgs(const TQString &cmd, int flags=0, int *err=0)
Splits cmd according to POSIX shell word splitting and quoting rules.
Definition: kshell.cpp:65
DCOPClient::call
bool call(const TQCString &remApp, const TQCString &remObj, const TQCString &remFun, const TQByteArray &data, TQCString &replyType, TQByteArray &replyData, bool useEventLoop, int timeout, bool forceRemote)
TDECrash::setApplicationName
static void setApplicationName(TQString name)
Sets the application name name which should be passed to Dr.
Definition: kcrash.h:108
KWin::setIcons
static void setIcons(WId win, const TQPixmap &icon, const TQPixmap &miniIcon)
Sets an icon and a miniIcon on window win.
Definition: twin.cpp:515
TDEApplication::settingsChanged
void settingsChanged(int category)
Emitted when the global settings have been changed - see TDEGlobalSettings TDEApplication takes care ...
TDEApplication::ShutdownConfirmNo
Don't confirm, shutdown without asking.
Definition: tdeapplication.h:349
KSessionManaged
Provides highlevel access to session management on a per-object base.
Definition: tdeapplication.h:1613
TDEInstance
Access to KDE global objects for use in shared libraries.
Definition: kinstance.h:47
TDEConfigBase::sync
virtual void sync()
Flushes all changes that currently reside only in memory back to disk / permanent storage...
Definition: tdeconfigbase.cpp:1786
TDEApplication::toolbarAppearanceChanged
void toolbarAppearanceChanged(int)
Emitted when the settings for toolbars have been changed.
TDEConfigBase::readNumEntry
int readNumEntry(const TQString &pKey, int nDefault=0) const
Reads a numerical value.
Definition: tdeconfigbase.cpp:637
KURL::setProtocol
void setProtocol(const TQString &_txt)
Sets the protocol for the URL.
Definition: kurl.cpp:1972
TDEApplication::saveYourself
void saveYourself()
Session management asks you to save the state of your application.
TDEApplication::keyboardModifiers
static uint keyboardModifiers() KDE_DEPRECATED
Definition: tdeapplication.cpp:3594
TDECmdLineOptions
Structure that holds command line options.
Definition: tdecmdlineargs.h:40

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.8.8
This website is maintained by Timothy Pearson.