;IRcap8 44374ba207a7715ae0d314253ca802ae
on 1:load:dccs

Alias DCCs {
  if (!$s(1)) { .hmake -s tool | .hload tool "lng\ $+ %idioma $+ \tool.lnh" }
  var %a = $readini ircap.ini ww dccs
  %dccs.skla = 560 220
  guiwin @dccs %a $s(dcmon)

  %dccs.w = $window(@dccs).w | %dccs.h = $window(@dccs).h

  %dccs.pñ1 = 24 56 1 dccs.pest $s(1) $+  $+ $s(2) $+  $+  $s(3) $+   $+  $s(4) $+  $+ $s(5) $+  $+ $s(6)
  dccs.pest 1

  window -wa @dccs

  .timerDCCstotal -o 0 4 dccs.total | dccs.total
  sss wina
}
alias -l S return $hget(tool,$1)

alias dccs.pest {
  cuag @dccs 14 56 $calc(%dccs.w - 30) $calc(%dccs.h - 72) $gettok(%gui.cc,1,32) | pestana @dccs dccs.pñ1
  .timerDCCSpest off | var %y = $calc(%dccs.h - 46)
  if $1 == 1 {
    %dccs.ls1 = 24 78 $calc(%dccs.w - 65) $int($calc((%dccs.h - 130) / 14)) 1 0 dccsn @dccs1 0,140,178,238,330
    window -c @dccs1 | window -hl @dccs1
    dccs.getsend | .timerDCCSpest -o 0 4 dccs.getsend
    %dccs.tx = 
    %dccs.bt = 124 %y 60 dccs.b1_can $s(7) |202 %y 94 dccs.b1_cane $s(8) |314 %y 108 dccs.b1_canr $s(9) |440 %y 80 dccs.b1_abre $s(10)
    guitgrid @dccs %dccs.ls1 $s(11)  $s(12)  $s(13)  $s(14)  $s(15)
  }
  if $1 == 2 {
    %dccs.ls1 = 24 78 $calc(%dccs.w - 65) $int($calc((%dccs.h - 130) / 14)) 1 0 dccsabre @dccs1 0,120,190
    window -c @dccs1 | window -hl @dccs1
    dccs.log R
    %dccs.tx = 
    %dccs.bt = 124 %y 54 dccs.b2_abre $s(18) |196 %y 54 dccs.b2_borra $s(19) |268 %y 60 dccs.b2_avp $s(20) |346 %y 70 dccs.b2_env $s(21)
    guitgrid @dccs %dccs.ls1 $s(22)  $s(23)  $s(24)
  }
  if $1 == 3 {
    %dccs.ls1 = 24 78 $calc(%dccs.w - 65) $int($calc((%dccs.h - 130) / 14)) 1 0 dccsabre @dccs1 0,120,190
    window -c @dccs1 | window -hl @dccs1
    dccs.log E
    %dccs.tx = 
    %dccs.bt = 124 %y 54 dccs.b2_abre $s(18) |196 %y 54 dccs.b2_borra $s(19) |268 %y 60 dccs.b2_avp $s(20) |346 %y 70 dccs.b2_env $s(21) |434 %y 90 dccs.b2_renv $s(25)
    guitgrid @dccs %dccs.ls1 $s(26)  $s(27)  $s(24)
  }
  if $1 == 4 {
    %dccs.ls1 = 24 78 $calc(%dccs.w - 65) $int($calc((%dccs.h - 130) / 14)) 1 0 dccsabre @dccs1 0,120,190
    window -c @dccs1 | window -hl @dccs1
    dccs.log P
    %dccs.tx = 
    %dccs.bt = 124 %y 54 dccs.b2_abre $s(18) |196 %y 54 dccs.b2_borra $s(19) |268 %y 60 dccs.b2_avp $s(20) |346 %y 70 dccs.b2_env $s(21) |434 %y 90 dccs.b2_pide $s(28)
    guitgrid @dccs %dccs.ls1 $s(29)  $s(23)  $s(24)
  }
  if $1 == 5 {
    %dccs.ls1 = 170 72 $calc(%dccs.w - 215) $int($calc((%dccs.h - 130) / 14)) 1 0 dccsn @dccs1 0,22,100, $+ $calc(%dccs.w - 276)
    window -c @dccs1 | window -hl @dccs1
    dccs.cola | .timerDCCSpest -oi 0 3 dccs.cola
    %dccs.tx = 130 72 26 fsn $s(29) |130 90 26 fsnu $s(30) |130 118 26 dcque.max $s(31) |130 138 26 dcque.umax $s(32)
    %dccs.bt = 170 %y 80 dccs.b5_b $s(33) |270 %y 80 dccs.b5_to $s(34) |435 %y 86 dccs.b5_abre $s(10) |372 %y 10 dccs.b5_su ^|402 %y 10 dccs.b5_ba v
  }
  if $1 == 6 {
    unset %dccs.ls1
    cuagr @dccs 30 64 280 86 | cuagr @dccs 316 64 210 86
    %dccs.ffe = $readini %perfil dccstats send
    %dccs.ffr = $readini %perfil dccstats get
    %dccs.ffeb = $readini %perfil dccstats bsend | %dccs.ffeb = $round($calc(%dccs.ffeb / 1048576),1)
    %dccs.ffrb = $readini %perfil dccstats bget | %dccs.ffrb = $round($calc(%dccs.ffrb / 1048576),1)
    %dccs.fff = $readini %perfil dccstats fecha
    %dccs.ffre = $readini %perfil dccstats record | %dccs.ffre = $round($calc(%dccs.ffre / 1024),1) Kb/s
    %dccs.ffn = $readini %perfil dccstats campeon
    %dccs.tx = 140 74 50 dccs.ffe $s(35) |140 94 50 dccs.ffr $s(36) |240 74 60 dccs.ffeb Mbytes|240 94 60 dccs.ffrb Mbytes|116 124 74 dccs.fff $s(23) |430 74 80 dccs.ffre $s(37) |430 99 80 dccs.ffn $s(38)
    %dccs.bt = 236 124 50 dccs.b6_1 $s(39) |446 124 50 dccs.b6_2 $s(39)
  }
  %dccs.bt = 24 %y 70 F3_setdcc $s(40) $chr(124) $+ %dccs.bt
  guidibtx @dccs %dccs.tx | guidibbt @dccs %dccs.bt | drawline @dccs
}

