Merge fix

This commit is contained in:
Sagi Dayan 2014-08-31 20:54:33 +03:00
commit 8172f695d1
36 changed files with 2455 additions and 1915 deletions

View file

@ -1,53 +1,55 @@
#------------------------------------------------- #-------------------------------------------------
# #
# Project created by QtCreator 2014-05-31T19:49:42 # Project created by QtCreator 2014-05-31T19:49:42
# #
#------------------------------------------------- #-------------------------------------------------
QT += core gui network QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = jceGrade TARGET = jceGrade
TEMPLATE = app TEMPLATE = app
RC_FILE = appConfigure.rc RC_FILE = appConfigure.rc
CONFIG += c++11 static CONFIG += c++11 static
SOURCES += main/coursestablemanager.cpp \
main/loginhandler.cpp \ FORMS += \
main/main.cpp \ main/mainscreen.ui
main/mainscreen.cpp \
src/connection/jcesslclient.cpp \ OTHER_FILES +=
src/user.cpp \
src/grades/Course.cpp \ RESOURCES += \
src/grades/GradePage.cpp \ resources/connectionstatus.qrc
src/grades/Page.cpp \
src/jce/jcedate.cpp \ HEADERS += \
src/jce/jcelogin.cpp \ main/CalendarTab/CalendarManager.h \
src/data/savedata.cpp \ main/CourseTab/coursestablemanager.h \
main/LoginTab/loginhandler.h \
main/mainscreen.h \
src/appDatabase/savedata.h \
src/jceConnection/jcesslclient.h \
HEADERS += main/coursestablemanager.h \ src/jceData/Calendar/calendarPage.h \
main/loginhandler.h \ src/jceData/Grades/gradeCourse.h \
main/mainscreen.h \ src/jceData/Grades/gradePage.h \
src/connection/jcesslclient.h \ src/jceData/course.h \
src/user.h \ src/jceData/page.h \
src/grades/Course.h \ src/jceSettings/jcelogin.h \
src/grades/GradePage.h \ src/jceSettings/jceLoginHtmlScripts.h \
src/grades/Page.h \ src/jceSettings/user.h \
src/jce/jcedate.h \ src/jceData/Calendar/calendarCourse.h
src/jce/jcelogin.h \
src/jce/jceLoginHtmlScripts.h \ SOURCES += \
src/data/savedata.h \ main/CalendarTab/CalendarManager.cpp \
main/CourseTab/coursestablemanager.cpp \
main/LoginTab/loginhandler.cpp \
TRANSLATIONS = jce_en.ts \ main/main.cpp \
jce_he.ts main/mainscreen.cpp \
src/appDatabase/savedata.cpp \
FORMS += \ src/jceConnection/jcesslclient.cpp \
main/mainscreen.ui src/jceData/Calendar/calendarPage.cpp \
src/jceData/Grades/gradeCourse.cpp \
OTHER_FILES += src/jceData/Grades/gradePage.cpp \
src/jceData/page.cpp \
RESOURCES += \ src/jceSettings/jcelogin.cpp \
resources/connectionstatus.qrc src/jceSettings/user.cpp \
src/jceData/Calendar/calendarCourse.cpp

251
jceGrade.pro.user Normal file
View 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>

View 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);
}

View 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

View file

