/src/Logopathy/Logopathy.Irc/TpChat.cs

https://github.com/wfarr/logopathy · C# · 98 lines · 81 code · 14 blank · 3 comment · 0 complexity · c7f1576869a3eaef184a7087f003f15f MD5 · raw file

  1. using System;
  2. using System.Collections;
  3. using Gtk;
  4. using Logopathy.Core;
  5. using Logopathy.Irc;
  6. namespace Logopathy.Irc {
  7. public class TpChat : IChat {
  8. private TextBuffer model;
  9. public TextBuffer Model {
  10. get {
  11. return model;
  12. }
  13. set {
  14. model = value;
  15. }
  16. }
  17. private string id;
  18. public string Id {
  19. get {
  20. return id;
  21. }
  22. set {
  23. id = value;
  24. }
  25. }
  26. private string name;
  27. public string Name {
  28. get {
  29. return name;
  30. }
  31. set {
  32. name = value;
  33. }
  34. }
  35. private ChatStatus status;
  36. public ChatStatus Status {
  37. get {
  38. return status;
  39. }
  40. set {
  41. status = value;
  42. }
  43. }
  44. private string username;
  45. public string Username {
  46. get {
  47. return username;
  48. }
  49. set {
  50. username = value;
  51. }
  52. }
  53. private ArrayList users;
  54. public ArrayList Users {
  55. get {
  56. return users;
  57. }
  58. set {
  59. users = value;
  60. }
  61. }
  62. public TpChat(string chatid /*FIXME when we have telepathy-glib-sharp &c.*/) {
  63. this.Id = chatid;
  64. this.Model = new Gtk.TextBuffer(new Gtk.TextTagTable());
  65. this.Name = "Something"; //FIXME when we can fetch this
  66. this.Status = ChatStatus.AllRead;
  67. this.Username = "Me"; //FIXME same as Name
  68. /* FIXME - there should be various event watches here for signals
  69. when the Telepathy chat has new messages, status changes, etc.
  70. But that depends on working bindings. */
  71. }
  72. public void Conversation(DateTime time, string username, string message) {
  73. string text = String.Format("<{0}> <b>*{1}</b>: {2}",Util.MakePrettyDate(time), username, message);
  74. AppendText(text);
  75. }
  76. public void Me(DateTime time, string username, string message) {
  77. string text = String.Format("<{0}> <b>*{1} {2}</b>", Util.MakePrettyDate(time), username, message);
  78. AppendText(text);
  79. }
  80. private void AppendText(string text) {
  81. Model.Text += text+"\n";
  82. }
  83. }
  84. }