aIRC — File Browser
aIRCv0.8.69 / aIRCv0.8.69 / script / addons.mrc
addons.mrc — 13.24 KB — Download this file
;/**********************************************************************
; *
; * aIRC
; * Addons
; *
; **********************************************************************/
alias addons {
_dialog -m addons addons
_addons.load
}
alias _addons.load {
if ($dialog(addons) == $null) { return }
did -r addons 1010,1011
return $findfile($_fixdir($_addonsdir),*.aan,0,_addons.loadlist $1-)
}
_addons.onload {
var %ids = $_getsetup(script,_addons),%i = $numtok(%ids,32)
}
alias _addons.loadlist {
var %file = $1-,%aname,%version,%tmp1,%tmp2
if ($isfile(%file) == $false) { return }
%aname = $_readini(%file,addon,name)
if ($_readini(%file,addon,version) != $null) { %version = $ifmatch }
%tmp1 = %aname %version
%tmp2 = %tmp1 $+ ? $+ %file
if (ERR* !iswm $_checkaddon(%file,s)) {
did -a addons 1010 %tmp1
did -a addons 1011 %tmp2
}
}
alias _checkaddon {
var %file = $1,%aname,%aver,%id,%win = @__checkaddon,%mfiles,%imf = 0,%tmpfile,%dir = $nofile(%file),%i,%type
if ($isfile(%file) == $false) { return ERR_NOFILE }
%aname = $_readini(%file,addon,name)
%aver = $_readini(%file,addon,aircver)
%id = $_readini(%file,addon,id)
%type = $_readini(%file,addon,type)
if ($_readini(%file,scriptfiles,1) == $null) || (%aname == $null) || ($_not($_isint(%aver))) || (%id == $null) {
close -@ %win
if (s isin $2) { error.a Invalid addon: $"(%file) - File corrupted }
return ERR_CORRUPT
}
if (%aver > $_aircvernum) {
close -@ %win
if (s isin $2) { error.a Invalid addon: $"(%file) - It's for aIRC $_vernum2ver(%aver) }
return ERR_NOFUTURE
}
if (f isin $2) {
%tmpfile = $_readini(%file,scriptfiles,%i)
if (%tmpfile != $null) {
%tmpfile = %dir $+ $_readini(%file,scriptfiles,%i)
if ($isfile(%tmpfile) == $false) {
inc %imf
%mfiles = %mfiles $nopath(%tmpfile)
}
}
%i = 1
while ($_readini(%file,scriptfiles,%i) != $null) {
%tmpfile = %dir $+ $ifmatch
if ($isfile(%tmpfile) == $false) {
inc %imf
%mfiles = %mfiles $nopath(%tmpfile)
}
inc %i
}
%i = 1
while ($_readini(%file,miscfiles,%i) != $null) {
%tmpfile = %dir $+ $ifmatch
if ($isfile(%tmpfile) == $false) {
inc %imf
%mfiles = %mfiles $nopath(%tmpfile)
}
inc %i
}
}
if (%imf) {
if (s isin $2) { error.a Invalid addon: $"(%file) - Missing files: $+ %mfiles }
return ERR_NOFILES %mfiles
}
return 0
}
alias _addons.refresh {
if ($dialog(addons) == $null) {
unset %c.addons.*
return
}
if ($script(0) != %c.addons.script) || ($alias(0) != %c.addons.alias) {
_addons.act
}
%c.addons.script = $script(0)
%c.addons.alias = $alias(0)
.timer -o 1 1 _addons.refresh
}
alias _addons.fixfile {
var %dir = $nofile($1-),%file = $nopath($1-)
if (?:\* !iswm %dir) { %dir = addons\ $+ %dir }
%dir = $_fixdir(%dir)
if (%file == $null) || ((*.* iswm %file) && (*.aan !iswm %file)) { return }
if (*.aan !iswm %file) { %file = %file $+ .aan }
while (.. isin %file) { %file = $replace(%file,..,.) }
return $findfile(%dir,%file,1)
}
alias _addons.install {
var %dir,%file = $_addons.fixfile($1-),%"file",%tmpfile,%id,%i
if (%file == $null) { return 1 }
%dir = $nofile(%file)
%id = $_readini(%file,addon,id)
%"file" = $"(%file)
if (ERR* iswm $_checkaddon(%file,sf)) { return }
if ($istok($_getsetup(script,_addons),%id,32)) {
error.a Addon already installed: $"($nopath(%file))
return
}
%i = 1
while ($_readini(%file,scriptfiles,%i) != $null) {
_loadremotefile +er %dir $+ $ifmatch
inc %i
}
_setsetup script _addons $sorttok($addtok($_getsetup(script,_addons),%id,32),32)
_addons.act
if ($dialog(_cpanel)) {
dialog -x _cpanel
cpanel
if ($dialog(addons)) { dialog -v addons }
}
_addons.winhookhelp 1 %file
if ($_readini(%file,addon,onload) != $null) { $ifmatch }
}
; /_addons.winhookhelp 1|0 file
; 1=add 0=del
alias _addons.winhookhelp {
var %com = $1,%file = $2-,%i,%n,%tmp,%helpfile,%mmm,%x,%y,%af,%z
%i = 1
while ($_readini(%file,windows,%i) != $null) {
tokenize 32 $ifmatch
if (@* iswm $1) && (@* iswm $2) && ($3- == $null) { $iif(%com,_window.menu.add,_window.menu.del) $1-2 }
inc %i
}
%i = 1
%n = $ini(%file,hooks,0)
while (%i <= %n) {
%tmp = $ini(%file,hooks,%i)
tokenize 32 $_readini(%file,hooks,%tmp)
if ($remove(%tmp,_) isalnum) && ($numtok($1-,32) == 1) { $iif(%com,_hook.add,_hook.del) %tmp $1 }
inc %i
}
%helpfile = $_readini(%file,addon,helpfile)
if (%helpfile != $null) {
%helpfile = $nofile(%file) $+ / $+ %helpfile
%helpfile = $_fixfilename(%helpfile,em)
if (%helpfile != $null) {
if (%com) { _setsetup help helpfiles $addtok($_getsetup(help,helpfiles),%helpfile,$asc(*)) }
else { _setsetup help helpfiles $remtok($_getsetup(help,helpfiles),%helpfile,$asc(*)) }
}
}
}
alias _addons.uninstall {
var %dir,%file = $_addons.fixfile($1-),%"file",%tmpfile,%id,%tmp,%i
if (%file == $null) { return 1 }
%dir = $nofile(%file)
%id = $_readini(%file,addon,id)
%"file" = $"(%file)
if (ERR* iswm $_checkaddon(%file,s)) { return }
if ($istok($_getsetup(script,_addons),%id,32) == $false) {
error.a Addon not installed: $"($nopath(%file))
return
}
_dummy
if ($_readini(%file,unload,unload) != $null) {
$ifmatch
if ($result) { return }
}
if ($_readini(%file,unload,variables) != $null) { unset $ifmatch }
if ($_readini(%file,unload,dialogs) != $null) { _closematchingdialogs $ifmatch }
if ($_readini(%file,unload,windows) != $null) { _closematchingwindows $ifmatch }
if ($_readini(%file,unload,sockets) != $null) { _closematchingsockets $ifmatch }
if ($_readini(%file,unload,timers) != $null) { _closematchingtimers $ifmatch }
%i = 1
while ($_readini(%file,scriptfiles,%i) != $null) {
unload -rs " $+ %dir $+ $ifmatch $+ "
inc %i
}
_setsetup script _addons $sorttok($remtok($_getsetup(script,_addons),%id,32),32)
_addons.winhookhelp 0 %file
_addons.act
if ($dialog(_cpanel)) {
dialog -x _cpanel
cpanel
if ($dialog(addons)) { dialog -v addons }
}
}
alias _addons.act {
var %d = addons,%file = $gettok($did(%d,1011,$did(%d,1010,1).sel),-1,63),%id,%setup,%help,%aname,%version
if ($_not($dialog(%d))) { return }
if (%file != $null) {
%id = $_readini(%file,addon,id)
%setup = $_readini(%file,addon,setup)
%help = $_readini(%file,addon,help)
%aname = $_readini(%file,addon,name)
if ($_readini(%file,addon,version) != $null) { %version = $ifmatch }
if ($did(%d,2001).state) {
if (%id != $did(%d,2503)) {
did -o %d 2503 1 %id
did -r %d 2502
did -o %d 2501 1 Info: %aname %version
_dida %d 2502 Addon: $+ $chr(9) $+ %aname
if (%version != $null) { _dida %d 2502 Version: $+ $chr(9) $+ %version }
if ($_vernum2ver($_readini(%file,addon,aircver)) != $null) { _dida %d 2502 aIRC ver: $+ $chr(9) $+ $ifmatch }
if ($asctime($_readini(%file,addon,released)) != $null) { _dida %d 2502 Release: $+ $chr(9) $+ $ifmatch }
if ($_readini(%file,addon,author) != $null) { _dida %d 2502 Author: $+ $chr(9) $+ $ifmatch }
if ($_readini(%file,addon,www) != $null) { _dida %d 2502 WWW: $+ $chr(9) $+ $ifmatch }
if ($_readini(%file,addon,mail) != $null) { _dida %d 2502 email: $+ $chr(9) $+ $ifmatch }
if ($ini(%file,desc)) {
did -a %d 2502 $crlf
_dialog.loadbufsection desc %d 2502 %file
did -u %d 2502
did -c %d 2502 1
}
_dida %d 2502
}
}
else { did -r %d 2501,2502,2503 }
}
if ($istok($_getsetup(script,_addons),%id,32)) {
did -e %d 2003
did -b %d 2002
did $iif(%setup != $null,-e,-b) %d 2004
did $iif(%help != $null,-e,-b) %d 2005
}
elseif (%file != $null) {
did -b %d 2003,2004,2005
did -e %d 2002
}
else { did -b %d 2002,2003,2004,2005 }
}
dialog addons {
size -1 -1 160 120
option dbu
title "Addons"
box "Addons",1,5 5 150 110
list 1010,10 15 100 100,sort
list 1011,10 15 100 120,hide sort
check "&Info",2001,115 15 33 15,push
button "&Install",2002,115 35 33 15
button "&Uninstall",2003,115 55 33 15
button "&Setup",2004,115 75 33 15
button "&Help",2005,115 95 33 15
box "Info",2501,160 5 150 110,hide
edit "",2502,165 15 140 95,hide multi read autohs autovs hsbar vsbar
edit "",2503,165 15 140 95,hide multi read autohs autovs hsbar vsbar
button "&OK",241,5 120 33 15,cancel hide
}
ON *:DIALOG:addons:*:*:{
var %d = $dname,%file = $gettok($did(%d,1011,$did(%d,1010,1).sel),-1,63),%id,%setup,%help
if ($devent == init) {
_mdx.init $_icofile(addons.ico)
_addons.refresh
}
elseif ($devent == sclick) {
if ($did == 2001) {
dialog -bs %d 5 -1 $iif($did(%d,2001).state,310,157) -1
did $iif($did(%d,2001).state,-v,-h) %d 2501,2502
}
elseif ($did == 2002) { .timer -o 1 0 _addons.install %file }
elseif ($did == 2003) { .timer -o 1 0 _addons.uninstall %file }
elseif ($did isnum 2004-2005) {
if ($isfile(%file)) {
if ($_readini(%file,addon,$iif($did == 2004,setup,help)) != $null) { .timer -o 1 0 $ifmatch }
}
}
if ($did == 241) { unset %c.addons.* }
}
_addons.act
}
alias _start.addons {
_window.menu.flush
_hook.flush
_hadd _aircjunk addonsnames
return $findfile($_fixdir($_addonsdir),*.aan,0,_start.addons.check $1-)
}
alias _start.addons.check {
var %file = $1-,%loaded,%aname,%aver,%id,%mfiles,%imf,%tmpfile,%dir = $nofile(%file),%i = 1,%n,%unload = 0,%tmpfile
%aname = $_readini(%file,addon,name)
%id = $_readini(%file,addon,id)
if ($istok($_getsetup(script,_addons),%id,32) == $false) || (ERR* iswm $_checkaddon(%file,sf)) {
%unload = 1
}
else { _hadd _aircjunk addonsnames $addtok($hget(_aircjunk,addonsnames),%aname,$asc(+)) }
while ($_readini(%file,scriptfiles,%i) != $null) {
%tmpfile = %dir $+ \ $+ $ifmatch
while (\\ isin %tmpfile) { %tmpfile = $replace(%tmpfile,\\,\) }
%loaded = $script(%tmpfile)
if (%unload) {
if (%loaded) { unload -rs " $+ %tmpfile $+ " }
}
else {
if ($_not(%loaded)) { _loadremotefile +er %tmpfile }
}
inc %i
}
if (%unload) { _setsetup script _addons $sorttok($remtok($_getsetup(script,_addons),%id,32),32) }
if ($istok($_getsetup(script,_addons),%id,32)) { _addons.winhookhelp 1 %file }
}
;;
;
; -( Saving addon text scheme (sound/fserve/xdcc) )-
;
;;
; /_addontextscheme.save parentdialog addon filextension id1,code1,flag1 id2,code2,flag2 id3,code3,flag3 ...
alias _addontextscheme.save {
var %d = _addontextscheme.save. $+ $2
if ($dialog(%d) == $null) {
set -u %addontextschemesave.parent $1
set -u %addontextschemesave.addon $2
set -u %addontextschemesave.filext $3
set -u %addontextschemesave.ids $4-
return $dialog(%d,_addontextscheme.save,-4)
}
}
dialog _addontextscheme.save {
size -1 -1 87 93
title "Save Scheme"
option dbu
box "",1000,2 2 82 70
text "Scheme name:",1001,5 10 70 8
edit "",1002,10 18 70 10,autohs
text "Author [optional]",1003,5 30 70 10
edit "",1004,10 38 70 10,autohs
text "Comment [optional]",1005,5 50 70 10
edit "",1006,10 58 70 10,autohs
button "&Save",2990,5 75 30 15,default ok
button "&Close",2991,50 75 30 15,cancel
edit "",2995,1 1 1 1,hide autohs result
list 2996,1 1 1 1
}
ON *:DIALOG:_addontextscheme.save.*:init:0:{
_mdx.init $_icofile(addons.ico)
did -o $dname 1000 1 %addontextschemesave.addon Text Scheme
did -o $dname 2996 1 %addontextschemesave.parent
did -o $dname 2996 2 %addontextschemesave.addon
did -o $dname 2996 3 %addontextschemesave.filext
did -o $dname 2996 4 %addontextschemesave.ids
_dummy $_lang.loaddialog($dname,_addontextscheme.save,00086969,main.lang,$scriptdir)
}
ON *:DIALOG:_addontextscheme.save.*:sclick:2990:{
var %name = $strip($nopath($did($dname,1002,1))),%author = $strip($did($dname,1004,1)),%comment = $strip($did($dname,1006,1)),%file = $_fixfilename(%name,fm),%ext = *. $+ $did($dname,2996,3),%parent = $did($dname,2996,1),%addon = $did($dname,2996,2),%ids = $did($dname,2996,4)
%file = $nopath(%file)
if ($len(%name) > 20) || (%file == $null) || (%name == default) || (%name == $null) { halt }
if (%ext !iswm %file) { %file = %file $+ . $+ $did($dname,2996,3) }
%file = addons\tschemes\ $+ %file
if ($isfile(%file)) && ($_not($_filexists(0,Saving [ %addon ] text scheme,%file))) { return }
write -c " $+ %file $+ " schemename %name
if (%author != $null) { write " $+ %file $+ " author $ifmatch }
if (%comment != $null) { write " $+ %file $+ " comment $ifmatch }
if (%addon != $null) { write " $+ %file $+ " addon $ifmatch }
write " $+ %file $+ " aircversion $_aircvernum
var %d = %parent,%i = 1,%n = $numtok(%ids,32),%t,%cid,%code,%flags
if ($dialog(%d) == $null) { return }
while (%i <= %n) {
var %t = $gettok(%ids,%i,32),%cid = $gettok(%t,1,44),%code = $gettok(%t,2,44),%flags = $gettok(%t,3,44)
if ($did(%d,%cid,1) != $null) { write " $+ %file $+ " %code $ifmatch }
inc %i
}
did -o $dname 2995 1 $nopath($remove(%file,"))
}