@ -1,251 +1,251 @@
#include "coursestablemanager.h" #include "coursestablemanager.h"
coursesTableManager::coursesTableManager(QTableWidget *ptr, user *usrPtr) coursesTableManager::coursesTableManager(QTableWidget *ptr, user *usrPtr)
{ {
this->gp = NULL; this->gp = NULL;
this->us = usrPtr; this->us = usrPtr;
this->courseTBL = ptr; this->courseTBL = ptr;
/* /*
* Initilizing Table * Initilizing Table
*/ */
courseTBL->setRowCount(0); courseTBL->setRowCount(0);
courseTBL->setColumnCount(COURSE_FIELDS); courseTBL->setColumnCount(COURSE_FIELDS);
QStringList mz; QStringList mz;
mz << QObject::tr("Code") << QObject::tr("Name") << QObject::tr("Type") << QObject::tr("Points") << QObject::tr("Hours") << QObject::tr("Grade") << QObject::tr("Additions"); 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->setHorizontalHeaderLabels(mz);
courseTBL->verticalHeader()->setVisible(true); courseTBL->verticalHeader()->setVisible(true);
courseTBL->setSelectionMode(QAbstractItemView::SingleSelection); courseTBL->setSelectionMode(QAbstractItemView::SingleSelection);
courseTBL->setShowGrid(true); courseTBL->setShowGrid(true);
courseTBL->setStyleSheet("QTableView {selection-background-color: red;}"); courseTBL->setStyleSheet("QTableView {selection-background-color: red;}");
} }
coursesTableManager::~coursesTableManager() coursesTableManager::~coursesTableManager()
{ {
courseTBL = NULL; courseTBL = NULL;
delete gp; delete gp;
gp = NULL; gp = NULL;
} }
/** /**
* @brief coursesTableManager::insertJceCoursesIntoTable phrasing the course list to rows in table * @brief coursesTableManager::insertJceCoursesIntoTable phrasing the course list to rows in table
*/ */
void coursesTableManager::insertJceCoursesIntoTable() void coursesTableManager::insertJceCoursesIntoTable()
{ {
for (Course *c: *gp->getCourses()) for (gradeCourse *c: *gp->getCourses())
{ {
if (us->getInfluenceCourseOnly()) if (us->getInfluenceCourseOnly())
{ {
if (isCourseInfluence(c)) if (isCourseInfluence(c))
addRow(c); addRow(c);
} }
else else
addRow(c); addRow(c);
} }
} }
/** /**
* @brief coursesTableManager::setCoursesList creating courses list with given html page * @brief coursesTableManager::setCoursesList creating courses list with given html page
* @param html * @param html
*/ */
void coursesTableManager::setCoursesList(std::string &html) void coursesTableManager::setCoursesList(std::string &html)
{ {
gp = new GradePage(html); gp = new GradePage(html);
} }
/** /**
* @brief coursesTableManager::changes when user changes the table manually it updates it * @brief coursesTableManager::changes when user changes the table manually it updates it
* @param change string change * @param change string change
* @param row row index * @param row row index
* @param col col index * @param col col index
* @return if change has been done * @return if change has been done
*/ */
bool coursesTableManager::changes(QString change, int row, int col) bool coursesTableManager::changes(QString change, int row, int col)
{ {
bool isNumFlag = true; bool isNumFlag = true;
int serialCourse = courseTBL->item(row,Course::CourseScheme::SERIAL)->text().toInt(); int serialCourse = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text().toInt();
for (Course *c: *gp->getCourses()) for (gradeCourse *c: *gp->getCourses())
{ {
if (c->getSerialNum() == serialCourse) if (c->getSerialNum() == serialCourse)
{ {
switch (col) switch (col)
{ {
case (Course::CourseScheme::NAME): case (gradeCourse::CourseScheme::NAME):
c->setName(change.toStdString()); c->setName(change.toStdString());
break; break;
case (Course::CourseScheme::TYPE): case (gradeCourse::CourseScheme::TYPE):
c->setType(change.toStdString()); c->setType(change.toStdString());
break; break;
case (Course::CourseScheme::POINTS): case (gradeCourse::CourseScheme::POINTS):
{ {
change.toDouble(&isNumFlag); change.toDouble(&isNumFlag);
if (!isNumFlag) if (!isNumFlag)
{ {
courseTBL->item(row,col)->setText(QString::number(c->getPoints())); courseTBL->item(row,col)->setText(QString::number(c->getPoints()));
} }
else else
c->setPoints(change.toDouble()); c->setPoints(change.toDouble());
break; break;
} }
case (Course::CourseScheme::HOURS): case (gradeCourse::CourseScheme::HOURS):
{ {
change.toDouble(&isNumFlag); change.toDouble(&isNumFlag);
if (!isNumFlag) if (!isNumFlag)
{ {
courseTBL->item(row,col)->setText(QString::number(c->getHours())); courseTBL->item(row,col)->setText(QString::number(c->getHours()));
} }
else else
c->setHours(change.toDouble()); c->setHours(change.toDouble());
break; break;
} }
case (Course::CourseScheme::GRADE): case (gradeCourse::CourseScheme::GRADE):
{ {
change.toDouble(&isNumFlag); change.toDouble(&isNumFlag);
if (!isNumFlag) if (!isNumFlag)
{ {
courseTBL->item(row,col)->setText(QString::number(c->getGrade())); courseTBL->item(row,col)->setText(QString::number(c->getGrade()));
} }
else else
{ {
if ((change.toDouble() >= 0) && (change.toDouble() <= 100)) if ((change.toDouble() >= 0) && (change.toDouble() <= 100))
c->setGrade(change.toDouble()); c->setGrade(change.toDouble());
else else
courseTBL->item(row,col)->setText(QString::number(c->getGrade())); courseTBL->item(row,col)->setText(QString::number(c->getGrade()));
} }
break; break;
} }
case (Course::CourseScheme::ADDITION): case (gradeCourse::CourseScheme::ADDITION):
c->setAdditions(change.toStdString()); c->setAdditions(change.toStdString());
break; break;
} }
break; break;
} }
} }
return isNumFlag; return isNumFlag;
} }
/** /**
* @brief coursesTableManager::addRow adds row with given information * @brief coursesTableManager::addRow adds row with given information
* @param courseToAdd if exists, add its information to table * @param courseToAdd if exists, add its information to table
*/ */
void coursesTableManager::addRow(const Course *courseToAdd) void coursesTableManager::addRow(const gradeCourse *courseToAdd)
{ {
int i,j; int i,j;
i = courseTBL->rowCount(); i = courseTBL->rowCount();
j = 0; j = 0;
QTableWidgetItem *serial,*name,*type,*points,*hours,*grade,*addition; QTableWidgetItem *serial,*name,*type,*points,*hours,*grade,*addition;
const Course * c; const gradeCourse * c;
if (courseToAdd != NULL) if (courseToAdd != NULL)
{ {
c = courseToAdd; c = courseToAdd;
if (!isCourseAlreadyInserted(c->getSerialNum())) if (!isCourseAlreadyInserted(c->getSerialNum()))
{ {
courseTBL->setRowCount(courseTBL->rowCount()+1); courseTBL->setRowCount(courseTBL->rowCount()+1);
serial = new QTableWidgetItem(QString::number(c->getSerialNum())); serial = new QTableWidgetItem(QString::number(c->getSerialNum()));
serial->setFlags(serial->flags() & ~Qt::ItemIsEditable); serial->setFlags(serial->flags() & ~Qt::ItemIsEditable);
points = new QTableWidgetItem(QString::number(c->getPoints())); points = new QTableWidgetItem(QString::number(c->getPoints()));
points->setFlags(serial->flags() & ~Qt::ItemIsEditable); points->setFlags(serial->flags() & ~Qt::ItemIsEditable);
hours = new QTableWidgetItem(QString::number(c->getHours())); hours = new QTableWidgetItem(QString::number(c->getHours()));
hours->setFlags(serial->flags() & ~Qt::ItemIsEditable); hours->setFlags(serial->flags() & ~Qt::ItemIsEditable);
grade = new QTableWidgetItem(QString::number(c->getGrade())); grade = new QTableWidgetItem(QString::number(c->getGrade()));
name = new QTableWidgetItem(QString::fromStdString(c->getName())); name = new QTableWidgetItem(QString::fromStdString(c->getName()));
name->setFlags(serial->flags() & ~Qt::ItemIsEditable); name->setFlags(serial->flags() & ~Qt::ItemIsEditable);
type = new QTableWidgetItem(QString::fromStdString(c->getType())); type = new QTableWidgetItem(QString::fromStdString(c->getType()));
type->setFlags(serial->flags() & ~Qt::ItemIsEditable); type->setFlags(serial->flags() & ~Qt::ItemIsEditable);
addition = new QTableWidgetItem(QString::fromStdString(c->getAddidtions())); addition = new QTableWidgetItem(QString::fromStdString(c->getAddidtions()));
courseTBL->setItem(i,j++,serial); courseTBL->setItem(i,j++,serial);
courseTBL->setItem(i,j++,name); courseTBL->setItem(i,j++,name);
courseTBL->setItem(i,j++,type); courseTBL->setItem(i,j++,type);
courseTBL->setItem(i,j++,points); courseTBL->setItem(i,j++,points);
courseTBL->setItem(i,j++,hours); courseTBL->setItem(i,j++,hours);
courseTBL->setItem(i,j++,grade); courseTBL->setItem(i,j++,grade);
courseTBL->setItem(i,j,addition); courseTBL->setItem(i,j,addition);
} }
} }
else else
{ {
} }
courseTBL->resizeColumnsToContents(); courseTBL->resizeColumnsToContents();
} }
double coursesTableManager::getAvg() double coursesTableManager::getAvg()
{ {
if (this->gp != NULL) if (this->gp != NULL)
return gp->getAvg(); return gp->getAvg();
return 0; return 0;
} }
void coursesTableManager::influnceCourseChanged(bool ignoreCourseStatus) void coursesTableManager::influnceCourseChanged(bool ignoreCourseStatus)
{ {
if (ignoreCourseStatus) if (ignoreCourseStatus)
{ {
int i = 0; int i = 0;
while (i < courseTBL->rowCount()) while (i < courseTBL->rowCount())
{ {
if (courseTBL->item(i,Course::CourseScheme::POINTS)->text().compare("0") == 0) if (courseTBL->item(i,gradeCourse::CourseScheme::POINTS)->text().compare("0") == 0)
courseTBL->removeRow(i--); courseTBL->removeRow(i--);
i++; i++;
} }
} }
else else
{ {
for (Course *c: *gp->getCourses()) for (gradeCourse *c: *gp->getCourses())
{ {
if (!(isCourseAlreadyInserted(c->getSerialNum()))) if (!(isCourseAlreadyInserted(c->getSerialNum())))
if (c->getPoints() == 0) if (c->getPoints() == 0)
addRow(c); addRow(c);
} }
} }
} }
void coursesTableManager::clearTable() void coursesTableManager::clearTable()
{ {
if (courseTBL->rowCount() == 0) if (courseTBL->rowCount() == 0)
return; return;
int i = 0; //starting point int i = 0; //starting point
while (courseTBL->rowCount() > i) while (courseTBL->rowCount() > i)
{ {
gp->removeCourse(courseTBL->item(i,Course::CourseScheme::SERIAL)->text().toStdString()); gp->removeCourse(courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text().toStdString());
courseTBL->removeRow(i); courseTBL->removeRow(i);
} }
gp = NULL; gp = NULL;
courseTBL->repaint(); courseTBL->repaint();
} }
Course *coursesTableManager::getCourseByRow(int row) gradeCourse *coursesTableManager::getCourseByRow(int row)
{ {
QString courseSerial = courseTBL->item(row,Course::CourseScheme::SERIAL)->text(); QString courseSerial = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text();
for (Course *c: *gp->getCourses()) for (gradeCourse *c: *gp->getCourses())
{ {
if (c->getSerialNum() == courseSerial.toDouble()) if (c->getSerialNum() == courseSerial.toDouble())
return c; return c;
} }
return NULL; return NULL;
} }
bool coursesTableManager::isCourseAlreadyInserted(double courseID) bool coursesTableManager::isCourseAlreadyInserted(double courseID)
{ {
int i=0; int i=0;
for (i = 0; i < courseTBL->rowCount(); ++i) for (i = 0; i < courseTBL->rowCount(); ++i)
{ {
QString courseSerial = courseTBL->item(i,Course::CourseScheme::SERIAL)->text(); QString courseSerial = courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text();
if (QString::number(courseID) == courseSerial) if (QString::number(courseID) == courseSerial)
return true; return true;
} }
return false; return false;
} }
bool coursesTableManager::isCourseInfluence(const Course *courseToCheck) bool coursesTableManager::isCourseInfluence(const gradeCourse *courseToCheck)
{ {
if (courseToCheck->getPoints() > 0) if (courseToCheck->getPoints() > 0)
return true; return true;
return false; return false;
} }

View file

@ -1,43 +1,43 @@
#ifndef COURSESTABLEMANAGER_H #ifndef COURSESTABLEMANAGER_H
#define COURSESTABLEMANAGER_H #define COURSESTABLEMANAGER_H
#include <QApplication> #include <QApplication>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QHeaderView> #include <QHeaderView>
#include <QMessageBox> #include <QMessageBox>
#include <QTableWidget> #include <QTableWidget>
#include <QString> #include <QString>
#include <QMessageBox> #include <QMessageBox>
#include <list> #include <list>
#include "src/grades/GradePage.h" #include "./src/jceData/Grades/gradePage.h"
#include "src/user.h" #include "./src/jceSettings/user.h"
class coursesTableManager class coursesTableManager
{ {
public: public:
coursesTableManager(QTableWidget *, user *usrPtr); coursesTableManager(QTableWidget *, user *usrPtr);
~coursesTableManager(); ~coursesTableManager();
void insertJceCoursesIntoTable(); void insertJceCoursesIntoTable();
void setCoursesList(std::string &htmlPage); void setCoursesList(std::string &htmlPage);
bool changes(QString change, int row, int col); bool changes(QString change, int row, int col);
void addRow(const Course * courseToAdd = 0); void addRow(const gradeCourse * courseToAdd = 0);
double getAvg(); double getAvg();
void influnceCourseChanged(bool status); void influnceCourseChanged(bool status);
void clearTable(); void clearTable();
private: private:
QTableWidget *courseTBL; QTableWidget *courseTBL;
GradePage *gp; GradePage *gp;
user *us; user *us;
Course * getCourseByRow(int row); gradeCourse * getCourseByRow(int row);
bool isCourseAlreadyInserted(double courseID); bool isCourseAlreadyInserted(double courseID);
bool isCourseInfluence(const Course *courseToCheck); bool isCourseInfluence(const gradeCourse *courseToCheck);
}; };
#endif // COURSESTABLEMANAGER_H #endif // COURSESTABLEMANAGER_H

View file

