A skype history message viewer written in c#
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
3.0 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using SKYPE4COMLib;
  11. namespace Skype_History_Viewer
  12. {
  13. public partial class FrmMain : Form
  14. {
  15. private Boolean connected = false;
  16. private Skype skype = new Skype();
  17. public FrmMain()
  18. {
  19. InitializeComponent();
  20. connected = connectToSkype();
  21. }
  22. private void cmdAdd_Click(object sender, EventArgs e)
  23. {
  24. if(!connected)
  25. {
  26. errorMessage();
  27. }
  28. else
  29. {
  30. //displays the chat of selected user
  31. String name = lstUsers.GetItemText(lstUsers.SelectedItem);
  32. String display = "";
  33. foreach (Chat oChat in skype.Chats)
  34. {
  35. foreach (ChatMessage oMessage in oChat.Messages)
  36. {
  37. if(oMessage.Sender.FullName.Equals(name))
  38. {
  39. if (chTime.Checked) display = oMessage.Timestamp.ToString() + " ";
  40. if (chUser.Checked) display += oMessage.Sender.FullName + " ";
  41. display += oMessage.Body;
  42. lstChat.Items.Add(display);
  43. display = "";
  44. }
  45. }
  46. }
  47. }
  48. }
  49. private void errorMessage()
  50. {
  51. connected = connectToSkype();
  52. if(!connected)
  53. {
  54. MessageBox.Show("Could not connect to skype, please make sure that skype is running and this plugin is allowed.");
  55. }
  56. }
  57. private Boolean connectToSkype()
  58. {
  59. try
  60. {
  61. //attaches the program to skype
  62. skype.Attach();
  63. //adds all users to lstUsers
  64. if(!connected)
  65. {
  66. foreach (User user in skype.Friends)
  67. {
  68. lstUsers.Items.Add(user.FullName);
  69. }
  70. }
  71. return true;
  72. }
  73. catch
  74. {
  75. return false;
  76. }
  77. }
  78. private void cmdExport_Click(object sender, EventArgs e)
  79. {
  80. if (!connected)
  81. {
  82. errorMessage();
  83. }
  84. else
  85. {
  86. }
  87. }
  88. private void cmdExportAll_Click(object sender, EventArgs e)
  89. {
  90. if (!connected)
  91. {
  92. errorMessage();
  93. }
  94. else
  95. {
  96. }
  97. }
  98. private void cmdClear_Click(object sender, EventArgs e)
  99. {
  100. lstChat.Items.Clear();
  101. }
  102. }
  103. }