summaryrefslogtreecommitdiffstats
path: root/ksirc/ioDCC.cpp
blob: be0cdbb6df6f5a52df834d6f8ec2746f8b8dd767 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
/**********************************************************************

 The IO DCC Window

 $$Id$$

 Display DCC progress, etc.  This in the future should be expanded.

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

#include "ioDCC.h"
#include "ksircprocess.h"
#include "displayMgr.h"
#include "control_message.h"

#include <kdebug.h>
#include <tdelocale.h>
#include <kpassivepopup.h>

#include <tqregexp.h>

extern DisplayMgr *displayMgr;

KSircIODCC::KSircIODCC(KSircProcess *_proc) :
    TQObject(),
    KSircMessageReceiver(_proc)
{
    proc = _proc;
    setBroadcast(FALSE);
    mgr = new dccTopLevel(0x0, "dccTopLevel Manager");
    displayMgr->newTopLevel(mgr, FALSE);
    displayMgr->setCaption(mgr, proc->serverName() + i18n(" DCC Controller"));

    connect(mgr->mgr(), TQT_SIGNAL(dccConnectClicked(dccItem *)), this, TQT_SLOT(dccConnectClicked(dccItem *)));
    connect(mgr->mgr(), TQT_SIGNAL(dccResumeClicked(dccItem *)), this, TQT_SLOT(dccResumeClicked(dccItem *)));
    connect(mgr->mgr(), TQT_SIGNAL(dccRenameClicked(dccItem *)), this, TQT_SLOT(dccRenameClicked(dccItem *)));
    connect(mgr->mgr(), TQT_SIGNAL(dccAbortClicked(dccItem *)), this, TQT_SLOT(dccAbortClicked(dccItem *)));
    connect(mgr->mgr(), TQT_SIGNAL(outputLine(TQCString)), this, TQT_SIGNAL(outputLine(TQCString)));
}


KSircIODCC::~KSircIODCC()
{
    //    displayMgr->removeTopLevel(mgr);
    if(mgr)
	delete (dccTopLevel *) mgr;
}

void KSircIODCC::sirc_receive(TQCString str, bool )
{
  if(!mgr)
        return;
  // Parse the string to find out what type it is.
  // Note the order here.
  // Most people tend to receive files, so let's
  // parse the byte xfered messages first since there's lot's of them.
  // The we get lots of send bytexfer messages so parse them second.
  // Then we look at the one time start/stop messages.  They only arrive
  // once in a long long time (compared to the byte messages) so if it takes
  // a few extra clock cycles to find them, who cares?
  if(str.find("DCC GET read:", 0) != -1){ /*fold01*/
      TQRegExp rx("read: (.+) who: (.+) bytes: (.*)");
      if(rx.search(str)){
	  TQString key = TQString("%1/%2").arg(rx.cap(1)).arg(rx.cap(2));
	  uint bytesXfer = rx.cap(3).toUInt();

	  //
	  // Only update the display for 1% intervals.
	  // LastSize + 1%Size must be less than the total xfered bytes.
	  //
	  if(DCCGetItems[key]){
	      DCCGetItems[key]->setReceivedBytes(bytesXfer/1024);
	  }
      }
  }
  else if(str.find("DCC SEND write:", 0) != -1){ /*fold01*/
      TQRegExp rx("write: (.+) who: (.+) bytes: (.*)");
      if(rx.search(str)){
	  TQString key = TQString("%1/%2").arg(rx.cap(1)).arg(rx.cap(2));
	  uint bytesXfer = rx.cap(3).toUInt();

	  if(DCCSendItems[key]){
	      DCCSendItems[key]->setReceivedBytes(bytesXfer/1024);
	  }
      }
  }
  else if(str.find("INBOUND DCC SEND", 0) != -1){ /*FOLD01*/
      TQRegExp rx("who: (.+) file: (.+) size: (.*) ip: (.+) port: (.+)");
      if(rx.search(str)){
          TQString who = rx.cap(1);
          TQString filename = rx.cap(2);
          TQString size = rx.cap(3);
          TQString ip = rx.cap(4);
          //TQSTring port = rx.cap(5);

          int fileSize = size.toInt(); // Bytes per step
          fileSize /= 1024;

          // setup dcc dialog
          displayMgr->show(mgr);
	  dccItem *it = mgr->mgr()->newGetItem(filename, who, dccItem::dccGotOffer, fileSize);
	  connect(it, TQT_SIGNAL(itemRenamed(dccItem *, TQString, TQString)),
                  this, TQT_SLOT(dccRenameDone(dccItem *, TQString, TQString)));
	  it->setWhoPostfix("(" + ip + ")");

          TQString key = TQString("%1/%2").arg(filename).arg(who);
	  if(DCCGetItems[key]){
	      /*
	       * don't add duplicates, this cuases real headaches
	       * for both us and the user.
               */
              TQString renamed;
	      dccItem *old = DCCGetItems.take(key);
	      int i;
	      for(i = 0; i <= (int) DCCGetItems.count()+1; i++){
		  renamed = TQString("%1 (finished %2)/%3").arg(filename).arg(i+1).arg(old->who());
		  if( DCCGetItems[renamed] == 0x0)
                      break;
	      }
	      old->changeFilename(TQString("%1 (finished %2)").arg(filename).arg(i+1));
              DCCGetItems.insert(renamed, it);
	  }

          DCCGetItems.insert(key, it);
      }
      else {
          kdDebug(5008) << "DCC SEND was unable to parse: " << str << endl;
      }
  }
  else if(str.find("Sent DCC SEND", 0) != -1){ /*FOLD01*/
      TQRegExp rx("who: (.+) file: (.+) size: (.*)");
      if(rx.search(str)){
          TQString who = rx.cap(1);
          TQString filename = rx.cap(2);
          TQString size = rx.cap(3);
          int fileSize = size.toInt(); // Bytes per step
          fileSize /= 1024;

          // setup dcc dialog
          displayMgr->show(mgr);
	  dccItem *it = mgr->mgr()->newSendItem(filename, who, dccItem::dccSentOffer, fileSize);
	  TQString key = TQString("%1/%2").arg(filename).arg(who);
	  if(DCCSendItems[key]){
	      /*
	       * don't add duplicates, this cuases real headaches
	       * for both us and the user.
	       * We can get these on repeated sends or old files,
	       * just renamed them, their finished anyways
               */
              TQString renamed;
	      dccItem *old = DCCSendItems.take(key);
	      int i;
	      for(i = 0; i <= (int) DCCSendItems.count()+1; i++){
		  renamed = TQString("%1 (sent %2)/%3").arg(filename).arg(i+1).arg(old->who());
		  if( DCCSendItems[renamed] == 0x0)
                      break;
	      }
	      old->changeFilename(TQString("%1 (sent %2)").arg(filename).arg(i+1));
              DCCSendItems.insert(renamed, it);
	  }
          DCCSendItems.insert(key, it);
      }
      else {
          kdDebug(5008) << "DCC SENT was unable to parse: " << str << endl;
      }
  }
  else if(str.find("DCC CHAT OFFERED", 0) != -1){ /*FOLD01*/
      TQRegExp rx("who: (.+) ip: (.+) port: (.+)");
      if(rx.search(str)){
          TQString who = rx.cap(1);
          TQString ip = rx.cap(2);
          TQString port = rx.cap(3);
          // setup dcc dialog
          displayMgr->show(mgr);
	  dccItem *it = mgr->mgr()->newChatItem(who, dccItem::dccGotOffer);
	  connect(it, TQT_SIGNAL(itemRenamed(dccItem *, TQString, TQString)),
		  this, TQT_SLOT(dccRenameDone(dccItem *, TQString, TQString)));
          it->setWhoPostfix("(" + ip + ")");
          DCCChatItems.insert(who, it);
      }
      else {
          kdDebug(5008) << "DCC CHAT SEND was unable to parse: " << str << endl;
      }
  }
  else if(str.find("DCC CHAT SEND", 0) != -1){ /*FOLD01*/
      TQRegExp rx("who: (.+)");
      if(rx.search(str)){
          TQString who = rx.cap(1);

          // setup dcc dialog
          displayMgr->show(mgr);
	  dccItem *it = mgr->mgr()->newChatItem(who, dccItem::dccSentOffer);
	  connect(it, TQT_SIGNAL(itemRenamed(dccItem *, TQString, TQString)),
		  this, TQT_SLOT(dccRenameDone(dccItem *, TQString, TQString)));
          DCCChatItems.insert(who, it);
      }
      else {
          kdDebug(5008) << "DCC CHAT SEND was unable to parse: " << str << endl;
      }
  }
  else if(str.find("DCC SEND terminated") != -1){ /*FOLD01*/
      TQRegExp rx("who: (.+) file: (.+) reason: (.*)");
      if(rx.search(str)){
          TQString who = rx.cap(1);
          TQString filename = rx.cap(2);
          TQString error = rx.cap(3);
          enum dccItem::dccStatus status = dccItem::dccDone;

	  if(error == "CLOSE"){
              status = dccItem::dccCancel;
	  }
          if(error != "OK"){
              status = dccItem::dccError;
              KPassivePopup::message(i18n("DCC SEND with %1 for %2 failed because of %3").arg(who).arg(filename).arg(error), mgr->mgr());
	  }
	  TQString key = TQString("%1/%2").arg(filename).arg(who);
          if(DCCSendItems[key]){
              kdDebug(5008) << "SendPercent: " << DCCSendItems[key]->getPercent() << endl;
              if((status == dccItem::dccDone) && (DCCSendItems[key]->getPercent() < 100))
                  status = dccItem::dccError;
              DCCSendItems[key]->changeStatus(status);
          }
      }
  }
  else if(str.find ("DCC GET terminated") != -1){ /*fold01*/
      kdDebug(5008) << "Term: " << str << endl;
      TQRegExp rx("who: (.+) file: (.+) reason: (.*)");
      if(rx.search(str)){
          TQString who = rx.cap(1);
          TQString filename = rx.cap(2);
          TQString error = rx.cap(3);
          enum dccItem::dccStatus status = dccItem::dccDone;

          if(error != "OK"){
              status = dccItem::dccError;
              KPassivePopup::message(i18n("DCC GET with %1 for %2 failed because of %3").arg(who).arg(filename).arg(error), mgr->mgr());
	  }
                    TQString key = TQString("%1/%2").arg(filename).arg(who);
          if(DCCGetItems[key]){
              kdDebug(5008) << "GetPercent: " << DCCGetItems[key]->getPercent() << endl;
              if((status == dccItem::dccDone) && (DCCGetItems[key]->getPercent() < 100))
                  status = dccItem::dccError;
              DCCGetItems[key]->changeStatus(status);
          }
      }
      else {
          kdDebug(5008) << "DCC Get term failed to parse: " << str << endl;
      }
  }
  else if(str.find("DCC GET resumed") != -1){ /*fold01*/
      TQRegExp rx("who: (.+) file: (.+)");
      if(rx.search(str)){
          TQString who = rx.cap(1);
	  TQString filename = rx.cap(2);
	  TQString key = TQString("%1/%2").arg(filename).arg(who);
	  if(DCCGetItems[key]){
	      dccItem *it = DCCGetItems[key];
	      kdDebug(5008) << "Got DCC GET resumed message..." << it->file() << endl;
	      if(it->status() == dccItem::dccWaitOnResume)
                  dccConnectClicked(it);
              it->changeStatus(dccItem::dccResumed);
          }
      }
  }
  else if(str.find("DCC SEND resumed") != -1){ /*fold01*/
      TQRegExp rx("who: (.+) file: (.+)");
      if(rx.search(str)){
          TQString who = rx.cap(1);
	  TQString filename = rx.cap(2);
	  TQString key = TQString("%1/%2").arg(filename).arg(who);
          if(DCCSendItems[key]){
              DCCSendItems[key]->changeStatus(dccItem::dccResumed);
          }
      }
  }
  else if(str.find("DCC GET established") != -1){ /*fold01*/
      TQRegExp rx("who: (.+) file: (.+)");
      if(rx.search(str)){
          TQString who = rx.cap(1);
	  TQString filename = rx.cap(2);
	  TQString key = TQString("%1/%2").arg(filename).arg(who);
          if(DCCGetItems[key]){
              DCCGetItems[key]->changeStatus(dccItem::dccRecving);
          }
      }
  }
  else if(str.find("DCC SEND established") != -1){ /*fold01*/
      TQRegExp rx("who: (.+) file: (.+) ip: (\\S+)");
      if(rx.search(str)){
          TQString who = rx.cap(1);
          TQString filename = rx.cap(2);
	  TQString ip = rx.cap(3);
	  TQString key = TQString("%1/%2").arg(filename).arg(who);
          if(DCCSendItems[key]){
              DCCSendItems[key]->setWhoPostfix("(" + ip + ")");
              DCCSendItems[key]->changeStatus(dccItem::dccSending);
          }
      }
  }
  else if(str.find("DCC CHAT established") != -1){ /*FOLD01*/
      TQRegExp rx("who: (.+)");
      if(rx.search(str)){
          TQString who = rx.cap(1);
          if(DCCChatItems[who]){
	      DCCChatItems[who]->changeStatus(dccItem::dccOpen);
              proc->new_toplevel(KSircChannel(proc->serverName(), TQString("=") + who.lower()));
          }
      }
  }
  else if(str.find("DCC CHAT inbound established") != -1){ /*FOLD01*/
      TQRegExp rx("who: (.+) ip: (.+)");
      if(rx.search(str)){
          TQString who = rx.cap(1);
          TQString ip = rx.cap(2);
          if(DCCChatItems[who]){
              DCCChatItems[who]->setWhoPostfix("(" + ip + ")");
	      DCCChatItems[who]->changeStatus(dccItem::dccOpen);
	      proc->new_toplevel(KSircChannel(proc->serverName(), TQString("=") + who.lower()));
          }
      }
  }
  else if(str.find("DCC GET failed") != -1){ /*fold01*/
      TQRegExp rx("who: (.+) file: (.+) reason: (.*)");
      if(rx.search(str)){
          TQString who = rx.cap(1);
          TQString filename = rx.cap(2);
	  TQString error = rx.cap(3);
	  TQString key = TQString("%1/%2").arg(filename).arg(who);
          if(DCCGetItems[key]){
              DCCGetItems[key]->changeStatus(dccItem::dccError);
          }
          KPassivePopup::message(i18n("DCC Get with %1 for %2 failed because of %3").arg(who).arg(filename).arg(error), mgr->mgr());
      }
  }
  else if(str.find("DCC CHAT failed") != -1){ /*FOLD01*/
      TQRegExp rx("who: (.+) reason: (.*)");
      if(rx.search(str)){
          TQString who = rx.cap(1);
          TQString error = rx.cap(2);
          if(DCCChatItems[who]){
              DCCChatItems[who]->changeStatus(dccItem::dccError);
          }
          KPassivePopup::message(i18n("DCC Chat with %1 failed because of %2").arg(who).arg(error), mgr->mgr());
      }
  }
  else if(str.find("DCC CHAT renamed") != -1){ /*FOLD01*/
      TQRegExp rx("who: (.+) to: (.+)");
      if(rx.search(str)){
	  TQString oldwho = rx.cap(1);
	  TQString newwho = rx.cap(2);

          TQString oldwin = "=" + oldwho;
	  if(proc->getWindowList().find(oldwin)){
	      proc->getWindowList().find(oldwin)->control_message(CHANGE_CHANNEL,TQString("=" +newwho).lower());
	  }
      }
  }
  else if(str.find("Closing DCC GET") != -1){ /*fold01*/
      TQRegExp rx("who: (.+) file: (.+)");
      if(rx.search(str)){
          TQString who = rx.cap(1);
	  TQString filename = rx.cap(2);
	  TQString key = TQString("%1/%2").arg(filename).arg(who);
          if(DCCGetItems[key]){
              DCCGetItems[key]->changeStatus(dccItem::dccCancel);
          }
      }
  }