@ -1,133 +1,141 @@
#include "loginhandler.h" #include "loginhandler.h"
loginHandler::loginHandler(user *ptr): logggedInFlag(false) loginHandler::loginHandler(user *ptr): logggedInFlag(false)
{ {
this->jceLog = new jceLogin(ptr); this->jceLog = new jceLogin(ptr);
} }
void loginHandler::setPointers(QLabel *statusLabelPtr,QLineEdit *pswdEditPtr,QLineEdit *usrnmEditPtr) void loginHandler::setPointers(QLabel *statusLabelPtr,QLineEdit *pswdEditPtr,QLineEdit *usrnmEditPtr)
{ {
this->statusLabelPtr = statusLabelPtr; this->statusLabelPtr = statusLabelPtr;
this->pswdEditPtr = pswdEditPtr; this->pswdEditPtr = pswdEditPtr;
this->usrnmEditPtr = usrnmEditPtr; this->usrnmEditPtr = usrnmEditPtr;
} }
bool loginHandler::makeConnection() bool loginHandler::makeConnection()
{ {
if (this->jceLog == NULL) if (this->jceLog == NULL)
return false; return false;
try try
{ {
jceLog->makeConnection(); jceLog->makeConnection();
} }
catch (jceLogin::jceStatus &a) catch (jceLogin::jceStatus &a)
{ {
int status = (int)a; int status = (int)a;
switch (status) switch (status)
{ {
case jceLogin::JCE_YOU_ARE_IN: case jceLogin::JCE_YOU_ARE_IN:
{ {
logggedInFlag = true; logggedInFlag = true;
return logggedInFlag; return logggedInFlag;
break; break;
} }
case jceLogin::ERROR_ON_VALIDATION: case jceLogin::ERROR_ON_VALIDATION:
{ {
popMessage("Please Check Your Username & Password",false); popMessage("Please Check Your Username & Password",false);
usrnmEditPtr->setDisabled(false); usrnmEditPtr->setDisabled(false);
pswdEditPtr->setDisabled(false); pswdEditPtr->setDisabled(false);
pswdEditPtr->selectAll(); pswdEditPtr->selectAll();
pswdEditPtr->setFocus(); pswdEditPtr->setFocus();
return false; return false;
} }
case jceLogin::ERROR_ON_VALIDATION_USER_BLOCKED: case jceLogin::ERROR_ON_VALIDATION_USER_BLOCKED:
{ {
popMessage("You have been blocked by JCE, please try in a couple of minutes."); popMessage("You have been blocked by JCE, please try in a couple of minutes.");
jceLog->closeAll(); jceLog->closeAll();
return false; return false;
} }
case jceLogin::ERROR_ON_OPEN_SOCKET: case jceLogin::ERROR_ON_OPEN_SOCKET:
{ {
popMessage("Please Check Your Internet Connection."); popMessage("Please Check Your Internet Connection.");
jceLog->closeAll(); jceLog->closeAll();
return false; return false;
} }
case jceLogin::JCE_NOT_CONNECTED: case jceLogin::JCE_NOT_CONNECTED:
{ {
jceLog->reConnect(); jceLog->reConnect();
/* /*
* Fix: need to add promte window to ask user whenever he wants to reconnect or not * Fix: need to add a prompte window to ask user whether he wants to reconnect or not
*/ */
break; break;
} }
case jceLogin::ERROR_ON_GETTING_INFO: case jceLogin::ERROR_ON_GETTING_INFO:
{ {
popMessage("Recieve Request Time Out."); popMessage("Recieve Request Time Out.");
jceLog->closeAll(); jceLog->closeAll();
return false; return false;
break; break;
} }
case jceLogin::ERROR_ON_SEND_REQUEST: case jceLogin::ERROR_ON_SEND_REQUEST:
{ {
popMessage("Send Request Time Out."); popMessage("Send Request Time Out.");
jceLog->closeAll(); jceLog->closeAll();
return false; return false;
break; break;
} }
} }
} }
return false; return false;
} }
bool loginHandler::isLoggedInFlag() bool loginHandler::isLoggedInFlag()
{ {
return this->logggedInFlag; return this->logggedInFlag;
} }
void loginHandler::setLoginFlag(bool flag) void loginHandler::setLoginFlag(bool flag)
{ {
this->logggedInFlag = flag; this->logggedInFlag = flag;
} }
QString loginHandler::getCurrentPageContect() QString loginHandler::getCurrentPageContect()
{ {
QTextEdit phrase; QTextEdit phrase;
if (isLoggedInFlag()) if (isLoggedInFlag())
phrase.setText(QString::fromStdString(jceLog->getPage())); phrase.setText(QString::fromStdString(jceLog->getPage()));
else else
throw jceLogin::ERROR_ON_GETTING_INFO; throw jceLogin::ERROR_ON_GETTING_INFO;
return phrase.toPlainText(); return phrase.toPlainText();
} }
void loginHandler::makeDisconnectionRequest() void loginHandler::makeDisconnectionRequest()
{ {
jceLog->closeAll(); jceLog->closeAll();
this->logggedInFlag = false; this->logggedInFlag = false;
} }
int loginHandler::makeGradeRequest() int loginHandler::makeGradeRequest(int fromYear, int toYear, int fromSemester, int toSemester)
{ {
if (isLoggedInFlag()) if (isLoggedInFlag())
return jceLog->getGrades(); return jceLog->getGrades(fromYear, toYear, fromSemester, toSemester);
else else
return jceLogin::JCE_NOT_CONNECTED; return jceLogin::JCE_NOT_CONNECTED;
} }
void loginHandler::popMessage(QString message,bool addInfo)
{ int loginHandler::makeCalendarRequest(int year, int semester)
if (addInfo) {
message.append("\nIf this message appear without reason, please contact me at liranbg@gmail.com"); if (isLoggedInFlag())
return jceLog->getCalendar(year,semester);
QMessageBox msgBox; else
msgBox.setWindowTitle("Error"); return jceLogin::JCE_NOT_CONNECTED;
msgBox.setText(message); }
msgBox.exec(); void loginHandler::popMessage(QString message,bool addInfo)
msgBox.setFocus(); {
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();
}

View file

@ -1,42 +1,44 @@
#ifndef LOGINHANDLER_H #ifndef LOGINHANDLER_H
#define LOGINHANDLER_H #define LOGINHANDLER_H
#include <QString> #include <QString>
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
#include <QTextEdit> #include <QTextEdit>
#include <QMessageBox> #include <QMessageBox>
#include <QPixmap> #include <QPixmap>
#include "src/jce/jcelogin.h" #include "./src/jceSettings/jcelogin.h"
#include "./src/data/savedata.h" #include "./src/appDatabase/savedata.h"
class loginHandler class loginHandler
{ {
public: public:
loginHandler(user *ptr); loginHandler(user *ptr);
void setPointers(QLabel *statusLabelPtr,QLineEdit *pswdEditPtr,QLineEdit *usrnmEditPtr); void setPointers(QLabel *statusLabelPtr,QLineEdit *pswdEditPtr,QLineEdit *usrnmEditPtr);
bool makeConnection(); bool makeConnection();
bool isLoggedInFlag(); bool isLoggedInFlag();
void setLoginFlag(bool flag); void setLoginFlag(bool flag);
QString getCurrentPageContect(); QString getCurrentPageContect();
int makeGradeRequest();
int makeGradeRequest(int fromYear, int toYear, int fromSemester, int toSemester);
void makeDisconnectionRequest(); int makeCalendarRequest(int year,int semester);
private: void makeDisconnectionRequest();
void popMessage(QString message, bool addInfo = true); private:
bool logggedInFlag; void popMessage(QString message, bool addInfo = true);
jceLogin *jceLog;
bool logggedInFlag;
QLabel *statusLabelPtr; jceLogin *jceLog;
QLineEdit *pswdEditPtr;
QLineEdit *usrnmEditPtr; QLabel *statusLabelPtr;
QLineEdit *pswdEditPtr;
QLineEdit *usrnmEditPtr;
};
#endif // LOGINHANDLER_H };
#endif // LOGINHANDLER_H

View file

@ -6,7 +6,7 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
{ {
ui->setupUi(this); ui->setupUi(this);
this->setFixedSize(this->size()); //main not resizeable //this->setFixedSize(this->size()); //main not resizeable
//Login Tab //Login Tab
@ -21,9 +21,8 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
ui->statusBar->addPermanentWidget(statusLabel,1); ui->statusBar->addPermanentWidget(statusLabel,1);
setLabelConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED); setLabelConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED);
//Course and Setting Tab //Course, Setting, Calendar Tab
ui->CoursesTab->setDisabled(true); ui->CoursesTab->setDisabled(true);
ui->SettingsTab->setDisabled(true);
ui->avgLCD->setPalette(QPalette(QPalette::WindowText,Qt::blue)); 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->userLoginSetting = new user("","");
this->courseTableMgr = new coursesTableManager(ui->coursesTable,userLoginSetting); this->courseTableMgr = new coursesTableManager(ui->coursesTable,userLoginSetting);
this->loginHandel = new loginHandler(userLoginSetting); this->loginHandel = new loginHandler(userLoginSetting);
this->calendar = new CalendarManager(ui->calendartext);
updateDates();
//check login File //check login File
SaveData::init(); SaveData::init();
@ -60,6 +58,24 @@ void MainScreen::on_loginButton_clicked()
uiSetConnectMode(); uiSetConnectMode();
} }
void MainScreen::on_pushButton_clicked()
{
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 if (status == jceLogin::JCE_NOT_CONNECTED)
{
QMessageBox::critical(this,tr("Error"),tr("Not Connected"));
}
}
}
void MainScreen::on_ratesButton_clicked() void MainScreen::on_ratesButton_clicked()
{ {
@ -67,7 +83,7 @@ void MainScreen::on_ratesButton_clicked()
int status = 0; int status = 0;
if (loginHandel->isLoggedInFlag()) 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(); pageString = loginHandel->getCurrentPageContect().toStdString();
courseTableMgr->setCoursesList(pageString); courseTableMgr->setCoursesList(pageString);
@ -82,51 +98,50 @@ void MainScreen::on_ratesButton_clicked()
} }
void MainScreen::on_spinBoxFromYear_editingFinished() void MainScreen::on_checkBoxCoursesInfluence_toggled(bool checked)
{ {
if (ui->spinBoxFromYear->value() > ui->spinBoxToYear->value()) this->userLoginSetting->setInfluenceCourseOnly(checked);
{ this->courseTableMgr->influnceCourseChanged(checked);
ui->spinBoxFromYear->setValue(ui->spinBoxToYear->value());
ui->spinBoxFromYear->setFocus();
updateDates();
}
else
updateDates();
} }
void MainScreen::on_spinBoxToYear_editingFinished() void MainScreen::on_spinBoxCoursesFromYear_editingFinished()
{ {
if (ui->spinBoxFromYear->value() > ui->spinBoxToYear->value()) if (ui->spinBoxCoursesFromYear->value() > ui->spinBoxCoursesToYear->value())
{ {
ui->spinBoxToYear->setValue(ui->spinBoxFromYear->value()); ui->spinBoxCoursesFromYear->setValue(ui->spinBoxCoursesToYear->value());
ui->spinBoxToYear->setFocus(); ui->spinBoxCoursesFromYear->setFocus();
updateDates();
} }
else
updateDates();
} }
void MainScreen::on_spinBoxFromSem_editingFinished() void MainScreen::on_spinBoxCoursesToYear_editingFinished()
{ {
if (ui->spinBoxFromYear->value() == ui->spinBoxToYear->value()) if (ui->spinBoxCoursesFromYear->value() > ui->spinBoxCoursesToYear->value())
{ {
if (ui->spinBoxFromSem->value() > ui->spinBoxToSemester->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->spinBoxFromSem->setValue(ui->spinBoxToSemester->value()); ui->spinBoxCoursesFromSemester->setValue(ui->spinBoxCoursesToSemester->value());
ui->spinBoxFromSem->setFocus(); ui->spinBoxCoursesFromSemester->setFocus();
} }
} }
updateDates();
} }
void MainScreen::on_spinBoxToSemester_editingFinished() void MainScreen::on_spinBoxCoursesToSemester_editingFinished()
{ {
if (ui->spinBoxFromYear->value() == ui->spinBoxToYear->value()) if (ui->spinBoxCoursesFromYear->value() == ui->spinBoxCoursesToYear->value())
{ {
if (ui->spinBoxFromSem->value() > ui->spinBoxToSemester->value()) if (ui->spinBoxCoursesFromSemester->value() > ui->spinBoxCoursesToSemester->value())
{ {
ui->spinBoxToSemester->setValue(ui->spinBoxFromSem->value()); ui->spinBoxCoursesToSemester->setValue(ui->spinBoxCoursesFromSemester->value());
ui->spinBoxToSemester->setFocus(); ui->spinBoxCoursesToSemester->setFocus();
} }
} }
updateDates();
} }
void MainScreen::on_coursesTable_itemChanged(QTableWidgetItem *item) void MainScreen::on_coursesTable_itemChanged(QTableWidgetItem *item)
@ -137,27 +152,10 @@ void MainScreen::on_coursesTable_itemChanged(QTableWidgetItem *item)
QMessageBox::critical(this,"Error","Missmatching data"); QMessageBox::critical(this,"Error","Missmatching data");
} }
void MainScreen::on_checkBox_toggled(bool checked)
{
this->userLoginSetting->setInfluenceCourseOnly(checked);
this->courseTableMgr->influnceCourseChanged(checked);
}
void MainScreen::on_usrnmLineEdit_editingFinished() void MainScreen::on_usrnmLineEdit_editingFinished()
{ {
ui->usrnmLineEdit->setText(ui->usrnmLineEdit->text().toLower()); ui->usrnmLineEdit->setText(ui->usrnmLineEdit->text().toLower());
} }
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() void MainScreen::uiSetDisconnectMode()
{ {
setLabelConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED); setLabelConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED);
@ -199,7 +197,6 @@ void MainScreen::uiSetConnectMode() //fix before distrbute
ui->loginButton->setText("&Logout"); ui->loginButton->setText("&Logout");
this->ui->ratesButton->setEnabled(true); this->ui->ratesButton->setEnabled(true);
ui->CoursesTab->setEnabled(true); ui->CoursesTab->setEnabled(true);
ui->SettingsTab->setEnabled(true);
} }
else else
@ -284,3 +281,5 @@ void MainScreen::on_actionHow_To_triggered()
"</ul>"); "</ul>");
} }

