rem: kdebug(KDEBUG_INFO, 0, msg);
add: kDebugInfo( 0, msg);
context: static void setSignalHandler(void (*handler)(int));static void recoverDeadLetters(void);static void processArgs(KCmdLineArgs *args);static void checkMessage(void);static void writePid(bool ready);//-----------------------------------------------------------------------------static void ungrabPtrKb(void){  if(!KTMainWindow::memberList) return;  QWidget* widg = KTMainWindow::memberList->first();  Display* dpy;  if (!widg) return;  dpy = widg->x11Display();  XUngrabKeyboard(dpy, CurrentTime);  XUngrabPointer(dpy, CurrentTime);}//-----------------------------------------------------------------------------// Message handlerstatic void kmailMsgHandler(QtMsgType aType, const char* aMsg){  QString appName = app->caption();  QString msg = aMsg;  static int recurse=-1;  recurse++;  switch (aType)  {  case QtDebugMsg:    kdebug(KDEBUG_INFO, 0, msg);    break;  case QtWarningMsg:    fprintf(stderr, "%s: %s\n", (const char*)app->name(), msg.data());    kdebug(KDEBUG_INFO, 0, msg);    break;  case QtFatalMsg:    ungrabPtrKb();    fprintf(stderr, appName+" "+i18n("fatal error")+": %s\n", msg.data());    KMessageBox::error(0, aMsg);    abort();  }  recurse--;}//--- Sven's pseudo IPC&locking start ---void serverReady(bool flag){  writePid(flag);  if (flag) // are we ready now?    checkMessage(); //check for any pending mesages}static void writePid (bool ready){  FILE* lck;  char nlck[80];  sprintf (nlck, "%s.kmail%d.lck", _PATH_TMP, getuid());  unlink (nlck); // Security - in case it was a socket, link, device...  lck = fopen (nlck, "w");  if (!ready)    fprintf (lck, "%d", 0-getpid());  else    fprintf (lck, "%d", getpid());  fclose (lck);}static void checkMessage(){  char lf[80];  sprintf (lf, "%s.kmail%d.msg", _PATH_TMP, getuid());  if (access(lf, F_OK) != 0)  {    debug ("No message for me");    printf ("No message for me\n");    return;  }  QString cmd;  QString delcmd;  cmd = kFileToString(lf);  delcmd.sprintf("%s.kmail%d.msg", _PATH_TMP, getuid());  unlink (delcmd.data()); // unlink  //system (delcmd.data()); // delete message if any  // find a KMMainWin  KMMainWin *kmmWin = 0;  if (kapp->mainWidget() && kapp->mainWidget()->isA("KMMainWin"))    kmmWin = (KMMainWin *) kapp->mainWidget();  if (cmd.find ("show") == 0)  {    //printf ("show();\n");    if (!kmmWin)    {      kmmWin = new KMMainWin;      kmmWin->show(); // thanks, Patrick!    }    else      KWM::activate(kmmWin->winId());  }  else if (cmd.find ("check") == 0)  {    //printf ("check();\n");    if (!kmmWin) {      kmmWin = new KMMainWin;      kmmWin->show(); // thanks, jbb!    }    else      KWM::activate(kmmWin->winId());    kmmWin->slotCheckMail();  }  else  {    int j;    int i = cmd.find ("To: ", 0, true);    if (i==-1)      return; // not a mailto command    QString to = "";    QString cc = "";    QString bcc = "";    QString subj = "";    j = cmd.find('\n', i);    to = cmd.mid(i+4,j-i-4);    i = cmd.find ("Cc: ", j, true);    if (i!=-1)    {      j = cmd.find('\n', i);      cc= cmd.mid(i+4,j-i-4);    }    i = cmd.find ("Bcc: ", j, true);    if (i!=-1)    {      j = cmd.find('\n', i);      bcc= cmd.mid(i+5,j-i-5);    }    i = cmd.find ("Subject: ", j, true);    if (i!=-1)    {      j = cmd.find('\n', i);      subj= cmd.mid(i+9,j-i-9);    }    //printf ("To: %s\nCc: %s\nBcc: %s\nSubject: %s\n",    //        to.data(), cc.data(), bcc.data(), subj.data());    KMComposeWin* win;    KMMessage* msg = new KMMessage;    msg->initHeader();    if (!cc.isEmpty()) msg->setCc(cc);    if (!bcc.isEmpty()) msg->setBcc(bcc);    if (!subj.isEmpty()) msg->setSubject(subj);    if (!to.isEmpty()) msg->setTo(to);    win = new KMComposeWin(msg);    assert(win != NULL);    win->show();  }  }//--- Sven's pseudo IPC&locking end ---//-----------------------------------------------------------------------------// Crash recovery signal handlerstatic void signalHandler(int sigId){  QWidget* win;  //--- Sven's pseudo IPC&locking start ---  if (sigId == SIGUSR1)  {    fprintf(stderr, "*** KMail got message\n");    checkMessage();    setSignalHandler(signalHandler);    return;  }  //--- Sven's pseudo IPC&locking end ---  fprintf(stderr, "*** KMail got signal %d\n", sigId);  // try to cleanup all windows  while (KTMainWindow::memberList->first() != NULL)  {    win = KTMainWindow::memberList->take();    if (win->inherits("KMComposeWin")) ((KMComposeWin*)win)->deadLetter();    delete win;  }  // If KMail crashes again below this line we consider the data lost :-|  // Otherwise KMail will end in an infinite loop.  setSignalHandler(SIG_DFL);  cleanup();  exit(1);}//-----------------------------------------------------------------------------static void setSignalHandler(void (*handler)(int)){  signal(SIGSEGV, handler);  signal(SIGKILL, handler);  signal(SIGTERM, handler);  signal(SIGHUP,  handler);  signal(SIGFPE,  handler);  signal(SIGABRT, handler);  //--- Sven's pseudo IPC&locking start ---  signal(SIGUSR1,  handler);  //--- Sven's pseudo IPC&locking end ---}