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