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 Gtk;
  4. using System.Collections.Generic;
  5.  
  6. namespace Dizzy
  7. {
  8.  
  9. /*
  10. * Problema: Supponiamo di avere un thread disperso per il programma
  11. * che ad un certo punto decide che deve comunicare all'utente che è
  12. * successo un gran casino. Come va?
  13. *
  14. * Soluzione 1: Emette un evento che da qualche altra parte è stato
  15. * collegato ad una funzione che crea un dialog. Questo crea problemi
  16. * con il fatto che le chiamate alle gtk vengono fatte dal thread sbagliato.
  17. *
  18. * Soluzione attuale: Riceviamo le chiamate qua dentro. Questo oggetto
  19. * inserisce le chiamate corrette nel thread principale.
  20. */
  21.  
  22. public class EventManager
  23. {
  24.  
  25. public static MessageDialog searchInProgress = null;
  26. public static MessageDialog listUpdate = null;
  27. public static AuthDialog authDialog = null;
  28.  
  29. // Gestione dei file e dei task. Questi devono essere inizializzati
  30. // Appena sono creati.
  31. public static FileTreeView fileTreeView;
  32. public static TaskTreeView taskTreeView;
  33.  
  34. public EventManager () {
  35. }
  36.  
  37. protected static Dictionary<string,TreeIter> iters = new Dictionary<string, TreeIter> ();
  38.  
  39. // Metodo generico per segnalare un'errore dell'applicazione.
  40. public static void ErrorMessage (string message) {
  41.  
  42. GLib.Idle.Add(delegate {
  43. Log.Error (message);
  44.  
  45. MessageDialog d = new Gtk.MessageDialog(null,
  46. Gtk.DialogFlags.DestroyWithParent,
  47. Gtk.MessageType.Error,
  48. Gtk.ButtonsType.Ok, "");
  49. d.Markup = message;
  50. d.Run ();
  51. d.Destroy ();
  52. return false;
  53. });
  54. }
  55.  
  56. // Metodi per gestire la ricerca
  57. public static void SearchStarted () {
  58.  
  59. // Questo significa che stiamo già effettuando una ricerca
  60. if (searchInProgress != null)
  61. return;
  62.  
  63. searchInProgress = new MessageDialog(null,
  64. DialogFlags.Modal,
  65. MessageType.Info,
  66. ButtonsType.None,
  67. true, "");
  68. searchInProgress.Markup = "Ricerca in corso, attendere.";
  69. GLib.Idle.Add (delegate {
  70. if (EventManager.searchInProgress != null)
  71. EventManager.searchInProgress.Run ();
  72. return false;
  73. });
  74. }
  75.  
  76. public static void AuthenticationRequired () {
  77. GLib.Idle.Add (delegate { return AuthenticationDialog (); });
  78. WaitForAuthentication ();
  79. }
  80.  
  81. public static bool AuthenticationDialog () {
  82. Log.Info ("Uei, sembra che qualcuno mi abbia chiesto di autenticarsi!");
  83. if (EventManager.authDialog == null)
  84. {
  85. EventManager.authDialog = new AuthDialog ();
  86. EventManager.authDialog.Run ();
  87. EventManager.authDialog.Destroy ();
  88. EventManager.authDialog = null;
  89. GlobalConfig.authenticated = true;
  90. }
  91. return false;
  92. }
  93.  
  94. public static void WaitForAuthentication () {
  95. while (!GlobalConfig.authenticated)
  96. System.Threading.Thread.Sleep (100);
  97. }
  98.  
  99. public static void SearchFinished () {
  100. if (searchInProgress == null)
  101. {
  102. Log.Warning ("Sembra che la ricerca sia già morta di per sè");
  103. return;
  104. }
  105. else
  106. {
  107. GLib.Idle.Add(delegate {
  108. searchInProgress.Destroy ();
  109. searchInProgress = null;
  110. return false;
  111. });
  112. }
  113. }
  114.  
  115. // Metodi per gestire l'update della lista
  116. public static void ListUpdateStarted () {
  117.  
  118. // Questo significa che stiamo già effettuando una ricerca
  119. if (listUpdate != null)
  120. return;
  121.  
  122. listUpdate = new MessageDialog(null,
  123. DialogFlags.Modal,
  124. MessageType.Info,
  125. ButtonsType.None,
  126. true, "");
  127. listUpdate.Markup = "Aggiornamento della lista in corso";
  128. GLib.Idle.Add (delegate {
  129. if (EventManager.listUpdate != null)
  130. EventManager.listUpdate.Run ();
  131. return false;
  132. });
  133. }
  134.  
  135. public static void ListUpdateFinished () {
  136. if (listUpdate == null)
  137. return;
  138. else
  139. {
  140. GLib.Idle.Add(delegate {
  141. listUpdate.Destroy ();
  142. Log.Info ("Aggiornamento completato");
  143. EventManager.listUpdate = null;
  144. return false;
  145. });
  146. }
  147. }
  148.  
  149. public static void FileTreeViewAddFile(File f)
  150. {
  151. if (fileTreeView == null) { return; }
  152. GLib.Idle.Add(delegate {
  153. lock(fileTreeView) {
  154. fileTreeView.AddFile (f);
  155. }
  156. return false;
  157. });
  158. }
  159.  
  160. public static void FileTreeViewClear() {
  161. if (fileTreeView == null) { return; }
  162. GLib.Idle.Add(delegate {
  163. lock(fileTreeView) {
  164. fileTreeView.Clear ();
  165. }
  166. return false;
  167. });
  168. }
  169.  
  170. public static void TaskTreeViewAddTask (string filename, int perc, string GUID)
  171. {
  172. if (taskTreeView == null)
  173. return;
  174. GLib.Idle.Add (delegate {
  175. lock(taskTreeView) {
  176. EventManager.AddIter(GUID, taskTreeView.AddTask (filename, perc));
  177. }
  178. return false;
  179. });
  180.  
  181. }
  182.  
  183. public static void TaskTreeViewSetProgress (string GUID, int perc)
  184. {
  185. if (taskTreeView == null)
  186. return;
  187. TreeIter iter;
  188. try {iter = iters[GUID];}
  189. catch (System.Collections.Generic.KeyNotFoundException)
  190. {
  191. // Questo si può verificare se abbiamo annullato il trasferimento
  192. // e già tolto il task, ma _get di sharpssh se ne deve ancora
  193. // rendere conto. In questo caso facciamo finta di nulla, tanto
  194. // se ne accorgerà appena avrà svuotato il buffer.
  195. return;
  196. }
  197. GLib.Idle.Add(delegate {
  198. lock (taskTreeView) {
  199. taskTreeView.SetProgress (iter, perc);
  200. }
  201. return false;
  202. });
  203. }
  204.  
  205. public static void TaskTreeViewRemove (string GUID)
  206. {
  207. if (taskTreeView == null)
  208. return;
  209. TreeIter iter = iters[GUID];
  210. GLib.Idle.Add (delegate {
  211. lock (taskTreeView) {
  212. taskTreeView.DeleteRow (iter); }
  213. return false;
  214. });
  215. iters.Remove (GUID);
  216. }
  217.  
  218. public static void AddIter (string GUID, TreeIter iter)
  219. {
  220. iters.Add(GUID, iter);
  221. }
  222.  
  223. public static TreeIter GetIter (string GUID)
  224. {
  225. TreeIter ret;
  226. try {
  227. ret = iters[GUID];
  228. return ret;
  229. }
  230. catch (Exception e)
  231. {
  232. // Aspettiamo nella speranza che le cose vadano meglio
  233. Log.Warning ("Sto richiamando GetIter () per ottenre l'iter (" + e.Message + ")");
  234. System.Threading.Thread.Sleep(200);
  235. }
  236. return GetIter(GUID);
  237. }
  238.  
  239. public static string GetGUID (TreePath path)
  240. {
  241. foreach(KeyValuePair<string, TreeIter> pair in iters)
  242. {
  243. if (taskTreeView.IterToPath (pair.Value).Compare(path) == 0)
  244. return pair.Key;
  245. }
  246. Log.Warning ("TreePath non trovato, ritorno null");
  247. return null;
  248. }
  249.  
  250. }
  251. }