summaryrefslogtreecommitdiffstats
path: root/ksirc/ioNotify.cpp
blob: b3b4a52fd6719da27eacfb55c6869e7ecee38cea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**********************************************************************

 IO Notify Messanger

 $$Id$$

**********************************************************************/

#include "ioNotify.h"
#include "ksircprocess.h"

#include <kdebug.h>

KSircIONotify::KSircIONotify(KSircProcess *_proc)
  : TQObject(),
    KSircMessageReceiver(_proc)
{
  proc = _proc;
  setBroadcast(FALSE);
}


KSircIONotify::~KSircIONotify()
{
}

void KSircIONotify::sirc_receive(TQCString str, bool)
{
  if(str.contains("*)*")){
    int s1, s2;
    s1 = str.find("Signon by") + 10;
    s2 = str.find(" ", s1);
    if(s1 < 0 || s2 < 0){
      kdDebug(5008) << "Nick Notify mesage broken: " << str << endl;
      return;
    }
    TQString nick = str.mid(s1, s2 - s1);
    emit notify_online(nick);
  }
  else if(str.contains("*(*")){
    int s1, s2;
    s1 = str.find("Signoff by") + 11;
    s2 = str.find(" ", s1);
    if(s1 < 0 || s2 < 0){
      kdDebug(5008) << "Nick Notify mesage broken: " << str << endl;
      return;
    }
    TQString nick = str.mid(s1, s2 - s1);
    emit notify_offline(nick);
  }
  else{
    proc->getWindowList()["!default"]->sirc_receive(str);
    kdDebug(5008) << "Nick Notifer got " << str << endl;
  }
}

void KSircIONotify::control_message(int, TQString)
{
}


filterRuleList *KSircIONotify::defaultRules()
{
  filterRule *fr;
  filterRuleList *frl = new filterRuleList();
  frl->setAutoDelete(TRUE);
  fr = new filterRule();
  fr->desc = "Send Nick Notifies to notifier parser";
  fr->search = "^\\*\\S?[\\(\\)]\\S?\\* ";
  fr->from = "^";
  fr->to = "~!notify~";
  frl->append(fr);
  return frl;
}
#include "ioNotify.moc"