643 lines
28 KiB
AutoIt
643 lines
28 KiB
AutoIt
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
|
|
#AutoIt3Wrapper_Icon=send-1.ico
|
|
#AutoIt3Wrapper_Outfile=..\..\..\Desktop\moveyourpop.Exe
|
|
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
|
|
#cs ----------------------------------------------------------------------------
|
|
|
|
AutoIt Version: 3.3.16.1
|
|
Author: myName
|
|
|
|
Script Function:
|
|
Template AutoIt script.
|
|
|
|
#ce ----------------------------------------------------------------------------
|
|
|
|
; Script Start - Add your code below here
|
|
#include <GUIConstantsEx.au3>
|
|
#include <WindowsConstants.au3>
|
|
#include <Array.au3>
|
|
#include <File.au3>
|
|
#include <AutoItConstants.au3>
|
|
#include <GuiEdit.au3>
|
|
#include <ScrollBarsConstants.au3>
|
|
#include <StaticConstants.au3>
|
|
#include <GuiListView.au3>
|
|
#include <ButtonConstants.au3>
|
|
#include <misc.au3>
|
|
#include <ListViewConstants.au3>
|
|
|
|
_Singleton(@ScriptName)
|
|
;commentaire de test pour git
|
|
$bypassSauvegarde = False
|
|
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
|
|
EndIf
|
|
|
|
$hGUI = GUICreate("MoveYourPOP", 800, 560)
|
|
GUISetBkColor(0xf2f2f2)
|
|
|
|
GUISetFont(10, 500, default, "Segoe UI")
|
|
|
|
GUICtrlCreateGroup("", 10, 5, 780, 80)
|
|
GUICtrlCreateLabel("👤 Profil Thunderbird : ", 20, 23, 200, 30)
|
|
GUICtrlSetColor(-1, $color)
|
|
GUIctrlSetFont(-1,12, 600, Default, "Segoe UI")
|
|
$labSizeProfile = GUICtrlCreateLabel("", 220, 25, 150, 30)
|
|
GUICtrlSetColor(-1, $color)
|
|
GUIctrlSetFont(-1,11, 600, Default, "Segoe UI")
|
|
;~ GUICtrlSetBkColor(-1, 0xff0000)
|
|
;~ GUICtrlCreateLabel("Domaine(s) :", 390, 25, 75, 30)
|
|
;~ GUICtrlSetColor(-1, $color)
|
|
;~ GUICtrlSetTip(-1, "Séparez les domaines par un |", "Domaines à rechercher")
|
|
;~ GUICtrlSetCursor(-1, 4)
|
|
;~ $searchDoamin = GUICtrlCreateInput("ac-nice.fr|ac-aix-marseille.fr", 470, 21, 140, 25)
|
|
;~ GUICtrlSetFont(-1, 10, 500, Default, "Segoe UI")
|
|
;~ $refresh = GUICtrlCreateLabel("🔄", 610, 20, 30, 33)
|
|
;~ GUICtrlSetFont(-1, 15, 500, Default, "Segoe UI")
|
|
;~ GUICtrlSetColor(-1, $color)
|
|
;~ GUICtrlSetCursor(-1, 0)
|
|
;~ GUICtrlSetTip(-1, "Rafraichir la liste des comptes")
|
|
$modifProFileDirectory = GUICtrlCreateButton("📂 Modifier", 660, 17, 120, 33)
|
|
GUICtrlSetBkColor(-1, $color2)
|
|
GUICtrlSetColor(-1, 0xffffff)
|
|
GUICtrlSetFont(-1, 11, 600, Default, "Segoe UI")
|
|
GUICtrlSetTip(-1, "Sélectionnez le dossier du profil Thunderbird")
|
|
$labProfile = GUICtrlCreateLabel("", 20, 52, 760, 25, $SS_SUNKEN+$SS_CENTER)
|
|
GUICtrlSetBkColor(-1, 0xffffff)
|
|
GUICtrlSetFont(-1, 11, 500, Default, "Segoe UI")
|
|
GUICtrlSetTip(-1, "Cliquez pour ouvrir le dossier")
|
|
guictrlsetcursor(-1, 0)
|
|
|
|
GUICtrlCreateGroup("", 10, 90, 780, 80)
|
|
GUICtrlCreateLabel("💾 Dossier de sauvegarde :", 20, 105, 230, 25)
|
|
GUICtrlSetColor(-1, $color)
|
|
GUIctrlSetFont(-1,12, 600, Default, "Segoe UI")
|
|
$labSizeSave = GUICtrlCreateLabel("", 250, 107, 250, 25)
|
|
GUICtrlSetColor(-1, $color)
|
|
GUIctrlSetFont(-1,11, 600, Default, "Segoe UI")
|
|
|
|
$modifSaveDirectory = GUICtrlCreateButton("📂 Modifier", 660, 101, 120, 33)
|
|
GUICtrlSetBkColor(-1, $color2)
|
|
GUICtrlSetColor(-1, 0xffffff)
|
|
GUICtrlSetFont(-1, 11, 600, Default, "Segoe UI")
|
|
GUICtrlSetTip(-1, "Sélectionnez le dossier de sauvegarde")
|
|
GUICtrlCreateContextMenu($modifSaveDirectory)
|
|
$bypassSave = GUICtrlCreateMenuItem("Bypasser la sauvegarde", $modifSaveDirectory)
|
|
$dstSave = @AppDataDir&"\Thunderbird\Profiles"
|
|
GUICtrlSetData($labSizeSave, "("&Round(DriveSpaceFree($dstSave)/1024, 0)&" Go disponible)")
|
|
$labSave = GUICtrlCreateLabel($dstSave, 20, 136, 760, 25, $SS_SUNKEN+$SS_CENTER)
|
|
GUICtrlSetBkColor(-1, 0xffffff)
|
|
GUICtrlSetFont(-1, 11, 500, Default, "Segoe UI")
|
|
GUICtrlSetTip(-1, "Cliquez pour ouvrir le dossier")
|
|
guictrlsetcursor(-1, 0)
|
|
|
|
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)
|
|
GUICtrlSetFont(-1, 11, 500, Default, "Segoe UI")
|
|
GUICtrlSetBkColor(-1, 0xff0000)
|
|
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, 5, -1) ; $LVSCW_AUTOSIZE
|
|
GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 6, -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
|
|
guictrlsendmsg($ListView, $LVM_SETCOLUMNWIDTH, 5, -2) ; $LVSCW_AUTOSIZE_USEHEADER
|
|
guictrlsendmsg($ListView, $LVM_SETCOLUMNWIDTH, 6, -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)
|
|
|
|
GUISetState()
|
|
|
|
While 1
|
|
Sleep(10)
|
|
Switch GUIGetMsg()
|
|
Case $GUI_EVENT_CLOSE
|
|
Exit
|
|
Case $bypassSave
|
|
$bypassSauvegarde = True
|
|
Case $modifProFileDirectory
|
|
$newProfileFolder = FileSelectFolder("Séléctionnez le dossier du profil", @AppDataDir&"\Thunderbird\Profiles")
|
|
If Not @error Then
|
|
$profileDirectory = $newProfileFolder
|
|
GUICtrlSetData($labProfile, $profileDirectory)
|
|
$dstSave = $newProfileFolder
|
|
$dstSave = StringRegExpReplace($dstSave, "\\[^\\]+$", "")
|
|
GUICtrlSetData($labSave, $dstSave)
|
|
GUICtrlSetData($labSizeSave, "("&Round(DriveSpaceFree($dstSave)/1024, 0)&" Go disponible)")
|
|
_getAllServer($profileDirectory)
|
|
EndIf
|
|
;~ Case $refresh
|
|
;~ _getAllServer($profileDirectory)
|
|
Case $modifSaveDirectory
|
|
$newSaveFolder = FileSelectFolder("Séléctionnez le dossier de sauvegarde", @AppDataDir&"\Thunderbird\Profiles")
|
|
If Not @error Then
|
|
$dstSave = $newSaveFolder
|
|
GUICtrlSetData($labSave, $dstSave)
|
|
GUICtrlSetData($labSizeSave, "("&Round(DriveSpaceFree($dstSave)/1024, 0)&" Go disponible)")
|
|
EndIf
|
|
Case $labProfile
|
|
ShellExecute($profileDirectory)
|
|
case $labSave
|
|
ShellExecute($dstSave)
|
|
Case $go
|
|
;~ MsgBox("","",$profileDirectory&" "&$dstSave)
|
|
;~ Exit
|
|
|
|
_checkSpace($profileDirectory, $dstSave)
|
|
If @error Then
|
|
$msg = MsgBox(52,"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)
|
|
$backup = _backup($profileDirectory, $dstSave)
|
|
$saveSize = Round(DirGetSize($dstSave&"\"&$backup)/1024/1024, 2)&" Mo"
|
|
$msg = MsgBox(68, "MoveYoutPop", "Taille du dossier du profil : "&$profileSizef&@crlf&"Taille de la sauvegdarde : "&$saveSize&@CRLF&@CRLF&"Continuer ?")
|
|
If $msg = 6 Then
|
|
$userjs = $profileDirectory&"\user.js"
|
|
FileDelete($userjs)
|
|
$serverLocalFolder = _searchValueInPrefsJsArray($prefsToArray, "mail.accountmanager.localfoldersserver")
|
|
$localFolderDirectory = _searchValueInPrefsJsArray($prefsToArray, "mail.server."&$serverLocalFolder&".directory-rel")
|
|
$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]
|
|
$identity = $allServer[$c][2]
|
|
$servID = $allServer[$c][3]
|
|
$directory = $allServer[$c][4]
|
|
$smtpID = $allServer[$c][5]
|
|
$popAdress = $allServer[$c][6]
|
|
If StringInStr($popAdress, "ac-nice.fr") Then
|
|
$domain = ".ac-nice.fr"
|
|
$smtpAddress = "smtps.ac-nice.fr"
|
|
ElseIf StringInStr($popAdress, "ac-aix-marseille.fr") Then
|
|
$domain = ".ac-aix-marseille.fr"
|
|
$smtpAddress = "smtp.ac-aix-marseille.fr"
|
|
EndIf
|
|
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.identity.'&$identity&'.archive_folder", "imap://'&$accountName&'@imap'&$domain&'/Archives");'&@CRLF)
|
|
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.identity.'&$identity&'.draft_folder", "imap://'&$accountName&'@imap'&$domain&'/Drafts");'&@CRLF)
|
|
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.identity.'&$identity&'.fcc_folder", "imap://'&$accountName&'@imap'&$domain&'/Sent");'&@CRLF)
|
|
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.identity.'&$identity&'.stationery_folder", "imap://'&$accountName&'@imap'&$domain&'/Templates");'&@CRLF)
|
|
|
|
$randomUID = Random(10000, 99999, 1)
|
|
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.server.'&$servID&'.directory", "'&StringReplace($proFileDirectory, "\", "\\")&'\\ImapMail\\imap'&$domain&'-'&$randomUID&'");'&@CRLF);'&@CRLF)
|
|
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.server.'&$servID&'.directory-rel", "[ProfD]ImapMail/imap'&$domain&'-'&$randomUID&'");'&@CRLF);'&@CRLF)
|
|
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.server.'&$servID&'.hostname", "imap'&$domain&'");'&@CRLF);'&@CRLF)
|
|
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.server.'&$servID&'.type", "imap");'&@CRLF);'&@CRLF)
|
|
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.server.'&$servID&'.port", 993);'&@CRLF)
|
|
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.server.'&$servID&'.socketType", 3);'&@CRLF);'&@CRLF)
|
|
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.server.'&$servID&'.spamActionTargetAccount", "imap://'&$accountName&'@imap'&$domain&'");'&@CRLF);'&@CRLF)
|
|
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.server.'&$servID&'.namespace.personal", "\"\"");'&@CRLF)
|
|
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.server.'&$servID&'.namespace.public", "\"Shared Folders/Public/\"");'&@CRLF)
|
|
|
|
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.smtpserver.'&$smtpID&'.authMethod", 3);'&@CRLF)
|
|
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.smtpserver.'&$smtpID&'.description", "");'&@CRLF)
|
|
|
|
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.smtpserver.'&$smtpID&'.hostname", "'&$smtpAddress&'");'&@CRLF)
|
|
FileWrite($profileDirectory&"\user.js", 'user_pref("mail.smtpserver.'&$smtpID&'.port", 465);'&@CRLF)
|
|
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é")
|
|
GUICtrlSetState($go, $GUI_DISABLE)
|
|
GUICtrlSetBkColor($go, 0x3CB371)
|
|
MsgBox(64, "MoveYourPOP", "Terminé ✅")
|
|
GUIDelete($hGUI)
|
|
$thunderbirdPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\thunderbird.exe", "")
|
|
If FileExists($thunderbirdPath) Then
|
|
Run($thunderbirdPath)
|
|
Sleep(20000)
|
|
FileMove($profileDirectory&"\user.js", $profileDirectory&"\user.js.bak", 1)
|
|
Exit
|
|
Else
|
|
MsgBox(16, "Erreur", "Thunderbird non trouvé !"&@CRLF&"Veuillez le lancer manuellement."&@crlf&"Pensez à supprimer le fichier user.js dans le dossier du profil Thunderbird.")
|
|
Exit
|
|
EndIf
|
|
EndIf
|
|
;~ Exit
|
|
EndSwitch
|
|
WEnd
|
|
|
|
Func _getAllServer($profileDirectory)
|
|
|
|
GUICtrlDelete($listview)
|
|
$listview = GUICtrlCreateListView("Username|Account|ID|ServerID|Dossier de stockage|smtpID|Size", 20, 220, 760, 250)
|
|
GUICtrlSetData($go, "🚀 Exécuter")
|
|
GUICtrlSetBkColor($go, $color2)
|
|
GUICtrlSetState($go, $GUI_ENABLE)
|
|
GUICtrlSetBkColor($labProfile, 0xffffff)
|
|
GUICtrlSetColor($labProfile, 0x000000)
|
|
GUICtrlSetBkColor($labSave, 0xffffff)
|
|
GUICtrlSetColor($labSave, 0x000000)
|
|
|
|
|
|
$jsFile = $proFileDirectory&"\prefs.js"
|
|
if Not FileExists($jsFile) Then
|
|
GUICtrlSetData($labProfile, "Pas de fichier prefs.js trouvé dans "&$profileDirectory)
|
|
GUICtrlSetBkColor($labProfile, 0xE24141)
|
|
GUICtrlSetColor($labProfile, 0xffffff)
|
|
GUICtrlSetState($go, $GUI_DISABLE)
|
|
Return SetError(13)
|
|
EndIf
|
|
$aArray = FileReadToArray($jsFile)
|
|
$prefsToArray = _prefsjsToArray($aArray)
|
|
;on cherche les serveur pop
|
|
$searchForServer = _searchKeyInPrefsJsArrayRegex($prefsToArray, "^pop3$")
|
|
|
|
If $searchForServer[0] = 0 Then
|
|
GUICtrlSetData($labProfile, "Pas de compte POP trouvé dans "&$profileDirectory)
|
|
GUICtrlSetBkColor($labProfile, 0xE24141)
|
|
GUICtrlSetColor($labProfile, 0xffffff)
|
|
GUICtrlSetState($go, $GUI_DISABLE)
|
|
return SetError(14)
|
|
EndIf
|
|
|
|
$profileSizef = Round(DirGetSize($profileDirectory)/1024/1024, 2)&" Mo"
|
|
GUICtrlSetData($labProfile, $profileDirectory)
|
|
GUICtrlSetData($labSizeProfile, "("&$profileSizef&")")
|
|
|
|
Global $allServer[1][7]
|
|
Local $count = 0
|
|
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
|
|
;~ $domainToSearch = GUICtrlRead($searchDoamin)
|
|
$domainToSearch = "ac-nice.fr|ac-aix-marseille.fr"
|
|
$domainToSearch = StringReplace($domainToSearch, ".", "\.")
|
|
$domainToSearch = StringReplace($domainToSearch, " ", "")
|
|
if StringRegExp($searchForAcNice[$p], $domainToSearch) Then
|
|
$infoServeur = _getInfosAboutServer($prefsToArray, $serverID)
|
|
$username = $infoServeur[0]
|
|
$IDAccount = $infoServeur[1]
|
|
$IDIdentity = $infoServeur[2]
|
|
$directory = StringReplace($infoServeur[3], "/", "\")
|
|
$directory = StringReplace($directory, "[ProfD]", $profileDirectory&"\")
|
|
$smtpID = _searchValueInPrefsJsArray($prefsToArray, "mail.identity."&$IDIdentity&".smtpServer")
|
|
;~ ConsoleWrite("mail.identity."&$IDIdentity&".smtpServer"&@CRLF&$smtpID&@CRLF)
|
|
if $smtpID = "0" Then
|
|
$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
|
|
$allServer[$count][3] = $serverID
|
|
$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
|
|
Next
|
|
Next
|
|
if $count = 0 then GUICtrlSetState($go, $GUI_DISABLE)
|
|
Redim $allServer[$count][7]
|
|
;~ _ArrayDisplay($allServer)
|
|
GUICtrlDelete($listview)
|
|
$listview = GUICtrlCreateListView("Username|Account|ID|ServerID|Dossier de stockage|smtpID|Adresse du POP", 20, 220, 760, 250)
|
|
GUICtrlSetFont(-1, 11, 500, Default, "Segoe UI")
|
|
_GUICtrlListView_AddArray($listview, $allServer)
|
|
;~ Redim $allServer[$count][6]
|
|
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, 5, -1) ; $LVSCW_AUTOSIZE
|
|
GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 6, -1) ; $LVSCW_AUTOSIZE
|
|
GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 7, -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
|
|
GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 5, -2) ; $LVSCW_AUTOSIZE_USEHEADER
|
|
GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 6, -2) ; $LVSCW_AUTOSIZE_USEHEADER
|
|
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
|
|
|
|
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
|
|
$aArray[0] = _searchValueInPrefsJsArray($prefsArray, "mail.server."&$serverID&".userName")
|
|
$accountID = _searchKeyInPrefsJsArray($prefsArray, $serverID)
|
|
$accountID = StringSplit($accountID, ".")
|
|
$accountID = $accountID[3]
|
|
$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
|
|
|
|
; on met le contenu du prefs.js sous la forme d'un tableau clé => valeur
|
|
Func _prefsjsToArray($readFile)
|
|
Local $value = ""
|
|
Local $arrayLength = UBound($readFile) - 1
|
|
If $arrayLength < 1 Then
|
|
Return SetError(13)
|
|
EndIf
|
|
Local $array[$arrayLength][2]
|
|
Local $x = 0
|
|
|
|
For $i = 1 to $arrayLength
|
|
If StringRegExp($readFile[$i], '^(?!\s*//)(?!\s*$).+') Then
|
|
$x = $x + 1
|
|
$value = ""
|
|
$string = StringRegExpReplace($readFile[$i], '^user_pref\(\"', "")
|
|
$string = StringRegExpReplace($string, '\"\)\;$', "")
|
|
$string = StringRegExpReplace($string, '\)\;$', "")
|
|
$string = StringReplace($string, '", "', ",")
|
|
$string = StringReplace($string, '", ', ",")
|
|
$split = StringSplit($string, ",")
|
|
If $split[0] > 2 Then
|
|
For $p = 2 to $split[0]
|
|
$value &= $split[$p]&","
|
|
Next
|
|
$value = StringRegExpReplace($value, ",$", "")
|
|
Else
|
|
$value = $split[2]
|
|
EndIf
|
|
$array[$x][0] = $split[1]
|
|
$array[$x][1] = $value
|
|
EndIf
|
|
Next
|
|
|
|
$array[0][0] = $x
|
|
ReDim $array[$x + 1][2]
|
|
Return $array
|
|
EndFunc
|
|
|
|
;recherche dans le tableau (prefs.js)
|
|
;reverse 0 => on cherche clé
|
|
;reverse 1 => on cherche une valeur
|
|
Func _searchValueInPrefsJsArrayRegex($array, $string)
|
|
Local $key, $value
|
|
Local $x = 0
|
|
Local $result[1]
|
|
For $p = 1 to $array[0][0]
|
|
$key = $array[$p][0]
|
|
$value = $array[$p][1]
|
|
If StringRegExp($key, $string) Then
|
|
_ArrayAdd($result, $value)
|
|
$x = $x + 1
|
|
EndIf
|
|
Next
|
|
$result[0] = $x
|
|
Return $result
|
|
EndFunc
|
|
|
|
Func _searchKeyInPrefsJsArrayRegex($array, $string)
|
|
Local $key, $value
|
|
Local $x = 0
|
|
Local $result[1]
|
|
For $p = 1 to $array[0][0]
|
|
$key = $array[$p][0]
|
|
$value = $array[$p][1]
|
|
If StringRegExp($value, $string) Then
|
|
_ArrayAdd($result, $key)
|
|
$x = $x + 1
|
|
EndIf
|
|
Next
|
|
$result[0] = $x
|
|
Return $result
|
|
EndFunc
|
|
|
|
Func _searchValueInPrefsJsArray($array, $string)
|
|
Local $key, $value
|
|
;~ Local $x = 0
|
|
For $p = 1 to $array[0][0]
|
|
$key = $array[$p][0]
|
|
$value = $array[$p][1]
|
|
If $key = $string Then
|
|
Return $value
|
|
EndIf
|
|
Next
|
|
EndFunc
|
|
|
|
Func _searchKeyInPrefsJsArray($array, $string)
|
|
Local $key, $value
|
|
;~ Local $x = 0
|
|
For $p = 1 to $array[0][0]
|
|
$key = $array[$p][0]
|
|
$value = $array[$p][1]
|
|
If $value = $string Then
|
|
Return $key
|
|
EndIf
|
|
Next
|
|
EndFunc
|
|
|
|
Func FindLatestPrefs($sBaseDir)
|
|
Local $aFileList = _FileListToArrayRec($sBaseDir, "prefs.js", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT)
|
|
If @error Then
|
|
Return SetError(666)
|
|
EndIf
|
|
|
|
Local $sLatestFile = "", $iLatestTime = 0
|
|
|
|
For $i = 1 To $aFileList[0]
|
|
Local $sFilePath = $sBaseDir & "\" & $aFileList[$i]
|
|
If Not StringInStr($sFilePath, "backup") Then
|
|
Local $sModTime = FileGetTime($sFilePath, $FT_MODIFIED, 1)
|
|
If $sModTime > $iLatestTime Then
|
|
$iLatestTime = $sModTime
|
|
$sLatestFile = $sFilePath
|
|
EndIf
|
|
EndIf
|
|
Next
|
|
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 |