//  else if(str.find("Closing DCC SEND") != -1){ /*FOLD01*/
//      TQRegExp rx("who: (.+) file: (.+)");
//      if(rx.search(str)){
//          TQString who = rx.cap(1);
//	  TQString filename = rx.cap(2);
//	  TQString key = TQString("%1/%2").arg(filename).arg(who);
//          if(DCCSendItems[key]){
//              DCCSendItems[key]->changeStatus(dccItem::dccCancel);
//          }
//      }
//  }
  else if(str.find("Closing DCC CHAT") != -1){ /*fold01*/
      TQRegExp rx("who: (.+)");
      if(rx.search(str)){
          TQString who = rx.cap(1);
          if(DCCChatItems[who]){
              DCCChatItems[who]->changeStatus(dccItem::dccDone);
          }
      }
  }
  else if(str.find("No DCC SEND") != -1){ /*fold01*/
      TQRegExp rx("who: (.+) file: (.+)");
      if(rx.search(str)){
          TQString who = rx.cap(1);
	  TQString filename = rx.cap(2);

	  //TQString key = TQString("%1/%2").arg(filename).arg(who);

          TQPtrList<dccItem> toDel;
          TQDict<dccItem> new_list;
          TQDictIterator<dccItem> it( DCCSendItems );
          for(;it.current(); ++it){
              if((it.current()->who() == who) &&
                 (it.current()->file() == filename)
                ){
                  toDel.append(it.current());
              }
              else {
                  new_list.insert(it.currentKey(), it.current());
              }
          }
          DCCSendItems = new_list;
          toDel.setAutoDelete(true);
          toDel.clear();
      }
  }
  else if(str.find("No DCC GET") != -1){ /*fold01*/
      TQRegExp rx("who: (.+) file: (.+)");
      if(rx.search(str)){
          TQString who = rx.cap(1);
          TQString filename = rx.cap(2);

          TQPtrList<dccItem> toDel;
          TQDict<dccItem> new_list;
          TQDictIterator<dccItem> it( DCCGetItems );
          for(;it.current(); ++it){
              if((it.current()->who() == who) &&
                 (it.current()->file() == filename)
                ){
                  toDel.append(it.current());
              }
              else {
                  new_list.insert(it.currentKey(), it.current());
              }
          }
          DCCGetItems = new_list;
          toDel.setAutoDelete(true);
          toDel.clear();
      }
  }
  else if(str.find("No DCC CHAT") != -1){ /*fold01*/
      TQRegExp rx("who: (.+)");
      if(rx.search(str)){
          TQString who = rx.cap(1);

          TQPtrList<dccItem> toDel;
          TQDict<dccItem> new_list;
          TQDictIterator<dccItem> it( DCCChatItems );
          for(;it.current(); ++it){
              if(it.current()->who() == who){
                  toDel.append(it.current());
              }
              else {
                  new_list.insert(it.currentKey(), it.current());
              }
          }
          DCCChatItems = new_list;
          toDel.setAutoDelete(true);
          toDel.clear();
      }
  }
  else{ /*FOLD01*/
    proc->getWindowList()["!default"]->sirc_receive(str);
  }

}

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