View file

@ -10,8 +10,9 @@
#include <string> #include <string>
#include <iostream> #include <iostream>
#include "coursestablemanager.h" #include "./CourseTab/coursestablemanager.h"
#include "loginhandler.h" #include "./LoginTab/loginhandler.h"
#include "./CalendarTab/CalendarManager.h"
#define StatusIconHeight 35 #define StatusIconHeight 35
namespace Ui { namespace Ui {
@ -30,18 +31,16 @@ private slots:
void on_ratesButton_clicked(); 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_loginButton_clicked();
void on_checkBox_toggled(bool checked);
void on_usrnmLineEdit_editingFinished(); void on_usrnmLineEdit_editingFinished();
void on_actionCredits_triggered(); void on_actionCredits_triggered();
@ -56,9 +55,12 @@ private slots:
void on_actionHow_To_triggered(); void on_actionHow_To_triggered();
void on_pushButton_clicked();
void on_checkBoxCoursesInfluence_toggled(bool checked);
private: private:
void updateDates();
void uiSetDisconnectMode(); void uiSetDisconnectMode();
void uiSetConnectMode(); void uiSetConnectMode();
void setLabelConnectionStatus(jceLogin::jceStatus statusDescription); void setLabelConnectionStatus(jceLogin::jceStatus statusDescription);
@ -67,6 +69,7 @@ private:
user *userLoginSetting; user *userLoginSetting;
CalendarManager * calendar;
coursesTableManager *courseTableMgr; coursesTableManager *courseTableMgr;
loginHandler *loginHandel; loginHandler *loginHandel;

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>855</width> <width>855</width>
<height>649</height> <height>517</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -21,7 +21,7 @@
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="../resources/connectionstatus.qrc"> <iconset resource="../resources/connectionstatus.qrc">
<normaloff>:/icons/icon.png</normaloff>:/icons/icon.png</iconset> <normaloff>:/icons/icon.ico</normaloff>:/icons/icon.ico</iconset>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">#centralWidget <string notr="true">#centralWidget
@ -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> <enum>QTabWidget::Rounded</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<property name="documentMode"> <property name="documentMode">
<bool>false</bool> <bool>false</bool>
@ -303,7 +303,7 @@ font-size: 15px;
<string notr="true"/> <string notr="true"/>
</property> </property>
<attribute name="title"> <attribute name="title">
<string>Courses</string> <string>GPA</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_4"> <layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0"> <item row="0" column="0">
@ -311,7 +311,7 @@ font-size: 15px;
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0"> <item row="3" column="0">
<widget class="QTableWidget" name="coursesTable"> <widget class="QTableWidget" name="coursesTable">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
@ -330,7 +330,7 @@ font-size: 15px;
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="4" column="0">
<layout class="QHBoxLayout" name="coursesTableControlHorizontalLayout"> <layout class="QHBoxLayout" name="coursesTableControlHorizontalLayout">
<item> <item>
<layout class="QHBoxLayout" name="coursesButtonLayout"> <layout class="QHBoxLayout" name="coursesButtonLayout">
@ -375,7 +375,7 @@ font-size: 15px;
<item> <item>
<layout class="QHBoxLayout" name="AvghorizontalLayout"> <layout class="QHBoxLayout" name="AvghorizontalLayout">
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="labelAverage">
<property name="text"> <property name="text">
<string>Average:</string> <string>Average:</string>
</property> </property>
@ -410,260 +410,211 @@ font-size: 15px;
</item> </item>
</layout> </layout>
</item> </item>
</layout> <item row="0" column="0">
</item> <layout class="QHBoxLayout" name="horizontalLayout_5">
</layout> <item>
</widget> <widget class="QCheckBox" name="checkBoxCoursesInfluence">
<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">
<property name="text"> <property name="text">
<string>Only influence Courses</string> <string>Only Main Courses</string>
</property> </property>
<property name="checked"> </widget>
<bool>false</bool> </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> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </item>
</item> </layout>
</layout> </item>
</widget> </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>
</widget> </widget>
</item> </item>
@ -675,7 +626,7 @@ font-size: 15px;
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>855</width> <width>855</width>
<height>29</height> <height>21</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuA_about"> <widget class="QMenu" name="menuA_about">
@ -723,15 +674,9 @@ font-size: 15px;
<tabstop>usrnmLineEdit</tabstop> <tabstop>usrnmLineEdit</tabstop>
<tabstop>pswdLineEdit</tabstop> <tabstop>pswdLineEdit</tabstop>
<tabstop>loginButton</tabstop> <tabstop>loginButton</tabstop>
<tabstop>tabWidget</tabstop>
<tabstop>ratesButton</tabstop> <tabstop>ratesButton</tabstop>
<tabstop>clearTableButton</tabstop> <tabstop>clearTableButton</tabstop>
<tabstop>checkBox</tabstop>
<tabstop>spinBoxFromSem</tabstop>
<tabstop>coursesTable</tabstop> <tabstop>coursesTable</tabstop>
<tabstop>spinBoxFromYear</tabstop>
<tabstop>spinBoxToSemester</tabstop>
<tabstop>spinBoxToYear</tabstop>
</tabstops> </tabstops>
<resources> <resources>
<include location="../resources/connectionstatus.qrc"/> <include location="../resources/connectionstatus.qrc"/>

View file

@ -1,8 +1,8 @@
<RCC> <RCC>
<qresource prefix="/icons"> <qresource prefix="/icons">
<file>blueStatusIcon.png</file> <file>blueStatusIcon.png</file>
<file>greenStatusIcon.png</file> <file>greenStatusIcon.png</file>
<file>redStatusIcon.png</file> <file>redStatusIcon.png</file>
<file>icon.png</file> <file>icon.ico</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -57,3 +57,4 @@ private:
}; };
#endif // SAVEDATA_H #endif // SAVEDATA_H

