viewgit/index.php:465 Only variables should be passed by reference [2048]

viewgit/index.php:466 Non-static method GeSHi::get_language_name_from_extension() should not be called statically [2048]

  1.  
  2. using System;
  3. using System.Collections;
  4. using System.Threading;
  5. using System.IO.Compression;
  6. using System.Text.RegularExpressions;
  7. using System.IO;
  8. using Tamir.SharpSsh;
  9. using System.Data.SQLite;
  10. using Dizzy;
  11.  
  12. namespace Dizzy
  13. {
  14.  
  15.  
  16. public class ProtocolException : ApplicationException
  17. {
  18. public ProtocolException () {}
  19. public ProtocolException (string Message) {}
  20. }
  21.  
  22. public class Protocol
  23. {
  24.  
  25. // I transfer attivi
  26. ArrayList transfers = new ArrayList ();
  27.  
  28. public delegate void Del (string src, string dest,
  29. int transferredBytes, int totalBytes, string message);
  30.  
  31.  
  32. ArrayList threads = new ArrayList ();
  33.  
  34. Thread finder, listUpdater;
  35.  
  36. // Dati letti dal thread che cerca per capire cosa cercare
  37. string keyword, user, type;
  38.  
  39.  
  40. public delegate void ProtocolEvent ();
  41.  
  42. // Questo evento sembra non dare problemi perché ogni volta che
  43. // è emesso aspettiamo che l'utente inserisca i dati necessari
  44. // con while(!this.config.authenticated) {}
  45. public event ProtocolEvent AuthenticationRequired;
  46.  
  47. public Protocol ()
  48. {
  49. }
  50.  
  51. public void Search(string keyword, string user, string type)
  52. {
  53. if (this.finder != null && this.finder.IsAlive)
  54. {
  55. Log.Info ("Ricerca in corso");
  56. return;
  57. }
  58. if (!System.IO.File.Exists(GlobalConfig.ListFileName ()))
  59. {
  60. // Dovremmo notificare l'utente che non c'è la lista
  61. Log.Warning ("La lista non è presente, chiedo di scaricarla");
  62. this.UpdateFileList ();
  63. }
  64.  
  65. Log.Info ("Avvio la ricerca nel database");
  66. this.keyword = keyword;
  67. this.user = user;
  68. this.type = type;
  69. this.finder = new Thread(new ThreadStart (this._Search));
  70. this.finder.Start ();
  71.  
  72. }
  73.  
  74. protected File ReadFile(StreamReader file)
  75. {
  76. string path = file.ReadLine();
  77. string user = file.ReadLine ();
  78. int size = System.Convert.ToInt32(file.ReadLine (), 10);
  79. return new File(path, user, size);
  80. }
  81.  
  82. protected void _Search()
  83. {
  84. // Questa funzione viene chiamata quando qualcuno richiede
  85. // una ricerca. Inoltre abbiamo la quasi certezza che ne venga
  86. // chiamata solo un'istanza nello stesso momento.
  87. EventManager.SearchStarted ();
  88. FileList list = new FileList ();
  89.  
  90. ArrayList files;
  91. try { files = list.Search (this.keyword, this.type, this.user); }
  92. catch (Exception e) {
  93. // Probabilmente stiamo solamente scaricando il database,
  94. // ma tant'è.
  95. Log.Error ("Impossibile effettuare la ricerca nel database: " + e.Message);
  96. files = new ArrayList ();
  97. }
  98.  
  99. // this.fileTreeView.Clear ();
  100. EventManager.FileTreeViewClear ();
  101.  
  102. foreach(File f in files)
  103. {
  104. // this.fileTreeView.AddFile (f);
  105. EventManager.FileTreeViewAddFile (f);
  106. }
  107. EventManager.SearchFinished ();
  108. if (files.Count == 0)
  109. EventManager.ErrorMessage ("Nessun risultato trovato!");
  110. }
  111.  
  112. public void UpdateFileList ()
  113. {
  114. if(this.listUpdater != null && this.listUpdater.IsAlive)
  115. {
  116. Log.Warning ("La lista è già in fase di aggiornamento, non faccio nulla");
  117. return;
  118. }
  119.  
  120.  
  121. this.listUpdater = new Thread (new ThreadStart (this._UpdateFileList));
  122. this.listUpdater.Start ();
  123. // _UpdateFileList ();
  124. }
  125.  
  126.  
  127.  
  128. protected void _UpdateFileList ()
  129. {
  130. // SFTPConnection s;
  131. Sftp s;
  132.  
  133. if (!GlobalConfig.authenticated)
  134. {
  135. Log.Info ("I dati di autenticazione non sono presenti");
  136. // this.AuthenticationRequired ();
  137. EventManager.AuthenticationRequired ();
  138.  
  139. // Aspetto che l'utente abbia fatto.
  140. while(!GlobalConfig.authenticated) {}
  141. Log.Info ("Ho acquisito utente e password");
  142. }
  143.  
  144. EventManager.ListUpdateStarted ();
  145.  
  146. // Inizializziamo la connessione con i dati che supponiamo
  147. // di avere.
  148. // s = new SFTPConnection (this.config.GetValue("user"),
  149. // this.config.password);
  150. s = new Sftp("poisson.phc.unipi.it", GlobalConfig.GetValue("user"),
  151. GlobalConfig.password);
  152.  
  153. try {
  154. s.Connect ();
  155. }
  156. catch (Exception e) {
  157. Log.Error ("Autenticazione errata (" + e.Message + ")");
  158. GlobalConfig.authenticated = false;
  159. }
  160.  
  161. if(!GlobalConfig.authenticated)
  162. {
  163. EventManager.ErrorMessage ("Autenticazione fallita");
  164. }
  165. else
  166. {
  167. Log.Info ("Aggiornamento della lista avviato");
  168.  
  169. // s.Download (new File("/nobackup/robol/index.db", "robol"),
  170. // this.config.ConfigDir ());
  171. s.Get("/nobackup/robol/index.db", GlobalConfig.ListFileName());
  172.  
  173. Log.Info ("Lista Aggiornata");
  174. s.Close ();
  175. }
  176. EventManager.ListUpdateFinished ();
  177. }
  178.  
  179.  
  180. public void Disconnect ()
  181. {
  182. foreach(FileTransfer t in this.transfers)
  183. {
  184. Log.Info ("Stopping transfers");
  185. t.Stop ();
  186. }
  187.  
  188. }
  189.  
  190. public void DisconnectPath (string GUID)
  191. {
  192. FileTransfer stoppedTransfer = null;
  193. foreach(FileTransfer t in this.transfers)
  194. {
  195. if ( t.GetGUID () == GUID)
  196. {
  197. t.Stop ();
  198. stoppedTransfer = t;
  199. }
  200. }
  201. if(stoppedTransfer != null)
  202. transfers.Remove (stoppedTransfer);
  203. }
  204.  
  205.  
  206. public void Download(File f, string downloadFolder)
  207. {
  208. Log.Info ("Cominciamo il download di " + f.name);
  209. // Preparo gli argomento da passare alla funzione.
  210. if (!GlobalConfig.authenticated)
  211. {
  212. Log.Info ("Chiedo di effettuare l'autenticazione");
  213. EventManager.AuthenticationRequired ();
  214. }
  215.  
  216.  
  217.  
  218. ArrayList args = new ArrayList ();
  219. args.Add (f);
  220. args.Add (downloadFolder);
  221. Thread t = new Thread (new ParameterizedThreadStart(_Download));
  222. t.Start (args);
  223. this.threads.Add (t);
  224. }
  225.  
  226. protected void _Download(object args)
  227. {
  228. // Questi cast sono piuttosto brutali ma posso passare
  229. // solo un oggetto a Download e quindi è il meglio che
  230. // mi riesce di fare.
  231. File f = (File) ((ArrayList) args)[0];
  232. string downloadFolder = (string) ((ArrayList) args)[1];
  233. Log.Info ("Avvio il download di " + f.name);
  234.  
  235. EventManager.WaitForAuthentication ();
  236.  
  237. Log.Info ("Bene, ora dovrei avere i dati!");
  238.  
  239. FileDownlad transfer;
  240. try {
  241. transfer = new FileDownlad (f, GlobalConfig.GetValue("user"), GlobalConfig.password, downloadFolder);
  242. this.transfers.Add (transfer);
  243. } catch (Exception e) {
  244. Log.Error (e.Message);
  245. GlobalConfig.authenticated = false;
  246.  
  247. EventManager.ErrorMessage ("Autenticazione fallita");
  248. return;
  249. }
  250.  
  251. try {transfer.Start ();}
  252. catch (Exception) {
  253. // Si lamenterà se e quando termineremo il trasferimento
  254. // brutalmente ma per ora sembra che non ci possiamo fare niente.
  255. }
  256.  
  257. }
  258.  
  259. public void Upload(string f)
  260. {
  261. // Preparo gli argomento da passare alla funzione.
  262. if (!GlobalConfig.authenticated)
  263. EventManager.AuthenticationRequired ();
  264. while(!GlobalConfig.authenticated) {}
  265.  
  266. ArrayList args = new ArrayList ();
  267. args.Add (f);
  268. Thread t = new Thread (new ParameterizedThreadStart(_Upload));
  269. t.Start (args);
  270. this.threads.Add (t);
  271. }
  272.  
  273. protected void _Upload(object args)
  274. {
  275. // Questi cast sono piuttosto brutali ma posso passare
  276. // solo un oggetto a Download e quindi è il meglio che
  277. // mi riesce di fare.
  278. string f = (string) ((ArrayList) args)[0];
  279. Log.Info ("Avvio l'upload di " + f);
  280.  
  281. FileUpload transfer;
  282. try {
  283. transfer = new FileUpload (f, GlobalConfig.GetValue("user"), GlobalConfig.password);
  284. this.transfers.Add (transfer);
  285.  
  286. } catch (Exception e) {
  287.  
  288. Log.Error (e.Message);
  289. GlobalConfig.authenticated = false;
  290. EventManager.ErrorMessage ("Autenticazione fallita");
  291. return;
  292. }
  293.  
  294. try {transfer.Start ();}
  295. catch (Exception) {
  296. // Ci potrebbero essere dei problemi ma per ora non
  297. // vogliamo occuparcene.
  298. }
  299. }
  300.  
  301.  
  302.  
  303. }
  304.  
  305.  
  306.  
  307.  
  308.  
  309. }