void KSircIODCC::cancelTransfer(TQString filename)
{
    //if(DlgList[filename]){
    //emit outputLine(DCCStatus[filename]->cancelMessage.ascii());
    //delete DlgList[filename];
    //DlgList.remove(filename);
    //delete DCCStatus[filename];
    //DCCStatus.remove(filename);
  //}
}

void KSircIODCC::getFile()
{
    /*
    TQString text = pending->fileListing()->text(pending->fileListing()->currentItem());
  int pos = text.find(" ", 0);
  TQString nick = text.mid(0, pos);
  pos = text.find(" ", pos+1) + 1;
  TQString filename = text.mid(pos, text.length() - pos);
  //if(DlgList[filename]->isVisible() == FALSE)
  //  DlgList[filename]->show();
  TQString command = "/dcc get " + nick + " " + filename + "\n";
  emit outputLine(command.ascii());
  for(uint i = 0; i < pending->fileListing()->count(); i++)
    if(TQString(pending->fileListing()->text(i)) == (nick + " offered " + filename))
      pending->fileListing()->removeItem(i);

  if(pending->fileListing()->count() == 0)
  pending->hide();
  */
}

void KSircIODCC::forgetFile()
{
    /*
  TQString text = pending->fileListing()->text(pending->fileListing()->currentItem());
  int pos = text.find(" ", 0);
  TQString nick = text.mid(0, pos);
  pos = text.find(" ", pos+1) + 1;
  TQString filename = text.mid(pos, text.length() - pos);
  TQString command = "/dcc close get " + nick + " " + filename + "\n";
  emit outputLine(command.ascii());
  for(uint i = 0; i < pending->fileListing()->count(); i++)
    if(TQString(pending->fileListing()->text(i)) == (nick + " offered " + filename))
      pending->fileListing()->removeItem(i);

  if(pending->fileListing()->count() == 0)
  pending->hide();
  */

}