View file

@ -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;
}

View file

@ -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] == '&')
{
//&nbsp;
std::string nbspChr = from.substr(index, 6);
if (nbspChr == "&nbsp;")
{
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;
}

View file

@ -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()
{
}

View file

@ -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

View 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;
}

View 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

View 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;
}

View 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

View 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;
}

View file

@ -1,64 +1,53 @@
#ifndef COURSE_H #ifndef GRADE_COURSE_H
#define COURSE_H #define GRADE_COURSE_H
/* This Code Made By Sagi Dayan /* This Code Made By Sagi Dayan
* SagiDayan@gmail.com * SagiDayan@gmail.com
* *
* Minor changes has been made by Liran Ben Gida * Minor changes has been made by Liran Ben Gida
* LiranBG@gmail.com * LiranBG@gmail.com
*/ */
#include "../course.h"
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <list> #include <list>
#define COURSE_FIELDS 7 #define COURSE_FIELDS 7
#define NO_GRADE_YET 101; #define NO_GRADE_YET 101;
class Course{ class gradeCourse : public Course {
public: public:
enum CourseScheme enum CourseScheme
{ {
SERIAL, SERIAL,
NAME, NAME,
TYPE, TYPE,
POINTS, POINTS,
HOURS, HOURS,
GRADE, GRADE,
ADDITION ADDITION
}; };
Course(int serial,std::string name, std::string type, double points, double hours, double grade, std::string additions); gradeCourse(int serial, std::string name, std::string type, double points,double hours, double grade, std::string additions);
~Course(); ~gradeCourse();
int getSerialNum() const {return this->serialNum;} double getHours() const {return this->hours;}
std::string getName() const {return this->name;} double getGrade() const ;
std::string getType() const {return this->type;} std::string getAddidtions() const {return this->additions;}
double getPoints() const {return this->points;}
double getHours() const {return this->hours;} void setHours(double hours);
double getGrade() const ; void setGrade(double grade);
std::string getAddidtions() const {return this->additions;} void setAdditions(std::string additions);
void setName(std::string name); private:
void setType(std::string type);
void setPoints(double points); double hours;
void setHours(double hours); double grade;
void setGrade(double grade); std::string additions;
void setAdditions(std::string additions); };
private:
int serialNum; #endif
std::string name;
std::string type;
double points;
double hours;
double grade;
std::string additions;
};
#endif

View file

@ -1,178 +1,172 @@
#include "GradePage.h" #include "gradePage.h"
GradePage::GradePage(std::string html) : Page(html) GradePage::GradePage(std::string html) : Page()
{ {
courses = new std::list<Course*>(); this->courses = new std::list<gradeCourse*>();
tempHtml = getString(); this->tempHtml = getString(html);
genList(); this->tempHtml = tokenToLines(this->tempHtml);
coursesListInit(this->tempHtml);
}
GradePage::~GradePage() }
{ GradePage::~GradePage()
for(Course* c : *courses) {
delete c; for(Course* c : *courses)
delete courses; delete c;
} delete courses;
void GradePage::genList() }
{
void GradePage::addCourse(gradeCourse *a)
this->tempHtml = tokenToLines( this->tempHtml , INFO_DATA_LINES_BEFORE_GRADES_DATA ); {
GradePage::courses->push_back(a);
coursesListInit(this->tempHtml); return;
}
}
void GradePage::addCourse(Course *a) void GradePage::removeCourse(std::string courseSerialID)
{ {
GradePage::courses->push_back(a); for(gradeCourse* c : *courses)
return; {
} if (c->getSerialNum() == stoi(courseSerialID))
{
void GradePage::removeCourse(std::string courseSerialID) courses->remove(c);
{ delete c;
for(Course* c : *courses) return;
{ }
if (c->getSerialNum() == stoi(courseSerialID)) }
{
courses->remove(c); }
delete c; void GradePage::coursesListInit(std::string& linesTokinzedString)
return; {
} std::list<std::string> stringHolder;
} std::string temp;
gradeCourse* cTemp = NULL;
} char* tok;
void GradePage::coursesListInit(std::string& linesTokinzedString) char* textToTok = strdup(linesTokinzedString.c_str());
{ tok = strtok(textToTok,"\n");
std::list<std::string> stringHolder; while (tok != NULL)
std::string temp; {
Course* cTemp = NULL; temp = tok;
char* tok; stringHolder.push_back(temp);
char* textToTok = strdup(linesTokinzedString.c_str()); tok = strtok(NULL, "\n");
tok = strtok(textToTok,"\n"); }
while (tok != NULL) for(std::string temp: stringHolder)
{ {
temp = tok; cTemp = lineToCourse(temp);
stringHolder.push_back(temp); if (cTemp != NULL)
tok = strtok(NULL, "\n"); addCourse(cTemp);
} }
for(std::string temp: stringHolder) }
{
cTemp = lineToCourse(temp); std::string GradePage::tokenToLines(std::string& textToPhrase)
if (cTemp != NULL) {
addCourse(cTemp); int ctr = 0;
} std::string temp = "";
} char *tok;
char* textToTok = strdup(textToPhrase.c_str());
std::string GradePage::tokenToLines(std::string& textToPhrase,int fromLine) tok = strtok(textToTok, "\n");
{ while(tok != NULL)
int ctr = 0; {
std::string temp = ""; //amount of data before the actual needed data and no empty lines
char *tok; if (strcmp(tok," \t ") != 0)
char* textToTok = strdup(textToPhrase.c_str()); {
tok = strtok(textToTok, "\n"); temp += tok;
while(tok != NULL) temp += "\n";
{ }
//amount of data before the actual needed data and no empty lines ctr++;
if ((ctr >= fromLine) && (strcmp(tok," \t ") != 0)) tok = strtok(NULL, "\n");
{ }
temp += tok; return temp;
temp += "\n";
} }
ctr++; gradeCourse* GradePage::lineToCourse(std::string line)
tok = strtok(NULL, "\n"); {
} gradeCourse *tempC = NULL;
return temp; std::string templinearray[COURSE_FIELDS];//[serial,name,type,points,hours,grade,additions]
int serial;
} double points,hours,grade;
Course* GradePage::lineToCourse(std::string line) std::string name,type, additions;
{ std::string tempS = "";
Course *tempC = NULL; int i = 0;
std::string templinearray[COURSE_FIELDS];//[serial,name,type,points,hours,grade,additions] char* tok;
int serial; char* cLine = strdup(line.c_str());
double points,hours,grade; tok = strtok(cLine, "\t");
std::string name,type, additions; while(tok != NULL)
std::string tempS = ""; {
int i = 0;
char* tok; tempS = tok;
char* cLine = strdup(line.c_str()); if (i == 1) //skip the tokenizing loop just once
tok = strtok(cLine, "\t"); {
while(tok != NULL) tempS = "";
{ char *tokTemp;
tokTemp = tok;
tempS = tok;
if (i == 1) //skip the tokenizing loop just once while (!(isdigit((int)*tokTemp)))
{ tokTemp++;
tempS = "";
char *tokTemp; while (isdigit((int)*tokTemp))
tokTemp = tok; {
tempS += *tokTemp;
while (!(isdigit((int)*tokTemp))) tokTemp++;
tokTemp++; }
templinearray[i-1] = tempS;
while (isdigit((int)*tokTemp)) templinearray[i] = tokTemp;
{
tempS += *tokTemp; }
tokTemp++; else if (i > 1)
} templinearray[i] = tempS;
templinearray[i-1] = tempS; i++;
templinearray[i] = tokTemp; tok=strtok(NULL, "\t");
}
} if (templinearray[0] == "") //empty phrasing
else if (i > 1) return NULL;
templinearray[i] = tempS;
i++; serial = stoi(templinearray[gradeCourse::CourseScheme::SERIAL]);
tok=strtok(NULL, "\t");
} name = templinearray[gradeCourse::CourseScheme::NAME];
if (templinearray[0] == "") //empty phrasing type = templinearray[gradeCourse::CourseScheme::TYPE];
return NULL;
points = stod(templinearray[gradeCourse::CourseScheme::POINTS]);
serial = stoi(templinearray[Course::CourseScheme::SERIAL]); hours = stod(templinearray[gradeCourse::CourseScheme::HOURS]);
name = templinearray[Course::CourseScheme::NAME]; if (isGradedYet(templinearray[gradeCourse::CourseScheme::GRADE]))
type = templinearray[Course::CourseScheme::TYPE]; grade = stod(templinearray[gradeCourse::CourseScheme::GRADE]);
else
points = stod(templinearray[Course::CourseScheme::POINTS]); grade = NO_GRADE_YET;
hours = stod(templinearray[Course::CourseScheme::HOURS]);
additions = templinearray[gradeCourse::CourseScheme::ADDITION];
if (isGradedYet(templinearray[Course::CourseScheme::GRADE]))
grade = stod(templinearray[Course::CourseScheme::GRADE]); tempC = new gradeCourse(serial,name,type,points,hours,grade,additions);
else return tempC;
grade = NO_GRADE_YET; }
additions = templinearray[Course::CourseScheme::ADDITION]; //checking if one of the chars inside grade is not a number
bool GradePage::isGradedYet(std::string grade)
tempC = new Course(serial,name,type,points,hours,grade,additions); {
return tempC; if (strlen(grade.c_str()) <= 1)
} return false;
//checking if one of the chars inside grade is not a number for (char c: grade)
bool GradePage::isGradedYet(std::string grade) {
{ if (c == '\0')
if (strlen(grade.c_str()) <= 1) break;
return false; if (((!isdigit((int)c)) && (!isspace((int)c)))) //48 = 0, 57 = 9
return false;
for (char c: grade)
{ }
if (c == '\0') return true;
break; }
if (((!isdigit((int)c)) && (!isspace((int)c)))) //48 = 0, 57 = 9 double GradePage::getAvg()
return false; {
double avg = 0;
} double points = 0;
return true; for(gradeCourse* c : *courses)
} {
double GradePage::getAvg() if ((c->getGrade() != 0))
{ {
double avg = 0; avg += c->getGrade() * c->getPoints();
double points = 0; points += c->getPoints();
for(Course* c : *courses) }
{ }
if ((c->getGrade() != 0))
{ avg /= points;
avg += c->getGrade() * c->getPoints(); return avg;
points += c->getPoints(); }
}
}
avg /= points;
return avg;
}

