From b16fc2b79200c52fb3f8cfbb99d03526e175ce37 Mon Sep 17 00:00:00 2001 From: liranbg Date: Sat, 27 Sep 2014 01:40:02 +0300 Subject: [PATCH] fix before first release fixed english translation, changed connectivity checkings add more debugging functions --- jceGrade.pro | 2 +- jce_en.qm | Bin 19276 -> 19314 bytes jce_en.ts | 107 +++---- jce_he.qm | Bin 11422 -> 11404 bytes jce_he.ts | 107 +++---- main/mainscreen.cpp | 436 +++++++++++++++-------------- main/mainscreen.h | 2 + main/mainscreen.ui | 6 +- src/jceConnection/jcesslclient.cpp | 436 ++++++++++++++++------------- src/jceConnection/jcesslclient.h | 2 + 10 files changed, 583 insertions(+), 515 deletions(-) diff --git a/jceGrade.pro b/jceGrade.pro index 5283ecb..3a29449 100644 --- a/jceGrade.pro +++ b/jceGrade.pro @@ -6,7 +6,7 @@ QT += core gui network widgets -CONFIG += qt c++11 static +CONFIG += qt c++11 #CONFIG += console static TARGET = jceManager diff --git a/jce_en.qm b/jce_en.qm index 9408f1692d003e86e4e24123d95a47884432ed05..919512b8b16dca9119ea304d80e8d7732c575ef0 100644 GIT binary patch delta 1296 zcmaJV7(H$8g?`*ZWk6+o)lLBs3j^7NRV*OY6(|$TVm86>ab+y5VgUpDu#RCI zVKZujQ(-eKlQ?E30~1HK7-dEVF*2hr7=Eclo)p~)rGL)!y01=%i zDgB4>`h1LQ!^TsCB=5!MFJA(p7h$(B1gyM=?w@|4&8+i`;NxNy%BLOUOb>9^0(iIbw; z!Tz{uF@K6e?GMCPUM&VztQWW4W?#;q;&yQWSQaV1`I{MtmBscq=)l_ZV&`lQkoCQI z+|lM?axCCOvl4hZBA|OyKk!UMpelD7NPQ=8o%Jj?)&#c9ks#@;I>|}m(7S49{|v2P zt}gjI6?pEFdh^7O6rQc_y?KjIkfI)Hbpq(rMwKrNPor z;HgW}R~|(@0XwB{n@JFQQm;=;UZ@JxTZ|sK1k(&zAs+M zKYFG9%!WN2d?&~d;RMot4hpf^=sGl(;VB}z(vO~BBHlmQ z1fLKeQxbWq{i1y5|6lc?vKqYh$fExu>bcY7^{q%A$k0z}7IazbOy#vT)vi_MO4-#Q xy9eTp=Y+&?IA~cO5rzJ(%c(?$TkU)F0Dd}0Zl0;I+*Mxf-5DD`V2hHH{{_f~JLv!b delta 1348 zcmY*X4NR1E9DeTZ{lndH2L{N8e0YL<6EHp&5#k|%bP`T!jTx6am?4gZATWsP8pD~R zSjI4enqlfpS`e%y%QYev$((>3BI83ojISE27_LEUJ$EOzc6;~xzrTBa&-47A|NG~8 z+3oYP4}4S40sAil?uUS^RKTMd(v>TK?i!>)3D~|0Y23)Z2_iEA2ws8sXdLkAgy=a2 z=xfdyJCMM2_-pz`FuD#(!A9 zvDe@NI-&SeV4Fk8o2ZUDUIZt!pCuAWfrvbC)C0WyC z1CVe*cJZeuz-3d`7Ic_`gR;#S3kP43%O>W4q-6QiGu(DZf;`$-NB5u04LMDKXS}>B zBL(mpkoRBvg2rEv50_Bbt3r{aBA<3b@#k}7l_+;M^uU~Zn`es{38I^xmVQJFoFG_iIzwEfRqmLrQxiZhgyeE z1LQ!=nnP<|CzDunRHV%Tu|~(tmBxABKGjr}nGL0@ zTAxIsD6P6WiV-~(s;=)?W0c#~-Gk+fyv9lWBj0x_owE9$WrXccukE_ZB)pw&HuHnh z8#HmDYC!R>Cb|7E4J>Q2WA1bQJx!~{2au0wE}6M;K#HdOAQ#gOX}XQ>Kwz8ZJG1N* zogC5pTulP^YOOXrj)FI|$7Xtg=y$ZGZ}1MoCbg%pa`5>?ZGATl^Hw`TbC^Uen1`kh_%dKyS|)(>v5AL)F`><9RTxtxxFAMlsEe3Eya$)&j5x)?^|9z_x_ zWTdN1;h{A5AQ|~6Lkep#ijX4a#3XcLTFi(Q)=4qW-+~yjofpNZ7#6=khcx8iWzJM^ z>c81BagT^4V(lyzu}p?xzFUNKc0^3^OoUiu9TN8%XEkm?R+TZEntjTyIQoCh#(K>T zGsVYj^g}kdMXZoyi3TV5Sg9>EZtab;+B>5*a$0_D$@<^2&15p7?JGZ7eVAN##T>EA zWSJ$>&ap!L1YY>MmrU`h!-WGH#xnbKDTXvu1M;@zb>x5Nmi3wY} zO0;vTZ7sHY> fek2ZjTn%aIy41=-U7D%5prY7RUea~QcUSbkjh}=r diff --git a/jce_en.ts b/jce_en.ts index 08621ff..13f13f0 100644 --- a/jce_en.ts +++ b/jce_en.ts @@ -46,8 +46,8 @@ MainScreen - JCE Avg Calculator - JCE Avg Calculator + JCE Manager + JCE Manager @@ -148,7 +148,8 @@ - <p align="right">Made By <a href="http://liranbg.github.io/JceManager/"><span style=" text-decoration: underline; color:#0000ff;">JceManager</span></a></p> + <p align="center">Made By <a href="http://liranbg.github.io/JceManager/"><span style=" text-decoration: underline; color:#0000ff;">JceManager</span></a></p> + <p align="right">Made By <a href="http://liranbg.github.io/JceManager/"><span style=" text-decoration: underline; color:#0000ff;">JceManager</span></a></p> <p align="right">Made By <a href="http://liranbg.github.io/JceManager/"><span style=" text-decoration: underline; color:#0000ff;">JceManager</span></a></p> @@ -192,107 +193,107 @@ How To - + Ready Ready - - - - + + + + Error Error - + Invalid Dates. Make Sure everything is correct and try again Invalid dates. Make sure everything is correct and try again - - + + Not Connected Not Connected - + Missmatching data Missmatching Data - + License: License: - + Powered By: powered by: Powered By: - + Developed By Developed By - + Help Guide Guide Help Guide - + Liran Liran Ben Gida - + Sagi Sagi Dayan - + <br><li>Login: <ul><li>Type your username and password and click Login.</li><li>Once you are connected, you will see a green ball in the right buttom panel.</li></ul></li> <br><li>Login: <ul><li>Type your username and password and click Login.</li><li>Once you are connected, you will see a green ball in the right buttom panel.</li></ul></li> - + <br><li>Getting GPA sheet<ul><li>Click on GPA Tab</li><li> Select your dates and click on Add</li></ul></li> <br><li>Getting GPA sheet<ul><li>Click on GPA Tab</li><li> Select your dates and click on Add</li></ul></li> - + <br><li>Average Changing<ul><li>Change one of your grade and see the average in the buttom panel changing.</li></ul></li> <br><li>Average Changing<ul><li>Change one of your grade and see the average in the buttom panel changing.</li></ul></li> - + <br><li>Getting Calendar<ul><li>Click on Calendar Tab</li><li> Select your dates and click on Get Calendar</li></ul></li> <br><li>Getting Calendar<ul><li>Click on Calendar Tab</li><li> Select your dates and click on Get Calendar</li></ul></li> - + <br><li>For exporting your calendar to a .CSV file:<ul><li>Do previous step and continue to next step</li><li> Click on Export to CSV</li><li>Select your dates and click OK</li><li>Once you're Done, go on your calendar and import your csv file</li></li> - <br><li>על מנת לייצא לקובץ CSV<ul><li>חזור על השלב הקודם ורק אז</li><li> לחת על ייצוא לקובץ CSV</li><li>בחר את התאריכים המתאימים ולחץ על אישור</li><li>ברגע שתסיים תוכל הודעה ולאחר מכן תוכל לייבא את הקובץ היכן שתרצה</li></li> + <br><li>For exporting your calendar to a .CSV file:<ul><li>Do previous step and continue to next step</li><li> Click on Export to CSV</li><li>Select your dates and click OK</li><li>Once you're Done, go on your calendar and import your csv file</li></li> - + <b>For more information, please visit us at: <a href='http://liranbg.github.io/JceManager/'>Jce Manager site</a></b> <b>For more information, please visit us at: <a href='http://liranbg.github.io/JceManager/'>Jce Manager site</a></b> - - + + Settings Settings - - - + + + Your settings will take effect next time you start the program Your settings will take effect next time you start the program @@ -423,117 +424,117 @@ If this message appear without reason, please contact me at liranbg@gmail.comFriday - + ConnectionRefusedError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + RemoteHostClosedError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + HostNotFoundError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + SocketAccessError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + SocketTimeoutError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + NetworkError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + SslHandshakeFailedError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + SslInternalError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + SslInvalidUserDataError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + DatagramTooLargeError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + OperationError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + AddressInUseError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + SocketAddressNotAvailableError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + UnsupportedSocketOperationError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + ProxyAuthenticationRequiredError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + ProxyConnectionRefusedError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + UnfinishedSocketOperationError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + ProxyConnectionClosedError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + ProxyConnectionTimeoutError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + ProxyNotFoundError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + ProxyProtocolError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + TemporaryError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD - + UnknownSocketError Your error is critical. Our team need your help, please send your log file named J_M_Log.log to us. see link in About. The file DOES NOT CONTAIN YOUR PASSWORD diff --git a/jce_he.qm b/jce_he.qm index 036e7aca4ae0c2482c8e72c3a7dfbd0cf03e2548..71711a31506927e704f3018df9fbf4863928575d 100644 GIT binary patch delta 963 zcmX9+drVVz7(Mp|?d@%ADF}*`(yi3T#u(0In99(KYYJ2Yi_vK{$SPxDUBPC7&3ThW zVhoe1gt++(Oq&gSApK)&W(eXUzG6*gj0{*1oyjt@ge)4v9@!!O@w?yszWbf?o%8+f z$<1GEKDcPL5qSGFV9x-mRs&g;kk6a}^6o%R$v|coH8$f=3)B} z?*h3x_Q@l_%dO~n@+YwPL)^GE1S%4;A5u(#U+_eK1?F!Nx+gk;mxhE>SBn7Maz*HO z*Kkmq@OSZD0{cZ_e40dY@zp81%Snl^h4uo4Rxwc9O*b=Q>$)-^J1UNT`yGX+Nh^&c z(nh6#dYJWMY1?Nlbf-w?^BjODCf#^?ltO!@pR1W0Z^>_6EFoX7e1CR7bmSMxk8-Ho zd0PJCt5FUZk)L&6pwc4wc~J)Qc4fumpD1uvSr^#PzCxvPYEEdW^8N=kbaFsxe$2kY z3FTuYL8mvB-7_v;!#7IDr$g+UR*pSeLqYE;XXo(lH`7kIM8Gwf*0Xg`r&C+H~lzUzzc`kGNdFakBL`kY22ouO!~}k=j0`l` zt0q%15}Hiv71r}&rmE3WuCT(ivmnk@51TF>$SHtS25bD-ZGo*JRDxViZg z-lg-lxjjyxM>TgOsT?p5ctqBBn}^@&m&# z9$~)4_-siGWV!|0ac|UF*VNb$S>>t^M`GcY#BW(c^0N5|z=sOrtH}`IX_&(p=7gv5 Ym;$~EXLVhqt|8ntlbw}#zA$e4AC=wp2><{9 delta 977 zcmX9+YfO`87(L$&dimPQMM0sZ6l--V5-*7&YFX8hmeoa;iNsEealq05);S) zTDm8*Fa!ALXCTD_6c+*`iy$940$BSYcgsNP9>})>+&4lgngQ5XK>79-Fvbt%{3^it zYHz@$9YgW=O<*YagsT(ysZq# z*o&QVCopz5S_TGz@ft2)=>Qc8Y4<25yG(G^-UUXL3Qcz!ft>$@=6`bm&3r-l)w!6B zqQa}Z8w9qC!tH(%wTY8^=`OuboD$dujLR0iB~5fQD6U;N7f5RmyM8%F;gWc*hKds$J6Oo5FOLCjD-;0j?d=<>v<|^pte{W9IrR^1MH$lJAs!b7&VdWX+WCr<1^b zT7L9h7aN?DUo@Sd(uwlR++^kr%8Up9@LW|EdUr9-RD8X|LVZf*mlU4UtgL>(x^aU_ zy%M9-9%bVb2e08zCAy)5bqMainScreen - JCE Avg Calculator - JCE Avg Calculator + JCE Manager + JCE Manager @@ -148,8 +148,9 @@ - <p align="right">Made By <a href="http://liranbg.github.io/JceManager/"><span style=" text-decoration: underline; color:#0000ff;">JceManager</span></a></p> - <p align="right">נוצר ע"י: <a href="http://liranbg.github.io/JceManager/"><span style=" text-decoration: underline; color:#0000ff;">JceManager</span></a></p> + <p align="center">Made By <a href="http://liranbg.github.io/JceManager/"><span style=" text-decoration: underline; color:#0000ff;">JceManager</span></a></p> + <p align="right">Made By <a href="http://liranbg.github.io/JceManager/"><span style=" text-decoration: underline; color:#0000ff;">JceManager</span></a></p> + <p align="center">נוצר ע"י: <a href="http://liranbg.github.io/JceManager/"><span style=" text-decoration: underline; color:#0000ff;">JceManager</span></a></p> @@ -192,107 +193,107 @@ עזרה - + Ready מוכן - - - - + + + + Error שגיאה - + Invalid Dates. Make Sure everything is correct and try again תאריכים לא חוקיים. אנא בדוק שהנתונים שהוזנו נכונים ונסה מחדשה - - + + Not Connected לא מחובר - + Missmatching data שגיאה בהכנסת נתונים - + License: רישיון: - + Powered By: powered by: מנוע: - + Developed By - + Help Guide Guide תפריט עזרה - + Liran לירן בן גידה - + Sagi שגיא דיין - + <br><li>Login: <ul><li>Type your username and password and click Login.</li><li>Once you are connected, you will see a green ball in the right buttom panel.</li></ul></li> <br><li>התחברות: <ul><li>הזן את שם המשתמש והסיסמה ולחץ על התחבר</li><li>בגמר ההתחברות תראה בכדור ירוק בשורת המצב. המשמעות שהינך מחובר לאתר</li></ul></li> - + <br><li>Getting GPA sheet<ul><li>Click on GPA Tab</li><li> Select your dates and click on Add</li></ul></li> <br><li>קבלת גליון ציונים<ul><li>לחץ על לשונית הציונים</li><li>בחר את טווח התאריכים הרצויים ולחץ על הוספה</li></ul></li> - + <br><li>Average Changing<ul><li>Change one of your grade and see the average in the buttom panel changing.</li></ul></li> <br><li>שינוי ממוצע<ul><li>שנה את אחד הציונים שלך בקורס והממוצע ישתנה בהתאם.</li></ul></li> - + <br><li>Getting Calendar<ul><li>Click on Calendar Tab</li><li> Select your dates and click on Get Calendar</li></ul></li> <br><li>קבלת שעות מערכת<ul><li>לחץ על לשונית שעות מערכת</li><li>בחר את השנה והסמסטר ולחץ על הצג מערכת</li></ul></li> - + <br><li>For exporting your calendar to a .CSV file:<ul><li>Do previous step and continue to next step</li><li> Click on Export to CSV</li><li>Select your dates and click OK</li><li>Once you're Done, go on your calendar and import your csv file</li></li> <br><li>על מנת לייצא לקובץ CSV<ul><li>בצע את השלב הקודם ואז</li><li> לחץ על ייצוא לCSV</li><li>בחר את התאריכים המתאימים ולחץ אישור</li><li>לאחר השלמת הפעולה תוכל לייבא את המערכת שעות</li></li> - + <b>For more information, please visit us at: <a href='http://liranbg.github.io/JceManager/'>Jce Manager site</a></b> <b>לעוד מידע: <a href='http://liranbg.github.io/JceManager/'>Jce Manager site</a></b> - - + + Settings הגדרות - - - + + + Your settings will take effect next time you start the program ההגדרות שלך ייכנסו לתוקפן בפעם הבאה שתפעיל את התוכנה @@ -423,117 +424,117 @@ If this message appear without reason, please contact me at liranbg@gmail.comשישי - + ConnectionRefusedError - + RemoteHostClosedError - + HostNotFoundError - + SocketAccessError - + SocketTimeoutError - + NetworkError - + SslHandshakeFailedError - + SslInternalError - + SslInvalidUserDataError - + DatagramTooLargeError - + OperationError - + AddressInUseError - + SocketAddressNotAvailableError - + UnsupportedSocketOperationError - + ProxyAuthenticationRequiredError - + ProxyConnectionRefusedError - + UnfinishedSocketOperationError - + ProxyConnectionClosedError - + ProxyConnectionTimeoutError - + ProxyNotFoundError - + ProxyProtocolError - + TemporaryError - + UnknownSocketError diff --git a/main/mainscreen.cpp b/main/mainscreen.cpp index d1fadd0..fa7d03f 100644 --- a/main/mainscreen.cpp +++ b/main/mainscreen.cpp @@ -4,343 +4,359 @@ MainScreen::MainScreen(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainScreen) { - ui->setupUi(this); - //this->setFixedSize(this->size()); //main not resizeable + ui->setupUi(this); + //this->setFixedSize(this->size()); //main not resizeable - //Login Tab - iconPix.load(":/icons/iconX.png"); - ui->pswdLineEdit->setEchoMode((QLineEdit::Password)); - ui->labelUsrInputStatus->setVisible(false); - ui->labelPswInputStatus->setVisible(false); - ui->labelUsrInputStatus->setPixmap(iconPix); - ui->labelPswInputStatus->setPixmap(iconPix); + ui->labelMadeBy->setOpenExternalLinks(true); - //StatusBar - ui->statusBar->setStyleSheet("QStatusBar::item { border: 0px solid black };"); - ui->statusBar->setFixedHeight(STATUS_ICON_HEIGH); - ui->statusBar->showMessage(tr("Ready")); + //Login Tab + iconPix.load(":/icons/iconX.png"); + ui->pswdLineEdit->setEchoMode((QLineEdit::Password)); + ui->labelUsrInputStatus->setVisible(false); + ui->labelPswInputStatus->setVisible(false); + ui->labelUsrInputStatus->setPixmap(iconPix); + ui->labelPswInputStatus->setPixmap(iconPix); - //GPA Tab - ui->avgLCD->setPalette(QPalette(QPalette::WindowText,Qt::blue)); + //StatusBar + ui->statusBar->setStyleSheet("QStatusBar::item { border: 0px solid black };"); + ui->statusBar->setFixedHeight(STATUS_ICON_HEIGH); + ui->statusBar->showMessage(tr("Ready")); - //Pointer allocating - qDebug() << Q_FUNC_INFO << "Allocating pointers"; - this->userLoginSetting = new user("",""); - this->courseTableMgr = new coursesTableManager(ui->coursesTable,userLoginSetting); - this->loginHandel = new loginHandler(userLoginSetting,ui->statusBar,ui->loginButton); - this->calendar = new CalendarManager(ui->calendarGridLayoutMain); - this->data = new SaveData(); + //GPA Tab + ui->avgLCD->setPalette(QPalette(QPalette::WindowText,Qt::blue)); - //check login File - if (data->isSaved()) + //Pointer allocating + qDebug() << Q_FUNC_INFO << "Allocating pointers"; + this->userLoginSetting = new user("",""); + this->courseTableMgr = new coursesTableManager(ui->coursesTable,userLoginSetting); + this->loginHandel = new loginHandler(userLoginSetting,ui->statusBar,ui->loginButton); + this->calendar = new CalendarManager(ui->calendarGridLayoutMain); + this->data = new SaveData(); + + //check login File + if (data->isSaved()) { - qDebug() << Q_FUNC_INFO << "Loading data from file"; - ui->usrnmLineEdit->setText(data->getUsername()); - ui->pswdLineEdit->setText(data->getPassword()); - ui->keepLogin->setChecked(true); + qDebug() << Q_FUNC_INFO << "Loading data from file"; + ui->usrnmLineEdit->setText(data->getUsername()); + ui->pswdLineEdit->setText(data->getPassword()); + ui->keepLogin->setChecked(true); } - //language - qDebug() << Q_FUNC_INFO << "Checking locale"; - checkLocale(); - qDebug() << Q_FUNC_INFO << "Ready."; + //language + qDebug() << Q_FUNC_INFO << "Checking locale"; + checkLocale(); + qDebug() << Q_FUNC_INFO << "Ready."; } MainScreen::~MainScreen() { - delete calendar; - delete courseTableMgr; - delete userLoginSetting; - delete loginHandel; - delete data; - delete ui; + delete calendar; + delete courseTableMgr; + delete userLoginSetting; + delete loginHandel; + delete data; + delete ui; } //EVENTS ON LOGIN TAB void MainScreen::on_loginButton_clicked() { - qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); - if ((ui->usrnmLineEdit->text().isEmpty()) || (ui->pswdLineEdit->text().isEmpty())) + qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); + if ((ui->usrnmLineEdit->text().isEmpty()) || (ui->pswdLineEdit->text().isEmpty())) { - if (ui->usrnmLineEdit->text().isEmpty()) + if (ui->usrnmLineEdit->text().isEmpty()) { - ui->labelUsrInputStatus->setVisible(true); - qDebug() << Q_FUNC_INFO << "username input is empty"; + ui->labelUsrInputStatus->setVisible(true); + qDebug() << Q_FUNC_INFO << "username input is empty"; } - else - ui->labelUsrInputStatus->setVisible(false); - if (ui->pswdLineEdit->text().isEmpty()) - { - ui->labelPswInputStatus->setVisible(true); - qDebug() << Q_FUNC_INFO << "password input is empty"; - } - else - ui->labelPswInputStatus->setVisible(false); - return; - } - else - { + else ui->labelUsrInputStatus->setVisible(false); - ui->labelPswInputStatus->setVisible(false); - } - qDebug() << Q_FUNC_INFO << "login session start"; - if (this->loginHandel->login(ui->usrnmLineEdit->text(),ui->pswdLineEdit->text()) == true) - { - qDebug() << Q_FUNC_INFO << "login session end with true"; - ui->pswdLineEdit->setDisabled(true); - ui->usrnmLineEdit->setDisabled(true); - if (ui->keepLogin->isChecked()) + if (ui->pswdLineEdit->text().isEmpty()) { - qDebug() << Q_FUNC_INFO << "saving data"; - data->setUsername(ui->usrnmLineEdit->text()); - data->setPassword(ui->pswdLineEdit->text()); + ui->labelPswInputStatus->setVisible(true); + qDebug() << Q_FUNC_INFO << "password input is empty"; + } + else + ui->labelPswInputStatus->setVisible(false); + return; + } + else + { + ui->labelUsrInputStatus->setVisible(false); + ui->labelPswInputStatus->setVisible(false); + } + qDebug() << Q_FUNC_INFO << "login session start"; + QApplication::setOverrideCursor(Qt::WaitCursor); + if (this->loginHandel->login(ui->usrnmLineEdit->text(),ui->pswdLineEdit->text()) == true) + { + qDebug() << Q_FUNC_INFO << "login session end with true"; + ui->pswdLineEdit->setDisabled(true); + ui->usrnmLineEdit->setDisabled(true); + if (ui->keepLogin->isChecked()) + { + qDebug() << Q_FUNC_INFO << "saving data"; + data->setUsername(ui->usrnmLineEdit->text()); + data->setPassword(ui->pswdLineEdit->text()); } } - else + else { - qDebug() << Q_FUNC_INFO << "login session end with false"; - ui->pswdLineEdit->setDisabled(false); - ui->usrnmLineEdit->setDisabled(false); + qDebug() << Q_FUNC_INFO << "login session end with false"; + ui->pswdLineEdit->setDisabled(false); + ui->usrnmLineEdit->setDisabled(false); } + QApplication::restoreOverrideCursor(); } void MainScreen::on_keepLogin_clicked() { - qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); - if (ui->keepLogin->isChecked()) + qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); + if (ui->keepLogin->isChecked()) { - qDebug() << Q_FUNC_INFO << "saving data"; - data->setUsername(ui->usrnmLineEdit->text()); - data->setPassword(ui->pswdLineEdit->text()); + qDebug() << Q_FUNC_INFO << "saving data"; + data->setUsername(ui->usrnmLineEdit->text()); + data->setPassword(ui->pswdLineEdit->text()); } - else - data->reset(); + else + data->reset(); } void MainScreen::on_usrnmLineEdit_editingFinished() { - qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); - ui->usrnmLineEdit->setText(ui->usrnmLineEdit->text().toLower()); + qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); + ui->usrnmLineEdit->setText(ui->usrnmLineEdit->text().toLower()); } //EVENTS ON GPA TAB void MainScreen::on_ratesButton_clicked() { - qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); - if (!checkIfValidDates()) + qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); + if (!checkIfValidDates()) { - qWarning() << Q_FUNC_INFO << "Invalid dates! return"; - QMessageBox::critical(this,tr("Error"),tr("Invalid Dates.\nMake Sure everything is correct and try again")); - return; + qWarning() << Q_FUNC_INFO << "Invalid dates! return"; + QMessageBox::critical(this,tr("Error"),tr("Invalid Dates.\nMake Sure everything is correct and try again")); + return; } - QString pageString; - int status = 0; - if (loginHandel->isLoggedInFlag()) + QString pageString; + int status = 0; + QApplication::setOverrideCursor(Qt::WaitCursor); + if (loginHandel->isLoggedInFlag()) { - if ((status = loginHandel->makeGradeRequest(ui->spinBoxCoursesFromYear->value(), - ui->spinBoxCoursesToYear->value(),ui->spinBoxCoursesFromSemester->value(), - ui->spinBoxCoursesToSemester->value())) == jceLogin::JCE_PAGE_PASSED) + if ((status = loginHandel->makeGradeRequest(ui->spinBoxCoursesFromYear->value(), + ui->spinBoxCoursesToYear->value(),ui->spinBoxCoursesFromSemester->value(), + ui->spinBoxCoursesToSemester->value())) == jceLogin::JCE_PAGE_PASSED) { - qDebug() << Q_FUNC_INFO << "grade page is ready"; - pageString = loginHandel->getCurrentPageContect(); - courseTableMgr->setCoursesList(pageString); - courseTableMgr->insertJceCoursesIntoTable(); + qDebug() << Q_FUNC_INFO << "grade page is ready"; + pageString = loginHandel->getCurrentPageContect(); + courseTableMgr->setCoursesList(pageString); + courseTableMgr->insertJceCoursesIntoTable(); } - else if (status == jceLogin::JCE_NOT_CONNECTED) + else if (status == jceLogin::JCE_NOT_CONNECTED) { - qWarning() << Q_FUNC_INFO << "not connected"; - QMessageBox::critical(this,tr("Error"),tr("Not Connected")); + qWarning() << Q_FUNC_INFO << "not connected"; + QApplication::restoreOverrideCursor(); + QMessageBox::critical(this,tr("Error"),tr("Not Connected")); } - else + else { - qCritical() << Q_FUNC_INFO << "grade get ended with" << status; + qCritical() << Q_FUNC_INFO << "grade get ended with" << status; } } + QApplication::restoreOverrideCursor(); } bool MainScreen::checkIfValidDates() { - bool flag = false; - if (ui->spinBoxCoursesFromYear->value() < ui->spinBoxCoursesToYear->value()) + bool flag = false; + if (ui->spinBoxCoursesFromYear->value() < ui->spinBoxCoursesToYear->value()) { - //doesnt matter what is the semester, its valid! + //doesnt matter what is the semester, its valid! + flag = true; + } + else if ((ui->spinBoxCoursesFromYear->value() == ui->spinBoxCoursesToYear->value())) + { + //semester from must be equal or less than to semester + if (ui->spinBoxCoursesFromSemester->value() <= ui->spinBoxCoursesToSemester->value()) flag = true; } - else if ((ui->spinBoxCoursesFromYear->value() == ui->spinBoxCoursesToYear->value())) - { - //semester from must be equal or less than to semester - if (ui->spinBoxCoursesFromSemester->value() <= ui->spinBoxCoursesToSemester->value()) - flag = true; - } - return flag; + return flag; } void MainScreen::on_checkBoxCoursesInfluence_toggled(bool checked) { - qDebug() << Q_FUNC_INFO << "only main courses toggeled" << checked; - this->userLoginSetting->setInfluenceCourseOnly(checked); - this->courseTableMgr->influnceCourseChanged(checked); + qDebug() << Q_FUNC_INFO << "only main courses toggeled" << checked; + this->userLoginSetting->setInfluenceCourseOnly(checked); + this->courseTableMgr->influnceCourseChanged(checked); } void MainScreen::on_spinBoxCoursesFromYear_valueChanged(int arg1) { - ui->spinBoxCoursesFromYear->setValue(arg1); + ui->spinBoxCoursesFromYear->setValue(arg1); } void MainScreen::on_spinBoxCoursesToYear_valueChanged(int arg1) { - ui->spinBoxCoursesToYear->setValue(arg1); + ui->spinBoxCoursesToYear->setValue(arg1); } void MainScreen::on_spinBoxCoursesFromSemester_valueChanged(int arg1) { - ui->spinBoxCoursesFromSemester->setValue(arg1%4); + ui->spinBoxCoursesFromSemester->setValue(arg1%4); } void MainScreen::on_spinBoxCoursesToSemester_valueChanged(int arg1) { - ui->spinBoxCoursesToSemester->setValue(arg1%4); + ui->spinBoxCoursesToSemester->setValue(arg1%4); } void MainScreen::on_coursesTable_itemChanged(QTableWidgetItem *item) { - qDebug() << Q_FUNC_INFO << "item at row:" << item->row() << " colum:" << item->column() << " text: " << item->text(); - if (this->courseTableMgr->changes(item->text(),item->row(),item->column())) - ui->avgLCD->display(courseTableMgr->getAvg()); - else + if (this->courseTableMgr->changes(item->text(),item->row(),item->column())) + ui->avgLCD->display(courseTableMgr->getAvg()); + else { - qWarning() << Q_FUNC_INFO << "missmatch data"; - QMessageBox::critical(this,tr("Error"),tr("Missmatching data")); + qWarning() << Q_FUNC_INFO << "missmatch data"; + QMessageBox::critical(this,tr("Error"),tr("Missmatching data")); } } void MainScreen::on_clearTableButton_clicked() { - qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); - courseTableMgr->clearTable(); - ui->avgLCD->display(courseTableMgr->getAvg()); + qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); + courseTableMgr->clearTable(); + ui->avgLCD->display(courseTableMgr->getAvg()); } //EVENTS ON CALENDAR TAB void MainScreen::on_getCalendarBtn_clicked() { - qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); - int status = 0; - if (loginHandel->isLoggedInFlag()) + qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); + int status = 0; + QApplication::setOverrideCursor(Qt::WaitCursor); + if (loginHandel->isLoggedInFlag()) { - if ((status = loginHandel->makeCalendarRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_PAGE_PASSED) + if ((status = loginHandel->makeCalendarRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_PAGE_PASSED) { - //Use it for debug. add plain text and change the object name to 'plainTextEdit' so you will get the html request - //ui->plainTextEdit->setPlainText(loginHandel->getCurrentPageContect()); - calendar->resetTable(); - calendar->setCalendar(loginHandel->getCurrentPageContect()); - qDebug() << Q_FUNC_INFO << "calendar is loaded"; + //Use it for debug. add plain text and change the object name to 'plainTextEdit' so you will get the html request + //ui->plainTextEdit->setPlainText(loginHandel->getCurrentPageContect()); + calendar->resetTable(); + calendar->setCalendar(loginHandel->getCurrentPageContect()); + qDebug() << Q_FUNC_INFO << "calendar is loaded"; } - else if (status == jceLogin::JCE_NOT_CONNECTED) + else if (status == jceLogin::JCE_NOT_CONNECTED) { - qWarning() << Q_FUNC_INFO << "not connected"; - QMessageBox::critical(this,tr("Error"),tr("Not Connected")); + qWarning() << Q_FUNC_INFO << "not connected"; + QApplication::restoreOverrideCursor(); + QMessageBox::critical(this,tr("Error"),tr("Not Connected")); } - else - qCritical() << Q_FUNC_INFO << "calendar get ended with" << status; + else + qCritical() << Q_FUNC_INFO << "calendar get ended with" << status; } + QApplication::restoreOverrideCursor(); } void MainScreen::on_exportToCVSBtn_clicked() { - qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); - if (loginHandel->isLoggedInFlag()) + qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); + if (loginHandel->isLoggedInFlag()) { - this->calendar->exportCalendarCSV(); + this->calendar->exportCalendarCSV(); } } //EVENTS ON MENU BAR void MainScreen::on_actionCredits_triggered() { - qDebug() << Q_FUNC_INFO; - QMessageBox::about(this, "About", - "Jce Manager v1.0.0