alias onedit.@dccs {
}

on 1:CLOSE:@DCCs: dccs.cierra
alias dccs.cierra unset %dccs.* | .timerDCCS* off | window -c @dccs1 | window -c @dccs | .timer 1 2 tolhfree | .unload -rs g-dccs.mrc

alias redim.@dccs {
  guiwin @dccs x x $window(@dccs).w $window(@dccs).h $s(dcmon)
  %dccs.w = $window(@dccs).w | %dccs.h = $window(@dccs).h
  dccs.pest $gettok(%dccs.pñ1,3,32)
  if $1 == fin { dccs.total | wmueve2 @dccs }
}

alias DCCS.getsend {
  var %se = $sline(@dccs1,1).ln
  clear @dccs1
  aline @dccs1  $s(16) 
  var %i = 1 | :L1 | var %a = $get(%i) | if %a != $null {
    var %i.bb = $get(%i).pc | %i.bb = $int($calc(%i.bb / 5)) | var %i.bbb = 9 $+ $str(l,%i.bb) $+ 14 $+ $str(l,$calc(20 - %i.bb)) $+ 
    var %est = $gettok($duration($calc(($get(%i).size - $get(%i).rcvd) / $get(%i).cps)),1-2,32) | if (%est == $null) { var %est = esperando... }
    aline @dccs1 %i.bbb %a $chr(8) $get(%i).pc $+ % $chr(8) $round($calc($get(%i).cps / 1024),1) $+ Kb/s $chr(8) %est $chr(8)  $+ $get(%i).file ( $bytes($get(%i).rcvd,M) $+ / $+ $bytes($get(%i).size,M) Mb)
    inc %i | goto L1
  }
  aline @dccs1  $s(17) 
  var %i = 1 | :L2 | var %a = $send(%i) | if %a != $null {
    var %i.bb = $send(%i).pc | %i.bb = $int($calc(%i.bb / 5)) | var %i.bbb = 9 $+ $str(l,%i.bb) $+ 14 $+ $str(l,$calc(20 - %i.bb)) $+ 
    var %est = $gettok($duration($calc(($send(%i).size - $send(%i).sent) / $send(%i).cps)),1-2,32) | if (%est == $null) { var %est = esperando... }
    aline @dccs1 %i.bbb %a $chr(8) $send(%i).pc $+ % $chr(8) $round($calc($send(%i).cps / 1024),1) $+ Kb/s $chr(8) %est $chr(8)  $+ $send(%i).file ( $bytes($send(%i).sent,M) $+ / $+ $bytes($send(%i).size,M) Mb)
    inc %i | goto L2
  }
  if (%se) { sline @dccs1 %se }
  guilista @dccs dccs.ls1
}

