Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 297 lines (278 sloc) 11.603 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 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
#pragma once

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

extern "C++"
{
void setSmtpServerAddress(String*,int);
void setPop3ServerAddress(String*,int);
void setUserInfo(String*,String*);
String* loginToPop3Server();
}

namespace SMTPemailclient
{
/// <summary>
/// Summary for loginForm
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public __gc class loginForm : public System::Windows::Forms::Form
{
public:
loginForm(void)
{
InitializeComponent();

}
        
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::Label * label1;
private: System::Windows::Forms::Label * label2;
private: System::Windows::Forms::Label * label3;
private: System::Windows::Forms::Label * label4;

private: System::Windows::Forms::PictureBox * pictureBox1;
private: System::Windows::Forms::Button * button1;
private: System::Windows::Forms::Button * button2;
private: System::Windows::Forms::TextBox * serverTextBox;
private: System::Windows::Forms::TextBox * usernameTextBox;
private: System::Windows::Forms::TextBox * passwordTextBox;
private: System::Windows::Forms::ErrorProvider * loginError;
private: System::Windows::Forms::CheckBox * checkBox1;
private: bool pop3enabled;

private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container* components;

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::Resources::ResourceManager * resources = new System::Resources::ResourceManager(__typeof(SMTPemailclient::loginForm));
this->label1 = new System::Windows::Forms::Label();
this->label2 = new System::Windows::Forms::Label();
this->label3 = new System::Windows::Forms::Label();
this->label4 = new System::Windows::Forms::Label();
this->serverTextBox = new System::Windows::Forms::TextBox();
this->usernameTextBox = new System::Windows::Forms::TextBox();
this->passwordTextBox = new System::Windows::Forms::TextBox();
this->pictureBox1 = new System::Windows::Forms::PictureBox();
this->button1 = new System::Windows::Forms::Button();
this->button2 = new System::Windows::Forms::Button();
this->loginError = new System::Windows::Forms::ErrorProvider();
this->checkBox1 = new System::Windows::Forms::CheckBox();
this->SuspendLayout();
//
// label1
//
this->label1->Font = new System::Drawing::Font(S"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
this->label1->Location = System::Drawing::Point(88, 32);
this->label1->Name = S"label1";
this->label1->Size = System::Drawing::Size(296, 24);
this->label1->TabIndex = 0;
this->label1->Text = S"Please type your user name and password.";
//
// label2
//
this->label2->Font = new System::Drawing::Font(S"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
this->label2->Location = System::Drawing::Point(96, 72);
this->label2->Name = S"label2";
this->label2->Size = System::Drawing::Size(88, 24);
this->label2->TabIndex = 1;
this->label2->Text = S"Server:";
this->label2->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
//
// label3
//
this->label3->Font = new System::Drawing::Font(S"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
this->label3->Location = System::Drawing::Point(96, 112);
this->label3->Name = S"label3";
this->label3->Size = System::Drawing::Size(88, 24);
this->label3->TabIndex = 2;
this->label3->Text = S"User name:";
this->label3->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
//
// label4
//
this->label4->Font = new System::Drawing::Font(S"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
this->label4->Location = System::Drawing::Point(96, 152);
this->label4->Name = S"label4";
this->label4->Size = System::Drawing::Size(88, 24);
this->label4->TabIndex = 3;
this->label4->Text = S"Password:";
this->label4->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
//
// serverTextBox
//
this->serverTextBox->Font = new System::Drawing::Font(S"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
this->serverTextBox->Location = System::Drawing::Point(192, 73);
this->serverTextBox->Name = S"serverTextBox";
this->serverTextBox->Size = System::Drawing::Size(272, 22);
this->serverTextBox->TabIndex = 1;
this->serverTextBox->Text = S"";
//
// usernameTextBox
//
this->usernameTextBox->Font = new System::Drawing::Font(S"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
this->usernameTextBox->Location = System::Drawing::Point(192, 113);
this->usernameTextBox->Name = S"usernameTextBox";
this->usernameTextBox->Size = System::Drawing::Size(272, 22);
this->usernameTextBox->TabIndex = 2;
this->usernameTextBox->Text = S"";
//
// passwordTextBox
//
this->passwordTextBox->Font = new System::Drawing::Font(S"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
this->passwordTextBox->Location = System::Drawing::Point(192, 153);
this->passwordTextBox->Name = S"passwordTextBox";
this->passwordTextBox->PasswordChar = '*';
this->passwordTextBox->Size = System::Drawing::Size(272, 22);
this->passwordTextBox->TabIndex = 3;
this->passwordTextBox->Text = S"";
//
// pictureBox1
//
this->pictureBox1->Image = (__try_cast<System::Drawing::Image * >(resources->GetObject(S"pictureBox1.Image")));
this->pictureBox1->Location = System::Drawing::Point(24, 56);
this->pictureBox1->Name = S"pictureBox1";
this->pictureBox1->Size = System::Drawing::Size(64, 72);
this->pictureBox1->TabIndex = 7;
this->pictureBox1->TabStop = false;
//
// button1
//
this->button1->Font = new System::Drawing::Font(S"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
this->button1->Location = System::Drawing::Point(288, 224);
this->button1->Name = S"button1";
this->button1->Size = System::Drawing::Size(72, 32);
this->button1->TabIndex = 4;
this->button1->Text = S"OK";
this->button1->Click += new System::EventHandler(this, button1_Click);
//
// button2
//
this->button2->Font = new System::Drawing::Font(S"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
this->button2->Location = System::Drawing::Point(392, 224);
this->button2->Name = S"button2";
this->button2->Size = System::Drawing::Size(72, 32);
this->button2->TabIndex = 5;
this->button2->Text = S"Cancel";
this->button2->Click += new System::EventHandler(this, button2_Click);
//
// loginError
//
this->loginError->ContainerControl = this;
//
// checkBox1
//
this->checkBox1->Location = System::Drawing::Point(48, 200);
this->checkBox1->Name = S"checkBox1";
this->checkBox1->Size = System::Drawing::Size(152, 24);
this->checkBox1->TabIndex = 8;
this->checkBox1->Text = S"login without pop3";
//
// loginForm
//
this->AcceptButton = this->button1;
this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
this->ClientSize = System::Drawing::Size(482, 272);
this->ControlBox = false;
this->Controls->Add(this->checkBox1);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->pictureBox1);
this->Controls->Add(this->passwordTextBox);
this->Controls->Add(this->usernameTextBox);
this->Controls->Add(this->serverTextBox);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog;
this->Name = S"loginForm";
this->ShowInTaskbar = false;
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = S"Please Sign in";
this->TopMost = true;
this->ResumeLayout(false);

}



private: System::Void button2_Click(System::Object * sender, System::EventArgs * e)
{
exit(0);
}

private: System::Void button1_Click(System::Object * sender, System::EventArgs * e)
{

String* server = S""; String* smtpServer = S""; String* pop3Server = S"";
String* username = S""; String* password = S""; String* serverMessage = S"";
Char delimStr = '.';
int index;
if(this->checkBox1->Checked)
{
pop3enabled = false;
if(this->serverTextBox->get_Text()->Equals(S""))
{
loginError->SetIconAlignment(this->serverTextBox,ErrorIconAlignment::MiddleLeft);
loginError->SetError(this->usernameTextBox,S"You must at least specify a server address");
}
else
{
server = this->serverTextBox->get_Text();
index = server->IndexOf(delimStr);
server = server->Remove(0,index);
smtpServer = System::String::Concat("mail",server);
setSmtpServerAddress(smtpServer,25);

this->Hide();
}
}
else
{
server = this->serverTextBox->get_Text();
username = this->usernameTextBox->get_Text();
password = this->passwordTextBox->get_Text();

index = server->IndexOf(delimStr);
server = server->Remove(0,index);
smtpServer = System::String::Concat("mail",server);
pop3Server = System::String::Concat("pop3",server);
setSmtpServerAddress(smtpServer,25);
setPop3ServerAddress(pop3Server,110);
setUserInfo(username,password);
bool connected = processServerMessage(loginToPop3Server());
if(connected)
this->Hide();
else
{
loginError->SetIconAlignment(this->usernameTextBox,ErrorIconAlignment::MiddleLeft);
loginError->SetError(this->usernameTextBox,S"ERROR: \n\nIncorrect username and or password, please try again");
this->usernameTextBox->Text = "";
this->passwordTextBox->Text = "";
}
}
}

bool processServerMessage(String* message)
{
if(message->StartsWith(S"+OK"))
return true;
else
return false;
}

public: bool getpop3enabled()
{
return pop3enabled;
}
};

}
Something went wrong with that request. Please try again.