" - +tr("License:")+ - "
GNU LESSER GENERAL PUBLIC LICENSE V2.1
" - +"
"+ - "JceManager Repository"+ - "

" - +tr("Powered By: ")+ - " Jce Connection

" - +tr("Developed By")+ - ":" - ); + qDebug() << Q_FUNC_INFO; + QMessageBox::about(this, "About", + "Jce Manager v1.0.0

" + +tr("License:")+ + "
GNU LESSER GENERAL PUBLIC LICENSE V2.1
" + +"
"+ + "JceManager Repository"+ + "

" + +tr("Powered By: ")+ + " Jce Connection

" + +tr("Developed By")+ + ":" + ); } void MainScreen::on_actionExit_triggered() { - qDebug() << Q_FUNC_INFO; - exit(0); + qDebug() << Q_FUNC_INFO; + exit(0); } void MainScreen::on_actionHow_To_triggered() { - qDebug() << Q_FUNC_INFO; - QMessageBox::information(this,"How To", - "" - +tr("Help Guide")+ - "
    " - +tr("
  • Login:
    • Type your username and password and click Login.
    • Once you are connected, you will see a green ball in the right buttom panel.
  • ") - +tr("
  • Getting GPA sheet
    • Click on GPA Tab
    • Select your dates and click on Add
  • ") - +tr("
  • Average Changing
    • Change one of your grade and see the average in the buttom panel changing.
  • ") - +tr("
  • Getting Calendar
    • Click on Calendar Tab
    • Select your dates and click on Get Calendar
  • ") - +tr("
  • For exporting your calendar to a .CSV file:
    • Do previous step and continue to next step
    • Click on Export to CSV
    • Select your dates and click OK
    • Once you're Done, go on your calendar and import your csv file
    • ")+ - "

      " - +tr("For more information, please visit us at: Jce Manager site")); + qDebug() << Q_FUNC_INFO; + QMessageBox::information(this,"How To", + "" + +tr("Help Guide")+ + "
        " + +tr("
      • Login:
        • Type your username and password and click Login.
        • Once you are connected, you will see a green ball in the right buttom panel.
      • ") + +tr("
      • Getting GPA sheet
        • Click on GPA Tab
        • Select your dates and click on Add
      • ") + +tr("
      • Average Changing
        • Change one of your grade and see the average in the buttom panel changing.
      • ") + +tr("
      • Getting Calendar
        • Click on Calendar Tab
        • Select your dates and click on Get Calendar
      • ") + +tr("
      • For exporting your calendar to a .CSV file:
        • Do previous step and continue to next step
        • Click on Export to CSV
        • Select your dates and click OK
        • Once you're Done, go on your calendar and import your csv file
        • ")+ + "

          " + +tr("For more information, please visit us at: Jce Manager site")); } void MainScreen::on_actionHebrew_triggered() { - qDebug() << Q_FUNC_INFO; - if (ui->actionEnglish->isChecked() || ui->actionOS_Default->isChecked()) + qDebug() << Q_FUNC_INFO; + if (ui->actionEnglish->isChecked() || ui->actionOS_Default->isChecked()) { - ui->actionEnglish->setChecked(false); - ui->actionOS_Default->setChecked(false); - qDebug() << Q_FUNC_INFO << "Changed Language to hebrew"; - data->setLocal("he"); - QMessageBox::information(this,tr("Settings"),tr("Your settings will take effect next time you start the program"),QMessageBox::Ok); + ui->actionEnglish->setChecked(false); + ui->actionOS_Default->setChecked(false); + qDebug() << Q_FUNC_INFO << "Changed Language to hebrew"; + data->setLocal("he"); + QMessageBox::information(this,tr("Settings"),tr("Your settings will take effect next time you start the program"),QMessageBox::Ok); } - else - ui->actionHebrew->setChecked(true); + else + ui->actionHebrew->setChecked(true); } void MainScreen::on_actionEnglish_triggered() { - qDebug() << Q_FUNC_INFO; - if (ui->actionHebrew->isChecked() || ui->actionOS_Default->isChecked()) + qDebug() << Q_FUNC_INFO; + if (ui->actionHebrew->isChecked() || ui->actionOS_Default->isChecked()) { - ui->actionHebrew->setChecked(false); - ui->actionOS_Default->setChecked(false); - qDebug() << Q_FUNC_INFO << "Changed Language to English"; - data->setLocal("en"); - QMessageBox::information(this,"Settings",tr("Your settings will take effect next time you start the program"),QMessageBox::Ok); + ui->actionHebrew->setChecked(false); + ui->actionOS_Default->setChecked(false); + qDebug() << Q_FUNC_INFO << "Changed Language to English"; + data->setLocal("en"); + QMessageBox::information(this,"Settings",tr("Your settings will take effect next time you start the program"),QMessageBox::Ok); } - else - ui->actionEnglish->setChecked(true); + else + ui->actionEnglish->setChecked(true); } void MainScreen::on_actionOS_Default_triggered() { - qDebug() << Q_FUNC_INFO; - if (ui->actionHebrew->isChecked() || ui->actionEnglish->isChecked()) + qDebug() << Q_FUNC_INFO; + if (ui->actionHebrew->isChecked() || ui->actionEnglish->isChecked()) { - ui->actionHebrew->setChecked(false); - ui->actionEnglish->setChecked(false); - qDebug() << Q_FUNC_INFO << "Changed Language to OS Default"; - data->setLocal("default"); - QMessageBox::information(this,tr("Settings"),tr("Your settings will take effect next time you start the program"),QMessageBox::Ok); + ui->actionHebrew->setChecked(false); + ui->actionEnglish->setChecked(false); + qDebug() << Q_FUNC_INFO << "Changed Language to OS Default"; + data->setLocal("default"); + QMessageBox::information(this,tr("Settings"),tr("Your settings will take effect next time you start the program"),QMessageBox::Ok); } - else - ui->actionOS_Default->setChecked(true); + else + ui->actionOS_Default->setChecked(true); } void MainScreen::checkLocale() { - if(data->getLocal() == "en") + if(data->getLocal() == "en") { - ui->actionHebrew->setChecked(false); - ui->actionOS_Default->setChecked(false); - ui->actionEnglish->setChecked(true); + ui->actionHebrew->setChecked(false); + ui->actionOS_Default->setChecked(false); + ui->actionEnglish->setChecked(true); }else if(data->getLocal() == "he"){ - ui->actionHebrew->setChecked(true); - ui->actionOS_Default->setChecked(false); - ui->actionEnglish->setChecked(false); + ui->actionHebrew->setChecked(true); + ui->actionOS_Default->setChecked(false); + ui->actionEnglish->setChecked(false); }else{ - ui->actionHebrew->setChecked(false); - ui->actionOS_Default->setChecked(true); - ui->actionEnglish->setChecked(false); + ui->actionHebrew->setChecked(false); + ui->actionOS_Default->setChecked(true); + ui->actionEnglish->setChecked(false); } } + +void MainScreen::on_labelMadeBy_linkActivated(const QString &link) +{ + qDebug() << Q_FUNC_INFO << "link: " << link; + + +} diff --git a/main/mainscreen.h b/main/mainscreen.h index a6186f9..7ab3d42 100644 --- a/main/mainscreen.h +++ b/main/mainscreen.h @@ -65,6 +65,8 @@ private slots: void on_spinBoxCoursesToSemester_valueChanged(int arg1); + void on_labelMadeBy_linkActivated(const QString &link); + private: void checkLocale(); diff --git a/main/mainscreen.ui b/main/mainscreen.ui index ac30be4..fc522ca 100644 --- a/main/mainscreen.ui +++ b/main/mainscreen.ui @@ -17,7 +17,7 @@ - JCE Avg Calculator + JCE Manager @@ -61,7 +61,7 @@ background: qlineargradient(spread:pad, x1:0.496, y1:0, x2:0.508, y2:1, stop:0 r QTabWidget::Rounded - 2 + 0 false @@ -627,7 +627,7 @@ font-size: 15px; - + <p align="center">Made By <a href="http://liranbg.github.io/JceManager/"><span style=" text-decoration: underline; color:#0000ff;">JceManager</span></a></p> diff --git a/src/jceConnection/jcesslclient.cpp b/src/jceConnection/jcesslclient.cpp index 00818b5..729447e 100644 --- a/src/jceConnection/jcesslclient.cpp +++ b/src/jceConnection/jcesslclient.cpp @@ -3,18 +3,17 @@ /** * @brief jceSSLClient::jceSSLClient Constructer, setting the signals */ -jceSSLClient::jceSSLClient() : flag(false), packet(""), networkConf(), reConnection(false) +jceSSLClient::jceSSLClient() : flag(false), packet(""),networkConf(), reConnection(false) { - //setting signals - connect(this,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(checkErrors(QAbstractSocket::SocketError))); - connect(this,SIGNAL(connected()),this,SLOT(setConnected())); - connect(this,SIGNAL(encrypted()),this,SLOT(setEncrypted())); - connect(this,SIGNAL(disconnected()),this,SLOT(setDisconnected())); - connect(&networkConf,SIGNAL(onlineStateChanged(bool)),this,SLOT(setOnlineState(bool))); - - //loop event will connect the server, and when it is connected, it will quit - but connection will be open - connect(this, SIGNAL(encrypted()), &loop, SLOT(quit())); - connect(this, SIGNAL(error(QAbstractSocket::SocketError)),&loop,SLOT(quit())); + //setting signals + connect(this,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(checkErrors(QAbstractSocket::SocketError))); + connect(this,SIGNAL(connected()),this,SLOT(setConnected())); + connect(this,SIGNAL(encrypted()),this,SLOT(setEncrypted())); + connect(this,SIGNAL(disconnected()),this,SLOT(setDisconnected())); + connect(&networkConf,SIGNAL(onlineStateChanged(bool)),this,SLOT(setOnlineState(bool))); + //loop event will connect the server, and when it is connected, it will quit - but connection will be open + connect(this, SIGNAL(encrypted()), &loop, SLOT(quit())); + connect(this, SIGNAL(error(QAbstractSocket::SocketError)),&loop,SLOT(quit())); } /** @@ -25,34 +24,48 @@ jceSSLClient::jceSSLClient() : flag(false), packet(""), networkConf(), reConnect */ bool jceSSLClient::makeConnect(QString server, int port) { - if (this->networkConf.isOnline() == false) - return false; - - if (reConnection) //reset reconnectiong flag + if (this->supportsSsl() == false) { - qDebug() << Q_FUNC_INFO << "Making Reconnection"; + qCritical() << Q_FUNC_INFO << "Couldnt load ssl package. ERROR"; + return false; } - else - qDebug() << Q_FUNC_INFO << "Making Connection"; + else + qDebug() << Q_FUNC_INFO << "ssl loaded."; - if (isConnected()) + if (isConnectedToNetwork() == false) { - qDebug() << Q_FUNC_INFO << "flag=true, calling makeDisconnect()"; - makeDiconnect(); + qDebug() << Q_FUNC_INFO << "return false. not online"; + return false; + } + else + qDebug() << Q_FUNC_INFO << "we're online"; + + + if (reConnection) //reset reconnectiong flag + { + qDebug() << Q_FUNC_INFO << "Making Reconnection"; + } + else + qDebug() << Q_FUNC_INFO << "Making Connection"; + + if (isConnected()) + { + qDebug() << Q_FUNC_INFO << "flag=true, calling makeDisconnect()"; + makeDiconnect(); } - qDebug() << Q_FUNC_INFO << "Connection to: " << server << "On Port: " << port; - connectToHostEncrypted(server.toStdString().c_str(), port); + qDebug() << Q_FUNC_INFO << "Connection to: " << server << "On Port: " << port; + connectToHostEncrypted(server.toStdString().c_str(), port); - loop.exec(); //starting connection, waiting to encryption and then it ends + loop.exec(); //starting connection, waiting to encryption and then it ends - qDebug() << Q_FUNC_INFO << "returning the connection status: " << isConnected(); - if (reConnection) + qDebug() << Q_FUNC_INFO << "returning the connection status: " << isConnected(); + if (reConnection) { - reConnection = false; - emit serverDisconnectedbyRemote(); + reConnection = false; + emit serverDisconnectedbyRemote(); } - return isConnected(); + return isConnected(); } /** @@ -61,15 +74,15 @@ bool jceSSLClient::makeConnect(QString server, int port) */ bool jceSSLClient::makeDiconnect() { - if (loop.isRunning()) + if (loop.isRunning()) { - qWarning() << Q_FUNC_INFO << "Killing connection thread"; - loop.exit(); + qWarning() << Q_FUNC_INFO << "Killing connection thread"; + loop.exit(); } - qDebug() << Q_FUNC_INFO << "disconnecting from host and emitting disconnected()"; - this->disconnectFromHost(); //emits disconnected > setDisconnected - setSocketState(QAbstractSocket::SocketState::UnconnectedState); - return (!isConnected()); + qDebug() << Q_FUNC_INFO << "disconnecting from host and emitting disconnected()"; + this->disconnectFromHost(); //emits disconnected > setDisconnected + setSocketState(QAbstractSocket::SocketState::UnconnectedState); + return (!isConnected()); } @@ -79,30 +92,30 @@ bool jceSSLClient::makeDiconnect() */ bool jceSSLClient::isConnected() { - bool tempFlag; - //checking state before returning flag! - if (state() == QAbstractSocket::SocketState::UnconnectedState) + bool tempFlag = false; + //checking state before returning flag! + if (state() == QAbstractSocket::SocketState::UnconnectedState) { - tempFlag = false; + tempFlag = false; } - else if (state() == QAbstractSocket::SocketState::ClosingState) + else if (state() == QAbstractSocket::SocketState::ClosingState) { - tempFlag = false; + tempFlag = false; } - else if (state() == QAbstractSocket::SocketState::ConnectedState) + else if (state() == QAbstractSocket::SocketState::ConnectedState) { - if (this->networkConf.isOnline()) - tempFlag = true; - else + if (isConnectedToNetwork()) + tempFlag = true; + else { - this->setSocketState(QAbstractSocket::SocketState::UnconnectedState); - tempFlag = false; + this->setSocketState(QAbstractSocket::SocketState::UnconnectedState); + tempFlag = false; } } - if (!this->networkConf.isOnline()) //no link, ethernet\wifi - tempFlag = false; - return ((flag) && (tempFlag)); + if (!isConnectedToNetwork()) //no link, ethernet\wifi + tempFlag = false; + return ((flag) && (tempFlag)); } /** * @brief jceSSLClient::sendData - given string, send it to server @@ -111,15 +124,16 @@ bool jceSSLClient::isConnected() */ bool jceSSLClient::sendData(QString str) { - bool sendDataFlag = false; - if (isConnected()) //if connected + bool sendDataFlag = false; + + if (isConnected()) //if connected { - write(str.toStdString().c_str(),str.length()); - if (waitForBytesWritten()) - sendDataFlag = true; + write(str.toStdString().c_str(),str.length()); + if (waitForBytesWritten()) + sendDataFlag = true; } - qDebug() << Q_FUNC_INFO << "Sending Data status is: " << sendDataFlag; - return sendDataFlag; + qDebug() << Q_FUNC_INFO << "Sending Data status is: " << sendDataFlag; + return sendDataFlag; } /** * @brief jceSSLClient::recieveData @@ -129,39 +143,39 @@ bool jceSSLClient::sendData(QString str) */ bool jceSSLClient::recieveData(QString &str, bool fast) { - qDebug() << Q_FUNC_INFO << "Data receiving!"; - packet = ""; - bool sflag = false; + qDebug() << Q_FUNC_INFO << "Data receiving!"; + packet = ""; + bool sflag = false; - if (fast) //fast mode connection, good only for login step!!!! + if (fast) //fast mode connection, good only for login step!!!! { - qDebug() << "jceSSLClient::recieveData login step receiving"; - QEventLoop loop; - connect(this, SIGNAL(readyRead()), &loop, SLOT(quit())); - connect(this, SIGNAL(readyRead()), this, SLOT(readIt())); - loop.exec(); - disconnect(this, SIGNAL(readyRead()), &loop, SLOT(quit())); - disconnect(this, SIGNAL(readyRead()), this, SLOT(readIt())); + qDebug() << "jceSSLClient::recieveData login step receiving"; + QEventLoop loop; + connect(this, SIGNAL(readyRead()), &loop, SLOT(quit())); + connect(this, SIGNAL(readyRead()), this, SLOT(readIt())); + loop.exec(); + disconnect(this, SIGNAL(readyRead()), &loop, SLOT(quit())); + disconnect(this, SIGNAL(readyRead()), this, SLOT(readIt())); } - else + else { - qDebug() << "jceSSLClient::recieveData normal receiving"; - QString p; - while (waitForReadyRead(milisTimeOut)) + qDebug() << "jceSSLClient::recieveData normal receiving"; + QString p; + while (waitForReadyRead(milisTimeOut)) { - do + do { - p = readAll(); - packet.append(p); + p = readAll(); + packet.append(p); }while (p.size() > 0); } } - str = packet; - qDebug() << Q_FUNC_INFO << "received bytes: " << str.length() ; - if (str.length() > 0) - sflag = true; - qDebug() << Q_FUNC_INFO << "return with flag: " << sflag; - return sflag; + str = packet; + qDebug() << Q_FUNC_INFO << "received bytes: " << str.length() ; + if (str.length() > 0) + sflag = true; + qDebug() << Q_FUNC_INFO << "return with flag: " << sflag; + return sflag; } /** @@ -169,29 +183,29 @@ bool jceSSLClient::recieveData(QString &str, bool fast) */ void jceSSLClient::readIt() { - QString p; - do + QString p; + do { - p = readAll(); - packet.append(p); + p = readAll(); + packet.append(p); }while (p.size() > 0); } void jceSSLClient::setOnlineState(bool isOnline) { - qWarning() << Q_FUNC_INFO << "isOnline status change: " << isOnline; - if (isOnline) //to be added later + qWarning() << Q_FUNC_INFO << "isOnline status change: " << isOnline; + if (isOnline) //to be added later { - qDebug() << Q_FUNC_INFO << "Online Statue has been changed. we are online"; - //we can add here auto reconnect if wifi\ethernet link has appear - //will be added next version + qDebug() << Q_FUNC_INFO << "Online Statue has been changed. we are online"; + //we can add here auto reconnect if wifi\ethernet link has appear + //will be added next version } - else + else { - qWarning() << Q_FUNC_INFO << "Online State has been changed. emitting NoInternetLink"; - this->makeDiconnect(); - emit noInternetLink(); + qWarning() << Q_FUNC_INFO << "Online State has been changed. emitting NoInternetLink"; + this->makeDiconnect(); + emit noInternetLink(); } } @@ -200,19 +214,19 @@ void jceSSLClient::setOnlineState(bool isOnline) */ void jceSSLClient::setConnected() { - waitForEncrypted(); + waitForEncrypted(); } /** * @brief jceSSLClient::setDisconnected closing socket, updating state and setting flag to false */ void jceSSLClient::setDisconnected() { - qDebug() << Q_FUNC_INFO << "connection has been DISCONNECTED"; - this->setSocketState(QAbstractSocket::SocketState::UnconnectedState); - packet.clear(); - flag = false; - if (reConnection) - makeConnect(); + qDebug() << Q_FUNC_INFO << "connection has been DISCONNECTED"; + this->setSocketState(QAbstractSocket::SocketState::UnconnectedState); + packet.clear(); + flag = false; + if (reConnection) + makeConnect(); } @@ -221,14 +235,14 @@ void jceSSLClient::setDisconnected() */ void jceSSLClient::setEncrypted() { - qDebug() << Q_FUNC_INFO << "connection has been ENCRYPTED"; - setReadBufferSize(10000); - setSocketOption(QAbstractSocket::KeepAliveOption,true); - flag = true; - if (!isConnected()) + qDebug() << Q_FUNC_INFO << "connection has been ENCRYPTED"; + setReadBufferSize(10000); + setSocketOption(QAbstractSocket::KeepAliveOption,true); + flag = true; + if (!isConnected()) { - qWarning() << Q_FUNC_INFO << "Connection status didnt change! reseting flag to false"; - flag = false; + qWarning() << Q_FUNC_INFO << "Connection status didnt change! reseting flag to false"; + flag = false; } } @@ -239,116 +253,116 @@ void jceSSLClient::setEncrypted() */ void jceSSLClient::showIfErrorMsg() { - QMessageBox msgBox; - SocketError enumError = error(); - QString errorString; - bool relevantError = false; - switch (enumError) + QMessageBox msgBox; + SocketError enumError = error(); + QString errorString; + bool relevantError = false; + switch (enumError) { case QAbstractSocket::SocketError::ConnectionRefusedError: /**/ - errorString = QObject::tr("ConnectionRefusedError"); - //The connection was refused by the peer (or timed out). - relevantError = true; - break; + errorString = QObject::tr("ConnectionRefusedError"); + //The connection was refused by the peer (or timed out). + relevantError = true; + break; case QAbstractSocket::SocketError::RemoteHostClosedError: /**/ - errorString = QObject::tr("RemoteHostClosedError"); - //The remote host closed the connection - if (networkConf.isOnline()) //we can reconnect + errorString = QObject::tr("RemoteHostClosedError"); + //The remote host closed the connection + if (isConnectedToNetwork()) //we can reconnect { - reConnection = true; + reConnection = true; } - else - relevantError = true; - break; + else + relevantError = true; + break; case QAbstractSocket::SocketError::HostNotFoundError: /**/ - errorString = QObject::tr("HostNotFoundError"); - //The host address was not found. - relevantError = true; - break; + errorString = QObject::tr("HostNotFoundError"); + //The host address was not found. + relevantError = true; + break; case QAbstractSocket::SocketError::SocketAccessError: /**/ - errorString = QObject::tr("SocketAccessError"); - //The socket operation failed because the application lacked the required privileges. - break; + errorString = QObject::tr("SocketAccessError"); + //The socket operation failed because the application lacked the required privileges. + break; case QAbstractSocket::SocketError::SocketTimeoutError: /**/ - errorString = QObject::tr("SocketTimeoutError"); - //The socket operation timed out. - if (isConnected()); //ignore it if connected. - else - relevantError = true; - break; + errorString = QObject::tr("SocketTimeoutError"); + //The socket operation timed out. + if (isConnected()); //ignore it if connected. + else + relevantError = true; + break; case QAbstractSocket::SocketError::NetworkError: /**/ - errorString = QObject::tr("NetworkError"); - //An error occurred with the network (e.g., the network cable was accidentally plugged out). - if (networkConf.isOnline()) //we can reconnect + errorString = QObject::tr("NetworkError"); + //An error occurred with the network (e.g., the network cable was accidentally plugged out). + if (isConnectedToNetwork()) //we can reconnect { } - else - relevantError = true; - break; + else + relevantError = true; + break; case QAbstractSocket::SocketError::SslHandshakeFailedError: /**/ - errorString = QObject::tr("SslHandshakeFailedError"); - relevantError = true; - break; + errorString = QObject::tr("SslHandshakeFailedError"); + relevantError = true; + break; case QAbstractSocket::SocketError::SslInternalError: /**/ - errorString = QObject::tr("SslInternalError"); - relevantError = true; - break; + errorString = QObject::tr("SslInternalError"); + relevantError = true; + break; case QAbstractSocket::SocketError::SslInvalidUserDataError: /**/ - errorString = QObject::tr("SslInvalidUserDataError"); - relevantError = true; - break; + errorString = QObject::tr("SslInvalidUserDataError"); + relevantError = true; + break; case QAbstractSocket::SocketError::DatagramTooLargeError: //not relevant to us - errorString = QObject::tr("DatagramTooLargeError"); - break; + errorString = QObject::tr("DatagramTooLargeError"); + break; case QAbstractSocket::SocketError::SocketResourceError: //not relevant to us - break; + break; case QAbstractSocket::SocketError::OperationError: //not relevant, except for debug - errorString = QObject::tr("OperationError"); - break; + errorString = QObject::tr("OperationError"); + break; case QAbstractSocket::SocketError::AddressInUseError: //not relevant to us - errorString = QObject::tr("AddressInUseError"); - break; + errorString = QObject::tr("AddressInUseError"); + break; case QAbstractSocket::SocketError::SocketAddressNotAvailableError: //not relevant to us - errorString = QObject::tr("SocketAddressNotAvailableError"); - break; + errorString = QObject::tr("SocketAddressNotAvailableError"); + break; case QAbstractSocket::SocketError::UnsupportedSocketOperationError: //for very old computers, not relevant to us - errorString = QObject::tr("UnsupportedSocketOperationError"); - break; + errorString = QObject::tr("UnsupportedSocketOperationError"); + break; case QAbstractSocket::SocketError::ProxyAuthenticationRequiredError: //not relevant to us - errorString = QObject::tr("ProxyAuthenticationRequiredError"); - break; + errorString = QObject::tr("ProxyAuthenticationRequiredError"); + break; case QAbstractSocket::SocketError::ProxyConnectionRefusedError: //not relevant to us - errorString = QObject::tr("ProxyConnectionRefusedError"); - break; + errorString = QObject::tr("ProxyConnectionRefusedError"); + break; case QAbstractSocket::SocketError::UnfinishedSocketOperationError: //not relevant to us - errorString = QObject::tr("UnfinishedSocketOperationError"); - break; + errorString = QObject::tr("UnfinishedSocketOperationError"); + break; case QAbstractSocket::SocketError::ProxyConnectionClosedError: //not relevant to us - errorString = QObject::tr("ProxyConnectionClosedError"); - break; + errorString = QObject::tr("ProxyConnectionClosedError"); + break; case QAbstractSocket::SocketError::ProxyConnectionTimeoutError: //not relevant to us - errorString = QObject::tr("ProxyConnectionTimeoutError"); - break; + errorString = QObject::tr("ProxyConnectionTimeoutError"); + break; case QAbstractSocket::SocketError::ProxyNotFoundError: //not relevant to us - errorString = QObject::tr("ProxyNotFoundError"); - break; + errorString = QObject::tr("ProxyNotFoundError"); + break; case QAbstractSocket::SocketError::ProxyProtocolError: //not relevant to us - errorString = QObject::tr("ProxyProtocolError"); - break; + errorString = QObject::tr("ProxyProtocolError"); + break; case QAbstractSocket::SocketError::TemporaryError: //not relevant to us - errorString = QObject::tr("TemporaryError"); - break; + errorString = QObject::tr("TemporaryError"); + break; case QAbstractSocket::SocketError::UnknownSocketError: //not relevant, except for debug - errorString = QObject::tr("UnknownSocketError"); - relevantError = true; - break; + errorString = QObject::tr("UnknownSocketError"); + relevantError = true; + break; } - if (relevantError) //informative string to be shown + if (relevantError) //informative string to be shown { - qDebug() << Q_FUNC_INFO << "relevant error."; - msgBox.setIcon(QMessageBox::Warning); - msgBox.setText(errorString); - msgBox.exec(); + qDebug() << Q_FUNC_INFO << "relevant error."; + msgBox.setIcon(QMessageBox::Warning); + msgBox.setText(errorString); + msgBox.exec(); } } /** @@ -357,14 +371,46 @@ void jceSSLClient::showIfErrorMsg() */ void jceSSLClient::checkErrors(QAbstractSocket::SocketError a) { - //ignore this stupid error - if (!((isConnected()) && (a == QAbstractSocket::SocketError::SocketTimeoutError))) + //ignore this stupid error + bool timeout = (a == QAbstractSocket::SocketError::SocketTimeoutError); + if (!((isConnected()) && (timeout))) { - qWarning() << Q_FUNC_INFO << "isOnline?: " << this->networkConf.isOnline(); - qWarning() << Q_FUNC_INFO << "state is: " << state(); - qWarning() << Q_FUNC_INFO << "Var Error: " << a; - qWarning() << Q_FUNC_INFO << "Error: " << errorString(); + qWarning() << Q_FUNC_INFO << "isOnline?: " << isConnectedToNetwork(); + qWarning() << Q_FUNC_INFO << "state is: " << state(); + qWarning() << Q_FUNC_INFO << "Var Error: " << a; + qWarning() << Q_FUNC_INFO << "Error: " << errorString(); } - showIfErrorMsg(); + else + { + qDebug() << Q_FUNC_INFO << "isConnected?: " << isConnected() << "is timeout?" << timeout; + qWarning() << Q_FUNC_INFO << "isOnline?: " << isConnectedToNetwork(); + qWarning() << Q_FUNC_INFO << "state is: " << state(); + qWarning() << Q_FUNC_INFO << "Var Error: " << a; + qWarning() << Q_FUNC_INFO << "Error: " << errorString(); + } + showIfErrorMsg(); +} + +/** written by KARAN BALKAR + * @brief jceSSLClient::isConnectedToNetwork + * @return + */ +bool jceSSLClient::isConnectedToNetwork(){ + + QList ifaces = QNetworkInterface::allInterfaces(); + bool result = false; + + for (int i = 0; i < ifaces.count(); ++i) + { + QNetworkInterface iface = ifaces.at(i); + + if ( iface.flags().testFlag(QNetworkInterface::IsUp) && !iface.flags().testFlag(QNetworkInterface::IsLoopBack)) + for (int j=0; j < iface.addressEntries().count(); ++j) + // got an interface which is up, and has an ip address + if (result == false) + result = true; + + } + return result; } diff --git a/src/jceConnection/jcesslclient.h b/src/jceConnection/jcesslclient.h index f67b2ac..d4f95e7 100644 --- a/src/jceConnection/jcesslclient.h +++ b/src/jceConnection/jcesslclient.h @@ -7,6 +7,7 @@ #include #include #include +#include #define milisTimeOut 4000 @@ -37,6 +38,7 @@ private slots: void setOnlineState(bool isOnline); private: + bool isConnectedToNetwork(); //checking if online bool flag; QString packet; QEventLoop loop; //handle the connection as thread