View file

@ -1,48 +1,45 @@
#ifndef GRADE_PAGE_H #ifndef GRADE_PAGE_H
#define GRADE_PAGE_H #define GRADE_PAGE_H
/* This Code Made By Sagi Dayan /* This Code Made By Sagi Dayan
* SagiDayan@gmail.com * SagiDayan@gmail.com
* *
* Minor changes has been made by Liran Ben Gida * Minor changes has been made by Liran Ben Gida
* LiranBG@gmail.com * LiranBG@gmail.com
*/ */
#include "Page.h" #include "../page.h"
#include "Course.h" #include "../Grades/gradeCourse.h"
#include <list> #include <list>
#include <string.h> //strlen and strtok to phrase the html file #include <string.h> //strlen and strtok to phrase the html file
#include <ctype.h> //checks if character is numeric #include <ctype.h> //checks if character is numeric
#define INFO_DATA_LINES_BEFORE_GRADES_DATA 5 class GradePage : public Page
{
class GradePage : public Page
{ public:
GradePage(std::string html);
public: ~GradePage();
GradePage(std::string html);
~GradePage(); void addCourse(gradeCourse *);
void removeCourse(std::string courseSerialID);
void addCourse(Course *); double getAvg();
void removeCourse(std::string courseSerialID);
double getAvg(); std::list<gradeCourse*>* getCourses() { return courses; }
std::list<Course*>* getCourses() { return courses; } private:
private: std::string tokenToLines(std::string& textToPhrase);
void coursesListInit(std::string& linesTokinzedString);
void genList(); gradeCourse* lineToCourse(std::string line);
std::string tokenToLines(std::string& textToPhrase,int fromLine = 0);
void coursesListInit(std::string& linesTokinzedString); bool isGradedYet(std::string grade);
Course* lineToCourse(std::string line);
std::list<gradeCourse*>* courses;
bool isGradedYet(std::string grade); std::string tempHtml;
std::list<Course*>* courses; };
std::string tempHtml;
}; #endif
#endif

View file

@ -1,42 +1,39 @@
#ifndef PAGE_H #ifndef PAGE_H
#define PAGE_H #define PAGE_H
/* This Code Made By Sagi Dayan /* This Code Made By Sagi Dayan
* SagiDayan@gmail.com * SagiDayan@gmail.com
* *
* Minor changes has been made by Liran Ben Gida * Minor changes has been made by Liran Ben Gida
* LiranBG@gmail.com * LiranBG@gmail.com
*/ */
#include <iostream> #include <iostream>
#include <string> #include <string>
class Page class Page
{ {
public: public:
~Page() {} ~Page() {}
protected: protected:
Page(std::string& html); Page();
std::string getString(); std::string getString(std::string& htmlToPhrased);
std::string getTitle(); void makeText(std::string& html);
void makeText(std::string& html);
private:
private:
int runToActualText(std::string& from, int index);
void manageTableContent(std::string& html, int index);
int findTitle(std::string& from, int index); int stitchText(std::string& from, std::string& to, int index);
int runToActualText(std::string& from, int index); bool endOfString(int index, int length);
void manageTableContent(std::string& html, int index);
int stitchText(std::string& from, std::string& to, int index); std::string text;
bool endOfString(int index, int length); std::string title;
std::string text; };
std::string title;
#endif
};
#endif

