; #= P&P -rs ; ######################################## ; Peace & Protection ; User profile support ; ########################################di ; ; User profiles ; alias profile { if ($bits == 16) { if ($1) { writeini config\profiles.ini startup ask 0 .timer 1 0 .timer 1 0 _startup.perform return } _error Profiles do not work on 16 bit mIRC.Only 32 bit mIRC has the features to support profiles. } set %.method $1 if ($dialog(profile,profile,-4) == startup) .timer 1 0 .timer 1 0 _startup.perform } alias _profile { var %profile,%name,%num,%id,%file,%data,%from,%tok ; NEW if ($1 == n) { if ($2) { ; Base profile %profile = $did(profile,11,$did(profile,1).sel) ; Importing? (sets %.ver, %.which, and %.whichp if ver 4) if (%profile == +) %name = $_profimport var %ver = %.ver,%which = %.which,%whichp = %.whichp %name = $_entry(0,%name,Profile name?(be as descriptive as you like)) ; Generate profile id %id = $_gen.id(%name) var %num :loop2 %data = %id $+ %num if ($null != $readini -n config\profiles.ini %data name) { inc %num | goto loop2 } %id = %data ; Create new profile _progress.1 Creating new profile... ( $+ %id $+ ) ; Directory _progress.2 0 Making directory saveini if ($exists(config\ [ $+ [ %id ] ] ) == $false) mkdir config\ $+ %id ; Copy files incl. mirc.ini _progress.2 33 Copying files if (%profile == +) { if (%ver == 4) { %from = $nofile(%which) $+ config\ $+ %whichp | %from = $shortfn(%from) } else %from = script\defcfg } elseif (%profile == -) %from = script\defcfg else %from = config\ $+ %profile .copy %from $+ \* config\ $+ %id if ((%profile == +) && (%ver == 3)) { _progress.2 50 Converting 3.x settings... ;;; NOT DONE YET.. perhaps move to after profile copy? separate progress... ;_load imprt320 _import320 config\ $+ %id %which } if (%profile == +) { if (%ver == 4) { %from = $nofile(%which) $+ config\profiles.ini if (%whichp == $readini -n %from startup main) .copy -o " $+ %which $+ " config\ $+ %id $+ \mirc.ini } else .copy -o " $+ %which $+ " config\ $+ %id $+ \mirc.ini } elseif (%profile == $readini -n config\profiles.ini startup main) .copy -o " $+ $mircdirmirc.ini" config\ $+ %id $+ \mirc.ini ; Add to profiles.ini _progress.2 66 Adding to profiles writeini config\profiles.ini %id name %name ; Fix sections from imported mirc.ini? if ((%profile == +) && (%ver != 4)) { %file = config\ $+ %id $+ \mirc.ini %data = pfiles rfiles afiles dragdrop clicks perform :loopfix %tok = $gettok(%data,1,32) remini %file %tok %num = [[ $+ %tok $+ ]] %num = $read -ns [ $+ [ %num ] ] $mircini %num = $readn + 1 :loopfix2 %from = $read -nl [ $+ [ %num ] ] $mircini if ((%from != $null) && ([*] !iswm %from)) { writeini %file %tok $gettok(%from,1,61) $gettok(%from,2-,61) inc %num | goto loopfix2 } %data = $gettok(%data,2-,32) if (%data) goto loopfix } _progress.2 100 Done! did -v profile 102,103,104,12,2,201,40 did -a profile 101 &Open profile did -h profile 80 _refill %id } else { dialog -t profile User Profile (creating new) did -h profile 102,103,104,12,2,201,40 did -a profile 101 Se&lect did -v profile 80 did -i profile 1 1 (import settings from another mIRC or P&P) did -i profile 11 1 + did -i profile 1 1 (default P&P settings) did -i profile 11 1 - did -u profile 1 _profdir } return } if ($did(profile,1).sel == $null) return %profile = $did(profile,11,$did(profile,1).sel) ; DEFAULT if ($1 == s) { if (%profile == $readini -n config\profiles.ini startup main) _error That profile is already the default. var %proini = $mircdirconfig\ $+ %profile $+ \mirc.ini if ($_inuse(%proini)) _error You cannot make that profile default.It is currently in use by another copy of mIRC. if ($_inuse($mircdirmirc.ini)) _error You cannot change the default profile.Another copy of mIRC is using the current default. _okcancel 0 This will $iif(%profile == %!user,require a TOTAL restart of mIRC-,RESTART mIRC with this profile-) Continue? %data = $readini -n config\profiles.ini startup main saveini .copy -o mirc.ini config\ $+ %data $+ \mirc.ini .copy -o " $+ %proini $+ " mirc.ini writeini config\profiles.ini startup main %profile unset %!user _swapto %profile $true } ; SWITCH if ($1 == l) { if (%profile == %!user) { if ($did(profile,50) == startup) .timer -o 1 0 _startup.perform else _okcancel 1 Open another copy of current profile? } saveini _swapto %profile $iif($did(profile,50) == startup,$true,$false) } ; RENAME if ($1 == r) { %name = $readini -n config\profiles.ini %profile name %name = $_entry(0,$_s2p(%name),Profile name?(be as descriptive as you like)) writeini config\profiles.ini %profile name %name _refill %profile } ; DELETE if ($1 == d) { if (%profile == %!user) _error You cannot delete the current profile.Switch to another profile if you want to delete this one. if (%profile == $readini -n config\profiles.ini startup main) _error You cannot delete the default profile.Change the default if you want to delete this one. %file = $mircdirconfig\ $+ %profile $+ \mirc.ini if ($_inuse(%file)) _error You cannot delete that profile.It is currently in use by another copy of mIRC. ; Delete profile _progress.1 Deleting profile... ( $+ %profile $+ ) ; Delete files _progress.2 0 Deleting files _remove.all * $mircdirconfig\ $+ %profile if ($findfile($mircdirconfig\ [ $+ [ %profile ] ] ,*,1)) _error Error deleting ' $+ $ifmatch $+ '.Profile was not entirely deleted. ; Delete directories %data = $finddir($mircdirconfig\ [ $+ [ %profile ] ] ,*,0,.rmdir $1-) if ($finddir($mircdirconfig\ [ $+ [ %profile ] ] ,*,1)) _error Error removing ' $+ $ifmatch $+ '.Profile was not entirely deleted. ; Remove from profiles.ini _progress.2 50 Removing from profiles remini config\profiles.ini %profile ; Remove main directory .rmdir config\ $+ %profile _progress.2 100 Done! _refill } } ;;; log dirs? ; Load profile (via restart of mIRC) ; $2 = $true to close this copy, $false to just open another copy alias _swapto { ; Load profile if (($2) && ($1 == %!user)) { if ($dialog(profile)) { did -r profile 50 | dialog -c profile } | return } if ($2) { if ($dialog(profile)) var %ask = $did(profile,2).state else var %ask = $readini -n config\profiles.ini startup ask writeini config\profiles.ini startup ask once $ddename $gettok(%ask,$numtok(%ask,32),32) if ($group(#pnpdde) == off) .timer.doexit 1 20 exit } if ($1 == $readini -n config\profiles.ini startup main) run $mircexe -i" $+ $mircdirmirc.ini" else run $mircexe -i" $+ $mircdirconfig\ $+ $1\mirc.ini" if ($dialog(profile)) { did -r profile 50 | dialog -c profile } halt } alias spawn { saveini if ($1) writeini config\profiles.ini startup connect $1- _swapto %!user } ; ; Profile dialogs ; dialog profile { title "User profile" size -1 -1 400 305 text "Choose a user profile by double-clicking, or select an option.", 40, 10 10 380 16 box "&User profiles", 13, 10 30 380 150 list 1, 20 50 230 140 list 11, 20 50 230 140, hide button "&Open profile", 101, 260 50 120 25, default button "&Delete profile", 102, 260 82 120 25 button "&Rename profile", 103, 260 114 120 25 button "&Set as default", 104, 260 146 120 25 text "", 75, 15 190 500 20 box "&Options", 12, 10 210 380 48 check "&Ask for profile on startup", 2, 20 230 230 16 button "&New profile", 201, 260 225 120 25 text "Select the profile or option you wish to base the new profile on", 80, 15 215 380 16, hide button "&Close", 202, 110 270 80 25, cancel button "&Help", 203, 210 270 80 25, disable edit "", 50, 1 1 1 1, hide result autohs } on *:DIALOG:profile:init:*:{ if ($readini config\profiles.ini startup ask) did -c $dname 2 _refill %!user if (%.method == startup) { did -h profile 102,103,104,201 did -a $dname 40 Choose a user profile by double-clicking. did -a $dname 50 %.method } unset %.method } alias -l _refill { dialog -t profile User Profile did -r profile 1,11 var %file1,%file2,%profile,%name,%num = 1,%default = $readini -n config\profiles.ini startup main :loop %profile = $nopath($finddir($mircdirconfig,*,%num,1)) %name = $readini -n config\profiles.ini %profile name if (%profile) { if (%name == $null) { %file1 = $mircdirconfig\ $+ %profile $+ \config.ini %file2 = $mircdirconfig\ $+ %profile $+ \cfgvar.dat if (($exists(%file1)) && ($exists(%file2))) { %name = %profile | writeini config\profiles.ini %profile name %profile } } if (%name != $null) { did -a $+ $iif(%profile == $1,c) profile 1 %name $iif(%profile == %!user,[current],$iif(%profile == %default,[default],$chr(32))) did -a profile 11 %profile } inc %num | goto loop } _profdir } alias -l _profdir { if (($did(profile,1).sel) && ($did(profile,11,$did(profile,1).sel) !isin +-)) did -av profile 75 Profile directory: $mircdirconfig\ $+ $ifmatch else did -h profile 75 } on *:DIALOG:profile:sclick:1:_profdir on *:DIALOG:profile:dclick:1:if ($did(101) == Se&lect) _juryrig _profile n 2 | elseif ($did(profile,50) == startup) _profile l | else _juryrig _profile l on *:DIALOG:profile:sclick:101:if ($did(101) == Se&lect) _juryrig _profile n 2 | elseif ($did(profile,50) == startup) _profile l | else _juryrig _profile l on *:DIALOG:profile:sclick:102:_juryrig _profile d on *:DIALOG:profile:sclick:103:_juryrig _profile r on *:DIALOG:profile:sclick:104:_juryrig _profile s on *:DIALOG:profile:sclick:201:_juryrig _profile n on *:DIALOG:profile:sclick:202:if ($did(profile,50) == startup) { did -c profile 1 1 | _profile l } on *:DIALOG:profile:sclick:2:writeini config\profiles.ini startup ask $did(profile,2).state ; ; Profile importing ; alias _profimport { var %how = $$dialog(profileimp,profileimp,-4) if (%how == search) { set %.where $_drivesearch if (%.where == $null) halt var %which = $$dialog(profilesearch,profilesearch,-4) } else { var %which = $$dir="Select MIRC.INI to import from:" [ [ $gettok($mircdir,1,58) ] $+ ] :\mirc.ini if ($exists(%which) == $false) halt } ; Determine version- plain mirc, 3.x, or 4.x var %file1 = $nofile(%which) $+ pp300\r-main.mrc,%file2 = $nofile(%which) $+ pp300\variable.mrc if (($exists(%file1)) && ($exists(%file2))) var %ver = 3 %file1 = $nofile(%which) $+ script\first.mrc %file2 = $nofile(%which) $+ config\profiles.ini if (($exists(%file1)) && ($exists(%file2))) { set %.which %which var %name = $$dialog(profimpsel,profimpsel,-4),%ver = 4 } else var %name = $readini -n %which mirc nick set -u %.which %which set -u %.ver %ver return %name } dialog profileimp { title "Profile Import" size -1 -1 400 70 text "Should P&&P search for your other copies of mIRC or do you wish to locate MIRC.INI manually?", 201, 14 5 280 30 button "&Search", 101, 13 40 130 25, default button "&Manual", 103, 163 40 130 25, OK button "&Cancel", 105, 313 40 65 25, cancel edit "manual", 1, 1 1 1 1, result hide } on *:DIALOG:profileimp:sclick:101:did -o $dname 1 1 search | dialog -k $dname dialog profilesearch { title "Select MIRC.INI" size -1 -1 216 210 text "Select MIRC.INI to import from:", 1, 5 5 200 16 list 2, 8 25 200 150, sort button "Select", 3, 63 180 90 25, default ok edit "", 4, 1 1 1 1, hide autohs result } on *:DIALOG:profilesearch:init:*:{ _progress.1 Searching for MIRC.INI... var %junk,%num = 1,%where = %.where unset %.where :loop1 if ($gettok(%where,%num,32)) { _progress.2 $round($calc((%num - 1) * 100 / $numtok(%where,32)),0) Searching $ifmatch ... %junk = $findfile($gettok(%where,%num,32),MIRC.INI,0,did -a profilesearch 2 $1-) inc %num | goto loop1 } _progress.2 100 Search complete ; Remove anything in our mircdir or in a \config\ subdir or in recycled %num = $did(2).lines :loop2 if ((*\recycle*\* iswm $did(2,%num)) || ($mircdir* iswm $did(2,%num)) || (*\config\*\mirc.ini iswm $did(2,%num)) || (*\script\defcfg\mirc.ini iswm $did(2,%num))) did -d $dname 2 %num if (%num > 1) { dec %num | goto loop2 } window -c @Progress if ($did(2).lines == 0) { dialog -c $dname | _error No MIRC.INIs found to import from } } on *:DIALOG:profilesearch:dclick:2:dialog -k $dname on *:DIALOG:profilesearch:sclick:3:did -o $dname 4 1 $did(2,$did(2).sel) dialog profimpsel { title "Select profile" size -1 -1 400 192 text "Import which profile?", 40, 10 10 380 16 box "&Profiles", 13, 10 30 380 150 list 1, 20 50 230 140 list 11, 20 50 230 140, hide button "&Select", 101, 260 50 120 25, default ok edit "", 50, 1 1 1 1, hide result autohs edit %.which, 51, 1 1 1 1, hide autohs } on *:DIALOG:profimpsel:init:*:{ var %where,%profile,%name,%num = 1,%dir = $nofile(%.which) $+ config unset %.which :loop %profile = $nopath($finddir(%dir,*,%num,1)) %where = " $+ %dir $+ \profiles.ini" %name = $readini -n %where %profile name if (%name) { did -a $dname 1 %name did -a $dname 11 %profile } if (%profile) { inc %num | goto loop } } on *:DIALOG:profimpsel:dclick:1:dialog -k $dname on *:DIALOG:profimpsel:sclick:101:set -u1 %.whichp $did(11,$did(1).sel) | did -o $dname 50 1 $did(1,$did(1).sel)