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. public Protocol ()
  40. {
  41. }
  42.  
  43. public void Search(string keyword, string user, string type)
  44. {
  45. if (this.finder != null && this.finder.IsAlive)
  46. {
  47. Log.Info ("Ricerca in corso");
  48. return;
  49. }
  50. if (!System.IO.File.Exists(GlobalConfig.ListFileName ()))
  51. {
  52. // Dovremmo notificare l'utente che non c'è la lista
  53. Log.Warning ("La lista non è presente, chiedo di scaricarla");
  54. this.UpdateFileList ();
  55. }
  56.  
  57. Log.Debug ("Call", "Avvio la ricerca nel database");
  58. this.keyword = keyword;
  59. this.user = user;
  60. this.type = type;
  61. this.finder = new Thread(new ThreadStart (this._Search));
  62. this.finder.Start ();
  63.  
  64. }
  65.  
  66. protected File ReadFile(StreamReader file)
  67. {
  68. string path = file.ReadLine();
  69. string user = file.ReadLine ();
  70. int size = System.Convert.ToInt32(file.ReadLine (), 10);
  71. return new File(path, user, size);
  72. }
  73.  
  74. protected void _Search()
  75. {
  76. // Questa funzione viene chiamata quando qualcuno richiede
  77. // una ricerca. Inoltre abbiamo la quasi certezza che ne venga
  78. // chiamata solo un'istanza nello stesso momento.
  79. EventManager.SearchStarted ();
  80. FileList list = new FileList ();
  81.  
  82. ArrayList files;
  83. try { files = list.Search (this.keyword, this.type, this.user); }
  84. catch (Exception e) {
  85. // Probabilmente stiamo solamente scaricando il database,
  86. // ma tant'è.
  87. Log.Error ("Impossibile effettuare la ricerca nel database: " + e.Message);
  88. files = new ArrayList ();
  89. }
  90.  
  91. // this.fileTreeView.Clear ();
  92. EventManager.FileTreeViewClear ();
  93.  
  94. foreach(File f in files)
  95. {
  96. // this.fileTreeView.AddFile (f);
  97. EventManager.FileTreeViewAddFile (f);
  98. }
  99. EventManager.SearchFinished ();
  100. if (files.Count == 0)
  101. EventManager.ErrorMessage ("Nessun risultato trovato!");
  102. }
  103.  
  104. public void UpdateFileList ()
  105. {
  106. if(this.listUpdater != null && this.listUpdater.IsAlive)
  107. {
  108. Log.Warning ("La lista è già in fase di aggiornamento, non faccio nulla");
  109. return;
  110. }
  111.  
  112.  
  113. this.listUpdater = new Thread (new ThreadStart (this._UpdateFileList));
  114. this.listUpdater.Start ();
  115. // _UpdateFileList ();
  116. }
  117.  
  118.  
  119.  
  120. protected void _UpdateFileList ()
  121. {
  122.  
  123. // SFTPConnection s;
  124. Sftp s;
  125.  
  126. if (!GlobalConfig.authenticated)
  127. {
  128. Log.Info ("I dati di autenticazione non sono presenti");
  129.  
  130. EventManager.AuthenticationRequired ();
  131.  
  132. Log.Debug ("Auth", "Ho acquisito utente e password");
  133. }
  134.  
  135. EventManager.ListUpdateStarted ();
  136.  
  137. s = new Sftp("poisson.phc.unipi.it", GlobalConfig.GetValue("user"),
  138. GlobalConfig.password);
  139.  
  140. try {
  141. s.Connect ();
  142. }
  143. catch (Exception e) {
  144. Log.Error ("Autenticazione errata (" + e.Message + ")");
  145. GlobalConfig.authenticated = false;
  146. }
  147.  
  148.  
  149. if(!GlobalConfig.authenticated)
  150. {
  151. EventManager.ErrorMessage ("Autenticazione fallita");
  152. }
  153. else
  154. {
  155. try {
  156. lock(typeof(GlobalConfig)){
  157. Log.Debug ("Net", "Aggiornamento della lista avviato");
  158. s.Get(GlobalConfig.GetValue("index"), GlobalConfig.ListFileName());
  159. Log.Info ("Lista Aggiornata");
  160. s.Close ();
  161. }}
  162. catch (Exception e) { Log.Error ("Errore: " + e.Message); }
  163. }
  164. EventManager.ListUpdateFinished ();
  165. }
  166.  
  167.  
  168. public void Disconnect ()
  169. {
  170. foreach(FileTransfer t in this.transfers)
  171. {
  172. Log.Info ("Termino i trasferimenti in corso");
  173. t.Stop ();
  174. }
  175.  
  176. }
  177.  
  178. public void DisconnectPath (string GUID)
  179. {
  180. FileTransfer stoppedTransfer = null;
  181. foreach(FileTransfer t in this.transfers)
  182. {
  183. if ( t.GetGUID () == GUID)
  184. {
  185. t.Stop ();
  186. stoppedTransfer = t;
  187. }
  188. }
  189. if(stoppedTransfer != null)
  190. transfers.Remove (stoppedTransfer);
  191. }
  192.  
  193.  
  194. public void Download(File f, string downloadFolder)
  195. {
  196. Log.Info ("Comincio il download di " + f.name);
  197. // Preparo gli argomento da passare alla funzione.
  198.  
  199. if (!GlobalConfig.authenticated)
  200. {
  201. Log.Debug ("Auth", "Chiedo di effettuare l'autenticazione");
  202. EventManager.AuthenticationDialog ();
  203. }
  204.  
  205.  
  206.  
  207. ArrayList args = new ArrayList ();
  208. args.Add (f);
  209. args.Add (downloadFolder);
  210. Thread t = new Thread (new ParameterizedThreadStart(_Download));
  211. t.Start (args);
  212. this.threads.Add (t);
  213. }
  214.  
  215. protected void _Download(object args)
  216. {
  217. // Questi cast sono piuttosto brutali ma posso passare
  218. // solo un oggetto a Download e quindi è il meglio che
  219. // mi riesce di fare.
  220. File f = (File) ((ArrayList) args)[0];
  221. string downloadFolder = (string) ((ArrayList) args)[1];
  222.  
  223.  
  224. FileDownlad transfer;
  225. try {
  226. transfer = new FileDownlad (f, GlobalConfig.GetValue("user"), GlobalConfig.password, downloadFolder);
  227. this.transfers.Add (transfer);
  228. } catch (Exception e) {
  229. Log.Error (e.Message);
  230. GlobalConfig.authenticated = false;
  231.  
  232. EventManager.ErrorMessage ("Autenticazione fallita");
  233. return;
  234. }
  235.  
  236. try {transfer.Start ();}
  237. catch (Exception) {
  238. // Si lamenterà se e quando termineremo il trasferimento
  239. // brutalmente ma per ora sembra che non ci possiamo fare niente.
  240. }
  241.  
  242. }
  243.  
  244. public void Upload(string f)
  245. {
  246. // Preparo gli argomento da passare alla funzione.
  247. if (!GlobalConfig.authenticated)
  248. EventManager.AuthenticationDialog ();
  249.  
  250.  
  251. ArrayList args = new ArrayList ();
  252. args.Add (f);
  253. Thread t = new Thread (new ParameterizedThreadStart(_Upload));
  254. t.Start (args);
  255. this.threads.Add (t);
  256. }
  257.  
  258. protected void _Upload(object args)
  259. {
  260. // Questi cast sono piuttosto brutali ma posso passare
  261. // solo un oggetto a Download e quindi è il meglio che
  262. // mi riesce di fare.
  263. string f = (string) ((ArrayList) args)[0];
  264. Log.Info ("Avvio l'upload di " + f);
  265.  
  266. FileUpload transfer;
  267. try {
  268. transfer = new FileUpload (f, GlobalConfig.GetValue("user"), GlobalConfig.password);
  269. this.transfers.Add (transfer);
  270.  
  271. } catch (Exception e) {
  272.  
  273. Log.Error (e.Message);
  274. GlobalConfig.authenticated = false;
  275. EventManager.ErrorMessage ("Autenticazione fallita");
  276. return;
  277. }
  278.  
  279. try {transfer.Start ();}
  280. catch (Exception) {
  281. // Ci potrebbero essere dei problemi ma per ora non
  282. // vogliamo occuparcene.
  283. }
  284. }
  285.  
  286.  
  287.  
  288. }
  289.  
  290.  
  291.  
  292.  
  293.  
  294. }