49
src/jceData/course.h Normal file
View 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
View 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] == '&')
{
//&nbsp;
std::string nbspChr = from.substr(index, 6);
if (nbspChr == "&nbsp;")
{
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;
}

View file

@ -1,72 +1,87 @@
#ifndef JCELOGINHTMLSCRIPTS_H #ifndef JCELOGINHTMLSCRIPTS_H
#define JCELOGINHTMLSCRIPTS_H #define JCELOGINHTMLSCRIPTS_H
#include <string> #include <string>
#define dst_host "yedion.jce.ac.il" #define dst_host "yedion.jce.ac.il"
#define dst_port 443 #define dst_port 443
#include "../user.h" #include "./src/jceSettings/user.h"
class jceLoginHtmlScripts class jceLoginHtmlScripts
{ {
private: private:
jceLoginHtmlScripts(); jceLoginHtmlScripts();
public: public:
static std::string makeRequest(std::string parameters) static std::string makeRequest(std::string parameters)
{ {
std::string msg; std::string msg;
msg = "POST /yedion/fireflyweb.aspx HTTP/1.1\r\n"; msg = "POST /yedion/fireflyweb.aspx HTTP/1.1\r\n";
msg += "Host: " + std::string(dst_host) + "\r\n"; msg += "Host: " + std::string(dst_host) + "\r\n";
msg += "Content-Type: application/x-www-form-urlencoded\r\n"; msg += "Content-Type: application/x-www-form-urlencoded\r\n";
msg += "Content-Length: " + to_string(parameters.length()) + "\r\n"; msg += "Content-Length: " + to_string(parameters.length()) + "\r\n";
msg += "Proxy-Connection: Keep-Alive\r\n"; msg += "Proxy-Connection: Keep-Alive\r\n";
msg += "Accept-Charset: utf-8"; msg += "Accept-Charset: utf-8";
msg += "Accept: text/plain\r\n"; msg += "Accept: text/plain\r\n";
msg += "Connection: Keep-Alive\r\n"; msg += "Connection: Keep-Alive\r\n";
msg += "\r\n"; msg += "\r\n";
msg += parameters; msg += parameters;
return msg; return msg;
} }
const static std::string getFirstValidationStep(const user &usr) const static std::string getFirstValidationStep(const user &usr)
{ {
std::string parameters = "?appname=BSHITA&prgname=LoginValidation&arguments=-N"; std::string parameters = "?appname=BSHITA&prgname=LoginValidation&arguments=-N";
parameters += usr.getUsername(); parameters += usr.getUsername();
parameters += ",-N"; parameters += ",-N";
parameters += usr.getPassword(); parameters += usr.getPassword();
return parameters; return parameters;
} }
const static std::string getSecondValidationStep(const user &usr) const static std::string getSecondValidationStep(const user &usr)
{ {
std::string parameters; std::string parameters;
parameters = "prgname=LoginValidtion1&Arguments=-N"; parameters = "prgname=LoginValidtion1&Arguments=-N";
parameters += usr.getUserID(); parameters += usr.getUserID();
parameters += ",-A,-N"; parameters += ",-A,-N";
parameters += usr.getHashedPassword(); parameters += usr.getHashedPassword();
parameters += ",-A,-A"; parameters += ",-A,-A";
return parameters; return parameters;
} }
const static std::string getGradesPath(const user &usr) const static std::string getGradesPath(const user &usr,
{ int fromYear,
std::string parameters; int toYear,
parameters = "PRGNAME=HADPASAT_MISMAHIM_LETALMID&ARGUMENTS=TZ,-N4,R1C2,R1C4,R1C1,R1C3,-A,-A,R1C5,-A,UNIQ&"; int fromSemester,
parameters += "TZ=" + usr.getUserID() + "&"; int toSemester)
parameters += "UNIQ=" + usr.getHashedPassword() + "&"; {
parameters += "R1C2=" + usr.date->getFYear() + "&"; std::string parameters;
parameters += "R1C1=" + usr.date->getTYear() + "&"; parameters = "PRGNAME=HADPASAT_MISMAHIM_LETALMID&ARGUMENTS=TZ,-N4,R1C2,R1C4,R1C1,R1C3,-A,-A,R1C5,-A,UNIQ&";
parameters += "R1C3=" + usr.date->getTSemester() + "&"; parameters += "TZ=" + usr.getUserID() + "&";
parameters += "R1C4=" + usr.date->getFSemester() + "&"; parameters += "UNIQ=" + usr.getHashedPassword() + "&";
parameters += "R1C5=0"; parameters += "R1C2=" + std::to_string(fromYear) + "&";
return parameters; parameters += "R1C1=" + std::to_string(toYear) + "&";
} parameters += "R1C3=" + std::to_string(toSemester) + "&";
parameters += "R1C4=" + std::to_string(fromSemester) + "&";
parameters += "R1C5=0";
}; return parameters;
}
#endif // JCELOGINHTMLSCRIPTS_H 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

View file

@ -1,213 +1,229 @@
#include "jcelogin.h" #include "jcelogin.h"
jceLogin::jceLogin(user * username) jceLogin::jceLogin(user * username)
{ {
this->recieverPage = new std::string(); this->recieverPage = new std::string();
this->jceA = username; this->jceA = username;
this->JceConnector = new jceSSLClient(); this->JceConnector = new jceSSLClient();
} }
jceLogin::~jceLogin() jceLogin::~jceLogin()
{ {
this->jceA = NULL; this->jceA = NULL;
delete recieverPage; delete recieverPage;
delete JceConnector; delete JceConnector;
JceConnector = NULL; JceConnector = NULL;
recieverPage = NULL; recieverPage = NULL;
} }
/** /**
* @brief jceLogin::makeConnection Connecting to JCE student web site with JceA (username object) and validate it. * @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 * throws error upon the given error from JCE website or Socket error
*/ */
void jceLogin::makeConnection() throw (jceStatus) void jceLogin::makeConnection() throw (jceStatus)
{ {
if (this->recieverPage == NULL) if (this->recieverPage == NULL)
this->recieverPage = new std::string(); this->recieverPage = new std::string();
if (JceConnector->makeConnect(dst_host,dst_port) == false) if (JceConnector->makeConnect(dst_host,dst_port) == false)
throw jceStatus::ERROR_ON_OPEN_SOCKET; throw jceStatus::ERROR_ON_OPEN_SOCKET;
int returnMode; int returnMode;
jceStatus status = jceStatus::JCE_NOT_CONNECTED; jceStatus status = jceStatus::JCE_NOT_CONNECTED;
returnMode = checkConnection(); returnMode = checkConnection();
if (returnMode == true) //connected to host if (returnMode == true) //connected to host
{ {
returnMode = makeFirstVisit(); returnMode = makeFirstVisit();
if (returnMode == true) //requst and send first validation if (returnMode == true) //requst and send first validation
{ {
status = jceStatus::JCE_START_VALIDATING_PROGRESS; status = jceStatus::JCE_START_VALIDATING_PROGRESS;
returnMode = checkValidation(); returnMode = checkValidation();
if (returnMode == true) //check if username and password are matching if (returnMode == true) //check if username and password are matching
{ {
status = jceStatus::JCE_VALIDATION_PASSED; status = jceStatus::JCE_VALIDATION_PASSED;
returnMode = makeSecondVisit(); returnMode = makeSecondVisit();
if (returnMode == true) //siging in the website if (returnMode == true) //siging in the website
{ {
status = jceStatus::JCE_YOU_ARE_IN; status = jceStatus::JCE_YOU_ARE_IN;
setLoginFlag(true); setLoginFlag(true);
} }
else if (returnMode == jceLogin::ERROR_ON_GETTING_INFO) else if (returnMode == jceLogin::ERROR_ON_GETTING_INFO)
{ {
status = jceLogin::ERROR_ON_GETTING_INFO; status = jceLogin::ERROR_ON_GETTING_INFO;
} }
else if (returnMode == jceLogin::ERROR_ON_SEND_REQUEST) else if (returnMode == jceLogin::ERROR_ON_SEND_REQUEST)
{ {
status = jceLogin::ERROR_ON_SEND_REQUEST; status = jceLogin::ERROR_ON_SEND_REQUEST;
} }
else else
status = jceStatus::ERROR_ON_VALIDATION; status = jceStatus::ERROR_ON_VALIDATION;
} }
else else
status = jceStatus::ERROR_ON_VALIDATION; status = jceStatus::ERROR_ON_VALIDATION;
} }
else if (returnMode == jceLogin::ERROR_ON_GETTING_INFO) else if (returnMode == jceLogin::ERROR_ON_GETTING_INFO)
{ {
status = jceLogin::ERROR_ON_GETTING_INFO; status = jceLogin::ERROR_ON_GETTING_INFO;
} }
else if (returnMode == jceLogin::ERROR_ON_SEND_REQUEST) else if (returnMode == jceLogin::ERROR_ON_SEND_REQUEST)
{ {
status = jceLogin::ERROR_ON_SEND_REQUEST; status = jceLogin::ERROR_ON_SEND_REQUEST;
} }
else else
status = jceStatus::ERROR_ON_VALIDATION_USER_BLOCKED; status = jceStatus::ERROR_ON_VALIDATION_USER_BLOCKED;
} }
else else
status = jceStatus::JCE_NOT_CONNECTED; status = jceStatus::JCE_NOT_CONNECTED;
//we throw status even if we are IN! //we throw status even if we are IN!
throw status; throw status;
} }
bool jceLogin::checkConnection() bool jceLogin::checkConnection()
{ {
if (JceConnector->isConnected()) if (JceConnector->isConnected())
return true; return true;
return false; return false;
} }
void jceLogin::reConnect() throw (jceStatus) void jceLogin::reConnect() throw (jceStatus)
{ {
closeAll(); closeAll();
if (this->JceConnector != NULL) if (this->JceConnector != NULL)
delete JceConnector; delete JceConnector;
this->recieverPage = new std::string(); this->recieverPage = new std::string();
this->JceConnector = new jceSSLClient(); this->JceConnector = new jceSSLClient();
try try
{ {
makeConnection(); makeConnection();
} }
catch (jceLogin::jceStatus &a) catch (jceLogin::jceStatus &a)
{ {
throw a; throw a;
} }
} }
void jceLogin::closeAll() void jceLogin::closeAll()
{ {
JceConnector->makeDiconnect(); JceConnector->makeDiconnect();
delete recieverPage; delete recieverPage;
recieverPage = NULL; recieverPage = NULL;
loginFlag = false; loginFlag = false;
} }
int jceLogin::makeFirstVisit() int jceLogin::makeFirstVisit()
{ {
std::string usr = jceA->getUsername(); std::string usr = jceA->getUsername();
std::string psw = jceA->getPassword(); std::string psw = jceA->getPassword();
if (JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getFirstValidationStep(*jceA)))) if (JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getFirstValidationStep(*jceA))))
{ {
if (!JceConnector->recieveData(*recieverPage,true)) if (!JceConnector->recieveData(*recieverPage,true))
return jceLogin::ERROR_ON_GETTING_INFO; return jceLogin::ERROR_ON_GETTING_INFO;
} }
else else
return jceLogin::ERROR_ON_SEND_REQUEST; return jceLogin::ERROR_ON_SEND_REQUEST;
return true; return true;
} }
int jceLogin::makeSecondVisit() int jceLogin::makeSecondVisit()
{ {
std::string usrid=jceA->getUserID(); std::string usrid=jceA->getUserID();
std::string pswid=jceA->getHashedPassword(); std::string pswid=jceA->getHashedPassword();
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getSecondValidationStep(*jceA))))) if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getSecondValidationStep(*jceA)))))
{ {
if (!(JceConnector->recieveData(*recieverPage,true))) if (!(JceConnector->recieveData(*recieverPage,true)))
return jceLogin::ERROR_ON_GETTING_INFO; return jceLogin::ERROR_ON_GETTING_INFO;
return true; return true;
} }
else else
return jceLogin::ERROR_ON_SEND_REQUEST; return jceLogin::ERROR_ON_SEND_REQUEST;
return true; return true;
} }
int jceLogin::getGrades() int jceLogin::getCalendar(int year, int semester)
{ {
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getGradesPath(*jceA))))) if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getCalendar(*jceA,year,semester)))))
{ {
if (!(JceConnector->recieveData(*recieverPage,false))) if (!(JceConnector->recieveData(*recieverPage,false)))
return jceLogin::ERROR_ON_GETTING_GRADES; return jceLogin::ERROR_ON_GETTING_GRADES;
else else
return jceLogin::JCE_GRADE_PAGE_PASSED; return jceLogin::JCE_GRADE_PAGE_PASSED;
} }
else else
return jceLogin::ERROR_ON_SEND_REQUEST; return jceLogin::ERROR_ON_SEND_REQUEST;
return true; return true;
} }
int jceLogin::getGrades(int fromYear, int toYear, int fromSemester, int toSemester)
void jceLogin::setLoginFlag(bool x) {
{ std::cout << fromYear << " " << toYear << " " << fromSemester << " " << toSemester << std::endl;
this->loginFlag = x; if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getGradesPath(*jceA,fromYear, toYear, fromSemester, toSemester)))))
} {
bool jceLogin::isLoginFlag() const if (!(JceConnector->recieveData(*recieverPage,false)))
{ return jceLogin::ERROR_ON_GETTING_GRADES;
return this->loginFlag; else
} return jceLogin::JCE_GRADE_PAGE_PASSED;
}
std::string jceLogin::getPage() else
{ return jceLogin::ERROR_ON_SEND_REQUEST;
return *recieverPage;
} return true;
/** }
* @brief jceLogin::checkValidation Made by Nadav Luzzato
* @return true if second validation step is right void jceLogin::setLoginFlag(bool x)
*/ {
bool jceLogin::checkValidation() this->loginFlag = x;
{ }
//finds the hashed password bool jceLogin::isLoginFlag() const
std::size_t hasspass_position1,hasspass_position2; {
return this->loginFlag;
if ((hasspass_position1 = recieverPage->find("-A,-N")) == string::npos) }
return false;
hasspass_position1 += 5; std::string jceLogin::getPage()
if ((hasspass_position2 = recieverPage->find(",-A,-A", hasspass_position1)) == string::npos) {
return false; return *recieverPage;
}
std::string hasspass = recieverPage->substr(hasspass_position1,hasspass_position2-hasspass_position1);
jceA->setHashedPassword(hasspass); /**
* @brief jceLogin::checkValidation Made by Nadav Luzzato
//finds the user id * @return true if second validation step is right
std::size_t id_position1 = recieverPage->find("value=\"-N", 0); */
id_position1 += 9; bool jceLogin::checkValidation()
std::size_t id_position2 = recieverPage->find(",-A", id_position1); {
if ((id_position2 != std::string::npos) && (id_position1 != std::string::npos)) //finds the hashed password
{ std::size_t hasspass_position1,hasspass_position2;
std::string hassid = recieverPage->substr(id_position1,id_position2-id_position1);
jceA->setUserID(hassid); if ((hasspass_position1 = recieverPage->find("-A,-N")) == string::npos)
} return false;
if (((jceA->getUserID()).empty()) || ((jceA->getHashedPassword()).empty())) hasspass_position1 += 5;
return false; if ((hasspass_position2 = recieverPage->find(",-A,-A", hasspass_position1)) == string::npos)
return false;
return true;
} 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;
}