filterRuleList *KSircIODCC::defaultRules()
{

//  filterRule *fr;
  filterRuleList *frl = new filterRuleList();
  frl->setAutoDelete(TRUE);
  /*
  fr = new filterRule();
  fr->desc = "Capture DCC IO Messages";
  fr->search = "^\\*D\\*";
  fr->from = "^";
  fr->to = "~!dcc~";
  frl->append(fr);
  */
  return frl;

}

void KSircIODCC::dccConnectClicked(dccItem *it)
{
    TQString str;
    kdDebug(5008) << "Got connect click on " << it->who() << " " << it->type() << endl;
    switch(it->type()){
    case dccItem::dccGet:
        str = "/dcc get " + it->who() + " " + it->file() + "\n";
        emit outputLine(str.ascii());
        break;
    case dccItem::dccChat:
        str = "/dcc chat " + it->who() + "\n";
        emit outputLine(str.ascii());
        break;
    default:
        break;
    }

}
void KSircIODCC::dccResumeClicked(dccItem *it)
{
    TQString str;
    kdDebug(5008) << "Got resume click on " << it->who() << " " << it->type() << endl;
    switch(it->type()){
    case dccItem::dccGet:
	it->changeStatus(dccItem::dccWaitOnResume);
        str = "/resume " + it->who() + " " + it->file() + "\n";
        emit outputLine(str.ascii());
        break;
    default:
        break;
    }

}
void KSircIODCC::dccRenameClicked(dccItem *it)
{
    it->doRename();
}
void KSircIODCC::dccAbortClicked(dccItem *it)
{
    TQString str;
    switch(it->status()){
    case dccItem::dccDone:
    case dccItem::dccCancel:
    case dccItem::dccError:
        switch(it->type()) {
	case dccItem::dccGet:
            DCCGetItems.remove(TQString("%1/%2").arg(it->file()).arg(it->who()));
            break;
        case dccItem::dccSend:
            DCCSendItems.remove(TQString("%1/%2").arg(it->file()).arg(it->who()));
            break;
        case dccItem::dccChat:
            DCCChatItems.remove(it->who());
            break;
        }
        delete it;
        break;
    default:
        switch(it->type()) {
        case dccItem::dccGet:
            str = "/dcc close get " + it->who() + " " + it->file() + "\n";
            emit outputLine(str.ascii());
            break;
        case dccItem::dccSend:
            str = "/dcc close send " + it->who() + " " + it->file() + "\n";
            emit outputLine(str.ascii());
            break;
        case dccItem::dccChat:
            str = "/dcc close chat " + it->who() + "\n";
            emit outputLine(str.ascii());
            break;
        }
    }
}

void KSircIODCC::dccRenameDone(dccItem *it, TQString oldWho, TQString oldFile)
{
    if(it->type() == dccItem::dccGet){
	TQString str = TQString("/dcc rename %1 %2 %3\n").arg(oldWho).arg(oldFile).arg(it->file());
	TQString key = TQString("%1/%2").arg(oldFile).arg(oldWho);
	if(DCCGetItems[key]){
            DCCGetItems.take(key);
	    TQString newkey = TQString("%1/%2").arg(it->file()).arg(it->who());
            DCCGetItems.insert(newkey, it);
	}
	emit outputLine(str.ascii());
    }
    else if(it->type() == dccItem::dccChat){
	if(DCCChatItems[oldWho]){
	    DCCChatItems.take(oldWho);
	    DCCChatItems.insert(it->who(), it);
	}
	TQString str = TQString("/dcc rchat %1 %2\n").arg(oldWho).arg(it->who());
	emit outputLine(str.ascii());

    }
}

void KSircIODCC::showMgr()
{
    displayMgr->show(mgr);
}

#include "ioDCC.moc"