alias DCCS.total {
  var %tg = 0 | var %i = $get(0) | while %i > 0 { %tg = $calc(%tg + $get(%i).cps) | dec %i }
  var %ts = 0 | var %i = $send(0) | while %i > 0 { %ts = $calc(%ts + $send(%i).cps) | dec %i }
  titula @DCCS $s(dcmon) : $s(16) ( $+ $get(0) $+ ) $round($calc(%tg / 1024),1) Kb/s · · $s(17) ( $+ $send(0) $+ ) $round($calc(%ts / 1024),1) Kb/s · · $s(5) $+ : $numtok(%dcque,231) $+ / $+ %dcque.max $iif(($send(0) >= %fsn) ,· · $s(44) $+ : $gettok($sendstat,3-9,32))
  drawline @dccs
}

alias DCCS.cola {
  alias setupdccola {
    var %s = $sline(@dccs1,1) , %i = 1 | clear @dccs1
    while ($line(@dccola,%i)) {
      var %l = $ifmatch
      aline @dccs1 %i $+ $chr(8) $+ $gettok(%l,1,32) $+ $chr(8) $+  $+ $nopath($gettok(%l,3-,32)) ( $nofile($gettok(%l,3-,32)) ) $+ $chr(8) $+ $replace($duration($calc($ctime - $gettok(%l,2,32))),mins,m,min,m,hrs,h,hr,h,secs,s,sec,s)
      inc %i
    }
    if (%s) sline @dccs1 %s
    guilista @dccs dccs.ls1
  }
}

alias DCCS.log {
  var %dc.ini = <recibidos> | if $1 == E { var %dc.ini = <enviados> } | if $1 == P { var %dc.ini = <pendientes> }
  clear @dccs1 | var %i = 1 | :L1
  var %a = $readini s/log/fserve.log %dc.ini %i | if %a == $null { guilista @dccs dccs.ls1 | return }
  aline @dccs1 $gettok(%a,1,32) - $gettok(%a,2,32) $chr(8) $gettok(%a,3,32) $chr(8)  $+ $nopath($gettok(%a,5-99,32))  ( $+ $nofile($gettok(%a,5-99,32)) $+ ) $int($calc($gettok(%a,4,32) / 1024)) kb
  inc %i | goto L1
}


alias DCCS.B1 {
  var %a = $dccsn
  goto $1
  :can | if (!%a) return | if SEND isin %a { close -s $+ $gettok(%a,2,32) } | else { close -g $+ $gettok(%a,2,32) } | goto L1
  :abre | if (!%a) return | var %c = $gettok(%a,2,32) | if SEND isin %a { dccs.b1b " $+ $send(%c).path $+ $send(%c).file $+ " } | else { dccs.b1b " $+ $send(%c).path $+ $get(%c).file $+ " } | return
  :cane | close -s | goto L1
  :canr | close -g
  :L1 | ggguilista reset @dccs dccs.ls1 | dccs.getsend
}
alias dccs.b1b if ($right($1-,4) isin .mp3 .wav .mid .wma .ogg) { zplay - $1- } | else rrun $1-

alias DCCSn {
  if $slinea(%dccs.ls1) == $null return
  var %a = $slinean(%dccs.ls1)
  if ($calc(%a - 1) <= $get(0)) && (%a > 1) { return GET $calc(%a - 1) }
  if (%a > $calc($get(0)) + 2)  { var %c = $calc(%a - 2 - $get(0)) | if %c > 0 return SEND %c }
}