View file

@ -1,59 +1,60 @@
#ifndef JCELOGIN_H #ifndef JCELOGIN_H
#define JCELOGIN_H #define JCELOGIN_H
#include <string> #include <string>
#include <fstream> #include <fstream>
#include "../connection/jcesslclient.h" #include "./src/jceConnection/jcesslclient.h"
#include "../user.h" #include "./src/jceSettings/user.h"
#include "jceLoginHtmlScripts.h" #include "jceLoginHtmlScripts.h"
class jceLogin class jceLogin
{ {
public: public:
enum jceStatus { enum jceStatus {
JCE_NOT_CONNECTED, JCE_NOT_CONNECTED,
ERROR_ON_VALIDATION, ERROR_ON_VALIDATION,
ERROR_ON_VALIDATION_USER_BLOCKED, ERROR_ON_VALIDATION_USER_BLOCKED,
ERROR_ON_OPEN_SOCKET, ERROR_ON_OPEN_SOCKET,
ERROR_ON_SEND_REQUEST, ERROR_ON_SEND_REQUEST,
ERROR_ON_GETTING_INFO, ERROR_ON_GETTING_INFO,
ERROR_ON_GETTING_GRADES, ERROR_ON_GETTING_GRADES,
JCE_START_VALIDATING_PROGRESS, JCE_START_VALIDATING_PROGRESS,
JCE_VALIDATION_PASSED, JCE_VALIDATION_PASSED,
JCE_YOU_ARE_IN, JCE_YOU_ARE_IN,
JCE_GRADE_PAGE_PASSED JCE_GRADE_PAGE_PASSED
}; };
jceLogin(user* username); jceLogin(user* username);
~jceLogin(); ~jceLogin();
void makeConnection() throw (jceStatus); void makeConnection() throw (jceStatus);
bool checkConnection(); bool checkConnection();
void reConnect() throw (jceStatus); void reConnect() throw (jceStatus);
void closeAll(); void closeAll();
int getGrades(); int getCalendar(int year, int semester);
bool isLoginFlag() const; int getGrades(int fromYear, int toYear, int fromSemester, int toSemester);
bool isLoginFlag() const;
std::string getPage();
std::string getPage();
private:
int makeFirstVisit(); private:
bool checkValidation(); int makeFirstVisit();
int makeSecondVisit(); bool checkValidation();
void setLoginFlag(bool x); int makeSecondVisit();
void setLoginFlag(bool x);
bool loginFlag;
std::string * recieverPage; bool loginFlag;
user * jceA; std::string * recieverPage;
jceSSLClient * JceConnector; user * jceA;
jceSSLClient * JceConnector;
};
};
#endif // JCELOGIN_H
#endif // JCELOGIN_H

View file

@ -1,52 +1,45 @@
#include "user.h" #include "user.h"
user::user(string username,string password) : hashedPassword(""),userID(""), influenceCourseOnly(false) user::user(string username,string password) : hashedPassword(""),userID(""), influenceCourseOnly(false)
{ {
this->username = username; this->username = username;
this->password = password; this->password = password;
} }
user::~user() user::~user()
{ {
delete date; }
}
void user::setDate(std::string fromYear, std::string fromSemester, std::string toYear, std::string toSemester)
{ void user::setInfluenceCourseOnly(bool status)
date->setFYear(fromYear); {
date->setFSemester(fromSemester); this->influenceCourseOnly = status;
date->setTYear(toYear); }
date->setTSemester(toSemester);
} bool user::getInfluenceCourseOnly() const
{
void user::setInfluenceCourseOnly(bool status) return this->influenceCourseOnly;
{ }
this->influenceCourseOnly = status;
} void user::setUsername(string& username) {
this->username=username;
bool user::getInfluenceCourseOnly() const }
{
return this->influenceCourseOnly; void user::setPassword(string& password) {
} this->password=password;
}
void user::setUsername(string& username) {
this->username=username; void user::setUserID(string& ID)
} {
this->userID = ID;
void user::setPassword(string& password) { }
this->password=password; void user::setHashedPassword(string& hashpass)
} {
this->hashedPassword = hashpass;
void user::setUserID(string& ID) }
{
this->userID = ID; string user::getPassword() const { return password; }
} string user::getUsername() const { return username; }
void user::setHashedPassword(string& hashpass) string user::getUserID() const { return userID; }
{ string user::getHashedPassword() const { return hashedPassword; }
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; }

View file

@ -1,48 +1,43 @@
#ifndef user_H #ifndef user_H
#define user_H #define user_H
#include <string> #include <string>
#include <iostream> #include <iostream>
#include "jce/jcedate.h"
using namespace std;
using namespace std; class user
class user {
{ public:
public: user(string username,string password);
user(string username,string password); ~user();
~user(); void setUsername(string& username);
void setUsername(string& username); void setPassword(string& password);
void setPassword(string& password);
string getPassword() const;
string getPassword() const; string getUsername() const;
string getUsername() const;
void setUserID(string& ID);
void setUserID(string& ID); void setHashedPassword(string& hashpass);
void setHashedPassword(string& hashpass);
string getUserID() const;
string getUserID() const; string getHashedPassword() const;
string getHashedPassword() const;
void setInfluenceCourseOnly(bool status);
void setDate(std::string fromYear, std::string fromSemester, std::string toYear, std::string toSemester); bool getInfluenceCourseOnly() const;
void setInfluenceCourseOnly(bool status); private:
bool getInfluenceCourseOnly() const;
string username;
jceDate * const date = new jceDate("","","",""); //we do not change the pointer string password;
private: string hashedPassword;
string userID;
string username;
string password; bool influenceCourseOnly;
string hashedPassword;
string userID;
};
bool influenceCourseOnly; #endif
};
#endif