Menu

[r19]: / trunk / WhatsappClient / Form_Debug.cs  Maximize  Restore  History

Download this file

141 lines (126 with data), 4.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
* by Swen Kooij aka Kirk - swenkooij@gmail.com
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
/// <summary>
/// The main namespace for the 'Whatsapp Desktop Client' project.
/// </summary>
namespace WhatsappClient
{
/// <summary>
/// A form that is used to test and debug new code and functionalitly
/// </summary>
public partial class Form_Debug : Form
{
// Create an empty instance of the WhatsAppHelper class
private WhatsAppHelper Helper;
/// <summary>
/// Class constructor, initializes the class.
/// </summary>
public Form_Debug()
{
InitializeComponent();
// Initliaze new instance of WhatsAppHelper class
Helper = new WhatsAppHelper();
}
/// <summary>
/// Adds a new line to the top of the RichTextBox designed for logging.
/// </summary>
/// <param name="Text">A string with the text that needs to be appended to the log.</param>
private void AddToLog(string Text)
{
RT_Log.Text = "-> " + Text + Environment.NewLine + RT_Log.Text;
}
/// <summary>
/// Event: Selected item in the 'Device OS' box changed
/// </summary>
private void ComboBox_DeviceOS_SelectedIndexChanged(object sender, EventArgs e)
{
string SelectedValue = ComboBox_DeviceOS.Text;
if (SelectedValue == "iOS")
Label_ImeiMac.Text = "Wifi Mac Adress:";
else
Label_ImeiMac.Text = "IMEI:";
}
/// <summary>
/// Event: The form has loaded
/// </summary>
private void Form_Debug_Load(object sender, EventArgs e)
{
ComboBox_DeviceOS.Text = "Android";
}
/// <summary>
/// Event: The 'Generate Password' button has been clicked
/// </summary>
private void Button_GeneratePassword_Click(object sender, EventArgs e)
{
if (ComboBox_DeviceOS.Text == "iOS")
{
TextBox_Password.Text = Helper.generatePassword(TextBox_ImeiMac.Text, WhatsAppHelper.DeviceOS.iOS);
}
else
{
TextBox_Password.Text = Helper.generatePassword(TextBox_ImeiMac.Text, WhatsAppHelper.DeviceOS.Other);
}
}
/// <summary>
/// Event: The 'Test Connection' button has been clicked
/// </summary>
private void Button_TestConnection_Click(object sender, EventArgs e)
{
ThreadedMethod tMethod = new ThreadedMethod(verifyAccount);
tMethod.Start();
}
/// <summary>
/// Verifies the account, this method is supposed to be called in a seperated thread using the ThreadedMethod class.
/// </summary>
private void verifyAccount()
{
// Verify account
bool Result = Helper.verifyAccount(TextBox_PhoneNumber.Text, TextBox_Password.Text);
if (Result)
AddToLog("Account exists!");
else
AddToLog("Account does not exists!");
}
/// <summary>
/// Event: The 'Get Version' button has been clicked
/// </summary>
private void Button_GetVersion_Click(object sender, EventArgs e)
{
ThreadedMethod tMethod = new ThreadedMethod(getVersion);
tMethod.Start();
}
/// <summary>
/// Retrieves the WhatsApp mobile app version and adds it to the log, this method is supposed
/// to be run in a seperated thread.
/// </summary>
private void getVersion()
{
AddToLog("Current Whatsapp version: " + Helper.getVersion());
}
/// <summary>
/// Event: The 'New Account' button has been clicked.
/// </summary>
private void Button_NewAccount_Click(object sender, EventArgs e)
{
ThreadedMethod tMethod = new ThreadedMethod(NewAccount);
tMethod.Start();
}
/// <summary>
/// Sends a request to the whatsapp servers to send a SMS with an activation code, this method is supposed
/// to be run in a seperated thread.
/// </summary>
private void NewAccount()
{
Helper.requestActivationSms(TextBox_PhoneNumber.Text);
}
}
}
MongoDB Logo MongoDB