コード例 #1
0
ファイル: kapplication.cpp プロジェクト: fluxer/kdelibs
void KApplicationPrivate::init()
{
  if ((getuid() != geteuid()) ||
      (getgid() != getegid()))
  {
     fprintf(stderr, "The KDE libraries are not designed to run with suid privileges.\n");
     ::exit(127);
  }


  KApplication::KApp = q;

  // make sure the clipboard is created before setting the window icon (bug 209263)
  (void) QApplication::clipboard();

  parseCommandLine();

  (void) KClipboardSynchronizer::self();

  QApplication::setDesktopSettingsAware( false );

#ifdef Q_WS_X11
  // create all required atoms in _one_ roundtrip to the X server
  const int max = 20;
  Atom* atoms[max];
  char* names[max];
  Atom atoms_return[max];
  int n = 0;

  atoms[n] = &atom_DesktopWindow;
  names[n++] = (char *) "KDE_DESKTOP_WINDOW";

  atoms[n] = &atom_NetSupported;
  names[n++] = (char *) "_NET_SUPPORTED";

  atoms[n] = &kde_xdnd_drop;
  names[n++] = (char *) "XdndDrop";

  XInternAtoms( QX11Info::display(), names, n, false, atoms_return );

  for (int i = 0; i < n; i++ )
    *atoms[i] = atoms_return[i];
#endif


  // sanity checking, to make sure we've connected
  QDBusConnectionInterface *bus = 0;
  if (!QDBusConnection::sessionBus().isConnected() || !(bus = QDBusConnection::sessionBus().interface())) {
      kFatal(240) << "Session bus not found" << endl <<
                  "To circumvent this problem try the following command (with Linux and bash)" << endl <<
                  "export $(dbus-launch)";
      ::exit(125);
  }

  extern bool s_kuniqueapplication_startCalled;
  if ( bus && !s_kuniqueapplication_startCalled ) // don't register again if KUniqueApplication did so already
  {
      QStringList parts = q->organizationDomain().split(QLatin1Char('.'), QString::SkipEmptyParts);
      QString reversedDomain;
      if (parts.isEmpty())
          reversedDomain = QLatin1String("local.");
      else
          foreach (const QString& s, parts)
          {
              reversedDomain.prepend(QLatin1Char('.'));
              reversedDomain.prepend(s);
          }