suppression des vieilles lignes

This commit is contained in:
jopazerty
2025-03-17 12:56:35 +01:00
parent 8701c6942b
commit d04e9bd615

View File

@ -26,14 +26,15 @@
#include <misc.au3>
#include <ListViewConstants.au3>
_Singleton(@ScriptName)
;commentaire de test pour git
$bypassSauvegarde = 0
Global $allServer, $profileDirectory, $dstSave, $profileSizef, $prefsToArray
$color = "0x4A90E2"
$color2 = "0x4A90E2"
$colorbk = "0x1E1E2E"
;~ Local $readFile
if ProcessExists("thunderbird.exe") Then
MsgBox(16, "MoveYourPOP", "Veuillez fermer Thunderbird avant de lancer le script.")
Exit
@ -43,7 +44,7 @@ $hGUI = GUICreate("MoveYourPOP", 800, 570)
GUISetBkColor(0xf2f2f2)
GUISetFont(10, 500, default, "Segoe UI")
GUICtrlCreateLabel("moveYourPOP by jop", 0, 555, 800, 15, $SS_CENTER)
GUICtrlCreateLabel("moveYourPOP© by jop - Version 1", 0, 553, 800, 15, $SS_CENTER)
GUICtrlSetFont(-1, 8, 500, 2, "Segoe UI")
GUICtrlSetBkColor(-1, 0xf2f2f2)
@ -104,8 +105,8 @@ GUICtrlCreateGroup("", 10, 175, 780, 310)
GUICtrlCreateLabel("✉️ Compte(s) POP trouvé(s) :", 20, 190, 240, 25)
GUICtrlSetColor(-1, $color)
GUIctrlSetFont(-1,12, 600, Default, "Segoe UI")
;~ $listview = GUICtrlCreateListView("Nom du Compte|Mail|Nom d'utilisateur|Dossier de stockage|Signature", 20, 220, 760, 250)
$listview = GUICtrlCreateListView("Username|Account|ID|ServerID|Dossier de stockage|smtpID|Size", 20, 220, 760, 250)
$listview = GUICtrlCreateListView("Username|Account|ID|ServerID|Dossier de stockage|smtpID|Adresse du POP", 20, 220, 760, 250)
GUICtrlSetFont(-1, 11, 500, Default, "Segoe UI")
GUICtrlSetBkColor(-1, 0xff0000)
GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 0, -1) ; $LVSCW_AUTOSIZE
@ -125,17 +126,12 @@ guictrlsendmsg($ListView, $LVM_SETCOLUMNWIDTH, 5, -2) ; $LVSCW_AUTOSIZE_USEHEADE
guictrlsendmsg($ListView, $LVM_SETCOLUMNWIDTH, 6, -2) ; $LVSCW_AUTOSIZE_USEHEADER
guictrlsendmsg($ListView, $LVM_SETCOLUMNWIDTH, 7, -2) ; $LVSCW_AUTOSIZE_USEHEADER
Global $hLV = GUICtrlGetHandle($ListView)
; Changer la couleur de fond du ListView (Ex: Bleu clair)
_SendMessage($hLV, 0x1001, 0, 0xADD8E6) ; LVM_SETBKCOLOR avec couleur hexadécimale (LightBlue)
_SendMessage($hLV, 0x1004, 0, 0xFFFFFF) ; LVM_SETTEXTBKCOLOR pour éviter un fond blanc sous le texte
$go = GUICtrlCreateButton("🚀 Exécuter", 10, 490, 780, 60)
GUICtrlSetBkColor(-1, $color2)
GUICtrlSetColor(-1, 0xffffff)
GUICtrlSetFont(-1, 14, 600, Default, "Segoe UI")
;~ GUICtrlSetBkColor($go, 0x3CB371)
;testdegit
$proFileDirectory = FindLatestPrefs(@AppDataDir&"\Thunderbird\Profiles")
_getAllServer($profileDirectory)
@ -179,14 +175,12 @@ While 1
case $labSave
ShellExecute($dstSave)
Case $go
;~ MsgBox("","",$profileDirectory&" "&$dstSave)
;~ Exit
if $bypassSauvegarde = 0 Then
_checkSpace($profileDirectory, $dstSave)
EndIf
If @error Then
$msg = MsgBox(48,"MoveYourPOP",$dstSave&@CRLF&" n'a pas assez d'espace disponible pour la sauvegarde."&@CRLF&@CRLF&"Sélectionnez un autre lecteur.")
Else
;~ ConsoleWrite($profileDirectory&@CRLF&$dstSave&@CRLF)
if $bypassSauvegarde = 0 Then
$backup = _backup($profileDirectory, $dstSave)
$saveSize = Round(DirGetSize($dstSave&"\"&$backup)/1024/1024, 2)&" Mo"
@ -203,12 +197,6 @@ While 1
$localFolderDirectory = StringReplace($localFolderDirectory, "[ProfD]", $profileDirectory&"\")
$localFolderDirectory = StringReplace($localFolderDirectory, "/", "\")
;~ $localFolderDirectory = StringReplace($localFolderDirectory, "\\", "\")
;~ _ArrayDisplay($allServer)
;~ $username
;~ $listAccount = _searchValueInPrefsJsArray($prefsToArray, "mail.accountmanager.accounts")
;~ _ArrayDisplay($allServer)
for $c = 0 to ubound($allServer) - 1
;~ _ArrayDisplay($allServer[$c])
$accountName = $allServer[$c][0]
@ -248,38 +236,11 @@ While 1
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.smtpserver.'&$smtpID&'.try_ssl", 3);'&@CRLF)
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.smtpserver.'&$smtpID&'.type", "smtp");'&@CRLF)
;~ $directory = StringReplace($directory, "\\", "\")
;~ MsgBox("","",$directory)
;~ if $sizePopAccount > 10737418240 then
DirCreate($localFolderDirectory&"\Archives de "&$accountName&".sbd")
$dst = $localFolderDirectory&"\Archives de "&$accountName&".sbd"
FileWrite($localFolderDirectory&"\Archives de "&$accountName, "")
RunWait(@ComSpec & ' /c powershell.exe -Command "Move-Item -Path ''' & $directory & '\*'' -Destination ''' & $dst & '''"', "")
;~ Else
;~ $dst = $proFileDirectory&"\ImapMail\imap.ac-nice.fr-"&$randomUID
;~ DirCreate($dst)
;~ RunWait(@ComSpec & ' /c powershell.exe -Command "Move-Item -Path ''' & $directory & '\*'' -Destination ''' & $dst & '''"', "")
;~ EndIf
;~ $mail = $allServer[$c][1]
;~ $username = $allServer[$c][2]
;~ $directory = $allServer[$c][3]
;~ $signature = $allServer[$c][4]
;~ $randomID = Random(1000, 9999, 1)
;~ $nextAccountID = Random(1000, 9999, 1)
;~ $listAccount = 'account'&$randomID&','&$listAccount
;~ _writeUserJs($nextAccountID, $randomID, $username, $accountName, $mail, $listAccount, $profileDirectory)
;~ $localFolder = _searchKeyInPrefsJsArray($prefsToArray, "Local Folders")
;~ $localFolder = StringSplit($localFolder, ".")
;~ $localFolder = $localFolder[3]
;~ $localFolderDirectory = _searchValueInPrefsJsArray($prefsToArray, "mail.server."&$localFolder&".directory")
;~ $localFolderDirectory = StringReplace($localFolderDirectory, "\\", "\")
;~ DirCreate($localFolderDirectory&"\Archives de "&$accountName&".sbd")
;~ FileWrite($localFolderDirectory&"\Archives de "&$accountName, "")
;~ $dst = $localFolderDirectory&"\Archives de "&$accountName&".sbd"
;~ RunWait(@ComSpec & ' /c powershell.exe -Command "Move-Item -Path ''' & $directory & '\*'' -Destination ''' & $dst & '''"', "")
Next
;~ FileWrite($profileDirectory&"\user.js", 'user_pref("mail.accountmanager.accounts", "'&$listAccount&'");'&@CRLF)
EndIf
GUICtrlSetData($go, "🚀 Terminé")
@ -350,8 +311,6 @@ Func _getAllServer($profileDirectory)
$serverID = $serverID[3]
$searchForAcNice = _searchValueInPrefsJsArrayRegex($prefsToArray, "mail\.server\."&$serverID&"\.hostname$")
For $p = 1 To $searchForAcNice[0]
;~ If StringInStr($searchForAcNice[$p], "ac-nice.fr") Then
;~ $domainToSearch = GUICtrlRead($searchDoamin)
$domainToSearch = "ac-nice.fr|ac-aix-marseille.fr"
$domainToSearch = StringReplace($domainToSearch, ".", "\.")
$domainToSearch = StringReplace($domainToSearch, " ", "")
@ -368,10 +327,7 @@ Func _getAllServer($profileDirectory)
$smtpID = _searchValueInPrefsJsArray($prefsToArray, "mail.smtp.defaultserver")
EndIf
$popHostname = $searchForAcNice[$p]
;~ ConsoleWrite($smtpID&@CRLF)
;~ $mail = $infoServeur[4]
;~ $username = $infoServeur[2]
;~ $signature = $infoServeur[5]
$allServer[$count][0] = $username
$allServer[$count][1] = $IDAccount
$allServer[$count][2] = $IDIdentity
@ -379,9 +335,7 @@ Func _getAllServer($profileDirectory)
$allServer[$count][4] = $directory
$allServer[$count][5] = $smtpID
$allServer[$count][6] = $popHostname
;~ $allServer[$count][2] = $username
;~ $allServer[$count][3] = StringReplace($directory, "\\", "\")
;~ $allServer[$count][4] = StringReplace($signature, "\\", "\")
$count += 1
Redim $allServer[$count + 1][7]
EndIf
@ -413,63 +367,11 @@ Func _getAllServer($profileDirectory)
GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 7, -2) ; $LVSCW_AUTOSIZE_USEHEADER
EndFunc
;~ func _getAllServer($profileFolder)
;~ Local $aArray = FileReadToArray($profileFolder)
;~ Local $prefsToArray = _prefsjsToArray($aArray)
;~ local $searchForServer = _searchKeyInPrefsJsArrayRegex($prefsToArray, "^pop3$")
;~ Local $allServer[1][5]
;~ Local $count = 0
;~ $profileSizef = Round(DirGetSize($profileDirectory)/1024/1024, 2)&" Mo"
;~ For $i = 1 to $searchForServer[0]
;~ $serverID = StringSplit($searchForServer[$i], ".")
;~ $serverID = $serverID[3]
;~ $searchForAcNice = _searchValueInPrefsJsArrayRegex($prefsToArray, "mail\.server\."&$serverID&"\.hostname$")
;~ For $p = 1 To $searchForAcNice[0]
;~ If StringInStr($searchForAcNice[$p], "ac-nice.fr") Then
;~ $infoServeur = _getInfosAboutServer($prefsToArray, $serverID)
;~ $accountName = $infoServeur[1]
;~ $directory = $infoServeur[0]
;~ $mail = $infoServeur[4]
;~ $username = $infoServeur[2]
;~ $signature = $infoServeur[5]
;~ $allServer[$count][0] = $accountName
;~ $allServer[$count][1] = $mail
;~ $allServer[$count][2] = $username
;~ $allServer[$count][3] = StringReplace($directory, "\\", "\")
;~ $allServer[$count][4] = StringReplace($signature, "\\", "\")
;~ $count += 1
;~ Redim $allServer[$count + 1][5]
;~ EndIf
;~ Next
;~ Next
;~ Redim $allServer[$count][5]
;~ ;~ _ArrayDisplay($allServer)
;~ GUICtrlDelete($listview)
;~ $listview = GUICtrlCreateListView("Nom du Compte|Mail|Nom d'utilisateur|Dossier de stockage|Signature", 20, 220, 760, 250)
;~ _GUICtrlListView_AddArray($listview, $allServer)
;~ GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 0, -1) ; $LVSCW_AUTOSIZE
;~ GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 1, -1) ; $LVSCW_AUTOSIZE
;~ GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 2, -1) ; $LVSCW_AUTOSIZE
;~ GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 3, -1) ; $LVSCW_AUTOSIZE
;~ GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 4, -1) ; $LVSCW_AUTOSIZE
;~ GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 0, -2) ; $LVSCW_AUTOSIZE_USEHEADER
;~ GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 1, -2) ; $LVSCW_AUTOSIZE_USEHEADER
;~ GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 2, -2) ; $LVSCW_AUTOSIZE_USEHEADER
;~ GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 3, -2) ; $LVSCW_AUTOSIZE_USEHEADER
;~ guictrlsendmsg($ListView, $LVM_SETCOLUMNWIDTH, 4, -2) ; $LVSCW_AUTOSIZE_USEHEADER
;~ Redim $allServer[$count][5]
;~ EndFunc
Func _backup($source, $destination)
$dateHeure = StringFormat("%02d_%02d_%04d_%02dh%02dm%02ds", @MDAY, @MON, @YEAR, @HOUR, @MIN, @SEC)
$name = StringSplit($source, "\")
$name = $name[$name[0]]&"_backup_"&$dateHeure
;~ MsgBox("","",$source&" "&$destination&"\"&$name)
;~ Exit
;~ RunWait("robocopy.exe "&$source&" "&$destination&"\"&$name&" /E /COPY:DAT /MT:16 /R:3 /W:5")
RunWait('robocopy.exe "' & $source & '" "' & $destination & '\' & $name & '" /E /COPY:DAT /MT:16 /R:3 /W:5')
Return $name
EndFunc
@ -477,17 +379,11 @@ func _checkSpace($profileDirectory, $dstSave)
Local $free, $profileSize
$free = DriveSpaceFree($dstSave)
$profileSize = DirGetSize($profileDirectory) /1024/1024
;~ $profileSize = 900000
If $profileSize > $free Then
Return SetError(666)
EndIf
EndFunc
;0 directory
;1 name;
;2 username
;3 accoundID
;4 mail
Func _getInfosAboutServer($prefsArray, $serverID)
Local $aArray[4]
Local $accountID
@ -498,25 +394,6 @@ Func _getInfosAboutServer($prefsArray, $serverID)
$aArray[1] = $accountID
$aArray[2] = _searchValueInPrefsJsArray($prefsArray, "mail.account."&$accountID&".identities")
$aArray[3] = _searchValueInPrefsJsArray($prefsArray, "mail.server."&$serverID&".directory-rel")
;~ $aArray[4] = _searchValueInPrefsJsArray($prefsArray, "mail.identity."&$accountID&".smtpServer")
;~ MsgBox("", "", "mail.identity."&$accountID&".smtpServer")
;~ _ArrayDisplay($aArray)
;~ _ArrayAdd($aArray, $accountID)
;~ Local $bArray = ["mail.server."&$serverID&".directory", _
;~ "mail.server."&$serverID&".name", _
;~ "mail.server."&$serverID&".userName"]
;~ For $i = 0 to 2
;~ $val = _searchValueInPrefsJsArray($prefsArray, $bArray[$i])
;~ _ArrayAdd($aArray, $val)
;~ Next
;~ $userID = _searchValueInPrefsJsArray($prefsArray, "mail.account."&$accountID&".identities")
;~ $usermail = _searchValueInPrefsJsArray($prefsArray, "mail.identity."&$userID&".useremail")
;~ $signature = _searchValueInPrefsJsArray($prefsArray, "mail.identity."&$userID&".sig_file")
;~ _ArrayAdd($aArray, $usermail)
;~ _ArrayAdd($aArray, $signature)
Return $aArray
EndFunc
@ -638,24 +515,3 @@ Func FindLatestPrefs($sBaseDir)
Local $latestDirectory = StringRegExpReplace($sLatestFile, "\\[^\\]+$", "")
Return $latestDirectory
EndFunc
;~ Func _writeUserJs($nextAccountID, $randomServerUI, $username, $name, $mail, $listAccount, $profileFolder)
;~ FileWrite($profileFolder&"\user.js",'user_pref("mail.server.server'&$randomServerUI&'.hostname", "imap.ac-nice.fr");'&@CRLF & _
;~ 'user_pref("mail.server.server'&$randomServerUI&'.name", "'&$name&' (imap)");'&@CRLF & _
;~ 'user_pref("mail.server.server'&$randomServerUI&'.port", 993);'&@CRLF & _
;~ 'user_pref("mail.server.server'&$randomServerUI&'.socketType", 3);'&@CRLF & _
;~ 'user_pref("mail.server.server'&$randomServerUI&'.type", "imap");'&@CRLF & _
;~ 'user_pref("mail.server.server'&$randomServerUI&'.userName", "'&$username&'");'&@CRLF & _
;~ 'user_pref("mail.account.account'&$randomServerUI&'.server", "server'&$randomServerUI&'");'&@CRLF & _
;~ 'user_pref("mail.account.account'&$randomServerUI&'.identities", "id'&$randomServerUI&'");'&@CRLF & _
;~ 'user_pref("mail.identity.id'&$randomServerUI&'.smtpServer", "smtp'&$randomServerUI&'");'&@CRLF & _
;~ 'user_pref("mail.identity.id'&$randomServerUI&'.useremail", "'&$mail&'");'&@CRLF & _
;~ 'user_pref("mail.identity.id'&$randomServerUI&'.smtpServer", "smtp'&$randomServerUI&'");'&@CRLF & _
;~ 'user_pref("mail.smtpserver.smtp'&$randomServerUI&'.authMethod", 3);'&@CRLF & _
;~ 'user_pref("mail.smtpserver.smtp'&$randomServerUI&'.hostname", "smtps.ac-nice.fr");'&@CRLF & _
;~ 'user_pref("mail.smtpserver.smtp'&$randomServerUI&'.port", 465);'&@CRLF & _
;~ 'user_pref("mail.smtpserver.smtp'&$randomServerUI&'.try_ssl", 3);'&@CRLF & _
;~ 'user_pref("mail.smtpserver.smtp'&$randomServerUI&'.type", "smtp");'&@CRLF & _
;~ 'user_pref("mail.smtpserver.smtp'&$randomServerUI&'.username", "'&$username&'");'&@CRLF & _
;~ 'user_pref("mail.account.lastKey", '&$randomServerUI&');'&@CRLF)
;~ EndFunc