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