Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 4163 → Rev 4164

/programs/cmm/liza/login.c
12,13 → 12,19
edit_box login_box= {PANEL_W-6,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(email_text)+2,#email_text,#mouse_dd,0b10};
edit_box pass_box= {PANEL_W-6,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(pass_text)+2,#pass_text,#mouse_dd,0b1};
 
void StopConnect(dword message)
{
if (message) notify(message);
aim = STOP;
}
 
 
void LoginBoxLoop()
{
int key, id;
char socket_char;
 
SetLoginStatus(NULL,NULL);
SetLoginStatus(NULL);
 
goto _LB_DRAW;
loop()
27,7 → 33,7
switch(EAX & 0xFF)
{
case evMouse:
IF (GetProcessSlot(Form.ID)-GetActiveProcess()!=0) break;
if (!CheckActiveProcess(Form.ID)) break;
edit_box_mouse stdcall (#login_box);
edit_box_mouse stdcall (#pass_box);
break;
35,12 → 41,11
case evButton:
id = GetButtonID();
if (id==1) SaveAndExit();
if (id==11) OptionsLoop();
if (id==11) SettingsDialog();
if (id==12)
{
if (!aim) aim=RESOLVE; else aim=NULL;
GetSettings();
SetLoginStatus(NULL, NULL);
DrawLoginScreen();
}
break;
57,12 → 62,10
edit_box_draw stdcall(#pass_box);
break;
}
if (key==13)
if (key==13) && (!aim)
{
if (aim) break;
aim=RESOLVE;
GetSettings();
SetLoginStatus(NULL, NULL);
DrawLoginScreen();
}
EAX=key<<8;
76,34 → 79,30
break;
 
default:
if (!aim) { SetLoginStatus(NULL, NULL); break; }
if (!email_text) { notify("Enter email!"); aim=NULL; }
if (!pass_text) { notify("Enter password!"); aim=NULL; }
if ((!login) || (!POP_server_path)) { notify("Email should be such as username@somesite.com"); aim=NULL; }
if (!aim) break;
if (!email_text) StopConnect("Enter email!");
if (!pass_text) StopConnect("Enter password!");
if ((!login) || (!POP_server_path)) StopConnect("Email should be such as username@somesite.com");
if (aim == RESOLVE)
{
SetLoginStatus(1, "Resolving server address...");
sockaddr.sin_family = AF_INET4;
AX = POP_server_port;
$xchg al, ah
sockaddr.sin_port = AX;
sockaddr.sin_addr = GetIPfromAdress(#POP_server_path);
if (!sockaddr.sin_addr) { SetLoginStatus(12, "Can't obtain server IP."); aim = FAILED; break;}
 
if (!sockaddr.sin_addr) { StopConnect("Can't obtain server IP."); break;}
aim = OPEN_CONNECTION;
break;
}
if (aim == OPEN_CONNECTION)
{
SetLoginStatus(1, "Connecting to server...");
socketnum = Socket(AF_INET4, SOCK_STREAM, 0);
if (socketnum == 0xffffffff) { SetLoginStatus(13, "Cannot open socket."); aim = FAILED; break;}
if (socketnum == 0xffffffff) { StopConnect("Cannot open socket."); break;}
Connect(socketnum, #sockaddr, 16);
SetLoginStatus(55, "Connection established. Waiting for answer...");
aim = GET_ANSWER_CONNECT;
break;
}
 
110,36 → 109,26
if (aim == GET_ANSWER_CONNECT)
{
ticks = Receive(socketnum, #immbuffer, BUFFERSIZE, 0);
if ((ticks == 0xffffff) || (ticks < 2)) { SetLoginStatus(61, "Connection failed"); aim = FAILED; break;}
if ((ticks == 0xffffff) || (ticks < 2)) { StopConnect("Connection failed"); break;}
immbuffer[ticks]='\0';
if (immbuffer[ticks-2]=='\n')
{
debug(#immbuffer);
if (strstr(#immbuffer,"+OK"))
{
SetLoginStatus(60, "Verifying username...");
aim = SEND_USER;
}
else
{
//aim=NULL; //may don't need retry?
SetLoginStatus(55, "Failed to connect to server. Retry...");
StopConnect("Failed to connect to server. Retry...");
}
}
else
{
SetLoginStatus(103, "Connection failed");
}
}
 
if (aim == SEND_USER)
{
request_len = GetRequest("USER", #login);
Send(socketnum, #request, request_len, 0);
if (EAX == 0xffffffff) { SetLoginStatus(60, "Failed to send USER. Retry..."); break;}
SetLoginStatus(70, "Login verifying...");
debug("Send USER, awaiting answer...");
if (Send(socketnum, #request, request_len, 0) == 0xffffffff)
{
SetLoginStatus("Failed to send USER. Retry...");
break;
}
aim = GET_ANSWER_USER;
}
 
146,30 → 135,33
if (aim == GET_ANSWER_USER)
{
ticks = Receive(socketnum, #immbuffer, BUFFERSIZE, 0);
if ((ticks == 0xffffffff) || (ticks < 2)) { SetLoginStatus(81, "Connection failed"); break;}
if ((ticks == 0xffffffff) || (ticks < 2)) { SetLoginStatus("Connection failed"); break;}
immbuffer[ticks]='\0';
if (immbuffer[ticks-2]=='\n')
{
debug("GOT::");
debug(#immbuffer);
if (strstr(#immbuffer,"+OK"))
{ aim = SEND_PASS; SetLoginStatus(80, "Verifying password...");}
aim = SEND_PASS;
else
{ notify("Wrong username"); aim=NULL;}
{
debug(#immbuffer);
StopConnect("Wrong username");
}
}
else
{
SetLoginStatus(103, "Connection failed");
StopConnect("Connection failed");
}
}
 
if (aim == SEND_PASS)
{
debug("\n Send PASS, awaiting answer...");
request_len = GetRequest("PASS", #pass_text);
Send(socketnum, #request, request_len, 0);
if (EAX == 0xffffffff) { SetLoginStatus(80, "Failed to send PASS. Retry..."); break;}
if (Send(socketnum, #request, request_len, 0) == 0xffffffff)
{
SetLoginStatus("Failed to send PASS. Retry...");
break;
}
aim = GET_ANSWER_PASS;
}
 
176,28 → 168,21
if (aim == GET_ANSWER_PASS)
{
ticks = Receive(socketnum, #immbuffer, BUFFERSIZE, 0);
if ((ticks == 0xffffff) || (ticks < 2)) { SetLoginStatus(101, "Server disconnected"); break;}
if ((ticks == 0xffffff) || (ticks < 2)) { SetLoginStatus("Server disconnected"); break;}
immbuffer[ticks]='\0';
if (immbuffer[ticks-2]=='\n')
{
debug("GOT::");
debug(#immbuffer);
if (strstr(#immbuffer,"+OK"))
{
SetLoginStatus(100, "Entering mailbox...");
aim=SEND_NSTAT;
MailBoxLoop();
}
if (strstr(#immbuffer,"+OK")) MailBoxLoop();
else
{
notify("Wrong password");
aim=NULL;
StopConnect("Wrong password or POP3 disabled");
debug(#immbuffer);
}
}
else
{
SetLoginStatus(103, "Connection failed");
StopConnect("Connection failed");
}
}
207,6 → 192,7
}
 
 
 
void DrawLoginScreen()
{
panel_x = Form.cwidth - PANEL_W /2;
237,7 → 223,7
}
else DrawCaptButton(panel_x+120,panel_y+90,100,20,12,sc.work_button, sc.work_button_text,"Stop");
SetLoginStatus(cur_st_percent, cur_st_text);
SetLoginStatus(cur_st_text);
}
 
 
271,11 → 257,10
 
void GetSettings()
{
GetServerPathAndLogin(); //get
GetServerPathAndLogin();
if (checked[CUSTOM])
{
if (!strcmp(#POP_server_path, "pop.gmail.com")) POP_server_port = 995;
else POP_server_port = DEFAULT_POP_PORT;
POP_server_port = DEFAULT_POP_PORT;
}
if (checked[MANUAL])
{
282,13 → 267,11
strcpy(#POP_server_path, #POP_server1);
POP_server_port = atoi(#POP_server_port1);
}
debug(#POP_server_path);
debug(itoa(POP_server_port));
if (!strcmp(#POP_server_path, "pop.gmail.com")) StopConnect("Can't connect GMAIL servers. Not support SSL/TLS encryption");
}
 
void SetLoginStatus(dword percent1, text1)
void SetLoginStatus(dword text1)
{
DrawProgressBar(10, Form.cheight-22, PANEL_W, 12, sc.work, sc.work_graph, 0x54B1D6, sc.work_text, percent1, text1);
cur_st_percent = percent1;
if (text1) WriteText(10, Form.cheight-22, 0x80, sc.work_text, text1);
cur_st_text = text1;
}