alias DCCS.B5 {
  var %a = $slinean(%dccs.ls1)
  goto $1
  :b | var %a = $sline(@dccs1,1).ln | if (%a) { dline @dccola %a | sline -r @dccs1 } | goto f
  :to | window -c @dccola | goto f
  :su | var %a = $sline(@dccs1,1).ln | if %a > 1 { var %b = $line(@dccola,%a) | dline @dccola %a | iline @dccola $calc(%a - 1) %b | sline @dccs1 $calc(%a - 1) } | goto f
  :ba | var %a = $sline(@dccs1,1).ln | if %a < $line(@dccs1,0) { var %b = $line(@dccola,%a) | dline @dccola %a | iline @dccola $calc(%a + 1) %b | sline @dccs1 $calc(%a + 1) } | goto f
  :abre | var %a = $sline(@dccs1,1).ln | if (%a) { dccs.b1b $gettok($line(@dccola,%a),3-,32) } | return
  :f | dccs.cola | drawline @dccs | return
}

alias DCCS.B2 {
  if $slinea(%dccs.ls1) == $null return
  var %dc.ini = <recibidos> | var %a = $gettok(%dccs.pñ1,3,32) | if %a == 3 { var %dc.ini = <enviados> } | if %a == 4 { var %dc.ini = <pendientes> }
  var %a = $slinean(%dccs.ls1)
  var %b = $readini s/log/fserve.log %dc.ini %a
  goto $1
  :abre | dccs.b1b $gettok(%b,5-99,32) | return
  :avp | run %avp $gettok(%b,5-99,32) | return
  :borra | smenu dccs.b2b 120 $s(41)  $s(42)  $s(43) | return
  :env | dcc send $$?=" $s(21) " $gettok(%b,5-99,32) | return
  :renv | dcc send $gettok(%b,3,32) $gettok(%b,5-99,32) | return
  :pide | msg $comcha($gettok(%b,3,32)) ! $+ $gettok(%b,3,32) $nopath($gettok(%b,5-99,32)) | return
}
alias DCCS.B2B {
  var %dc.ini = <recibidos> | var %a = $gettok(%dccs.pñ1,3,32) | if %a == 3 { var %dc.ini = <enviados> } | if %a == 4 { var %dc.ini = <pendientes> }
  goto $1
  :1 | dccsborra %dc.ini $slinean(%dccs.ls1) | dccs.pest $gettok(%dccs.pñ1,3,32) | return
  :2 | .timer -m 1 200 remove " $+ $gettok($readini s/log/fserve.log %dc.ini $slinean(%dccs.ls1),5-99,32) $+ " | dccsborra %dc.ini $slinean(%dccs.ls1) | dccs.pest $gettok(%dccs.pñ1,3,32) | return
  :3 | remini s/log/fserve.log %dc.ini | dccs.pest $gettok(%dccs.pñ1,3,32) | return
}

alias DCCSborra {
  var %i = $2 | :L1
  var %s = $readini s/log/fserve.log $1 $calc(%i + 1) | if %s == $null { remini s/log/fserve.log $1 %i | return }
  writeini s/log/fserve.log $1 %i %s | inc %i | goto L1
}

alias DCCS.B6 {
  goto $1
  :1 | remini %perfil dccstats send
  remini %perfil dccstats get
  remini %perfil dccstats bsend
  remini %perfil dccstats bget
  writeini %perfil dccstats fecha $date
  goto 3
  :2 | remini %perfil dccstats record
  remini %perfil dccstats campeon
  :3 | dccs.pest $gettok(%dccs.pñ1,3,32)
}

alias DCCSabre if $1 == 2 { dccs.b2 abre }

on 1:FILERCVD:*: if $gettok(%dccs.pñ1,3,32) == 2 dccs.pest 2
on 1:FILESENT:*: if $gettok(%dccs.pñ1,3,32) == 3 dccs.pest 3
on 1:GETFAIL:*: if $gettok(%dccs.pñ1,3,32) == 4 dccs.pest 4

;EOF-dt
