diff --git a/Assets/Clef.meta b/Assets/Clef.meta new file mode 100644 index 0000000000000000000000000000000000000000..03e084f3e19286a0aa1b4628da4c65ed6b4e309f --- /dev/null +++ b/Assets/Clef.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 90805bf69fbcb074ea657bc54ca24691 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Clef/Resources.meta b/Assets/Clef/Resources.meta new file mode 100644 index 0000000000000000000000000000000000000000..c790a22f2069149390dd0ab6481ee8161c9ae305 --- /dev/null +++ b/Assets/Clef/Resources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dfa998dadb5e0dc40bb8273b6036e3c5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Clef/Resources/clefPrivee.txt b/Assets/Clef/Resources/clefPrivee.txt new file mode 100644 index 0000000000000000000000000000000000000000..d17ac8451b5a734d063768c8cb7f28dcb582d688 --- /dev/null +++ b/Assets/Clef/Resources/clefPrivee.txt @@ -0,0 +1,39 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIG4wIBAAKCAYEA6PyRuZV+1wTeTla21Oqe3XGxZAq1x1w6zplL1RRGXMbC3aUC +5UuY1BvB9MAECkG1S9WtalW9Tleh2UghViafuhposI/Ik6U3eH5rjHGhXLiPyuBP +T7V2JV1iPuAv4JahM3LO2/G+JLe0YC/wG53vbEQv+ildGHDUFV9dwbOVQ5WFYiq2 +usl2AsNIWOF2DjVWOTx41GNp5IEkKf+5IXisJR54Aci2y7p+P1FuaJaBg0SQS394 +U+RN5nOLotzt14w9GcUlcFTLiV5OcNzFundSxbRFttcu3NqSakTzjFsif7jfTxPR +M07E1fAFIkRMcMl2faxj2K8jsxLkcOVMrWj+TFu7SUkI5Nm8jQ3+Zi0xxO8wYXTB +hfOEXHuAMB5IaVd1v3LecruzGVHYw9iHbe6vgAQRjspPkRBmBOsEdtPQ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lLVjhKtJH3pdLt/Sw4TSXjJwg/LmhVOJG0MRMZ +nQq/ycQDxrHflntwqUREiiDDqtDbw2MfzrWOvE17AoHAPCbdglHsv7yBXflgq0yE +HSKoFJo74t8ZI8j2VvungvBBDfZxG0OciL8IGV3o/pB1dBNKLunfH17USx1lmwNj +2NM5a3cQvankxeOTN3I0dtpVemVAuGkN+U7qorbFyGCn50Lp4fAGYH7sDr1NuoWF +F+PYfGk2/Wylhcwca4FcuWwouwXJXunVAc+6t742TvM4vt8B3aVAMP79PGTyAHJI +yu1+OKBt30KcKFMT91ye5tgPqHNWCcAp4MdtE+B2H4bRAoHAXP4cpJu+6dRn8nOA +UkAIDgYXJM3BesJGpE2eTmRhvd2a26BllLv91Sv8Dt+x0YtgdpPerU+InA3HqJk0 +uqqt4HTAd41N9tJCvvO6Ho+7CS2efN07gNeYCwHDdaTa+Z6egMf7XWrmQ5/PP71G +B48ErDdzG9n9z2nF83csZ1ImaiWOtAcBMM2g/x0TWHaZ9WP7WTmo6cEeh2xaB7MT +XwLZCTcGlLhXNHRHZbC2UwgAjK38fmVBG9B9nG9tSE0EeetxAoHAE0gQ5frnqzc9 +X1aMNlCdVTX4QE6kIAHQP8y38oVYtF+5Pdw5jsh5ZZRzKUi8pRHUV2F3bd0R2dVF +gqHAieDKg1G/AR4vqAVfAlvn+XCAWH1x+lu43mY8HtdGxXVIbalNzbEJRSnFerI3 +2ANtvWP3KFUpWc86OXC+syFdk+Cw8Zrtmr9yKaCscU+aZ+DWNYmUcgWy6j9BvzgT +WpoE0muDIzQ80sB3Tj/FzWUFTLHGTnu7Z+3o8s0u7Nq4v+YpHmwv +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/Assets/Clef/Resources/clefPrivee.txt.meta b/Assets/Clef/Resources/clefPrivee.txt.meta new file mode 100644 index 0000000000000000000000000000000000000000..d5036154309d7185ddcf18608cafb2cc722e7765 --- /dev/null +++ b/Assets/Clef/Resources/clefPrivee.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2d30b634930bced4db16664605875c46 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/FileTransferManager.cs b/Assets/FileTransferManager.cs new file mode 100644 index 0000000000000000000000000000000000000000..4fe31862e3038e3e2f583f59732835a0c290e06d --- /dev/null +++ b/Assets/FileTransferManager.cs @@ -0,0 +1,94 @@ +using UnityEngine; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Net.Sockets; +using Renci.SshNet; + +public static class FileTransferManager +{ + private static SftpClient leclient; + + public static void SendFile(string filePath) + { + Debug.Log("***************** NEW SendFile********************"); + string url = "sftp://palulu_scan@leikki.lezinter.net"; + Uri uri = new Uri(url); + string username = uri.UserInfo.Split(':')[0]; // Récupère le nom d'utilisateur + string host = uri.Host; // Récupère le nom d'hôte + string remotePath = "traces/evalulu/"; + Debug.Log("***************** NEW SendFile2********************"); + var authenticationMethods = new List<AuthenticationMethod>(); + Debug.Log("***************** NEW SendFile3********************"); + // Utiliser la clé privée + string privateKeyResourceName = "clefPrivee"; + + TextAsset privateKeyAsset = Resources.Load<TextAsset>(privateKeyResourceName); + string privateKey = privateKeyAsset.text; + var privateKeyFile = new PrivateKeyFile(new MemoryStream(Encoding.UTF8.GetBytes(privateKey))); + authenticationMethods.Add(new PrivateKeyAuthenticationMethod(username, privateKeyFile)); + + var connectionInfo = new ConnectionInfo(host, username, authenticationMethods.ToArray()); + leclient = new SftpClient(connectionInfo); + Debug.Log("***************** try begins ********************"); + + try + { + leclient.Connect(); + if(filePath!="") + { + string fileName = Path.GetFileName(filePath); + //string timestamp = "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff"); + //string fileNameWithTimestamp = Path.ChangeExtension(fileName, timestamp + ".json"); + string remoteFilePath = remotePath + fileName; + + using (var fileStream = System.IO.File.OpenRead(filePath)) + { + leclient.UploadFile(fileStream, remoteFilePath, callbackUploadFile); + } + + if (!leclient.Exists(remoteFilePath)) + { + uploadStaticMechanism.uploadOneFileAsynchroneFinished(-1, "Connexion réussie au serveur SFTP mais fichier incorrectement transféré"); + + } + else + { + Debug.Log("***************** NEW SendFile SUCCESS ********************"); + Debug.Log("Le fichier a été correctement transféré sur le serveur."); + uploadStaticMechanism.uploadOneFileAsynchroneFinished(1, "Le fichier a été correctement transféré sur le serveur."); + } + } + } + catch (SocketException e) + { + uploadStaticMechanism.uploadOneFileAsynchroneFinished(-1, "Erreur : Connexion au serveur impossible."); + + } + catch (IOException ex) + { + uploadStaticMechanism.uploadOneFileAsynchroneFinished(-1, "Erreur d'entrée/sortie lors de la lecture du fichier"); + } + finally + { + leclient.Disconnect(); + } + } + + private static void callbackUploadFile(ulong uploadedBytes) + { + // Implémentation de la méthode de rappel pour la progression du téléchargement + Debug.Log($"Uploaded {uploadedBytes} bytes."); + } + + private static void AddTraceSound(string arg1, string arg2) + { + // Implémentation de addTraceSound + } + + private static void InitializeTraces() + { + // Implémentation de initializeTraces + } +} diff --git a/Assets/FileTransferManager.cs.meta b/Assets/FileTransferManager.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..48f33b0cd591e6e45f535f617ae29c861f0623fd --- /dev/null +++ b/Assets/FileTransferManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 497878e615d28fb40878b5b8e54f58e2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Renci.SshNet.dll b/Assets/Renci.SshNet.dll new file mode 100644 index 0000000000000000000000000000000000000000..66f5c41778184e81aae0b4ea9aee6fa882bacd41 Binary files /dev/null and b/Assets/Renci.SshNet.dll differ diff --git a/Assets/Renci.SshNet.dll.meta b/Assets/Renci.SshNet.dll.meta new file mode 100644 index 0000000000000000000000000000000000000000..245ffdfc7a8dd92fb99e22b411ab571adeb31dfe --- /dev/null +++ b/Assets/Renci.SshNet.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: ffbed5623c40a2741bd881abd9587ae0 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uploadStaticMechanism.cs b/Assets/uploadStaticMechanism.cs index e19bb55b4a64599bf63c71bccfeb6228440684be..2413bbdda02dc58b1c378a87aae97741385d15b2 100644 --- a/Assets/uploadStaticMechanism.cs +++ b/Assets/uploadStaticMechanism.cs @@ -24,7 +24,6 @@ public static class uploadStaticMechanism private static bool fromhmscenestart = false; private static bool isthereOldArchivesTotest = false; private static int indexArchiveToTestExistenceOnServer = 0; - private static bool modeCheckIfExistsOnServer = false; public class path_andteacherid_and_userid { @@ -49,7 +48,6 @@ public static class uploadStaticMechanism public static void sendTraces(bool fromhmscenestart1 = false, List<string> successSynchroAccount = null, bool terminateSceneAFterTrasfert1 = false, mainManager mM1=null) { - modeCheckIfExistsOnServer = true; //Debug.LogError("sendTraces thisTeacherCode="+ thisTeacherCode+ " loginCode = "+ loginCode); pathDirectory = Application.persistentDataPath + "/newSystemeTraces/"; pathDirectoryArchive = Application.persistentDataPath + "/newSystemeTraces/ArchiveReal"; @@ -93,6 +91,9 @@ public static class uploadStaticMechanism string[] savedFilesWaitingToBeUploaded_temp1 = Directory.GetFiles(pathDirectory, "*.json"); // attention, ici on prend TOUT les fichiers sans distinction alors qu'il faudrait à minima check le enseignant ID string[] savedFilesWaitingToBeUploaded_inOldArciveFolder_temp = Directory.GetFiles(pathDirectoryArchiveAncien, "*.json"); // attention, ici on prend TOUT les fichiers sans distinction alors qu'il faudrait à minima check le enseignant ID string[] savedFilesWaitingToBeUploaded_temp = savedFilesWaitingToBeUploaded_temp1.Concat(savedFilesWaitingToBeUploaded_inOldArciveFolder_temp).ToArray(); + + + if (fromhmscenestart) { foreach (string teacheraccount in successSynchroAccount) @@ -205,7 +206,7 @@ public static class uploadStaticMechanism if (nbOfFilesToUpload > 0) { - if (isthereOldArchivesTotest && modeCheckIfExistsOnServer) + if (isthereOldArchivesTotest) { Debug.Log("START CHECK ARCHIVES ON SERVER"); @@ -396,16 +397,18 @@ public static class uploadStaticMechanism string teachercode = savedFilesWaitingToBeUploaded[nbOfFilesUploaded].teachercode; int userIconID = savedFilesWaitingToBeUploaded[nbOfFilesUploaded].usericonID; string userloginCode = savedFilesWaitingToBeUploaded[nbOfFilesUploaded].usercode; + FileTransferManager.SendFile(currentlySentTemporaryFilePath); + /* if (fromhmscenestart) { HM_PluginController.UploadTrace(currentlySentTemporaryFilePath, uploadOneFileAsynchroneFinished, teachercode, userIconID, userloginCode); - + } else { HM_PluginController.UploadTrace(currentlySentTemporaryFilePath, uploadOneFileAsynchroneFinished); - } + }*/ } catch (Exception ex) { @@ -479,11 +482,11 @@ public static class uploadStaticMechanism } } - private static void uploadOneFileAsynchroneFinished(int resultCode, string resultMessage) + public static void uploadOneFileAsynchroneFinished(int resultCode, string resultMessage) { //Debug.LogError("resultCode=" + resultCode + " resultMessage=" + resultMessage + " nombreDeFichiersTraites=" + nbOfFilesUploaded + " nombreDeFichiersATransferer=" + nbOfFilesToUpload); ////Debug.Log("transfertAsynchroneFinished resultCode = " + resultCode.ToString() + " resultMessage=" + resultMessage + " nombreDeFichiersTraites = " + nombreDeFichiersTraites); - + Debug.Log("RESULT MESSAGE : " + resultMessage); if (resultCode == 1 || resultCode == 0) { nbFilesReallyUploaded++; diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index bcd04c383b442ee50b6048b7368c82b28653078e..c9afe168318f908c988a0d5babdf75d46f9f4cf3 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -387,6 +387,103 @@ PlayerSettings: m_Height: 81 m_Kind: 2 m_SubKind: + - m_BuildTarget: iPhone + m_Icons: + - m_Textures: [] + m_Width: 180 + m_Height: 180 + m_Kind: 0 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 120 + m_Height: 120 + m_Kind: 0 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 167 + m_Height: 167 + m_Kind: 0 + m_SubKind: iPad + - m_Textures: [] + m_Width: 152 + m_Height: 152 + m_Kind: 0 + m_SubKind: iPad + - m_Textures: [] + m_Width: 76 + m_Height: 76 + m_Kind: 0 + m_SubKind: iPad + - m_Textures: [] + m_Width: 120 + m_Height: 120 + m_Kind: 3 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 80 + m_Height: 80 + m_Kind: 3 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 80 + m_Height: 80 + m_Kind: 3 + m_SubKind: iPad + - m_Textures: [] + m_Width: 40 + m_Height: 40 + m_Kind: 3 + m_SubKind: iPad + - m_Textures: [] + m_Width: 87 + m_Height: 87 + m_Kind: 1 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 58 + m_Height: 58 + m_Kind: 1 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 29 + m_Height: 29 + m_Kind: 1 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 58 + m_Height: 58 + m_Kind: 1 + m_SubKind: iPad + - m_Textures: [] + m_Width: 29 + m_Height: 29 + m_Kind: 1 + m_SubKind: iPad + - m_Textures: [] + m_Width: 60 + m_Height: 60 + m_Kind: 2 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 40 + m_Height: 40 + m_Kind: 2 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 40 + m_Height: 40 + m_Kind: 2 + m_SubKind: iPad + - m_Textures: [] + m_Width: 20 + m_Height: 20 + m_Kind: 2 + m_SubKind: iPad + - m_Textures: [] + m_Width: 1024 + m_Height: 1024 + m_Kind: 4 + m_SubKind: App Store m_BuildTargetBatching: [] m_BuildTargetShaderSettings: [] m_BuildTargetGraphicsJobs: diff --git a/UserSettings/EditorUserSettings.asset b/UserSettings/EditorUserSettings.asset index df08c4acdf01ecad20aa40f0a9ca129b8c5fc90a..3aa90c7dd952042dd5b7ec3c2b418181fa73f91d 100644 --- a/UserSettings/EditorUserSettings.asset +++ b/UserSettings/EditorUserSettings.asset @@ -24,10 +24,10 @@ EditorUserSettings: value: 51530603000d5e0a5c0c5a7044705c44404f1a7d7b2d20607a714d66b4b9626a flags: 0 RecentlyUsedSceneGuid-6: - value: 515250075c0c595e5f5a5e71122159444e4e4a2f7a7d7f602f284d66b4b76661 + value: 025701560657515e545d0926447508454e474f2f797820647b7d4c35e1b93661 flags: 0 RecentlyUsedSceneGuid-7: - value: 025701560657515e545d0926447508454e474f2f797820647b7d4c35e1b93661 + value: 515250075c0c595e5f5a5e71122159444e4e4a2f7a7d7f602f284d66b4b76661 flags: 0 RecentlyUsedSceneGuid-8: value: 52045152560d5d025858542140750e44404f4d2b74797431292b1f66b1e5373c