Add calendar option
bug fixes, better phrasing, calendar option
This commit is contained in:
parent
1a3813d858
commit
95ccaa39d0
35 changed files with 2904 additions and 1899 deletions
108
jceGrade.pro
108
jceGrade.pro
|
@ -1,53 +1,55 @@
|
|||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2014-05-31T19:49:42
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui network
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
TARGET = jceGrade
|
||||
TEMPLATE = app
|
||||
RC_FILE = appConfigure.rc
|
||||
CONFIG += c++11 static
|
||||
SOURCES += main/coursestablemanager.cpp \
|
||||
main/loginhandler.cpp \
|
||||
main/main.cpp \
|
||||
main/mainscreen.cpp \
|
||||
src/connection/jcesslclient.cpp \
|
||||
src/user.cpp \
|
||||
src/grades/Course.cpp \
|
||||
src/grades/GradePage.cpp \
|
||||
src/grades/Page.cpp \
|
||||
src/jce/jcedate.cpp \
|
||||
src/jce/jcelogin.cpp \
|
||||
src/data/savedata.cpp \
|
||||
|
||||
|
||||
|
||||
|
||||
HEADERS += main/coursestablemanager.h \
|
||||
main/loginhandler.h \
|
||||
main/mainscreen.h \
|
||||
src/connection/jcesslclient.h \
|
||||
src/user.h \
|
||||
src/grades/Course.h \
|
||||
src/grades/GradePage.h \
|
||||
src/grades/Page.h \
|
||||
src/jce/jcedate.h \
|
||||
src/jce/jcelogin.h \
|
||||
src/jce/jceLoginHtmlScripts.h \
|
||||
src/data/savedata.h \
|
||||
|
||||
|
||||
TRANSLATIONS = jce_en.ts \
|
||||
jce_he.ts
|
||||
|
||||
FORMS += \
|
||||
main/mainscreen.ui
|
||||
|
||||
OTHER_FILES +=
|
||||
|
||||
RESOURCES += \
|
||||
resources/connectionstatus.qrc
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2014-05-31T19:49:42
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui network
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
TARGET = jceGrade
|
||||
TEMPLATE = app
|
||||
RC_FILE = appConfigure.rc
|
||||
CONFIG += c++11 static
|
||||
|
||||
FORMS += \
|
||||
main/mainscreen.ui
|
||||
|
||||
OTHER_FILES +=
|
||||
|
||||
RESOURCES += \
|
||||
resources/connectionstatus.qrc
|
||||
|
||||
HEADERS += \
|
||||
main/CalendarTab/CalendarManager.h \
|
||||
main/CourseTab/coursestablemanager.h \
|
||||
main/LoginTab/loginhandler.h \
|
||||
main/mainscreen.h \
|
||||
src/appDatabase/savedata.h \
|
||||
src/jceConnection/jcesslclient.h \
|
||||
src/jceData/Calendar/calendarPage.h \
|
||||
src/jceData/Grades/gradeCourse.h \
|
||||
src/jceData/Grades/gradePage.h \
|
||||
src/jceData/course.h \
|
||||
src/jceData/page.h \
|
||||
src/jceSettings/jcelogin.h \
|
||||
src/jceSettings/jceLoginHtmlScripts.h \
|
||||
src/jceSettings/user.h \
|
||||
src/jceData/Calendar/calendarCourse.h
|
||||
|
||||
SOURCES += \
|
||||
main/CalendarTab/CalendarManager.cpp \
|
||||
main/CourseTab/coursestablemanager.cpp \
|
||||
main/LoginTab/loginhandler.cpp \
|
||||
main/main.cpp \
|
||||
main/mainscreen.cpp \
|
||||
src/appDatabase/savedata.cpp \
|
||||
src/jceConnection/jcesslclient.cpp \
|
||||
src/jceData/Calendar/calendarPage.cpp \
|
||||
src/jceData/Grades/gradeCourse.cpp \
|
||||
src/jceData/Grades/gradePage.cpp \
|
||||
src/jceData/page.cpp \
|
||||
src/jceSettings/jcelogin.cpp \
|
||||
src/jceSettings/user.cpp \
|
||||
src/jceData/Calendar/calendarCourse.cpp
|
||||
|
||||
|
|
251
jceGrade.pro.user
Normal file
251
jceGrade.pro.user
Normal file
|
@ -0,0 +1,251 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 3.1.1, 2014-08-31T12:32:46. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
<value type="int">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||
<value type="QString" key="language">Cpp</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||
<value type="QString" key="language">QmlJS</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap"/>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.3.0 MinGW 32bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.3.0 MinGW 32bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.53.win32_mingw482_kit</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/Dropbox/cpp/jceConQT/build-jceGrade-Desktop_Qt_5_3_0_MinGW_32bit-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/Dropbox/cpp/jceConQT/build-jceGrade-Desktop_Qt_5_3_0_MinGW_32bit-Release</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
||||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||
<value type="int">0</value>
|
||||
<value type="int">1</value>
|
||||
<value type="int">2</value>
|
||||
<value type="int">3</value>
|
||||
<value type="int">4</value>
|
||||
<value type="int">5</value>
|
||||
<value type="int">6</value>
|
||||
<value type="int">7</value>
|
||||
<value type="int">8</value>
|
||||
<value type="int">9</value>
|
||||
<value type="int">10</value>
|
||||
<value type="int">11</value>
|
||||
<value type="int">12</value>
|
||||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</valuelist>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">jceGrade</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:D:/Dropbox/cpp/jceConQT/jceAverageCalculator/jceGrade.pro</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">jceGrade.pro</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||
<value type="int">1</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
|
||||
<value type="QByteArray">{f3f3b933-8225-47b3-aa78-fc5de0bd714b}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||
<value type="int">15</value>
|
||||
</data>
|
||||
</qtcreator>
|
17
main/CalendarTab/CalendarManager.cpp
Normal file
17
main/CalendarTab/CalendarManager.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include "CalendarManager.h"
|
||||
|
||||
CalendarManager::CalendarManager(QPlainTextEdit *ptr)
|
||||
{
|
||||
this->ptr = ptr;
|
||||
}
|
||||
|
||||
void CalendarManager::setCalendar(std::string html)
|
||||
{
|
||||
cali = new CalendarPage(html);
|
||||
QString text;
|
||||
for (calendarCourse *a: *cali->getCourses())
|
||||
{
|
||||
text += QString::fromStdString(a->courseToString());
|
||||
}
|
||||
ptr->setPlainText(text);
|
||||
}
|
24
main/CalendarTab/CalendarManager.h
Normal file
24
main/CalendarTab/CalendarManager.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef CALENDARMANAGER_H
|
||||
#define CALENDARMANAGER_H
|
||||
|
||||
#include "./src/jceData/Calendar/calendarPage.h"
|
||||
#include <iostream>
|
||||
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
class CalendarManager
|
||||
{
|
||||
public:
|
||||
CalendarManager(QPlainTextEdit *ptr);
|
||||
~CalendarManager()
|
||||
{
|
||||
delete cali;
|
||||
}
|
||||
|
||||
void setCalendar(std::string html);
|
||||
private:
|
||||
QPlainTextEdit * ptr;
|
||||
CalendarPage * cali;
|
||||
};
|
||||
|
||||
#endif // CALENDARMANAGER_H
|
251
main/CourseTab/coursestablemanager.cpp
Normal file
251
main/CourseTab/coursestablemanager.cpp
Normal file
|
@ -0,0 +1,251 @@
|
|||
#include "coursestablemanager.h"
|
||||
|
||||
coursesTableManager::coursesTableManager(QTableWidget *ptr, user *usrPtr)
|
||||
{
|
||||
this->gp = NULL;
|
||||
this->us = usrPtr;
|
||||
this->courseTBL = ptr;
|
||||
|
||||
/*
|
||||
* Initilizing Table
|
||||
*/
|
||||
courseTBL->setRowCount(0);
|
||||
courseTBL->setColumnCount(COURSE_FIELDS);
|
||||
QStringList mz;
|
||||
mz << QObject::tr("Code") << QObject::tr("Name") << QObject::tr("Type") << QObject::tr("Points") << QObject::tr("Hours") << QObject::tr("Grade") << QObject::tr("Additions");
|
||||
courseTBL->setHorizontalHeaderLabels(mz);
|
||||
courseTBL->verticalHeader()->setVisible(true);
|
||||
courseTBL->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
courseTBL->setShowGrid(true);
|
||||
courseTBL->setStyleSheet("QTableView {selection-background-color: red;}");
|
||||
}
|
||||
|
||||
coursesTableManager::~coursesTableManager()
|
||||
{
|
||||
courseTBL = NULL;
|
||||
delete gp;
|
||||
gp = NULL;
|
||||
}
|
||||
/**
|
||||
* @brief coursesTableManager::insertJceCoursesIntoTable phrasing the course list to rows in table
|
||||
*/
|
||||
void coursesTableManager::insertJceCoursesIntoTable()
|
||||
{
|
||||
for (gradeCourse *c: *gp->getCourses())
|
||||
{
|
||||
if (us->getInfluenceCourseOnly())
|
||||
{
|
||||
if (isCourseInfluence(c))
|
||||
addRow(c);
|
||||
}
|
||||
else
|
||||
addRow(c);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief coursesTableManager::setCoursesList creating courses list with given html page
|
||||
* @param html
|
||||
*/
|
||||
void coursesTableManager::setCoursesList(std::string &html)
|
||||
{
|
||||
gp = new GradePage(html);
|
||||
}
|
||||
/**
|
||||
* @brief coursesTableManager::changes when user changes the table manually it updates it
|
||||
* @param change string change
|
||||
* @param row row index
|
||||
* @param col col index
|
||||
* @return if change has been done
|
||||
*/
|
||||
bool coursesTableManager::changes(QString change, int row, int col)
|
||||
{
|
||||
|
||||
bool isNumFlag = true;
|
||||
|
||||
int serialCourse = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text().toInt();
|
||||
for (gradeCourse *c: *gp->getCourses())
|
||||
{
|
||||
if (c->getSerialNum() == serialCourse)
|
||||
{
|
||||
switch (col)
|
||||
{
|
||||
case (gradeCourse::CourseScheme::NAME):
|
||||
c->setName(change.toStdString());
|
||||
break;
|
||||
case (gradeCourse::CourseScheme::TYPE):
|
||||
c->setType(change.toStdString());
|
||||
break;
|
||||
case (gradeCourse::CourseScheme::POINTS):
|
||||
{
|
||||
change.toDouble(&isNumFlag);
|
||||
|
||||
if (!isNumFlag)
|
||||
{
|
||||
courseTBL->item(row,col)->setText(QString::number(c->getPoints()));
|
||||
}
|
||||
else
|
||||
c->setPoints(change.toDouble());
|
||||
break;
|
||||
}
|
||||
case (gradeCourse::CourseScheme::HOURS):
|
||||
{
|
||||
change.toDouble(&isNumFlag);
|
||||
|
||||
if (!isNumFlag)
|
||||
{
|
||||
courseTBL->item(row,col)->setText(QString::number(c->getHours()));
|
||||
}
|
||||
else
|
||||
c->setHours(change.toDouble());
|
||||
break;
|
||||
}
|
||||
case (gradeCourse::CourseScheme::GRADE):
|
||||
{
|
||||
change.toDouble(&isNumFlag);
|
||||
|
||||
if (!isNumFlag)
|
||||
{
|
||||
courseTBL->item(row,col)->setText(QString::number(c->getGrade()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((change.toDouble() >= 0) && (change.toDouble() <= 100))
|
||||
c->setGrade(change.toDouble());
|
||||
else
|
||||
courseTBL->item(row,col)->setText(QString::number(c->getGrade()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (gradeCourse::CourseScheme::ADDITION):
|
||||
c->setAdditions(change.toStdString());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isNumFlag;
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief coursesTableManager::addRow adds row with given information
|
||||
* @param courseToAdd if exists, add its information to table
|
||||
*/
|
||||
void coursesTableManager::addRow(const gradeCourse *courseToAdd)
|
||||
{
|
||||
int i,j;
|
||||
i = courseTBL->rowCount();
|
||||
j = 0;
|
||||
QTableWidgetItem *serial,*name,*type,*points,*hours,*grade,*addition;
|
||||
const gradeCourse * c;
|
||||
if (courseToAdd != NULL)
|
||||
{
|
||||
c = courseToAdd;
|
||||
if (!isCourseAlreadyInserted(c->getSerialNum()))
|
||||
{
|
||||
courseTBL->setRowCount(courseTBL->rowCount()+1);
|
||||
serial = new QTableWidgetItem(QString::number(c->getSerialNum()));
|
||||
serial->setFlags(serial->flags() & ~Qt::ItemIsEditable);
|
||||
points = new QTableWidgetItem(QString::number(c->getPoints()));
|
||||
points->setFlags(serial->flags() & ~Qt::ItemIsEditable);
|
||||
hours = new QTableWidgetItem(QString::number(c->getHours()));
|
||||
hours->setFlags(serial->flags() & ~Qt::ItemIsEditable);
|
||||
grade = new QTableWidgetItem(QString::number(c->getGrade()));
|
||||
name = new QTableWidgetItem(QString::fromStdString(c->getName()));
|
||||
name->setFlags(serial->flags() & ~Qt::ItemIsEditable);
|
||||
type = new QTableWidgetItem(QString::fromStdString(c->getType()));
|
||||
type->setFlags(serial->flags() & ~Qt::ItemIsEditable);
|
||||
addition = new QTableWidgetItem(QString::fromStdString(c->getAddidtions()));
|
||||
|
||||
courseTBL->setItem(i,j++,serial);
|
||||
courseTBL->setItem(i,j++,name);
|
||||
courseTBL->setItem(i,j++,type);
|
||||
courseTBL->setItem(i,j++,points);
|
||||
courseTBL->setItem(i,j++,hours);
|
||||
courseTBL->setItem(i,j++,grade);
|
||||
courseTBL->setItem(i,j,addition);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
courseTBL->resizeColumnsToContents();
|
||||
|
||||
}
|
||||
double coursesTableManager::getAvg()
|
||||
{
|
||||
if (this->gp != NULL)
|
||||
return gp->getAvg();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void coursesTableManager::influnceCourseChanged(bool ignoreCourseStatus)
|
||||
{
|
||||
if (ignoreCourseStatus)
|
||||
{
|
||||
int i = 0;
|
||||
while (i < courseTBL->rowCount())
|
||||
{
|
||||
if (courseTBL->item(i,gradeCourse::CourseScheme::POINTS)->text().compare("0") == 0)
|
||||
courseTBL->removeRow(i--);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (gradeCourse *c: *gp->getCourses())
|
||||
{
|
||||
if (!(isCourseAlreadyInserted(c->getSerialNum())))
|
||||
if (c->getPoints() == 0)
|
||||
addRow(c);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void coursesTableManager::clearTable()
|
||||
{
|
||||
if (courseTBL->rowCount() == 0)
|
||||
return;
|
||||
|
||||
int i = 0; //starting point
|
||||
while (courseTBL->rowCount() > i)
|
||||
{
|
||||
gp->removeCourse(courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text().toStdString());
|
||||
courseTBL->removeRow(i);
|
||||
}
|
||||
gp = NULL;
|
||||
courseTBL->repaint();
|
||||
}
|
||||
|
||||
gradeCourse *coursesTableManager::getCourseByRow(int row)
|
||||
{
|
||||
QString courseSerial = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text();
|
||||
for (gradeCourse *c: *gp->getCourses())
|
||||
{
|
||||
if (c->getSerialNum() == courseSerial.toDouble())
|
||||
return c;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool coursesTableManager::isCourseAlreadyInserted(double courseID)
|
||||
{
|
||||
int i=0;
|
||||
for (i = 0; i < courseTBL->rowCount(); ++i)
|
||||
{
|
||||
QString courseSerial = courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text();
|
||||
if (QString::number(courseID) == courseSerial)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool coursesTableManager::isCourseInfluence(const gradeCourse *courseToCheck)
|
||||
{
|
||||
if (courseToCheck->getPoints() > 0)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
}
|
43
main/CourseTab/coursestablemanager.h
Normal file
43
main/CourseTab/coursestablemanager.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
#ifndef COURSESTABLEMANAGER_H
|
||||
#define COURSESTABLEMANAGER_H
|
||||
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QHeaderView>
|
||||
#include <QMessageBox>
|
||||
#include <QTableWidget>
|
||||
#include <QString>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "./src/jceData/Grades/gradePage.h"
|
||||
#include "./src/jceSettings/user.h"
|
||||
|
||||
class coursesTableManager
|
||||
{
|
||||
public:
|
||||
coursesTableManager(QTableWidget *, user *usrPtr);
|
||||
~coursesTableManager();
|
||||
void insertJceCoursesIntoTable();
|
||||
void setCoursesList(std::string &htmlPage);
|
||||
bool changes(QString change, int row, int col);
|
||||
void addRow(const gradeCourse * courseToAdd = 0);
|
||||
double getAvg();
|
||||
|
||||
void influnceCourseChanged(bool status);
|
||||
void clearTable();
|
||||
|
||||
private:
|
||||
QTableWidget *courseTBL;
|
||||
GradePage *gp;
|
||||
user *us;
|
||||
|
||||
gradeCourse * getCourseByRow(int row);
|
||||
bool isCourseAlreadyInserted(double courseID);
|
||||
bool isCourseInfluence(const gradeCourse *courseToCheck);
|
||||
};
|
||||
|
||||
#endif // COURSESTABLEMANAGER_H
|
141
main/LoginTab/loginhandler.cpp
Normal file
141
main/LoginTab/loginhandler.cpp
Normal file
|
@ -0,0 +1,141 @@
|
|||
#include "loginhandler.h"
|
||||
|
||||
loginHandler::loginHandler(user *ptr): logggedInFlag(false)
|
||||
{
|
||||
this->jceLog = new jceLogin(ptr);
|
||||
}
|
||||
void loginHandler::setPointers(QLabel *statusLabelPtr,QLineEdit *pswdEditPtr,QLineEdit *usrnmEditPtr)
|
||||
{
|
||||
|
||||
this->statusLabelPtr = statusLabelPtr;
|
||||
this->pswdEditPtr = pswdEditPtr;
|
||||
this->usrnmEditPtr = usrnmEditPtr;
|
||||
}
|
||||
|
||||
bool loginHandler::makeConnection()
|
||||
{
|
||||
if (this->jceLog == NULL)
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
jceLog->makeConnection();
|
||||
}
|
||||
catch (jceLogin::jceStatus &a)
|
||||
{
|
||||
int status = (int)a;
|
||||
switch (status)
|
||||
{
|
||||
case jceLogin::JCE_YOU_ARE_IN:
|
||||
{
|
||||
logggedInFlag = true;
|
||||
return logggedInFlag;
|
||||
break;
|
||||
}
|
||||
case jceLogin::ERROR_ON_VALIDATION:
|
||||
{
|
||||
popMessage("Please Check Your Username & Password",false);
|
||||
|
||||
usrnmEditPtr->setDisabled(false);
|
||||
pswdEditPtr->setDisabled(false);
|
||||
|
||||
pswdEditPtr->selectAll();
|
||||
pswdEditPtr->setFocus();
|
||||
return false;
|
||||
}
|
||||
case jceLogin::ERROR_ON_VALIDATION_USER_BLOCKED:
|
||||
{
|
||||
popMessage("You have been blocked by JCE, please try in a couple of minutes.");
|
||||
jceLog->closeAll();
|
||||
return false;
|
||||
}
|
||||
case jceLogin::ERROR_ON_OPEN_SOCKET:
|
||||
{
|
||||
popMessage("Please Check Your Internet Connection.");
|
||||
jceLog->closeAll();
|
||||
return false;
|
||||
}
|
||||
case jceLogin::JCE_NOT_CONNECTED:
|
||||
{
|
||||
jceLog->reConnect();
|
||||
/*
|
||||
* Fix: need to add a prompte window to ask user whether he wants to reconnect or not
|
||||
*/
|
||||
break;
|
||||
}
|
||||
case jceLogin::ERROR_ON_GETTING_INFO:
|
||||
{
|
||||
popMessage("Recieve Request Time Out.");
|
||||
jceLog->closeAll();
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
case jceLogin::ERROR_ON_SEND_REQUEST:
|
||||
{
|
||||
popMessage("Send Request Time Out.");
|
||||
jceLog->closeAll();
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool loginHandler::isLoggedInFlag()
|
||||
{
|
||||
return this->logggedInFlag;
|
||||
}
|
||||
|
||||
void loginHandler::setLoginFlag(bool flag)
|
||||
{
|
||||
this->logggedInFlag = flag;
|
||||
}
|
||||
|
||||
QString loginHandler::getCurrentPageContect()
|
||||
{
|
||||
QTextEdit phrase;
|
||||
if (isLoggedInFlag())
|
||||
phrase.setText(QString::fromStdString(jceLog->getPage()));
|
||||
else
|
||||
throw jceLogin::ERROR_ON_GETTING_INFO;
|
||||
|
||||
return phrase.toPlainText();
|
||||
}
|
||||
|
||||
void loginHandler::makeDisconnectionRequest()
|
||||
{
|
||||
jceLog->closeAll();
|
||||
this->logggedInFlag = false;
|
||||
}
|
||||
|
||||
int loginHandler::makeGradeRequest(int fromYear, int toYear, int fromSemester, int toSemester)
|
||||
{
|
||||
if (isLoggedInFlag())
|
||||
return jceLog->getGrades(fromYear, toYear, fromSemester, toSemester);
|
||||
else
|
||||
return jceLogin::JCE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
int loginHandler::makeCalendarRequest(int year, int semester)
|
||||
{
|
||||
if (isLoggedInFlag())
|
||||
return jceLog->getCalendar(year,semester);
|
||||
else
|
||||
return jceLogin::JCE_NOT_CONNECTED;
|
||||
}
|
||||
void loginHandler::popMessage(QString message,bool addInfo)
|
||||
{
|
||||
if (addInfo)
|
||||
message.append("\nIf this message appear without reason, please contact me at liranbg@gmail.com");
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle("Error");
|
||||
msgBox.setText(message);
|
||||
msgBox.exec();
|
||||
msgBox.setFocus();
|
||||
|
||||
}
|
||||
|
||||
|
44
main/LoginTab/loginhandler.h
Normal file
44
main/LoginTab/loginhandler.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
#ifndef LOGINHANDLER_H
|
||||
#define LOGINHANDLER_H
|
||||
#include <QString>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QTextEdit>
|
||||
#include <QMessageBox>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "./src/jceSettings/jcelogin.h"
|
||||
#include "./src/appDatabase/savedata.h"
|
||||
|
||||
|
||||
class loginHandler
|
||||
{
|
||||
public:
|
||||
loginHandler(user *ptr);
|
||||
void setPointers(QLabel *statusLabelPtr,QLineEdit *pswdEditPtr,QLineEdit *usrnmEditPtr);
|
||||
bool makeConnection();
|
||||
bool isLoggedInFlag();
|
||||
void setLoginFlag(bool flag);
|
||||
|
||||
QString getCurrentPageContect();
|
||||
|
||||
int makeGradeRequest(int fromYear, int toYear, int fromSemester, int toSemester);
|
||||
int makeCalendarRequest(int year,int semester);
|
||||
|
||||
void makeDisconnectionRequest();
|
||||
|
||||
private:
|
||||
|
||||
void popMessage(QString message, bool addInfo = true);
|
||||
|
||||
bool logggedInFlag;
|
||||
jceLogin *jceLog;
|
||||
|
||||
QLabel *statusLabelPtr;
|
||||
QLineEdit *pswdEditPtr;
|
||||
QLineEdit *usrnmEditPtr;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // LOGINHANDLER_H
|
|
@ -6,7 +6,7 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
this->setFixedSize(this->size()); //main not resizeable
|
||||
//this->setFixedSize(this->size()); //main not resizeable
|
||||
|
||||
|
||||
//Login Tab
|
||||
|
@ -21,9 +21,8 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
|
|||
ui->statusBar->addPermanentWidget(statusLabel,1);
|
||||
setLabelConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED);
|
||||
|
||||
//Course and Setting Tab
|
||||
//Course, Setting, Calendar Tab
|
||||
ui->CoursesTab->setDisabled(true);
|
||||
ui->SettingsTab->setDisabled(true);
|
||||
ui->avgLCD->setPalette(QPalette(QPalette::WindowText,Qt::blue));
|
||||
|
||||
|
||||
|
@ -32,8 +31,7 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
|
|||
this->userLoginSetting = new user("","");
|
||||
this->courseTableMgr = new coursesTableManager(ui->coursesTable,userLoginSetting);
|
||||
this->loginHandel = new loginHandler(userLoginSetting);
|
||||
|
||||
updateDates();
|
||||
this->calendar = new CalendarManager(ui->calendartext);
|
||||
|
||||
//check login File
|
||||
SaveData::init();
|
||||
|
@ -51,7 +49,6 @@ MainScreen::~MainScreen()
|
|||
delete loginHandel;
|
||||
delete ui;
|
||||
}
|
||||
/*** LOGIN TAB FUNCTIONS ***/
|
||||
void MainScreen::on_loginButton_clicked()
|
||||
{
|
||||
if (loginHandel->isLoggedInFlag())
|
||||
|
@ -61,26 +58,32 @@ void MainScreen::on_loginButton_clicked()
|
|||
uiSetConnectMode();
|
||||
|
||||
}
|
||||
void MainScreen::on_usrnmLineEdit_editingFinished()
|
||||
void MainScreen::on_pushButton_clicked()
|
||||
{
|
||||
ui->usrnmLineEdit->setText(ui->usrnmLineEdit->text().toLower());
|
||||
}
|
||||
void MainScreen::on_keepLogin_clicked()
|
||||
{
|
||||
if (ui->keepLogin->isChecked())
|
||||
SaveData::save(ui->usrnmLineEdit->text(),ui->pswdLineEdit->text());
|
||||
int status = 0;
|
||||
if (loginHandel->isLoggedInFlag())
|
||||
{
|
||||
if ((status = loginHandel->makeCalendarRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_GRADE_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->setCalendar(loginHandel->getCurrentPageContect().toStdString());
|
||||
}
|
||||
|
||||
else
|
||||
SaveData::deleteData();
|
||||
else if (status == jceLogin::JCE_NOT_CONNECTED)
|
||||
{
|
||||
QMessageBox::critical(this,tr("Error"),tr("Not Connected"));
|
||||
}
|
||||
}
|
||||
}
|
||||
/*** COURSES TAB FUNCTIONS ***/
|
||||
|
||||
void MainScreen::on_ratesButton_clicked()
|
||||
{
|
||||
std::string pageString;
|
||||
int status = 0;
|
||||
if (loginHandel->isLoggedInFlag())
|
||||
{
|
||||
if ((status = loginHandel->makeGradeRequest()) == jceLogin::JCE_GRADE_PAGE_PASSED)
|
||||
if ((status = loginHandel->makeGradeRequest(ui->spinBoxCoursesFromYear->value(),ui->spinBoxCoursesToYear->value(),ui->spinBoxCoursesFromSemester->value(),ui->spinBoxCoursesToSemester->value())) == jceLogin::JCE_GRADE_PAGE_PASSED)
|
||||
{
|
||||
pageString = loginHandel->getCurrentPageContect().toStdString();
|
||||
courseTableMgr->setCoursesList(pageString);
|
||||
|
@ -91,7 +94,56 @@ void MainScreen::on_ratesButton_clicked()
|
|||
QMessageBox::critical(this,tr("Error"),tr("Not Connected"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
void MainScreen::on_checkBoxCoursesInfluence_toggled(bool checked)
|
||||
{
|
||||
this->userLoginSetting->setInfluenceCourseOnly(checked);
|
||||
this->courseTableMgr->influnceCourseChanged(checked);
|
||||
}
|
||||
void MainScreen::on_spinBoxCoursesFromYear_editingFinished()
|
||||
{
|
||||
if (ui->spinBoxCoursesFromYear->value() > ui->spinBoxCoursesToYear->value())
|
||||
{
|
||||
ui->spinBoxCoursesFromYear->setValue(ui->spinBoxCoursesToYear->value());
|
||||
ui->spinBoxCoursesFromYear->setFocus();
|
||||
}
|
||||
|
||||
}
|
||||
void MainScreen::on_spinBoxCoursesToYear_editingFinished()
|
||||
{
|
||||
if (ui->spinBoxCoursesFromYear->value() > ui->spinBoxCoursesToYear->value())
|
||||
{
|
||||
ui->spinBoxCoursesToYear->setValue(ui->spinBoxCoursesFromYear->value());
|
||||
ui->spinBoxCoursesToYear->setFocus();
|
||||
|
||||
}
|
||||
}
|
||||
void MainScreen::on_spinBoxCoursesFromSemester_editingFinished()
|
||||
{
|
||||
if (ui->spinBoxCoursesFromYear->value() == ui->spinBoxCoursesToYear->value())
|
||||
{
|
||||
if (ui->spinBoxCoursesFromSemester->value() > ui->spinBoxCoursesToSemester->value())
|
||||
{
|
||||
ui->spinBoxCoursesFromSemester->setValue(ui->spinBoxCoursesToSemester->value());
|
||||
ui->spinBoxCoursesFromSemester->setFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
void MainScreen::on_spinBoxCoursesToSemester_editingFinished()
|
||||
{
|
||||
if (ui->spinBoxCoursesFromYear->value() == ui->spinBoxCoursesToYear->value())
|
||||
{
|
||||
if (ui->spinBoxCoursesFromSemester->value() > ui->spinBoxCoursesToSemester->value())
|
||||
{
|
||||
ui->spinBoxCoursesToSemester->setValue(ui->spinBoxCoursesFromSemester->value());
|
||||
ui->spinBoxCoursesToSemester->setFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainScreen::on_coursesTable_itemChanged(QTableWidgetItem *item)
|
||||
{
|
||||
if (this->courseTableMgr->changes(item->text(),item->row(),item->column()))
|
||||
|
@ -99,79 +151,11 @@ void MainScreen::on_coursesTable_itemChanged(QTableWidgetItem *item)
|
|||
else
|
||||
QMessageBox::critical(this,"Error","Missmatching data");
|
||||
}
|
||||
void MainScreen::on_clearTableButton_clicked()
|
||||
{
|
||||
|
||||
courseTableMgr->clearTable();
|
||||
ui->avgLCD->display(courseTableMgr->getAvg());
|
||||
}
|
||||
|
||||
/*** SETTING TAB FUNCTIONS ***/
|
||||
void MainScreen::on_spinBoxFromYear_editingFinished()
|
||||
void MainScreen::on_usrnmLineEdit_editingFinished()
|
||||
{
|
||||
if (ui->spinBoxFromYear->value() > ui->spinBoxToYear->value())
|
||||
{
|
||||
ui->spinBoxFromYear->setValue(ui->spinBoxToYear->value());
|
||||
ui->spinBoxFromYear->setFocus();
|
||||
updateDates();
|
||||
}
|
||||
else
|
||||
updateDates();
|
||||
ui->usrnmLineEdit->setText(ui->usrnmLineEdit->text().toLower());
|
||||
}
|
||||
void MainScreen::on_spinBoxToYear_editingFinished()
|
||||
{
|
||||
if (ui->spinBoxFromYear->value() > ui->spinBoxToYear->value())
|
||||
{
|
||||
ui->spinBoxToYear->setValue(ui->spinBoxFromYear->value());
|
||||
ui->spinBoxToYear->setFocus();
|
||||
updateDates();
|
||||
}
|
||||
else
|
||||
updateDates();
|
||||
}
|
||||
void MainScreen::on_spinBoxFromSem_editingFinished()
|
||||
{
|
||||
if (ui->spinBoxFromYear->value() == ui->spinBoxToYear->value())
|
||||
{
|
||||
if (ui->spinBoxFromSem->value() > ui->spinBoxToSemester->value())
|
||||
{
|
||||
ui->spinBoxFromSem->setValue(ui->spinBoxToSemester->value());
|
||||
ui->spinBoxFromSem->setFocus();
|
||||
}
|
||||
}
|
||||
updateDates();
|
||||
}
|
||||
void MainScreen::on_spinBoxToSemester_editingFinished()
|
||||
{
|
||||
if (ui->spinBoxFromYear->value() == ui->spinBoxToYear->value())
|
||||
{
|
||||
if (ui->spinBoxFromSem->value() > ui->spinBoxToSemester->value())
|
||||
{
|
||||
ui->spinBoxToSemester->setValue(ui->spinBoxFromSem->value());
|
||||
ui->spinBoxToSemester->setFocus();
|
||||
}
|
||||
}
|
||||
updateDates();
|
||||
}
|
||||
void MainScreen::on_checkBox_toggled(bool checked)
|
||||
{
|
||||
this->userLoginSetting->setInfluenceCourseOnly(checked);
|
||||
this->courseTableMgr->influnceCourseChanged(checked);
|
||||
}
|
||||
/*
|
||||
* ------------------------------
|
||||
*
|
||||
*/
|
||||
void MainScreen::updateDates()
|
||||
{
|
||||
std::string fy,ty,fs,ts;
|
||||
fy = std::to_string(ui->spinBoxFromYear->value());
|
||||
ty = std::to_string(ui->spinBoxToYear->value());
|
||||
fs = std::to_string(ui->spinBoxFromSem->value());
|
||||
ts = std::to_string(ui->spinBoxToSemester->value());
|
||||
userLoginSetting->setDate(fy,fs,ty,ts);
|
||||
}
|
||||
|
||||
void MainScreen::uiSetDisconnectMode()
|
||||
{
|
||||
setLabelConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED);
|
||||
|
@ -213,7 +197,6 @@ void MainScreen::uiSetConnectMode() //fix before distrbute
|
|||
ui->loginButton->setText("&Logout");
|
||||
this->ui->ratesButton->setEnabled(true);
|
||||
ui->CoursesTab->setEnabled(true);
|
||||
ui->SettingsTab->setEnabled(true);
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -262,6 +245,12 @@ void MainScreen::on_actionCredits_triggered()
|
|||
"</ul>");
|
||||
}
|
||||
|
||||
void MainScreen::on_clearTableButton_clicked()
|
||||
{
|
||||
|
||||
courseTableMgr->clearTable();
|
||||
ui->avgLCD->display(courseTableMgr->getAvg());
|
||||
}
|
||||
|
||||
void MainScreen::on_actionExit_triggered()
|
||||
{
|
||||
|
@ -269,7 +258,14 @@ void MainScreen::on_actionExit_triggered()
|
|||
}
|
||||
|
||||
|
||||
void MainScreen::on_keepLogin_clicked()
|
||||
{
|
||||
if (ui->keepLogin->isChecked())
|
||||
SaveData::save(ui->usrnmLineEdit->text(),ui->pswdLineEdit->text());
|
||||
|
||||
else
|
||||
SaveData::deleteData();
|
||||
}
|
||||
|
||||
void MainScreen::on_actionHow_To_triggered()
|
||||
{
|
||||
|
|
|
@ -10,8 +10,9 @@
|
|||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include "coursestablemanager.h"
|
||||
#include "loginhandler.h"
|
||||
#include "./CourseTab/coursestablemanager.h"
|
||||
#include "./LoginTab/loginhandler.h"
|
||||
#include "./CalendarTab/CalendarManager.h"
|
||||
|
||||
#define StatusIconHeight 35
|
||||
namespace Ui {
|
||||
|
@ -30,18 +31,16 @@ private slots:
|
|||
|
||||
void on_ratesButton_clicked();
|
||||
|
||||
void on_spinBoxFromYear_editingFinished();
|
||||
void on_spinBoxCoursesFromYear_editingFinished();
|
||||
|
||||
void on_spinBoxFromSem_editingFinished();
|
||||
void on_spinBoxCoursesFromSemester_editingFinished();
|
||||
|
||||
void on_spinBoxToYear_editingFinished();
|
||||
void on_spinBoxCoursesToYear_editingFinished();
|
||||
|
||||
void on_spinBoxToSemester_editingFinished();
|
||||
void on_spinBoxCoursesToSemester_editingFinished();
|
||||
|
||||
void on_loginButton_clicked();
|
||||
|
||||
void on_checkBox_toggled(bool checked);
|
||||
|
||||
void on_usrnmLineEdit_editingFinished();
|
||||
|
||||
void on_actionCredits_triggered();
|
||||
|
@ -55,10 +54,13 @@ private slots:
|
|||
void on_keepLogin_clicked();
|
||||
|
||||
void on_actionHow_To_triggered();
|
||||
|
||||
|
||||
void on_pushButton_clicked();
|
||||
|
||||
void on_checkBoxCoursesInfluence_toggled(bool checked);
|
||||
|
||||
private:
|
||||
|
||||
void updateDates();
|
||||
void uiSetDisconnectMode();
|
||||
void uiSetConnectMode();
|
||||
void setLabelConnectionStatus(jceLogin::jceStatus statusDescription);
|
||||
|
@ -67,6 +69,7 @@ private:
|
|||
|
||||
user *userLoginSetting;
|
||||
|
||||
CalendarManager * calendar;
|
||||
coursesTableManager *courseTableMgr;
|
||||
loginHandler *loginHandel;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>855</width>
|
||||
<height>649</height>
|
||||
<height>517</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -61,7 +61,7 @@ background: qlineargradient(spread:pad, x1:0.496, y1:0, x2:0.508, y2:1, stop:0 r
|
|||
<enum>QTabWidget::Rounded</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="documentMode">
|
||||
<bool>false</bool>
|
||||
|
@ -303,7 +303,7 @@ font-size: 15px;
|
|||
<string notr="true"/>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Courses</string>
|
||||
<string>GPA</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
|
@ -311,7 +311,7 @@ font-size: 15px;
|
|||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QTableWidget" name="coursesTable">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
|
@ -330,7 +330,7 @@ font-size: 15px;
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="4" column="0">
|
||||
<layout class="QHBoxLayout" name="coursesTableControlHorizontalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="coursesButtonLayout">
|
||||
|
@ -375,7 +375,7 @@ font-size: 15px;
|
|||
<item>
|
||||
<layout class="QHBoxLayout" name="AvghorizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel" name="labelAverage">
|
||||
<property name="text">
|
||||
<string>Average:</string>
|
||||
</property>
|
||||
|
@ -410,260 +410,211 @@ font-size: 15px;
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="SettingsTab">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Settings</string>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="gridLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>251</width>
|
||||
<height>159</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="semNyearHorizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="SemLabel">
|
||||
<property name="text">
|
||||
<string>Semester</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="YearLabel">
|
||||
<property name="text">
|
||||
<string>Year</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="fromNtoLabel">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="FromLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>From</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="ToLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>To</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="SpinBoxeshorizontalLayout1">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxFromSem">
|
||||
<property name="maximum">
|
||||
<number>3</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxFromYear">
|
||||
<property name="readOnly">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="showGroupSeparator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>2009</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2015</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>2009</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="SpinBoxeshorizontalLayout2">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxToSemester">
|
||||
<property name="maximum">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>3</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxToYear">
|
||||
<property name="minimum">
|
||||
<number>2010</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2026</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>2015</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxCoursesInfluence">
|
||||
<property name="text">
|
||||
<string>Only influence Courses</string>
|
||||
<string>Only Main Courses</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelFrom">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Ignored">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>From</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelFromYear">
|
||||
<property name="text">
|
||||
<string>Year:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxCoursesFromYear">
|
||||
<property name="minimum">
|
||||
<number>2008</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2015</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>2011</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelFromSemester">
|
||||
<property name="text">
|
||||
<string>Semester:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxCoursesFromSemester">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>3</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelTo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Ignored">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>To</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelToYear">
|
||||
<property name="text">
|
||||
<string>Year:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxCoursesToYear">
|
||||
<property name="minimum">
|
||||
<number>2008</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2015</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>2014</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelToSemester">
|
||||
<property name="text">
|
||||
<string>Semester</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxCoursesToSemester">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>3</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="CalendarTab">
|
||||
<attribute name="title">
|
||||
<string>Calendar</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxYear">
|
||||
<property name="minimum">
|
||||
<number>2012</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2020</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>2014</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxSemester">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>2</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Get Calendar</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="calendartext">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -675,7 +626,7 @@ font-size: 15px;
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>855</width>
|
||||
<height>29</height>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuA_about">
|
||||
|
@ -723,15 +674,9 @@ font-size: 15px;
|
|||
<tabstop>usrnmLineEdit</tabstop>
|
||||
<tabstop>pswdLineEdit</tabstop>
|
||||
<tabstop>loginButton</tabstop>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
<tabstop>ratesButton</tabstop>
|
||||
<tabstop>clearTableButton</tabstop>
|
||||
<tabstop>checkBox</tabstop>
|
||||
<tabstop>spinBoxFromSem</tabstop>
|
||||
<tabstop>coursesTable</tabstop>
|
||||
<tabstop>spinBoxFromYear</tabstop>
|
||||
<tabstop>spinBoxToSemester</tabstop>
|
||||
<tabstop>spinBoxToYear</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../resources/connectionstatus.qrc"/>
|
||||
|
|
|
@ -1,200 +1,200 @@
|
|||
#include "savedata.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Checks the status tag in the file
|
||||
* @return boolean the status
|
||||
*/
|
||||
bool SaveData::isSaved()
|
||||
{
|
||||
QString status;
|
||||
QFile* file = new QFile(FILE_NAME);
|
||||
/* Opening file for read */
|
||||
if(file->open(QIODevice::ReadOnly|QIODevice::Text))
|
||||
{
|
||||
status = getValViaTag("status", file);
|
||||
if(status == "true")
|
||||
{
|
||||
file->close(); //close & return
|
||||
return true;
|
||||
}
|
||||
return false; //close & return
|
||||
file->close();
|
||||
}
|
||||
/* If Faild to open */
|
||||
std::cout << "Faild To Accsess file: " << FILE_NAME << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief This Function will modify the file, and save the data.
|
||||
* @param username - QString
|
||||
* @param password - QString
|
||||
* @return true if saved - false if error
|
||||
*/
|
||||
bool SaveData::save(QString username, QString password)
|
||||
{
|
||||
std::cout << "Trying to save data..." << std::endl;
|
||||
QFile file(FILE_NAME);
|
||||
if(!file.open(QIODevice::WriteOnly|QIODevice::Text))
|
||||
return false; /* IO Error! */
|
||||
QTextStream output(&file);
|
||||
QString hash_pass = hashPassword(password);
|
||||
output << "[status]true[/]\n[username]"<<username<<"[/]\n"<<"[password]"<<hash_pass<<"[/]"; //Un Hashed Password in string!
|
||||
file.close();
|
||||
std::cout << "Saved!" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Deletes the data from file, and sets status tag to false.
|
||||
* @return true if success
|
||||
*/
|
||||
bool SaveData::deleteData()
|
||||
{
|
||||
QFile file(FILE_NAME);
|
||||
if(!file.open(QIODevice::WriteOnly|QIODevice::Text))
|
||||
return false; /* IO Error! */
|
||||
QTextStream output(&file);
|
||||
output << DEFAULT_DATA_EMPTY;
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief username getter
|
||||
* @return QString - username
|
||||
*/
|
||||
QString SaveData::getUsername()
|
||||
{
|
||||
QString username = "";
|
||||
QFile* file = new QFile(FILE_NAME);
|
||||
|
||||
/* Opening file for read */
|
||||
if(file->open(QIODevice::ReadOnly|QIODevice::Text))
|
||||
username = getValViaTag("username", file);
|
||||
file->close();
|
||||
return username;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief getter for password
|
||||
* @return QString - password
|
||||
*/
|
||||
QString SaveData::getPassword()
|
||||
{
|
||||
QString pass = "";
|
||||
QFile* file = new QFile(FILE_NAME);
|
||||
/* Opening file for read */
|
||||
if(file->open(QIODevice::ReadOnly|QIODevice::Text))
|
||||
pass = getValViaTag("password", file);
|
||||
file->close();
|
||||
pass = deHashPasword(pass);
|
||||
return pass;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This is A functions that will init the tags file.
|
||||
* if it exist - do nothing
|
||||
* if there is no file, it will create it and run the deleteData function
|
||||
* so tags will be set.
|
||||
*/
|
||||
void SaveData::init()
|
||||
{
|
||||
QFile file(FILE_NAME);
|
||||
if(!file.exists())
|
||||
{
|
||||
file.open(QIODevice::ReadWrite | QIODevice::Text);
|
||||
file.close();
|
||||
deleteData();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function will return the vale of a given tag name.
|
||||
* NOTE: valid tag names are : "status", "username", "password"
|
||||
* if tag is invalid - will return "" - an empty QString!
|
||||
* @param tag - QString, the tag name
|
||||
* @param file - a QFile pointer
|
||||
* @return QString - the value in tag
|
||||
* NOTE: if NULL value, or an invalid tag name -> return "" (empty QString!)
|
||||
*/
|
||||
QString SaveData::getValViaTag(QString tag, QFile* file)
|
||||
{
|
||||
QString val, line , tmpTag;
|
||||
QTextStream textStream( file);
|
||||
while((line = textStream.readLine()) != NULL)
|
||||
{
|
||||
std::cout << "DEBUG: line => " << line.toStdString() << std::endl;
|
||||
for(int i = 0 ; i< line.length() ;++i)
|
||||
{
|
||||
if(line[i] == '[' && line[i+1] != '/') //get open tag at begining of line and not end of tag ("[/")
|
||||
{
|
||||
i++;
|
||||
tmpTag = line.mid(i, tag.length());
|
||||
if(tmpTag == tag)
|
||||
{
|
||||
i+= tag.length()+1; // i is now right after '['
|
||||
int j = i;
|
||||
while(line[j] != '[')// put j at the end of the value
|
||||
j++;
|
||||
/* Then... the value is :*/
|
||||
val = line.mid(i, j-i);
|
||||
std::cout << "DEBUG: ["<<tag.toStdString()<<"]"<<val.toStdString()<<"[/]"<<std::endl;
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""; //this will be as NULL
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function will provide the user the most basic security of the stored password.
|
||||
* it is NOT an encryption! it will store every char of the password as ascii encoded,
|
||||
* separated by "-" for the deHsh func.
|
||||
* @param pass - a QString to "hash"
|
||||
* @return QString - The "hashed" password
|
||||
*/
|
||||
QString SaveData::hashPassword(QString pass)
|
||||
{
|
||||
QString hash="";
|
||||
int code;
|
||||
for(QChar c : pass)
|
||||
{
|
||||
code = (int)c.toLatin1();
|
||||
hash.append(QString::number(code));
|
||||
hash.append("-");
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function will "dehash" the "hashed" password.
|
||||
* uses standard c string.h strtok with the "-" as the choping points.
|
||||
* builds a QString from the ascii.
|
||||
* @param pass - The hashed password
|
||||
* @return QString - password uncoded
|
||||
*/
|
||||
QString SaveData::deHashPasword(QString pass)
|
||||
{
|
||||
char* cpyPass = strdup(pass.toStdString().c_str());
|
||||
char* tok;
|
||||
char* ch;
|
||||
int val;
|
||||
QString password;
|
||||
tok = strtok(cpyPass,"-");
|
||||
while (tok != NULL)
|
||||
{
|
||||
ch = tok;
|
||||
val = atoi(ch);
|
||||
password.append(val);
|
||||
tok = strtok(NULL, "-");
|
||||
}
|
||||
return password;
|
||||
}
|
||||
#include "savedata.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Checks the status tag in the file
|
||||
* @return boolean the status
|
||||
*/
|
||||
bool SaveData::isSaved()
|
||||
{
|
||||
QString status;
|
||||
QFile* file = new QFile(FILE_NAME);
|
||||
/* Opening file for read */
|
||||
if(file->open(QIODevice::ReadOnly|QIODevice::Text))
|
||||
{
|
||||
status = getValViaTag("status", file);
|
||||
if(status == "true")
|
||||
{
|
||||
file->close(); //close & return
|
||||
return true;
|
||||
}
|
||||
return false; //close & return
|
||||
file->close();
|
||||
}
|
||||
/* If Faild to open */
|
||||
std::cout << "Faild To Accsess file: " << FILE_NAME << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief This Function will modify the file, and save the data.
|
||||
* @param username - QString
|
||||
* @param password - QString
|
||||
* @return true if saved - false if error
|
||||
*/
|
||||
bool SaveData::save(QString username, QString password)
|
||||
{
|
||||
std::cout << "Trying to save data..." << std::endl;
|
||||
QFile file(FILE_NAME);
|
||||
if(!file.open(QIODevice::WriteOnly|QIODevice::Text))
|
||||
return false; /* IO Error! */
|
||||
QTextStream output(&file);
|
||||
QString hash_pass = hashPassword(password);
|
||||
output << "[status]true[/]\n[username]"<<username<<"[/]\n"<<"[password]"<<hash_pass<<"[/]"; //Un Hashed Password in string!
|
||||
file.close();
|
||||
std::cout << "Saved!" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Deletes the data from file, and sets status tag to false.
|
||||
* @return true if success
|
||||
*/
|
||||
bool SaveData::deleteData()
|
||||
{
|
||||
QFile file(FILE_NAME);
|
||||
if(!file.open(QIODevice::WriteOnly|QIODevice::Text))
|
||||
return false; /* IO Error! */
|
||||
QTextStream output(&file);
|
||||
output << DEFAULT_DATA_EMPTY;
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief username getter
|
||||
* @return QString - username
|
||||
*/
|
||||
QString SaveData::getUsername()
|
||||
{
|
||||
QString username = "";
|
||||
QFile* file = new QFile(FILE_NAME);
|
||||
|
||||
/* Opening file for read */
|
||||
if(file->open(QIODevice::ReadOnly|QIODevice::Text))
|
||||
username = getValViaTag("username", file);
|
||||
file->close();
|
||||
return username;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief getter for password
|
||||
* @return QString - password
|
||||
*/
|
||||
QString SaveData::getPassword()
|
||||
{
|
||||
QString pass = "";
|
||||
QFile* file = new QFile(FILE_NAME);
|
||||
/* Opening file for read */
|
||||
if(file->open(QIODevice::ReadOnly|QIODevice::Text))
|
||||
pass = getValViaTag("password", file);
|
||||
file->close();
|
||||
pass = deHashPasword(pass);
|
||||
return pass;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This is A functions that will init the tags file.
|
||||
* if it exist - do nothing
|
||||
* if there is no file, it will create it and run the deleteData function
|
||||
* so tags will be set.
|
||||
*/
|
||||
void SaveData::init()
|
||||
{
|
||||
QFile file(FILE_NAME);
|
||||
if(!file.exists())
|
||||
{
|
||||
file.open(QIODevice::ReadWrite | QIODevice::Text);
|
||||
file.close();
|
||||
deleteData();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function will return the vale of a given tag name.
|
||||
* NOTE: valid tag names are : "status", "username", "password"
|
||||
* if tag is invalid - will return "" - an empty QString!
|
||||
* @param tag - QString, the tag name
|
||||
* @param file - a QFile pointer
|
||||
* @return QString - the value in tag
|
||||
* NOTE: if NULL value, or an invalid tag name -> return "" (empty QString!)
|
||||
*/
|
||||
QString SaveData::getValViaTag(QString tag, QFile* file)
|
||||
{
|
||||
QString val, line , tmpTag;
|
||||
QTextStream textStream( file);
|
||||
while((line = textStream.readLine()) != NULL)
|
||||
{
|
||||
std::cout << "DEBUG: line => " << line.toStdString() << std::endl;
|
||||
for(int i = 0 ; i< line.length() ;++i)
|
||||
{
|
||||
if(line[i] == '[' && line[i+1] != '/') //get open tag at begining of line and not end of tag ("[/")
|
||||
{
|
||||
i++;
|
||||
tmpTag = line.mid(i, tag.length());
|
||||
if(tmpTag == tag)
|
||||
{
|
||||
i+= tag.length()+1; // i is now right after '['
|
||||
int j = i;
|
||||
while(line[j] != '[')// put j at the end of the value
|
||||
j++;
|
||||
/* Then... the value is :*/
|
||||
val = line.mid(i, j-i);
|
||||
std::cout << "DEBUG: ["<<tag.toStdString()<<"]"<<val.toStdString()<<"[/]"<<std::endl;
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""; //this will be as NULL
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function will provide the user the most basic security of the stored password.
|
||||
* it is NOT an encryption! it will store every char of the password as ascii encoded,
|
||||
* separated by "-" for the deHsh func.
|
||||
* @param pass - a QString to "hash"
|
||||
* @return QString - The "hashed" password
|
||||
*/
|
||||
QString SaveData::hashPassword(QString pass)
|
||||
{
|
||||
QString hash="";
|
||||
int code;
|
||||
for(QChar c : pass)
|
||||
{
|
||||
code = (int)c.toLatin1();
|
||||
hash.append(QString::number(code));
|
||||
hash.append("-");
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function will "dehash" the "hashed" password.
|
||||
* uses standard c string.h strtok with the "-" as the choping points.
|
||||
* builds a QString from the ascii.
|
||||
* @param pass - The hashed password
|
||||
* @return QString - password uncoded
|
||||
*/
|
||||
QString SaveData::deHashPasword(QString pass)
|
||||
{
|
||||
char* cpyPass = strdup(pass.toStdString().c_str());
|
||||
char* tok;
|
||||
char* ch;
|
||||
int val;
|
||||
QString password;
|
||||
tok = strtok(cpyPass,"-");
|
||||
while (tok != NULL)
|
||||
{
|
||||
ch = tok;
|
||||
val = atoi(ch);
|
||||
password.append(val);
|
||||
tok = strtok(NULL, "-");
|
||||
}
|
||||
return password;
|
||||
}
|
|
@ -1,54 +1,54 @@
|
|||
#ifndef SAVEDATA_H
|
||||
#define SAVEDATA_H
|
||||
|
||||
/**
|
||||
* SaveData Class
|
||||
* --------------------------------------
|
||||
*
|
||||
* all functions in this class are static!
|
||||
* no need to create an object!
|
||||
*
|
||||
* provides all the needed functions
|
||||
* for saving user data for JCE login.
|
||||
*
|
||||
* the class will enteract with a file formated by tags for storing the valus.
|
||||
* the file format is as sutch:
|
||||
*
|
||||
* [status]Status Value[/]
|
||||
* [username]usernaem vale[/]
|
||||
* [password]hashed(not really) password vale[/]
|
||||
*
|
||||
* the class will create a file if not exists by calling Save Data::init() function.
|
||||
*
|
||||
* for more info about functions - see implantation
|
||||
*/
|
||||
|
||||
/* QT libs */
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
/* C/C++ libs */
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
|
||||
#define FILE_NAME "JAC_DB.dat"
|
||||
#define DEFAULT_DATA_EMPTY "[status]false[/]\n[username][/]\n[password][/]"
|
||||
|
||||
class SaveData
|
||||
{
|
||||
public:
|
||||
bool static isSaved();
|
||||
bool static save(QString username, QString password);
|
||||
bool static deleteData();
|
||||
QString static getUsername();
|
||||
QString static getPassword();
|
||||
void static init();
|
||||
private:
|
||||
QString static getValViaTag(QString tag, QFile *file);
|
||||
QString static hashPassword(QString pass);
|
||||
QString static deHashPasword(QString pass);
|
||||
};
|
||||
|
||||
#endif // SAVEDATA_H
|
||||
#ifndef SAVEDATA_H
|
||||
#define SAVEDATA_H
|
||||
|
||||
/**
|
||||
* SaveData Class
|
||||
* --------------------------------------
|
||||
*
|
||||
* all functions in this class are static!
|
||||
* no need to create an object!
|
||||
*
|
||||
* provides all the needed functions
|
||||
* for saving user data for JCE login.
|
||||
*
|
||||
* the class will enteract with a file formated by tags for storing the valus.
|
||||
* the file format is as sutch:
|
||||
*
|
||||
* [status]Status Value[/]
|
||||
* [username]usernaem vale[/]
|
||||
* [password]hashed(not really) password vale[/]
|
||||
*
|
||||
* the class will create a file if not exists by calling Save Data::init() function.
|
||||
*
|
||||
* for more info about functions - see implantation
|
||||
*/
|
||||
|
||||
/* QT libs */
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
/* C/C++ libs */
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
|
||||
#define FILE_NAME "JAC_DB.dat"
|
||||
#define DEFAULT_DATA_EMPTY "[status]false[/]\n[username][/]\n[password][/]"
|
||||
|
||||
class SaveData
|
||||
{
|
||||
public:
|
||||
bool static isSaved();
|
||||
bool static save(QString username, QString password);
|
||||
bool static deleteData();
|
||||
QString static getUsername();
|
||||
QString static getPassword();
|
||||
void static init();
|
||||
private:
|
||||
QString static getValViaTag(QString tag, QFile *file);
|
||||
QString static hashPassword(QString pass);
|
||||
QString static deHashPasword(QString pass);
|
||||
};
|
||||
|
||||
#endif // SAVEDATA_H
|
|
@ -1,55 +0,0 @@
|
|||
#include "Course.h"
|
||||
|
||||
Course::Course(int serial, std::string name, std::string type, double points, double hours, double grade, std::string additions)
|
||||
{
|
||||
this->serialNum = serial;
|
||||
this->name = name;
|
||||
this->type = type;
|
||||
this->points = points;
|
||||
this->hours = hours;
|
||||
this->grade = grade;
|
||||
this->additions = additions;
|
||||
}
|
||||
|
||||
Course::~Course()
|
||||
{
|
||||
|
||||
}
|
||||
double Course::getGrade() const
|
||||
{
|
||||
double noGrade = NO_GRADE_YET;
|
||||
if (grade == noGrade)
|
||||
return 0;
|
||||
else
|
||||
return this->grade;
|
||||
}
|
||||
|
||||
void Course::setName(std::string name)
|
||||
{
|
||||
this->name = name;
|
||||
}
|
||||
|
||||
void Course::setType(std::string type)
|
||||
{
|
||||
this->type = type;
|
||||
}
|
||||
|
||||
void Course::setPoints(double points)
|
||||
{
|
||||
this->points=points;
|
||||
}
|
||||
|
||||
void Course::setHours(double hours)
|
||||
{
|
||||
this->hours = hours;
|
||||
}
|
||||
|
||||
void Course::setGrade(double grade)
|
||||
{
|
||||
this->grade = grade;
|
||||
}
|
||||
|
||||
void Course::setAdditions(std::string additions)
|
||||
{
|
||||
this->additions = additions;
|
||||
}
|
|
@ -1,164 +0,0 @@
|
|||
#include "Page.h"
|
||||
|
||||
Page::Page(std::string& html)
|
||||
{
|
||||
makeText(html);
|
||||
}
|
||||
void Page::makeText(std::string& html)
|
||||
{
|
||||
int index = 0;
|
||||
index = findTitle(html, index);
|
||||
index = runToActualText(html, index); //set index into the actual place where the data is
|
||||
manageTableContent(html, index);
|
||||
}
|
||||
|
||||
int Page::findTitle(std::string& from, int index)
|
||||
{
|
||||
std::string temp;
|
||||
while(index < (int)from.length())
|
||||
{
|
||||
if(from[index] == '<')
|
||||
{
|
||||
//title>
|
||||
index++;
|
||||
std::string titleTag = from.substr(index, 5); //legth of title
|
||||
if(titleTag == "title") //check if the tag is title
|
||||
{
|
||||
while(from[index] != '>')
|
||||
index++;
|
||||
index++;
|
||||
while(from[index] != '<')
|
||||
{
|
||||
temp += from[index];
|
||||
index++;
|
||||
}
|
||||
this->title = temp; //sets the title
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Page::runToActualText(std::string& from, int index)
|
||||
{
|
||||
while(index < (int)from.length())
|
||||
{
|
||||
if(from[index] == '<')
|
||||
{
|
||||
index++;
|
||||
if(from[index] == '!')
|
||||
{
|
||||
//!--FileName
|
||||
std::string bodyTag = from.substr(index, 11); //!--FileName
|
||||
|
||||
if(bodyTag == "!--FileName") //check if the tag is body tag
|
||||
{
|
||||
while(from[index] != '>')
|
||||
index++;
|
||||
return index;
|
||||
}
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Page::manageTableContent(std::string& html, int index)
|
||||
{
|
||||
std::string temp;
|
||||
for (int i = index; i < (int)html.length(); i++)
|
||||
{
|
||||
if(html[i] == '<')
|
||||
{
|
||||
//<tr> / <td> / <th>
|
||||
std::string endofTable = "</tbody>";
|
||||
std::string tableTag = html.substr(i, 4); //legth of "tr/td"
|
||||
if(tableTag == "<tr>")
|
||||
{
|
||||
temp += "\n"; //new row -> new line
|
||||
i = stitchText(html, temp, i+4);
|
||||
if(i == -1) //EOF
|
||||
break;
|
||||
}
|
||||
else if(tableTag == "<td>" || tableTag == "<th>")
|
||||
{
|
||||
temp += "\t"; // new cell -> tab between data
|
||||
i = stitchText(html, temp, i+4);
|
||||
if (i == -1) //EOF
|
||||
break;
|
||||
}
|
||||
else if(tableTag == "<td ") // a Year title (in grades table)
|
||||
{
|
||||
temp += "\t";
|
||||
while(html[i] != '>')
|
||||
i++;
|
||||
i = stitchText(html, temp, i+1);
|
||||
}
|
||||
else if (html.substr(i,(endofTable).length()) == endofTable) //is end of table
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this->text = temp;
|
||||
}
|
||||
|
||||
int Page::stitchText(std::string& from, std::string& to, int index)
|
||||
{
|
||||
if (from[index] == '<')
|
||||
{
|
||||
std::string bTag = from.substr(index, 3);
|
||||
if (bTag != "<b>")
|
||||
return index-1; //go back one step - for the main function to inc i
|
||||
index += 3;
|
||||
}
|
||||
|
||||
while (from[index] != '<' && index < (int)from.length())
|
||||
{
|
||||
if (from[index] == '&')
|
||||
{
|
||||
//
|
||||
std::string nbspChr = from.substr(index, 6);
|
||||
if (nbspChr == " ")
|
||||
{
|
||||
index += 5;
|
||||
from.at(index) = ' ';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (endOfString(index,(int) from.length()))
|
||||
return -1; //EOF
|
||||
|
||||
else if (from[index] == '<')
|
||||
return index - 1; //go back one step - for the main function to inc i
|
||||
|
||||
if (from[index] != '\n') //check the actuall data before continue
|
||||
to += from[index];
|
||||
index++;
|
||||
}
|
||||
|
||||
return index-1;
|
||||
}
|
||||
bool Page::endOfString(int index, int length)
|
||||
{
|
||||
if(index < length)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string Page::getString()
|
||||
{
|
||||
return this->text;
|
||||
}
|
||||
|
||||
std::string Page::getTitle()
|
||||
{
|
||||
return this->title;
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
#include "jcedate.h"
|
||||
|
||||
jceDate::jceDate(std::string fromYear,std::string fromSemester,std::string toYear,std::string toSemester)
|
||||
{
|
||||
this->fSemester = fromSemester;
|
||||
this->fYear = fromYear;
|
||||
this->tSemester = toSemester;
|
||||
this->tYear = toYear;
|
||||
}
|
||||
|
||||
void jceDate::setFYear(std::string fromYear)
|
||||
{
|
||||
this->fYear = fromYear;
|
||||
}
|
||||
|
||||
void jceDate::setTYear(std::string toYear)
|
||||
{
|
||||
this->tYear = toYear;
|
||||
}
|
||||
|
||||
void jceDate::setFSemester(std::string fromSemester)
|
||||
{
|
||||
this->fSemester = fromSemester;
|
||||
}
|
||||
|
||||
void jceDate::setTSemester(std::string toSemester)
|
||||
{
|
||||
this->tSemester = toSemester;
|
||||
}
|
||||
|
||||
jceDate::~jceDate()
|
||||
{
|
||||
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
#ifndef JCEDATE_H
|
||||
#define JCEDATE_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class jceDate
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
jceDate(std::string fromYear, std::string fromSemester, std::string toYear, std::string toSemester);
|
||||
~jceDate();
|
||||
|
||||
void setFYear(std::string fromYear);
|
||||
void setTYear(std::string toYear);
|
||||
void setFSemester(std::string fromSemester);
|
||||
void setTSemester(std::string toSemester);
|
||||
|
||||
std::string getFYear() { return this->fYear;}
|
||||
std::string getTYear() { return this->tYear;}
|
||||
std::string getFSemester() { return this->fSemester;}
|
||||
std::string getTSemester() { return this->tSemester;}
|
||||
|
||||
private:
|
||||
std::string fYear; //from
|
||||
std::string fSemester;
|
||||
|
||||
std::string tYear; //to
|
||||
std::string tSemester;
|
||||
|
||||
};
|
||||
|
||||
#endif // JCEDATE_H
|
|
@ -1,132 +1,132 @@
|
|||
#include "jcesslclient.h"
|
||||
|
||||
jceSSLClient::jceSSLClient() : flag(false), packet("")
|
||||
{
|
||||
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()));
|
||||
|
||||
}
|
||||
|
||||
bool jceSSLClient::makeConnect(std::string server, int port)
|
||||
{
|
||||
QEventLoop loop;
|
||||
QObject::connect(this, SIGNAL(encrypted()), &loop, SLOT(quit()));
|
||||
if (isConnected())
|
||||
abort();
|
||||
if (isOpen())
|
||||
abort();
|
||||
|
||||
connectToHostEncrypted(server.c_str(), port);
|
||||
loop.exec();
|
||||
return isConnected();
|
||||
|
||||
}
|
||||
bool jceSSLClient::makeDiconnect()
|
||||
{
|
||||
|
||||
abort();
|
||||
if (state() == QAbstractSocket::SocketState::ConnectedState)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
flag = true;
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
bool jceSSLClient::isConnected()
|
||||
{
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
bool jceSSLClient::sendData(std::string str)
|
||||
{
|
||||
if (isConnected()) //if connected
|
||||
{
|
||||
write(str.c_str(),str.length());
|
||||
while (waitForBytesWritten());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* @brief jceSSLClient::recieveData
|
||||
* @param str this variable will store the recieved data
|
||||
* @param fast true for LOGIN ONLY, false to retrieve all data
|
||||
* @return true if recieved data bigger than zero
|
||||
*/
|
||||
bool jceSSLClient::recieveData(std::string &str, bool fast)
|
||||
{
|
||||
packet = "";
|
||||
bool sflag = false;
|
||||
|
||||
if (fast) //fast connection, good for login only!!
|
||||
{
|
||||
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
|
||||
{
|
||||
QString p;
|
||||
while (waitForReadyRead(milisTimeOut))
|
||||
{
|
||||
do
|
||||
{
|
||||
p = readAll();
|
||||
packet.append(p);
|
||||
}while (p.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
str = packet.toStdString();
|
||||
if (str.size() > 0)
|
||||
sflag = true;
|
||||
|
||||
return sflag;
|
||||
|
||||
}
|
||||
void jceSSLClient::readIt()
|
||||
{
|
||||
QString p;
|
||||
do
|
||||
{
|
||||
p = readAll();
|
||||
packet.append(p);
|
||||
}while (p.size() > 0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
void jceSSLClient::setConnected()
|
||||
{
|
||||
waitForEncrypted();
|
||||
}
|
||||
|
||||
void jceSSLClient::setEncrypted()
|
||||
{
|
||||
setReadBufferSize(10000);
|
||||
setSocketOption(QAbstractSocket::KeepAliveOption,1);
|
||||
flag = true;
|
||||
}
|
||||
|
||||
void jceSSLClient::setDisconnected()
|
||||
{
|
||||
abort();
|
||||
flag = false;
|
||||
}
|
||||
|
||||
|
||||
void jceSSLClient::checkErrors(QAbstractSocket::SocketError)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#include "jcesslclient.h"
|
||||
|
||||
jceSSLClient::jceSSLClient() : flag(false), packet("")
|
||||
{
|
||||
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()));
|
||||
|
||||
}
|
||||
|
||||
bool jceSSLClient::makeConnect(std::string server, int port)
|
||||
{
|
||||
QEventLoop loop;
|
||||
QObject::connect(this, SIGNAL(encrypted()), &loop, SLOT(quit()));
|
||||
if (isConnected())
|
||||
abort();
|
||||
if (isOpen())
|
||||
abort();
|
||||
|
||||
connectToHostEncrypted(server.c_str(), port);
|
||||
loop.exec();
|
||||
return isConnected();
|
||||
|
||||
}
|
||||
bool jceSSLClient::makeDiconnect()
|
||||
{
|
||||
|
||||
abort();
|
||||
if (state() == QAbstractSocket::SocketState::ConnectedState)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
flag = true;
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
bool jceSSLClient::isConnected()
|
||||
{
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
bool jceSSLClient::sendData(std::string str)
|
||||
{
|
||||
if (isConnected()) //if connected
|
||||
{
|
||||
write(str.c_str(),str.length());
|
||||
while (waitForBytesWritten());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* @brief jceSSLClient::recieveData
|
||||
* @param str this variable will store the recieved data
|
||||
* @param fast true for LOGIN ONLY, false to retrieve all data
|
||||
* @return true if recieved data bigger than zero
|
||||
*/
|
||||
bool jceSSLClient::recieveData(std::string &str, bool fast)
|
||||
{
|
||||
packet = "";
|
||||
bool sflag = false;
|
||||
|
||||
if (fast) //fast connection, good for login only!!
|
||||
{
|
||||
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
|
||||
{
|
||||
QString p;
|
||||
while (waitForReadyRead(milisTimeOut))
|
||||
{
|
||||
do
|
||||
{
|
||||
p = readAll();
|
||||
packet.append(p);
|
||||
}while (p.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
str = packet.toStdString();
|
||||
if (str.size() > 0)
|
||||
sflag = true;
|
||||
|
||||
return sflag;
|
||||
|
||||
}
|
||||
void jceSSLClient::readIt()
|
||||
{
|
||||
QString p;
|
||||
do
|
||||
{
|
||||
p = readAll();
|
||||
packet.append(p);
|
||||
}while (p.size() > 0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
void jceSSLClient::setConnected()
|
||||
{
|
||||
waitForEncrypted();
|
||||
}
|
||||
|
||||
void jceSSLClient::setEncrypted()
|
||||
{
|
||||
setReadBufferSize(10000);
|
||||
setSocketOption(QAbstractSocket::KeepAliveOption,1);
|
||||
flag = true;
|
||||
}
|
||||
|
||||
void jceSSLClient::setDisconnected()
|
||||
{
|
||||
abort();
|
||||
flag = false;
|
||||
}
|
||||
|
||||
|
||||
void jceSSLClient::checkErrors(QAbstractSocket::SocketError)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -1,39 +1,39 @@
|
|||
#ifndef JCESSLCLIENT_H
|
||||
#define JCESSLCLIENT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSslSocket>
|
||||
#include <QThread>
|
||||
#include <QEventLoop>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#define milisTimeOut 3500
|
||||
|
||||
class jceSSLClient : QSslSocket
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
jceSSLClient();
|
||||
|
||||
bool makeConnect(std::string server,int port);
|
||||
bool isConnected();
|
||||
bool sendData(std::string str);
|
||||
bool recieveData(std::string &str, bool fast);
|
||||
bool makeDiconnect();
|
||||
|
||||
private slots:
|
||||
void checkErrors(QAbstractSocket::SocketError);
|
||||
void setConnected();
|
||||
void setEncrypted();
|
||||
void setDisconnected();
|
||||
void readIt();
|
||||
|
||||
private:
|
||||
|
||||
bool flag;
|
||||
QString packet;
|
||||
|
||||
};
|
||||
|
||||
#endif // JCESSLCLIENT_H
|
||||
#ifndef JCESSLCLIENT_H
|
||||
#define JCESSLCLIENT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSslSocket>
|
||||
#include <QThread>
|
||||
#include <QEventLoop>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#define milisTimeOut 3500
|
||||
|
||||
class jceSSLClient : QSslSocket
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
jceSSLClient();
|
||||
|
||||
bool makeConnect(std::string server,int port);
|
||||
bool isConnected();
|
||||
bool sendData(std::string str);
|
||||
bool recieveData(std::string &str, bool fast);
|
||||
bool makeDiconnect();
|
||||
|
||||
private slots:
|
||||
void checkErrors(QAbstractSocket::SocketError);
|
||||
void setConnected();
|
||||
void setEncrypted();
|
||||
void setDisconnected();
|
||||
void readIt();
|
||||
|
||||
private:
|
||||
|
||||
bool flag;
|
||||
QString packet;
|
||||
|
||||
};
|
||||
|
||||
#endif // JCESSLCLIENT_H
|
142
src/jceData/Calendar/calendarCourse.cpp
Normal file
142
src/jceData/Calendar/calendarCourse.cpp
Normal file
|
@ -0,0 +1,142 @@
|
|||
#include "calendarCourse.h"
|
||||
|
||||
calendarCourse::calendarCourse(int serial, std::string name, std::string type, std::string lecturer, double points,
|
||||
double semesterHours, std::string dayAndHour,
|
||||
std::string room) : Course(serial,name, type,points)
|
||||
{
|
||||
this->lecturer = lecturer;
|
||||
this->semesterHours = semesterHours;
|
||||
this->room = room;
|
||||
setDayAndHour(dayAndHour);
|
||||
|
||||
}
|
||||
void calendarCourse::setDayAndHour(std::string phrase)
|
||||
{
|
||||
int ctr = 0;
|
||||
std::string temp = "";
|
||||
QTime timetemp;
|
||||
char *tok;
|
||||
char* textToTok = strdup(phrase.c_str());
|
||||
tok = strtok(textToTok, " -");
|
||||
while(tok != NULL)
|
||||
{
|
||||
temp = tok;
|
||||
switch (ctr)
|
||||
{
|
||||
case 0:
|
||||
setDay(temp);
|
||||
break;
|
||||
case 1:
|
||||
timetemp = QTime::fromString(QString::fromStdString(temp),"hh:mm");
|
||||
setHourBegin(timetemp.hour());
|
||||
setMinutesBegin(timetemp.minute());
|
||||
break;
|
||||
case 2:
|
||||
timetemp = QTime::fromString(QString::fromStdString(temp),"hh:mm");
|
||||
setHourEnd(timetemp.hour());
|
||||
setMinutesEnd(timetemp.minute());
|
||||
break;
|
||||
}
|
||||
|
||||
ctr++;
|
||||
tok = strtok(NULL, " -");
|
||||
}
|
||||
}
|
||||
|
||||
std::string calendarCourse::getLecturer() const
|
||||
{
|
||||
return lecturer;
|
||||
}
|
||||
|
||||
void calendarCourse::setLecturer(const std::string &value)
|
||||
{
|
||||
lecturer = value;
|
||||
}
|
||||
double calendarCourse::getSemesterHours() const
|
||||
{
|
||||
return semesterHours;
|
||||
}
|
||||
|
||||
void calendarCourse::setSemesterHours(double value)
|
||||
{
|
||||
semesterHours = value;
|
||||
}
|
||||
int calendarCourse::getHourBegin() const
|
||||
{
|
||||
return hourBegin;
|
||||
}
|
||||
|
||||
void calendarCourse::setHourBegin(int value)
|
||||
{
|
||||
hourBegin = value;
|
||||
}
|
||||
int calendarCourse::getMinutesBegin() const
|
||||
{
|
||||
return minutesBegin;
|
||||
}
|
||||
|
||||
void calendarCourse::setMinutesBegin(int value)
|
||||
{
|
||||
minutesBegin = value;
|
||||
}
|
||||
int calendarCourse::getHourEnd() const
|
||||
{
|
||||
return hourEnd;
|
||||
}
|
||||
|
||||
void calendarCourse::setHourEnd(int value)
|
||||
{
|
||||
hourEnd = value;
|
||||
}
|
||||
int calendarCourse::getMinutesEnd() const
|
||||
{
|
||||
return minutesEnd;
|
||||
}
|
||||
|
||||
void calendarCourse::setMinutesEnd(int value)
|
||||
{
|
||||
minutesEnd = value;
|
||||
}
|
||||
|
||||
std::string calendarCourse::courseToString()
|
||||
{
|
||||
std::string courseText = "";
|
||||
courseText += " " + std::to_string(this->getSerialNum());
|
||||
courseText += " " + this->getName();
|
||||
courseText += " " + this->getType();
|
||||
courseText += " " + this->lecturer;
|
||||
courseText += " " + std::to_string(this->getPoints());
|
||||
courseText += " " + std::to_string(this->semesterHours);
|
||||
courseText += " " + this->day;
|
||||
courseText += " " + std::to_string(this->hourBegin) + ":" + std::to_string(this->minutesBegin) + "-" + std::to_string(this->hourEnd) + ":" + std::to_string(this->minutesEnd);
|
||||
courseText += " " + this->room;
|
||||
courseText += "\n";
|
||||
return courseText;
|
||||
|
||||
}
|
||||
std::string calendarCourse::getDay() const
|
||||
{
|
||||
return day;
|
||||
}
|
||||
|
||||
void calendarCourse::setDay(const std::string &value)
|
||||
{
|
||||
day = value;
|
||||
}
|
||||
|
||||
std::string calendarCourse::getRoom() const
|
||||
{
|
||||
return room;
|
||||
}
|
||||
|
||||
void calendarCourse::setRoom(const std::string &value)
|
||||
{
|
||||
room = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
69
src/jceData/Calendar/calendarCourse.h
Normal file
69
src/jceData/Calendar/calendarCourse.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
#ifndef CALENDARCOURSE_H
|
||||
#define CALENDARCOURSE_H
|
||||
|
||||
#include "../course.h"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
#include <QTime>
|
||||
|
||||
#define CALENDAR_COURSE_FIELDS 8
|
||||
|
||||
class calendarCourse : public Course
|
||||
{
|
||||
public:
|
||||
enum CourseScheme
|
||||
{
|
||||
SERIAL,
|
||||
NAME,
|
||||
TYPE,
|
||||
LECTURER,
|
||||
POINTS,
|
||||
SEM_HOURS,
|
||||
DAY_AND_HOURS,
|
||||
ROOM
|
||||
};
|
||||
|
||||
calendarCourse(int serial, std::string name, std::string type, std::string lecturer,
|
||||
double points, double semesterHours, std::string dayAndHour, std::string room);
|
||||
~calendarCourse(){}
|
||||
|
||||
std::string getDay() const;
|
||||
std::string getLecturer() const;
|
||||
std::string getRoom() const;
|
||||
double getSemesterHours() const;
|
||||
int getHourBegin() const;
|
||||
int getMinutesBegin() const;
|
||||
int getHourEnd() const;
|
||||
int getMinutesEnd() const;
|
||||
|
||||
void setDay(const std::string &value);
|
||||
void setLecturer(const std::string &value);
|
||||
void setRoom(const std::string &value);
|
||||
void setSemesterHours(double value);
|
||||
void setHourBegin(int value);
|
||||
void setMinutesBegin(int value);
|
||||
void setHourEnd(int value);
|
||||
void setMinutesEnd(int value);
|
||||
|
||||
std::string courseToString();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void setDayAndHour(std::string phrase);
|
||||
|
||||
std::string lecturer;
|
||||
double semesterHours;
|
||||
std::string day;
|
||||
int hourBegin;
|
||||
int minutesBegin;
|
||||
int hourEnd;
|
||||
int minutesEnd;
|
||||
std::string room;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // CALENDARCOURSE_H
|
111
src/jceData/Calendar/calendarPage.cpp
Normal file
111
src/jceData/Calendar/calendarPage.cpp
Normal file
|
@ -0,0 +1,111 @@
|
|||
#include "calendarPage.h"
|
||||
|
||||
CalendarPage::CalendarPage(std::string html)
|
||||
{
|
||||
courses = new std::list<calendarCourse*>();
|
||||
tempHtml = getString(html);
|
||||
tempHtml = tokenToLines(tempHtml);
|
||||
std::cout << "last one..." << std::endl;
|
||||
calendarListInit(tempHtml);
|
||||
}
|
||||
|
||||
std::string CalendarPage::htmlToString()
|
||||
{
|
||||
return tempHtml;
|
||||
}
|
||||
|
||||
std::string CalendarPage::tokenToLines(std::string &textToPhrase)
|
||||
{
|
||||
int ctr = 0;
|
||||
std::string temp = "";
|
||||
char *tok;
|
||||
char* textToTok = strdup(textToPhrase.c_str());
|
||||
tok = strtok(textToTok, "\n");
|
||||
while(tok != NULL)
|
||||
{
|
||||
//amount of data before the actual needed data and no empty lines
|
||||
if (strcmp(tok," \t ") != 0)
|
||||
{
|
||||
temp += tok;
|
||||
temp += "\n";
|
||||
}
|
||||
ctr++;
|
||||
tok = strtok(NULL, "\n");
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
void CalendarPage::calendarListInit(std::string &linesTokinzedString)
|
||||
{
|
||||
std::list<std::string> stringHolder;
|
||||
std::string temp;
|
||||
calendarCourse * cTemp = NULL;
|
||||
char* tok;
|
||||
char* textToTok = strdup(linesTokinzedString.c_str());
|
||||
tok = strtok(textToTok,"\n");
|
||||
while (tok != NULL)
|
||||
{
|
||||
temp = tok;
|
||||
stringHolder.push_back(temp);
|
||||
tok = strtok(NULL, "\n");
|
||||
}
|
||||
for(std::string temp: stringHolder)
|
||||
{
|
||||
cTemp = lineToCourse(temp);
|
||||
if (cTemp != NULL)
|
||||
courses->push_back(cTemp);
|
||||
}
|
||||
}
|
||||
|
||||
calendarCourse *CalendarPage::lineToCourse(std::string line)
|
||||
{
|
||||
|
||||
calendarCourse *tempC = NULL;
|
||||
std::string templinearray[CALENDAR_COURSE_FIELDS];//[serial,name,type,lecturer,points,semesterhours,dayandhours,room]
|
||||
int serial;
|
||||
double points,semesterHours;
|
||||
std::string name,type, lecturer,dayAndHour,room;
|
||||
std::string tempS = "";
|
||||
std::string emptyTab = " ";
|
||||
int i = 0;
|
||||
char* tok;
|
||||
char* cLine = strdup(line.c_str());
|
||||
tok = strtok(cLine, "\t");
|
||||
while(tok != NULL)
|
||||
{
|
||||
|
||||
tempS = tok;
|
||||
if (i>=1)
|
||||
templinearray[i-1] = tempS;
|
||||
i++;
|
||||
if (i > 8)
|
||||
break;
|
||||
tok=strtok(NULL, "\t");
|
||||
}
|
||||
if (templinearray[0] == "") //empty phrasing
|
||||
return NULL;
|
||||
for (int p = 0; p < 8; ++p)
|
||||
{
|
||||
std::cout << "index : " << p << " is: " << templinearray[p] << std::endl;
|
||||
}
|
||||
serial = stoi(templinearray[calendarCourse::CourseScheme::SERIAL]);
|
||||
name = templinearray[calendarCourse::CourseScheme::NAME];
|
||||
type = templinearray[calendarCourse::CourseScheme::TYPE];
|
||||
lecturer = templinearray[calendarCourse::CourseScheme::LECTURER];
|
||||
|
||||
if (templinearray[calendarCourse::CourseScheme::POINTS].compare(" ") == 0)
|
||||
points = stod(templinearray[calendarCourse::CourseScheme::POINTS]);
|
||||
else
|
||||
points = 0;
|
||||
if (templinearray[calendarCourse::CourseScheme::SEM_HOURS].compare(" ") == 0)
|
||||
semesterHours = stod(templinearray[calendarCourse::CourseScheme::SEM_HOURS]);
|
||||
else
|
||||
semesterHours = 0;
|
||||
dayAndHour = templinearray[calendarCourse::CourseScheme::DAY_AND_HOURS];
|
||||
room = templinearray[calendarCourse::CourseScheme::ROOM];
|
||||
|
||||
|
||||
tempC = new calendarCourse(serial,name,type,lecturer,points,semesterHours,dayAndHour,room);
|
||||
|
||||
return tempC;
|
||||
}
|
26
src/jceData/Calendar/calendarPage.h
Normal file
26
src/jceData/Calendar/calendarPage.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef CALENDARPAGE_H
|
||||
#define CALENDARPAGE_H
|
||||
|
||||
#include "../page.h"
|
||||
#include "calendarCourse.h"
|
||||
#include <list>
|
||||
#include <string.h> //strlen and strtok to phrase the html file
|
||||
#include <ctype.h> //checks if character is numeric
|
||||
|
||||
class CalendarPage : public Page
|
||||
{
|
||||
public:
|
||||
CalendarPage(std::string html);
|
||||
std::string htmlToString();
|
||||
std::list<calendarCourse*>* getCourses() { return courses; }
|
||||
|
||||
private:
|
||||
std::string tokenToLines(std::string& textToPhrase);
|
||||
void calendarListInit(std::string& linesTokinzedString);
|
||||
calendarCourse* lineToCourse(std::string line);
|
||||
|
||||
std::string tempHtml;
|
||||
std::list<calendarCourse*>* courses;
|
||||
};
|
||||
|
||||
#endif // CALENDARPAGE_H
|
36
src/jceData/Grades/gradeCourse.cpp
Normal file
36
src/jceData/Grades/gradeCourse.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "gradeCourse.h"
|
||||
|
||||
gradeCourse::gradeCourse(int serial,std::string name, std::string type, double points, double hours, double grade, std::string additions) : Course(serial,name,type,points)
|
||||
{
|
||||
this->hours = hours;
|
||||
this->grade = grade;
|
||||
this->additions = additions;
|
||||
}
|
||||
|
||||
gradeCourse::~gradeCourse()
|
||||
{
|
||||
|
||||
}
|
||||
double gradeCourse::getGrade() const
|
||||
{
|
||||
double noGrade = NO_GRADE_YET;
|
||||
if (grade == noGrade)
|
||||
return 0;
|
||||
else
|
||||
return this->grade;
|
||||
}
|
||||
|
||||
void gradeCourse::setHours(double hours)
|
||||
{
|
||||
this->hours = hours;
|
||||
}
|
||||
|
||||
void gradeCourse::setGrade(double grade)
|
||||
{
|
||||
this->grade = grade;
|
||||
}
|
||||
|
||||
void gradeCourse::setAdditions(std::string additions)
|
||||
{
|
||||
this->additions = additions;
|
||||
}
|
|
@ -1,64 +1,53 @@
|
|||
#ifndef COURSE_H
|
||||
#define COURSE_H
|
||||
|
||||
/* This Code Made By Sagi Dayan
|
||||
* SagiDayan@gmail.com
|
||||
*
|
||||
* Minor changes has been made by Liran Ben Gida
|
||||
* LiranBG@gmail.com
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
#define COURSE_FIELDS 7
|
||||
#define NO_GRADE_YET 101;
|
||||
|
||||
|
||||
class Course{
|
||||
|
||||
public:
|
||||
enum CourseScheme
|
||||
{
|
||||
SERIAL,
|
||||
NAME,
|
||||
TYPE,
|
||||
POINTS,
|
||||
HOURS,
|
||||
GRADE,
|
||||
ADDITION
|
||||
};
|
||||
|
||||
Course(int serial,std::string name, std::string type, double points, double hours, double grade, std::string additions);
|
||||
~Course();
|
||||
|
||||
int getSerialNum() const {return this->serialNum;}
|
||||
std::string getName() const {return this->name;}
|
||||
std::string getType() const {return this->type;}
|
||||
double getPoints() const {return this->points;}
|
||||
double getHours() const {return this->hours;}
|
||||
double getGrade() const ;
|
||||
std::string getAddidtions() const {return this->additions;}
|
||||
|
||||
void setName(std::string name);
|
||||
void setType(std::string type);
|
||||
void setPoints(double points);
|
||||
void setHours(double hours);
|
||||
void setGrade(double grade);
|
||||
void setAdditions(std::string additions);
|
||||
|
||||
private:
|
||||
|
||||
int serialNum;
|
||||
std::string name;
|
||||
std::string type;
|
||||
double points;
|
||||
double hours;
|
||||
double grade;
|
||||
std::string additions;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#ifndef GRADE_COURSE_H
|
||||
#define GRADE_COURSE_H
|
||||
|
||||
/* This Code Made By Sagi Dayan
|
||||
* SagiDayan@gmail.com
|
||||
*
|
||||
* Minor changes has been made by Liran Ben Gida
|
||||
* LiranBG@gmail.com
|
||||
*/
|
||||
#include "../course.h"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
#define COURSE_FIELDS 7
|
||||
#define NO_GRADE_YET 101;
|
||||
|
||||
|
||||
class gradeCourse : public Course {
|
||||
|
||||
public:
|
||||
enum CourseScheme
|
||||
{
|
||||
SERIAL,
|
||||
NAME,
|
||||
TYPE,
|
||||
POINTS,
|
||||
HOURS,
|
||||
GRADE,
|
||||
ADDITION
|
||||
};
|
||||
|
||||
gradeCourse(int serial, std::string name, std::string type, double points,double hours, double grade, std::string additions);
|
||||
~gradeCourse();
|
||||
|
||||
double getHours() const {return this->hours;}
|
||||
double getGrade() const ;
|
||||
std::string getAddidtions() const {return this->additions;}
|
||||
|
||||
void setHours(double hours);
|
||||
void setGrade(double grade);
|
||||
void setAdditions(std::string additions);
|
||||
|
||||
private:
|
||||
|
||||
double hours;
|
||||
double grade;
|
||||
std::string additions;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -1,178 +1,172 @@
|
|||
#include "GradePage.h"
|
||||
|
||||
GradePage::GradePage(std::string html) : Page(html)
|
||||
{
|
||||
courses = new std::list<Course*>();
|
||||
tempHtml = getString();
|
||||
genList();
|
||||
|
||||
}
|
||||
GradePage::~GradePage()
|
||||
{
|
||||
for(Course* c : *courses)
|
||||
delete c;
|
||||
delete courses;
|
||||
}
|
||||
void GradePage::genList()
|
||||
{
|
||||
|
||||
this->tempHtml = tokenToLines( this->tempHtml , INFO_DATA_LINES_BEFORE_GRADES_DATA );
|
||||
|
||||
coursesListInit(this->tempHtml);
|
||||
|
||||
}
|
||||
void GradePage::addCourse(Course *a)
|
||||
{
|
||||
GradePage::courses->push_back(a);
|
||||
return;
|
||||
}
|
||||
|
||||
void GradePage::removeCourse(std::string courseSerialID)
|
||||
{
|
||||
for(Course* c : *courses)
|
||||
{
|
||||
if (c->getSerialNum() == stoi(courseSerialID))
|
||||
{
|
||||
courses->remove(c);
|
||||
delete c;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void GradePage::coursesListInit(std::string& linesTokinzedString)
|
||||
{
|
||||
std::list<std::string> stringHolder;
|
||||
std::string temp;
|
||||
Course* cTemp = NULL;
|
||||
char* tok;
|
||||
char* textToTok = strdup(linesTokinzedString.c_str());
|
||||
tok = strtok(textToTok,"\n");
|
||||
while (tok != NULL)
|
||||
{
|
||||
temp = tok;
|
||||
stringHolder.push_back(temp);
|
||||
tok = strtok(NULL, "\n");
|
||||
}
|
||||
for(std::string temp: stringHolder)
|
||||
{
|
||||
cTemp = lineToCourse(temp);
|
||||
if (cTemp != NULL)
|
||||
addCourse(cTemp);
|
||||
}
|
||||
}
|
||||
|
||||
std::string GradePage::tokenToLines(std::string& textToPhrase,int fromLine)
|
||||
{
|
||||
int ctr = 0;
|
||||
std::string temp = "";
|
||||
char *tok;
|
||||
char* textToTok = strdup(textToPhrase.c_str());
|
||||
tok = strtok(textToTok, "\n");
|
||||
while(tok != NULL)
|
||||
{
|
||||
//amount of data before the actual needed data and no empty lines
|
||||
if ((ctr >= fromLine) && (strcmp(tok," \t ") != 0))
|
||||
{
|
||||
temp += tok;
|
||||
temp += "\n";
|
||||
}
|
||||
ctr++;
|
||||
tok = strtok(NULL, "\n");
|
||||
}
|
||||
return temp;
|
||||
|
||||
}
|
||||
Course* GradePage::lineToCourse(std::string line)
|
||||
{
|
||||
Course *tempC = NULL;
|
||||
std::string templinearray[COURSE_FIELDS];//[serial,name,type,points,hours,grade,additions]
|
||||
int serial;
|
||||
double points,hours,grade;
|
||||
std::string name,type, additions;
|
||||
std::string tempS = "";
|
||||
int i = 0;
|
||||
char* tok;
|
||||
char* cLine = strdup(line.c_str());
|
||||
tok = strtok(cLine, "\t");
|
||||
while(tok != NULL)
|
||||
{
|
||||
|
||||
tempS = tok;
|
||||
if (i == 1) //skip the tokenizing loop just once
|
||||
{
|
||||
tempS = "";
|
||||
char *tokTemp;
|
||||
tokTemp = tok;
|
||||
|
||||
while (!(isdigit((int)*tokTemp)))
|
||||
tokTemp++;
|
||||
|
||||
while (isdigit((int)*tokTemp))
|
||||
{
|
||||
tempS += *tokTemp;
|
||||
tokTemp++;
|
||||
}
|
||||
templinearray[i-1] = tempS;
|
||||
templinearray[i] = tokTemp;
|
||||
|
||||
}
|
||||
else if (i > 1)
|
||||
templinearray[i] = tempS;
|
||||
i++;
|
||||
tok=strtok(NULL, "\t");
|
||||
}
|
||||
if (templinearray[0] == "") //empty phrasing
|
||||
return NULL;
|
||||
|
||||
serial = stoi(templinearray[Course::CourseScheme::SERIAL]);
|
||||
|
||||
name = templinearray[Course::CourseScheme::NAME];
|
||||
type = templinearray[Course::CourseScheme::TYPE];
|
||||
|
||||
points = stod(templinearray[Course::CourseScheme::POINTS]);
|
||||
hours = stod(templinearray[Course::CourseScheme::HOURS]);
|
||||
|
||||
if (isGradedYet(templinearray[Course::CourseScheme::GRADE]))
|
||||
grade = stod(templinearray[Course::CourseScheme::GRADE]);
|
||||
else
|
||||
grade = NO_GRADE_YET;
|
||||
|
||||
additions = templinearray[Course::CourseScheme::ADDITION];
|
||||
|
||||
tempC = new Course(serial,name,type,points,hours,grade,additions);
|
||||
return tempC;
|
||||
}
|
||||
|
||||
//checking if one of the chars inside grade is not a number
|
||||
bool GradePage::isGradedYet(std::string grade)
|
||||
{
|
||||
if (strlen(grade.c_str()) <= 1)
|
||||
return false;
|
||||
|
||||
for (char c: grade)
|
||||
{
|
||||
if (c == '\0')
|
||||
break;
|
||||
if (((!isdigit((int)c)) && (!isspace((int)c)))) //48 = 0, 57 = 9
|
||||
return false;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
double GradePage::getAvg()
|
||||
{
|
||||
double avg = 0;
|
||||
double points = 0;
|
||||
for(Course* c : *courses)
|
||||
{
|
||||
if ((c->getGrade() != 0))
|
||||
{
|
||||
avg += c->getGrade() * c->getPoints();
|
||||
points += c->getPoints();
|
||||
}
|
||||
}
|
||||
|
||||
avg /= points;
|
||||
return avg;
|
||||
}
|
||||
#include "gradePage.h"
|
||||
|
||||
GradePage::GradePage(std::string html) : Page()
|
||||
{
|
||||
this->courses = new std::list<gradeCourse*>();
|
||||
this->tempHtml = getString(html);
|
||||
this->tempHtml = tokenToLines(this->tempHtml);
|
||||
coursesListInit(this->tempHtml);
|
||||
|
||||
}
|
||||
GradePage::~GradePage()
|
||||
{
|
||||
for(Course* c : *courses)
|
||||
delete c;
|
||||
delete courses;
|
||||
}
|
||||
|
||||
void GradePage::addCourse(gradeCourse *a)
|
||||
{
|
||||
GradePage::courses->push_back(a);
|
||||
return;
|
||||
}
|
||||
|
||||
void GradePage::removeCourse(std::string courseSerialID)
|
||||
{
|
||||
for(gradeCourse* c : *courses)
|
||||
{
|
||||
if (c->getSerialNum() == stoi(courseSerialID))
|
||||
{
|
||||
courses->remove(c);
|
||||
delete c;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void GradePage::coursesListInit(std::string& linesTokinzedString)
|
||||
{
|
||||
std::list<std::string> stringHolder;
|
||||
std::string temp;
|
||||
gradeCourse* cTemp = NULL;
|
||||
char* tok;
|
||||
char* textToTok = strdup(linesTokinzedString.c_str());
|
||||
tok = strtok(textToTok,"\n");
|
||||
while (tok != NULL)
|
||||
{
|
||||
temp = tok;
|
||||
stringHolder.push_back(temp);
|
||||
tok = strtok(NULL, "\n");
|
||||
}
|
||||
for(std::string temp: stringHolder)
|
||||
{
|
||||
cTemp = lineToCourse(temp);
|
||||
if (cTemp != NULL)
|
||||
addCourse(cTemp);
|
||||
}
|
||||
}
|
||||
|
||||
std::string GradePage::tokenToLines(std::string& textToPhrase)
|
||||
{
|
||||
int ctr = 0;
|
||||
std::string temp = "";
|
||||
char *tok;
|
||||
char* textToTok = strdup(textToPhrase.c_str());
|
||||
tok = strtok(textToTok, "\n");
|
||||
while(tok != NULL)
|
||||
{
|
||||
//amount of data before the actual needed data and no empty lines
|
||||
if (strcmp(tok," \t ") != 0)
|
||||
{
|
||||
temp += tok;
|
||||
temp += "\n";
|
||||
}
|
||||
ctr++;
|
||||
tok = strtok(NULL, "\n");
|
||||
}
|
||||
return temp;
|
||||
|
||||
}
|
||||
gradeCourse* GradePage::lineToCourse(std::string line)
|
||||
{
|
||||
gradeCourse *tempC = NULL;
|
||||
std::string templinearray[COURSE_FIELDS];//[serial,name,type,points,hours,grade,additions]
|
||||
int serial;
|
||||
double points,hours,grade;
|
||||
std::string name,type, additions;
|
||||
std::string tempS = "";
|
||||
int i = 0;
|
||||
char* tok;
|
||||
char* cLine = strdup(line.c_str());
|
||||
tok = strtok(cLine, "\t");
|
||||
while(tok != NULL)
|
||||
{
|
||||
|
||||
tempS = tok;
|
||||
if (i == 1) //skip the tokenizing loop just once
|
||||
{
|
||||
tempS = "";
|
||||
char *tokTemp;
|
||||
tokTemp = tok;
|
||||
|
||||
while (!(isdigit((int)*tokTemp)))
|
||||
tokTemp++;
|
||||
|
||||
while (isdigit((int)*tokTemp))
|
||||
{
|
||||
tempS += *tokTemp;
|
||||
tokTemp++;
|
||||
}
|
||||
templinearray[i-1] = tempS;
|
||||
templinearray[i] = tokTemp;
|
||||
|
||||
}
|
||||
else if (i > 1)
|
||||
templinearray[i] = tempS;
|
||||
i++;
|
||||
tok=strtok(NULL, "\t");
|
||||
}
|
||||
if (templinearray[0] == "") //empty phrasing
|
||||
return NULL;
|
||||
|
||||
serial = stoi(templinearray[gradeCourse::CourseScheme::SERIAL]);
|
||||
|
||||
name = templinearray[gradeCourse::CourseScheme::NAME];
|
||||
type = templinearray[gradeCourse::CourseScheme::TYPE];
|
||||
|
||||
points = stod(templinearray[gradeCourse::CourseScheme::POINTS]);
|
||||
hours = stod(templinearray[gradeCourse::CourseScheme::HOURS]);
|
||||
|
||||
if (isGradedYet(templinearray[gradeCourse::CourseScheme::GRADE]))
|
||||
grade = stod(templinearray[gradeCourse::CourseScheme::GRADE]);
|
||||
else
|
||||
grade = NO_GRADE_YET;
|
||||
|
||||
additions = templinearray[gradeCourse::CourseScheme::ADDITION];
|
||||
|
||||
tempC = new gradeCourse(serial,name,type,points,hours,grade,additions);
|
||||
return tempC;
|
||||
}
|
||||
|
||||
//checking if one of the chars inside grade is not a number
|
||||
bool GradePage::isGradedYet(std::string grade)
|
||||
{
|
||||
if (strlen(grade.c_str()) <= 1)
|
||||
return false;
|
||||
|
||||
for (char c: grade)
|
||||
{
|
||||
if (c == '\0')
|
||||
break;
|
||||
if (((!isdigit((int)c)) && (!isspace((int)c)))) //48 = 0, 57 = 9
|
||||
return false;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
double GradePage::getAvg()
|
||||
{
|
||||
double avg = 0;
|
||||
double points = 0;
|
||||
for(gradeCourse* c : *courses)
|
||||
{
|
||||
if ((c->getGrade() != 0))
|
||||
{
|
||||
avg += c->getGrade() * c->getPoints();
|
||||
points += c->getPoints();
|
||||
}
|
||||
}
|
||||
|
||||
avg /= points;
|
||||
return avg;
|
||||
}
|
|
@ -1,48 +1,45 @@
|
|||
#ifndef GRADE_PAGE_H
|
||||
#define GRADE_PAGE_H
|
||||
|
||||
/* This Code Made By Sagi Dayan
|
||||
* SagiDayan@gmail.com
|
||||
*
|
||||
* Minor changes has been made by Liran Ben Gida
|
||||
* LiranBG@gmail.com
|
||||
*/
|
||||
|
||||
#include "Page.h"
|
||||
#include "Course.h"
|
||||
|
||||
#include <list>
|
||||
#include <string.h> //strlen and strtok to phrase the html file
|
||||
#include <ctype.h> //checks if character is numeric
|
||||
|
||||
#define INFO_DATA_LINES_BEFORE_GRADES_DATA 5
|
||||
|
||||
class GradePage : public Page
|
||||
{
|
||||
|
||||
public:
|
||||
GradePage(std::string html);
|
||||
~GradePage();
|
||||
|
||||
void addCourse(Course *);
|
||||
void removeCourse(std::string courseSerialID);
|
||||
double getAvg();
|
||||
|
||||
std::list<Course*>* getCourses() { return courses; }
|
||||
|
||||
private:
|
||||
|
||||
void genList();
|
||||
std::string tokenToLines(std::string& textToPhrase,int fromLine = 0);
|
||||
void coursesListInit(std::string& linesTokinzedString);
|
||||
Course* lineToCourse(std::string line);
|
||||
|
||||
bool isGradedYet(std::string grade);
|
||||
|
||||
std::list<Course*>* courses;
|
||||
std::string tempHtml;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#ifndef GRADE_PAGE_H
|
||||
#define GRADE_PAGE_H
|
||||
|
||||
/* This Code Made By Sagi Dayan
|
||||
* SagiDayan@gmail.com
|
||||
*
|
||||
* Minor changes has been made by Liran Ben Gida
|
||||
* LiranBG@gmail.com
|
||||
*/
|
||||
|
||||
#include "../page.h"
|
||||
#include "../Grades/gradeCourse.h"
|
||||
|
||||
#include <list>
|
||||
#include <string.h> //strlen and strtok to phrase the html file
|
||||
#include <ctype.h> //checks if character is numeric
|
||||
|
||||
class GradePage : public Page
|
||||
{
|
||||
|
||||
public:
|
||||
GradePage(std::string html);
|
||||
~GradePage();
|
||||
|
||||
void addCourse(gradeCourse *);
|
||||
void removeCourse(std::string courseSerialID);
|
||||
double getAvg();
|
||||
|
||||
std::list<gradeCourse*>* getCourses() { return courses; }
|
||||
|
||||
private:
|
||||
|
||||
std::string tokenToLines(std::string& textToPhrase);
|
||||
void coursesListInit(std::string& linesTokinzedString);
|
||||
gradeCourse* lineToCourse(std::string line);
|
||||
|
||||
bool isGradedYet(std::string grade);
|
||||
|
||||
std::list<gradeCourse*>* courses;
|
||||
std::string tempHtml;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -1,42 +1,39 @@
|
|||
#ifndef PAGE_H
|
||||
#define PAGE_H
|
||||
|
||||
/* This Code Made By Sagi Dayan
|
||||
* SagiDayan@gmail.com
|
||||
*
|
||||
* Minor changes has been made by Liran Ben Gida
|
||||
* LiranBG@gmail.com
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
class Page
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
~Page() {}
|
||||
|
||||
protected:
|
||||
Page(std::string& html);
|
||||
std::string getString();
|
||||
std::string getTitle();
|
||||
void makeText(std::string& html);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
int findTitle(std::string& from, int index);
|
||||
int runToActualText(std::string& from, int index);
|
||||
void manageTableContent(std::string& html, int index);
|
||||
int stitchText(std::string& from, std::string& to, int index);
|
||||
bool endOfString(int index, int length);
|
||||
|
||||
std::string text;
|
||||
std::string title;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef PAGE_H
|
||||
#define PAGE_H
|
||||
|
||||
/* This Code Made By Sagi Dayan
|
||||
* SagiDayan@gmail.com
|
||||
*
|
||||
* Minor changes has been made by Liran Ben Gida
|
||||
* LiranBG@gmail.com
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
class Page
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
~Page() {}
|
||||
|
||||
protected:
|
||||
Page();
|
||||
std::string getString(std::string& htmlToPhrased);
|
||||
void makeText(std::string& html);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
int runToActualText(std::string& from, int index);
|
||||
void manageTableContent(std::string& html, int index);
|
||||
int stitchText(std::string& from, std::string& to, int index);
|
||||
bool endOfString(int index, int length);
|
||||
|
||||
std::string text;
|
||||
std::string title;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
49
src/jceData/course.h
Normal file
49
src/jceData/course.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
#ifndef COURSE_H
|
||||
#define COURSE_H
|
||||
|
||||
/* This Code Made By Sagi Dayan
|
||||
* SagiDayan@gmail.com
|
||||
*
|
||||
* minor changes by Liran Ben Gida
|
||||
* LiranBG@gmail.com
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
|
||||
class Course {
|
||||
|
||||
public:
|
||||
|
||||
Course(int serial,std::string name, std::string type, double points) {
|
||||
this->serialNum = serial;
|
||||
this->name = name;
|
||||
this->type = type;
|
||||
this->points = points;
|
||||
}
|
||||
virtual ~Course() { }
|
||||
|
||||
int getSerialNum() const {return this->serialNum;}
|
||||
virtual std::string getName() const {return this->name;}
|
||||
virtual std::string getType() const {return this->type;}
|
||||
virtual double getPoints() const {return this->points;}
|
||||
|
||||
virtual void setName(std::string name) { this->name = name;}
|
||||
virtual void setType(std::string type){ this->type = type;}
|
||||
virtual void setPoints(double points){ this->points = points;}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
int serialNum;
|
||||
std::string name;
|
||||
std::string type;
|
||||
double points;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
144
src/jceData/page.cpp
Normal file
144
src/jceData/page.cpp
Normal file
|
@ -0,0 +1,144 @@
|
|||
#include "page.h"
|
||||
|
||||
Page::Page()
|
||||
{
|
||||
|
||||
}
|
||||
std::string Page::getString(std::string& htmlToPhrased)
|
||||
{
|
||||
makeText(htmlToPhrased);
|
||||
return this->text;
|
||||
}
|
||||
void Page::makeText(std::string& html)
|
||||
{
|
||||
int index = 0;
|
||||
index = runToActualText(html, index); //set index into the actual place where the data is
|
||||
manageTableContent(html, index);
|
||||
}
|
||||
|
||||
int Page::runToActualText(std::string& from, int index)
|
||||
{
|
||||
while (index < (int)from.length())
|
||||
{
|
||||
if (from[index] == '<')
|
||||
{
|
||||
if (from.substr(index,7) == "<tbody>")
|
||||
return index+7;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
// while(index < (int)from.length())
|
||||
// {
|
||||
// if(from[index] == '<')
|
||||
// {
|
||||
// index++;
|
||||
// if(from[index] == '!')
|
||||
// {
|
||||
// //!--FileName
|
||||
// std::string bodyTag = from.substr(index, 11); //!--FileName
|
||||
|
||||
// if(bodyTag == "!--FileName") //check if the tag is body tag
|
||||
// {
|
||||
// while(from[index] != '>')
|
||||
// index++;
|
||||
// return index;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// index++;
|
||||
//}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Page::manageTableContent(std::string& html, int index)
|
||||
{
|
||||
std::string temp;
|
||||
for (int i = index; i < (int)html.length(); i++)
|
||||
{
|
||||
if(html[i] == '<')
|
||||
{
|
||||
//<tr> / <td> / <th>
|
||||
std::string endofTable = "</tbody>";
|
||||
std::string tableTag = html.substr(i, 4); //legth of "tr/td"
|
||||
if(tableTag == "<tr>")
|
||||
{
|
||||
temp += "\n"; //new row -> new line
|
||||
i = stitchText(html, temp, i+4);
|
||||
if(i == -1) //EOF
|
||||
break;
|
||||
}
|
||||
else if(tableTag == "<td>" || tableTag == "<th>")
|
||||
{
|
||||
temp += "\t"; // new cell -> tab between data
|
||||
if (html.substr(i, 6) == "<td><a") //link to lecturer portal, need to be deleted
|
||||
{
|
||||
i += 6;
|
||||
while (html.at(++i) != '>');
|
||||
i = stitchText(html, temp, i+1);
|
||||
}
|
||||
else
|
||||
i = stitchText(html, temp, i+4);
|
||||
if (i == -1) //EOF
|
||||
break;
|
||||
}
|
||||
else if(tableTag == "<td ") // a Year title (in grades table)
|
||||
{
|
||||
temp += "\t";
|
||||
while(html[i] != '>')
|
||||
i++;
|
||||
i = stitchText(html, temp, i+1);
|
||||
}
|
||||
else if (html.substr(i,(endofTable).length()) == endofTable) //is end of table
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this->text = temp;
|
||||
}
|
||||
|
||||
int Page::stitchText(std::string& from, std::string& to, int index)
|
||||
{
|
||||
if (from[index] == '<')
|
||||
{
|
||||
std::string bTag = from.substr(index, 3);
|
||||
if (bTag != "<b>")
|
||||
return index-1; //go back one step - for the main function to inc i
|
||||
index += 3;
|
||||
}
|
||||
|
||||
while (from[index] != '<' && index < (int)from.length())
|
||||
{
|
||||
if (from[index] == '&')
|
||||
{
|
||||
//
|
||||
std::string nbspChr = from.substr(index, 6);
|
||||
if (nbspChr == " ")
|
||||
{
|
||||
index += 5;
|
||||
from.at(index) = ' ';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (endOfString(index,(int) from.length()))
|
||||
return -1; //EOF
|
||||
|
||||
else if (from[index] == '<')
|
||||
return index - 1; //go back one step - for the main function to inc i
|
||||
|
||||
if (from[index] != '\n') //check the actuall data before continue
|
||||
to += from[index];
|
||||
index++;
|
||||
}
|
||||
|
||||
return index-1;
|
||||
}
|
||||
bool Page::endOfString(int index, int length)
|
||||
{
|
||||
if(index < length)
|
||||
return false;
|
||||
return true;
|
||||
}
|
|
@ -1,72 +1,87 @@
|
|||
#ifndef JCELOGINHTMLSCRIPTS_H
|
||||
#define JCELOGINHTMLSCRIPTS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#define dst_host "yedion.jce.ac.il"
|
||||
#define dst_port 443
|
||||
|
||||
#include "../user.h"
|
||||
|
||||
class jceLoginHtmlScripts
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
jceLoginHtmlScripts();
|
||||
|
||||
public:
|
||||
|
||||
static std::string makeRequest(std::string parameters)
|
||||
{
|
||||
std::string msg;
|
||||
msg = "POST /yedion/fireflyweb.aspx HTTP/1.1\r\n";
|
||||
msg += "Host: " + std::string(dst_host) + "\r\n";
|
||||
msg += "Content-Type: application/x-www-form-urlencoded\r\n";
|
||||
msg += "Content-Length: " + to_string(parameters.length()) + "\r\n";
|
||||
msg += "Proxy-Connection: Keep-Alive\r\n";
|
||||
msg += "Accept-Charset: utf-8";
|
||||
msg += "Accept: text/plain\r\n";
|
||||
msg += "Connection: Keep-Alive\r\n";
|
||||
msg += "\r\n";
|
||||
msg += parameters;
|
||||
return msg;
|
||||
}
|
||||
|
||||
const static std::string getFirstValidationStep(const user &usr)
|
||||
{
|
||||
std::string parameters = "?appname=BSHITA&prgname=LoginValidation&arguments=-N";
|
||||
parameters += usr.getUsername();
|
||||
parameters += ",-N";
|
||||
parameters += usr.getPassword();
|
||||
return parameters;
|
||||
}
|
||||
|
||||
const static std::string getSecondValidationStep(const user &usr)
|
||||
{
|
||||
std::string parameters;
|
||||
parameters = "prgname=LoginValidtion1&Arguments=-N";
|
||||
parameters += usr.getUserID();
|
||||
parameters += ",-A,-N";
|
||||
parameters += usr.getHashedPassword();
|
||||
parameters += ",-A,-A";
|
||||
return parameters;
|
||||
}
|
||||
const static std::string getGradesPath(const user &usr)
|
||||
{
|
||||
std::string parameters;
|
||||
parameters = "PRGNAME=HADPASAT_MISMAHIM_LETALMID&ARGUMENTS=TZ,-N4,R1C2,R1C4,R1C1,R1C3,-A,-A,R1C5,-A,UNIQ&";
|
||||
parameters += "TZ=" + usr.getUserID() + "&";
|
||||
parameters += "UNIQ=" + usr.getHashedPassword() + "&";
|
||||
parameters += "R1C2=" + usr.date->getFYear() + "&";
|
||||
parameters += "R1C1=" + usr.date->getTYear() + "&";
|
||||
parameters += "R1C3=" + usr.date->getTSemester() + "&";
|
||||
parameters += "R1C4=" + usr.date->getFSemester() + "&";
|
||||
parameters += "R1C5=0";
|
||||
return parameters;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // JCELOGINHTMLSCRIPTS_H
|
||||
#ifndef JCELOGINHTMLSCRIPTS_H
|
||||
#define JCELOGINHTMLSCRIPTS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#define dst_host "yedion.jce.ac.il"
|
||||
#define dst_port 443
|
||||
|
||||
#include "./src/jceSettings/user.h"
|
||||
|
||||
class jceLoginHtmlScripts
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
jceLoginHtmlScripts();
|
||||
|
||||
public:
|
||||
|
||||
static std::string makeRequest(std::string parameters)
|
||||
{
|
||||
std::string msg;
|
||||
msg = "POST /yedion/fireflyweb.aspx HTTP/1.1\r\n";
|
||||
msg += "Host: " + std::string(dst_host) + "\r\n";
|
||||
msg += "Content-Type: application/x-www-form-urlencoded\r\n";
|
||||
msg += "Content-Length: " + to_string(parameters.length()) + "\r\n";
|
||||
msg += "Proxy-Connection: Keep-Alive\r\n";
|
||||
msg += "Accept-Charset: utf-8";
|
||||
msg += "Accept: text/plain\r\n";
|
||||
msg += "Connection: Keep-Alive\r\n";
|
||||
msg += "\r\n";
|
||||
msg += parameters;
|
||||
return msg;
|
||||
}
|
||||
|
||||
const static std::string getFirstValidationStep(const user &usr)
|
||||
{
|
||||
std::string parameters = "?appname=BSHITA&prgname=LoginValidation&arguments=-N";
|
||||
parameters += usr.getUsername();
|
||||
parameters += ",-N";
|
||||
parameters += usr.getPassword();
|
||||
return parameters;
|
||||
}
|
||||
|
||||
const static std::string getSecondValidationStep(const user &usr)
|
||||
{
|
||||
std::string parameters;
|
||||
parameters = "prgname=LoginValidtion1&Arguments=-N";
|
||||
parameters += usr.getUserID();
|
||||
parameters += ",-A,-N";
|
||||
parameters += usr.getHashedPassword();
|
||||
parameters += ",-A,-A";
|
||||
return parameters;
|
||||
}
|
||||
const static std::string getGradesPath(const user &usr,
|
||||
int fromYear,
|
||||
int toYear,
|
||||
int fromSemester,
|
||||
int toSemester)
|
||||
{
|
||||
std::string parameters;
|
||||
parameters = "PRGNAME=HADPASAT_MISMAHIM_LETALMID&ARGUMENTS=TZ,-N4,R1C2,R1C4,R1C1,R1C3,-A,-A,R1C5,-A,UNIQ&";
|
||||
parameters += "TZ=" + usr.getUserID() + "&";
|
||||
parameters += "UNIQ=" + usr.getHashedPassword() + "&";
|
||||
parameters += "R1C2=" + std::to_string(fromYear) + "&";
|
||||
parameters += "R1C1=" + std::to_string(toYear) + "&";
|
||||
parameters += "R1C3=" + std::to_string(toSemester) + "&";
|
||||
parameters += "R1C4=" + std::to_string(fromSemester) + "&";
|
||||
parameters += "R1C5=0";
|
||||
return parameters;
|
||||
}
|
||||
const static std::string getCalendar(const user &usr,int year, int semester)
|
||||
{
|
||||
std::string parameters;
|
||||
parameters = "PRGNAME=Bitsua_maarechet_shaot&ARGUMENTS=TZ,UNIQ,MisparSheilta,R1C1,R1C2&";
|
||||
parameters += "TZ=" + usr.getUserID() + "&";
|
||||
parameters += "UNIQ=" + usr.getHashedPassword() + "&";
|
||||
parameters += "MisparSheilta=3&";
|
||||
parameters += "R1C1=" + std::to_string(year) + "&";
|
||||
parameters += "R1C2=" + std::to_string(semester) + "&";
|
||||
return parameters;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // JCELOGINHTMLSCRIPTS_H
|
|
@ -1,213 +1,229 @@
|
|||
#include "jcelogin.h"
|
||||
|
||||
jceLogin::jceLogin(user * username)
|
||||
{
|
||||
this->recieverPage = new std::string();
|
||||
this->jceA = username;
|
||||
this->JceConnector = new jceSSLClient();
|
||||
}
|
||||
|
||||
jceLogin::~jceLogin()
|
||||
{
|
||||
this->jceA = NULL;
|
||||
delete recieverPage;
|
||||
delete JceConnector;
|
||||
JceConnector = NULL;
|
||||
recieverPage = NULL;
|
||||
}
|
||||
/**
|
||||
* @brief jceLogin::makeConnection Connecting to JCE student web site with JceA (username object) and validate it.
|
||||
* throws error upon the given error from JCE website or Socket error
|
||||
*/
|
||||
void jceLogin::makeConnection() throw (jceStatus)
|
||||
{
|
||||
if (this->recieverPage == NULL)
|
||||
this->recieverPage = new std::string();
|
||||
|
||||
if (JceConnector->makeConnect(dst_host,dst_port) == false)
|
||||
throw jceStatus::ERROR_ON_OPEN_SOCKET;
|
||||
|
||||
int returnMode;
|
||||
jceStatus status = jceStatus::JCE_NOT_CONNECTED;
|
||||
|
||||
returnMode = checkConnection();
|
||||
if (returnMode == true) //connected to host
|
||||
{
|
||||
returnMode = makeFirstVisit();
|
||||
if (returnMode == true) //requst and send first validation
|
||||
{
|
||||
status = jceStatus::JCE_START_VALIDATING_PROGRESS;
|
||||
returnMode = checkValidation();
|
||||
if (returnMode == true) //check if username and password are matching
|
||||
{
|
||||
status = jceStatus::JCE_VALIDATION_PASSED;
|
||||
returnMode = makeSecondVisit();
|
||||
if (returnMode == true) //siging in the website
|
||||
{
|
||||
status = jceStatus::JCE_YOU_ARE_IN;
|
||||
setLoginFlag(true);
|
||||
}
|
||||
else if (returnMode == jceLogin::ERROR_ON_GETTING_INFO)
|
||||
{
|
||||
status = jceLogin::ERROR_ON_GETTING_INFO;
|
||||
}
|
||||
else if (returnMode == jceLogin::ERROR_ON_SEND_REQUEST)
|
||||
{
|
||||
status = jceLogin::ERROR_ON_SEND_REQUEST;
|
||||
}
|
||||
else
|
||||
status = jceStatus::ERROR_ON_VALIDATION;
|
||||
}
|
||||
else
|
||||
status = jceStatus::ERROR_ON_VALIDATION;
|
||||
|
||||
}
|
||||
else if (returnMode == jceLogin::ERROR_ON_GETTING_INFO)
|
||||
{
|
||||
status = jceLogin::ERROR_ON_GETTING_INFO;
|
||||
}
|
||||
else if (returnMode == jceLogin::ERROR_ON_SEND_REQUEST)
|
||||
{
|
||||
status = jceLogin::ERROR_ON_SEND_REQUEST;
|
||||
}
|
||||
else
|
||||
status = jceStatus::ERROR_ON_VALIDATION_USER_BLOCKED;
|
||||
|
||||
}
|
||||
else
|
||||
status = jceStatus::JCE_NOT_CONNECTED;
|
||||
|
||||
//we throw status even if we are IN!
|
||||
throw status;
|
||||
|
||||
}
|
||||
|
||||
bool jceLogin::checkConnection()
|
||||
{
|
||||
if (JceConnector->isConnected())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void jceLogin::reConnect() throw (jceStatus)
|
||||
{
|
||||
closeAll();
|
||||
if (this->JceConnector != NULL)
|
||||
delete JceConnector;
|
||||
this->recieverPage = new std::string();
|
||||
this->JceConnector = new jceSSLClient();
|
||||
try
|
||||
{
|
||||
|
||||
makeConnection();
|
||||
}
|
||||
catch (jceLogin::jceStatus &a)
|
||||
{
|
||||
throw a;
|
||||
}
|
||||
}
|
||||
|
||||
void jceLogin::closeAll()
|
||||
{
|
||||
JceConnector->makeDiconnect();
|
||||
delete recieverPage;
|
||||
recieverPage = NULL;
|
||||
loginFlag = false;
|
||||
|
||||
}
|
||||
|
||||
int jceLogin::makeFirstVisit()
|
||||
{
|
||||
std::string usr = jceA->getUsername();
|
||||
std::string psw = jceA->getPassword();
|
||||
if (JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getFirstValidationStep(*jceA))))
|
||||
{
|
||||
if (!JceConnector->recieveData(*recieverPage,true))
|
||||
return jceLogin::ERROR_ON_GETTING_INFO;
|
||||
}
|
||||
else
|
||||
return jceLogin::ERROR_ON_SEND_REQUEST;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int jceLogin::makeSecondVisit()
|
||||
{
|
||||
std::string usrid=jceA->getUserID();
|
||||
std::string pswid=jceA->getHashedPassword();
|
||||
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getSecondValidationStep(*jceA)))))
|
||||
{
|
||||
if (!(JceConnector->recieveData(*recieverPage,true)))
|
||||
return jceLogin::ERROR_ON_GETTING_INFO;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return jceLogin::ERROR_ON_SEND_REQUEST;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int jceLogin::getGrades()
|
||||
{
|
||||
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getGradesPath(*jceA)))))
|
||||
{
|
||||
if (!(JceConnector->recieveData(*recieverPage,false)))
|
||||
return jceLogin::ERROR_ON_GETTING_GRADES;
|
||||
else
|
||||
return jceLogin::JCE_GRADE_PAGE_PASSED;
|
||||
}
|
||||
else
|
||||
return jceLogin::ERROR_ON_SEND_REQUEST;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
void jceLogin::setLoginFlag(bool x)
|
||||
{
|
||||
this->loginFlag = x;
|
||||
}
|
||||
bool jceLogin::isLoginFlag() const
|
||||
{
|
||||
return this->loginFlag;
|
||||
}
|
||||
|
||||
std::string jceLogin::getPage()
|
||||
{
|
||||
return *recieverPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief jceLogin::checkValidation Made by Nadav Luzzato
|
||||
* @return true if second validation step is right
|
||||
*/
|
||||
bool jceLogin::checkValidation()
|
||||
{
|
||||
//finds the hashed password
|
||||
std::size_t hasspass_position1,hasspass_position2;
|
||||
|
||||
if ((hasspass_position1 = recieverPage->find("-A,-N")) == string::npos)
|
||||
return false;
|
||||
hasspass_position1 += 5;
|
||||
if ((hasspass_position2 = recieverPage->find(",-A,-A", hasspass_position1)) == string::npos)
|
||||
return false;
|
||||
|
||||
std::string hasspass = recieverPage->substr(hasspass_position1,hasspass_position2-hasspass_position1);
|
||||
jceA->setHashedPassword(hasspass);
|
||||
|
||||
//finds the user id
|
||||
std::size_t id_position1 = recieverPage->find("value=\"-N", 0);
|
||||
id_position1 += 9;
|
||||
std::size_t id_position2 = recieverPage->find(",-A", id_position1);
|
||||
if ((id_position2 != std::string::npos) && (id_position1 != std::string::npos))
|
||||
{
|
||||
std::string hassid = recieverPage->substr(id_position1,id_position2-id_position1);
|
||||
jceA->setUserID(hassid);
|
||||
}
|
||||
if (((jceA->getUserID()).empty()) || ((jceA->getHashedPassword()).empty()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
#include "jcelogin.h"
|
||||
|
||||
jceLogin::jceLogin(user * username)
|
||||
{
|
||||
this->recieverPage = new std::string();
|
||||
this->jceA = username;
|
||||
this->JceConnector = new jceSSLClient();
|
||||
}
|
||||
|
||||
jceLogin::~jceLogin()
|
||||
{
|
||||
this->jceA = NULL;
|
||||
delete recieverPage;
|
||||
delete JceConnector;
|
||||
JceConnector = NULL;
|
||||
recieverPage = NULL;
|
||||
}
|
||||
/**
|
||||
* @brief jceLogin::makeConnection Connecting to JCE student web site with JceA (username object) and validate it.
|
||||
* throws error upon the given error from JCE website or Socket error
|
||||
*/
|
||||
void jceLogin::makeConnection() throw (jceStatus)
|
||||
{
|
||||
if (this->recieverPage == NULL)
|
||||
this->recieverPage = new std::string();
|
||||
|
||||
if (JceConnector->makeConnect(dst_host,dst_port) == false)
|
||||
throw jceStatus::ERROR_ON_OPEN_SOCKET;
|
||||
|
||||
int returnMode;
|
||||
jceStatus status = jceStatus::JCE_NOT_CONNECTED;
|
||||
|
||||
returnMode = checkConnection();
|
||||
if (returnMode == true) //connected to host
|
||||
{
|
||||
returnMode = makeFirstVisit();
|
||||
if (returnMode == true) //requst and send first validation
|
||||
{
|
||||
status = jceStatus::JCE_START_VALIDATING_PROGRESS;
|
||||
returnMode = checkValidation();
|
||||
if (returnMode == true) //check if username and password are matching
|
||||
{
|
||||
status = jceStatus::JCE_VALIDATION_PASSED;
|
||||
returnMode = makeSecondVisit();
|
||||
if (returnMode == true) //siging in the website
|
||||
{
|
||||
status = jceStatus::JCE_YOU_ARE_IN;
|
||||
setLoginFlag(true);
|
||||
}
|
||||
else if (returnMode == jceLogin::ERROR_ON_GETTING_INFO)
|
||||
{
|
||||
status = jceLogin::ERROR_ON_GETTING_INFO;
|
||||
}
|
||||
else if (returnMode == jceLogin::ERROR_ON_SEND_REQUEST)
|
||||
{
|
||||
status = jceLogin::ERROR_ON_SEND_REQUEST;
|
||||
}
|
||||
else
|
||||
status = jceStatus::ERROR_ON_VALIDATION;
|
||||
}
|
||||
else
|
||||
status = jceStatus::ERROR_ON_VALIDATION;
|
||||
|
||||
}
|
||||
else if (returnMode == jceLogin::ERROR_ON_GETTING_INFO)
|
||||
{
|
||||
status = jceLogin::ERROR_ON_GETTING_INFO;
|
||||
}
|
||||
else if (returnMode == jceLogin::ERROR_ON_SEND_REQUEST)
|
||||
{
|
||||
status = jceLogin::ERROR_ON_SEND_REQUEST;
|
||||
}
|
||||
else
|
||||
status = jceStatus::ERROR_ON_VALIDATION_USER_BLOCKED;
|
||||
|
||||
}
|
||||
else
|
||||
status = jceStatus::JCE_NOT_CONNECTED;
|
||||
|
||||
//we throw status even if we are IN!
|
||||
throw status;
|
||||
|
||||
}
|
||||
|
||||
bool jceLogin::checkConnection()
|
||||
{
|
||||
if (JceConnector->isConnected())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void jceLogin::reConnect() throw (jceStatus)
|
||||
{
|
||||
closeAll();
|
||||
if (this->JceConnector != NULL)
|
||||
delete JceConnector;
|
||||
this->recieverPage = new std::string();
|
||||
this->JceConnector = new jceSSLClient();
|
||||
try
|
||||
{
|
||||
|
||||
makeConnection();
|
||||
}
|
||||
catch (jceLogin::jceStatus &a)
|
||||
{
|
||||
throw a;
|
||||
}
|
||||
}
|
||||
|
||||
void jceLogin::closeAll()
|
||||
{
|
||||
JceConnector->makeDiconnect();
|
||||
delete recieverPage;
|
||||
recieverPage = NULL;
|
||||
loginFlag = false;
|
||||
|
||||
}
|
||||
|
||||
int jceLogin::makeFirstVisit()
|
||||
{
|
||||
std::string usr = jceA->getUsername();
|
||||
std::string psw = jceA->getPassword();
|
||||
if (JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getFirstValidationStep(*jceA))))
|
||||
{
|
||||
if (!JceConnector->recieveData(*recieverPage,true))
|
||||
return jceLogin::ERROR_ON_GETTING_INFO;
|
||||
}
|
||||
else
|
||||
return jceLogin::ERROR_ON_SEND_REQUEST;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int jceLogin::makeSecondVisit()
|
||||
{
|
||||
std::string usrid=jceA->getUserID();
|
||||
std::string pswid=jceA->getHashedPassword();
|
||||
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getSecondValidationStep(*jceA)))))
|
||||
{
|
||||
if (!(JceConnector->recieveData(*recieverPage,true)))
|
||||
return jceLogin::ERROR_ON_GETTING_INFO;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return jceLogin::ERROR_ON_SEND_REQUEST;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int jceLogin::getCalendar(int year, int semester)
|
||||
{
|
||||
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getCalendar(*jceA,year,semester)))))
|
||||
{
|
||||
if (!(JceConnector->recieveData(*recieverPage,false)))
|
||||
return jceLogin::ERROR_ON_GETTING_GRADES;
|
||||
else
|
||||
return jceLogin::JCE_GRADE_PAGE_PASSED;
|
||||
}
|
||||
else
|
||||
return jceLogin::ERROR_ON_SEND_REQUEST;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
int jceLogin::getGrades(int fromYear, int toYear, int fromSemester, int toSemester)
|
||||
{
|
||||
std::cout << fromYear << " " << toYear << " " << fromSemester << " " << toSemester << std::endl;
|
||||
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getGradesPath(*jceA,fromYear, toYear, fromSemester, toSemester)))))
|
||||
{
|
||||
if (!(JceConnector->recieveData(*recieverPage,false)))
|
||||
return jceLogin::ERROR_ON_GETTING_GRADES;
|
||||
else
|
||||
return jceLogin::JCE_GRADE_PAGE_PASSED;
|
||||
}
|
||||
else
|
||||
return jceLogin::ERROR_ON_SEND_REQUEST;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
void jceLogin::setLoginFlag(bool x)
|
||||
{
|
||||
this->loginFlag = x;
|
||||
}
|
||||
bool jceLogin::isLoginFlag() const
|
||||
{
|
||||
return this->loginFlag;
|
||||
}
|
||||
|
||||
std::string jceLogin::getPage()
|
||||
{
|
||||
return *recieverPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief jceLogin::checkValidation Made by Nadav Luzzato
|
||||
* @return true if second validation step is right
|
||||
*/
|
||||
bool jceLogin::checkValidation()
|
||||
{
|
||||
//finds the hashed password
|
||||
std::size_t hasspass_position1,hasspass_position2;
|
||||
|
||||
if ((hasspass_position1 = recieverPage->find("-A,-N")) == string::npos)
|
||||
return false;
|
||||
hasspass_position1 += 5;
|
||||
if ((hasspass_position2 = recieverPage->find(",-A,-A", hasspass_position1)) == string::npos)
|
||||
return false;
|
||||
|
||||
std::string hasspass = recieverPage->substr(hasspass_position1,hasspass_position2-hasspass_position1);
|
||||
jceA->setHashedPassword(hasspass);
|
||||
|
||||
//finds the user id
|
||||
std::size_t id_position1 = recieverPage->find("value=\"-N", 0);
|
||||
id_position1 += 9;
|
||||
std::size_t id_position2 = recieverPage->find(",-A", id_position1);
|
||||
if ((id_position2 != std::string::npos) && (id_position1 != std::string::npos))
|
||||
{
|
||||
std::string hassid = recieverPage->substr(id_position1,id_position2-id_position1);
|
||||
jceA->setUserID(hassid);
|
||||
}
|
||||
if (((jceA->getUserID()).empty()) || ((jceA->getHashedPassword()).empty()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
|
@ -1,59 +1,60 @@
|
|||
#ifndef JCELOGIN_H
|
||||
#define JCELOGIN_H
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
#include "../connection/jcesslclient.h"
|
||||
#include "../user.h"
|
||||
#include "jceLoginHtmlScripts.h"
|
||||
|
||||
class jceLogin
|
||||
{
|
||||
public:
|
||||
|
||||
enum jceStatus {
|
||||
JCE_NOT_CONNECTED,
|
||||
ERROR_ON_VALIDATION,
|
||||
ERROR_ON_VALIDATION_USER_BLOCKED,
|
||||
ERROR_ON_OPEN_SOCKET,
|
||||
ERROR_ON_SEND_REQUEST,
|
||||
ERROR_ON_GETTING_INFO,
|
||||
ERROR_ON_GETTING_GRADES,
|
||||
|
||||
JCE_START_VALIDATING_PROGRESS,
|
||||
JCE_VALIDATION_PASSED,
|
||||
JCE_YOU_ARE_IN,
|
||||
JCE_GRADE_PAGE_PASSED
|
||||
};
|
||||
|
||||
jceLogin(user* username);
|
||||
~jceLogin();
|
||||
void makeConnection() throw (jceStatus);
|
||||
bool checkConnection();
|
||||
void reConnect() throw (jceStatus);
|
||||
void closeAll();
|
||||
int getGrades();
|
||||
bool isLoginFlag() const;
|
||||
|
||||
std::string getPage();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
int makeFirstVisit();
|
||||
bool checkValidation();
|
||||
int makeSecondVisit();
|
||||
void setLoginFlag(bool x);
|
||||
|
||||
bool loginFlag;
|
||||
std::string * recieverPage;
|
||||
user * jceA;
|
||||
jceSSLClient * JceConnector;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // JCELOGIN_H
|
||||
#ifndef JCELOGIN_H
|
||||
#define JCELOGIN_H
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
#include "./src/jceConnection/jcesslclient.h"
|
||||
#include "./src/jceSettings/user.h"
|
||||
#include "jceLoginHtmlScripts.h"
|
||||
|
||||
class jceLogin
|
||||
{
|
||||
public:
|
||||
|
||||
enum jceStatus {
|
||||
JCE_NOT_CONNECTED,
|
||||
ERROR_ON_VALIDATION,
|
||||
ERROR_ON_VALIDATION_USER_BLOCKED,
|
||||
ERROR_ON_OPEN_SOCKET,
|
||||
ERROR_ON_SEND_REQUEST,
|
||||
ERROR_ON_GETTING_INFO,
|
||||
ERROR_ON_GETTING_GRADES,
|
||||
|
||||
JCE_START_VALIDATING_PROGRESS,
|
||||
JCE_VALIDATION_PASSED,
|
||||
JCE_YOU_ARE_IN,
|
||||
JCE_GRADE_PAGE_PASSED
|
||||
};
|
||||
|
||||
jceLogin(user* username);
|
||||
~jceLogin();
|
||||
void makeConnection() throw (jceStatus);
|
||||
bool checkConnection();
|
||||
void reConnect() throw (jceStatus);
|
||||
void closeAll();
|
||||
int getCalendar(int year, int semester);
|
||||
int getGrades(int fromYear, int toYear, int fromSemester, int toSemester);
|
||||
bool isLoginFlag() const;
|
||||
|
||||
std::string getPage();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
int makeFirstVisit();
|
||||
bool checkValidation();
|
||||
int makeSecondVisit();
|
||||
void setLoginFlag(bool x);
|
||||
|
||||
bool loginFlag;
|
||||
std::string * recieverPage;
|
||||
user * jceA;
|
||||
jceSSLClient * JceConnector;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // JCELOGIN_H
|
|
@ -1,52 +1,45 @@
|
|||
#include "user.h"
|
||||
|
||||
|
||||
user::user(string username,string password) : hashedPassword(""),userID(""), influenceCourseOnly(false)
|
||||
{
|
||||
|
||||
this->username = username;
|
||||
this->password = password;
|
||||
}
|
||||
user::~user()
|
||||
{
|
||||
delete date;
|
||||
}
|
||||
void user::setDate(std::string fromYear, std::string fromSemester, std::string toYear, std::string toSemester)
|
||||
{
|
||||
date->setFYear(fromYear);
|
||||
date->setFSemester(fromSemester);
|
||||
date->setTYear(toYear);
|
||||
date->setTSemester(toSemester);
|
||||
}
|
||||
|
||||
void user::setInfluenceCourseOnly(bool status)
|
||||
{
|
||||
this->influenceCourseOnly = status;
|
||||
}
|
||||
|
||||
bool user::getInfluenceCourseOnly() const
|
||||
{
|
||||
return this->influenceCourseOnly;
|
||||
}
|
||||
|
||||
void user::setUsername(string& username) {
|
||||
this->username=username;
|
||||
}
|
||||
|
||||
void user::setPassword(string& password) {
|
||||
this->password=password;
|
||||
}
|
||||
|
||||
void user::setUserID(string& ID)
|
||||
{
|
||||
this->userID = ID;
|
||||
}
|
||||
void user::setHashedPassword(string& hashpass)
|
||||
{
|
||||
this->hashedPassword = hashpass;
|
||||
}
|
||||
|
||||
string user::getPassword() const { return password; }
|
||||
string user::getUsername() const { return username; }
|
||||
string user::getUserID() const { return userID; }
|
||||
string user::getHashedPassword() const { return hashedPassword; }
|
||||
#include "user.h"
|
||||
|
||||
|
||||
user::user(string username,string password) : hashedPassword(""),userID(""), influenceCourseOnly(false)
|
||||
{
|
||||
|
||||
this->username = username;
|
||||
this->password = password;
|
||||
}
|
||||
user::~user()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void user::setInfluenceCourseOnly(bool status)
|
||||
{
|
||||
this->influenceCourseOnly = status;
|
||||
}
|
||||
|
||||
bool user::getInfluenceCourseOnly() const
|
||||
{
|
||||
return this->influenceCourseOnly;
|
||||
}
|
||||
|
||||
void user::setUsername(string& username) {
|
||||
this->username=username;
|
||||
}
|
||||
|
||||
void user::setPassword(string& password) {
|
||||
this->password=password;
|
||||
}
|
||||
|
||||
void user::setUserID(string& ID)
|
||||
{
|
||||
this->userID = ID;
|
||||
}
|
||||
void user::setHashedPassword(string& hashpass)
|
||||
{
|
||||
this->hashedPassword = hashpass;
|
||||
}
|
||||
|
||||
string user::getPassword() const { return password; }
|
||||
string user::getUsername() const { return username; }
|
||||
string user::getUserID() const { return userID; }
|
||||
string user::getHashedPassword() const { return hashedPassword; }
|
|
@ -1,48 +1,43 @@
|
|||
#ifndef user_H
|
||||
#define user_H
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "jce/jcedate.h"
|
||||
|
||||
using namespace std;
|
||||
class user
|
||||
{
|
||||
public:
|
||||
user(string username,string password);
|
||||
~user();
|
||||
void setUsername(string& username);
|
||||
void setPassword(string& password);
|
||||
|
||||
string getPassword() const;
|
||||
string getUsername() const;
|
||||
|
||||
void setUserID(string& ID);
|
||||
void setHashedPassword(string& hashpass);
|
||||
|
||||
string getUserID() const;
|
||||
string getHashedPassword() const;
|
||||
|
||||
void setDate(std::string fromYear, std::string fromSemester, std::string toYear, std::string toSemester);
|
||||
|
||||
void setInfluenceCourseOnly(bool status);
|
||||
bool getInfluenceCourseOnly() const;
|
||||
|
||||
jceDate * const date = new jceDate("","","",""); //we do not change the pointer
|
||||
|
||||
private:
|
||||
|
||||
string username;
|
||||
string password;
|
||||
|
||||
string hashedPassword;
|
||||
string userID;
|
||||
|
||||
bool influenceCourseOnly;
|
||||
|
||||
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef user_H
|
||||
#define user_H
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
class user
|
||||
{
|
||||
public:
|
||||
user(string username,string password);
|
||||
~user();
|
||||
void setUsername(string& username);
|
||||
void setPassword(string& password);
|
||||
|
||||
string getPassword() const;
|
||||
string getUsername() const;
|
||||
|
||||
void setUserID(string& ID);
|
||||
void setHashedPassword(string& hashpass);
|
||||
|
||||
string getUserID() const;
|
||||
string getHashedPassword() const;
|
||||
|
||||
void setInfluenceCourseOnly(bool status);
|
||||
bool getInfluenceCourseOnly() const;
|
||||
|
||||
private:
|
||||
|
||||
string username;
|
||||
string password;
|
||||
|
||||
string hashedPassword;
|
||||
string userID;
|
||||
|
||||
bool influenceCourseOnly;
|
||||
|
||||
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in a new issue