-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
189 lines (161 loc) · 7.34 KB
/
main.cpp
File metadata and controls
189 lines (161 loc) · 7.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#include <iostream>
#include"headers/PathManager.h"
#include "headers/Task.h"
#include "headers/Visuals.h"
#include "headers/base64.h"
#include "headers/inputtask.h"
#include "headers/taghandler.h"
#include "headers/table.h"
#include "headers/aes128.h"
#include "headers/initializer.h"
#include "headers/outputtask.h"
#include "headers/attachment.h"
#include "headers/inputhandler.h"
using namespace std;
int main(int argc, char *argv[]) {
//=================================================main body of code starts here == you may comment them while testing=====================================
verybegin:
try {
core::initializer maininitializer;
if (argc == 1) {
begin:
core::Visuals::showintro();
if (!maininitializer.dotsymfolderchecker()) {
maininitializer.initialize();
goto begin;
} else {
maininitializer.enterpassword();
maininitializer.decrypttaskfile();
core::table mytable1;
//mytable1.showTable();
start:
//cin.ignore();
string input;
cout << "Enter your command >> ";
cin >> input;
if(input == "insert"){core::inputtask myinput; myinput.insert();}
else if(input == "insert-tag"){core::taghandler mytaghandler; mytaghandler.inputtag();}
else if(input == "show-attachment") {core::attachment myattachment; myattachment.showattachment();}
else if(input == "history") {core::outputtask myoutput; myoutput.printHistory();}
else if(input == "show-profile"){core::Visuals::showporfile();}
else if(input == "show-expired") {core::outputtask myoutput; myoutput.showExpired();}
else if(input == "show-urgent"){core::outputtask myoutput; myoutput.showUrgent();}
else if(input == "show-important"){core::outputtask myoutput; myoutput.showImportant();}
else if(input == "show-noturgent"){core::outputtask myoutput; myoutput.shownotUrgent();}
else if(input == "show-notimportant"){core::outputtask myoutput; myoutput.shownotImportant();}
else if(input == "show-urgent-important"){core::outputtask myoutput; myoutput.showUrgentImportant();}
else if(input == "show-urgent-notimportant"){core::outputtask myoutput; myoutput.showUrgentnotImportant();}
else if(input == "show-noturgent-important"){core::outputtask myoutput; myoutput.shownotUrgentImportant();}
else if(input == "show-noturgent-notimportant"){core::outputtask myoutput; myoutput.shownotUrgentnotImportant();}
else if(input == "edit-task") { core::inputhandler myoutput; myoutput.editTask();}
else if(input == "delete-task") { core::inputhandler myoutput; myoutput.deleteTask();}
else if (input == "help") core::Visuals::showhelp();
else if(input == "version") core::Visuals::showversion();
else if(input == "randomizer") core::Visuals::randomiser();
else if (input == "show-table") {core::table mytable;mytable.showTable();}
else if (input == "clear") system("clear"); //system("cls");
else if (input == "exit") {maininitializer.exithandler();}
else cout << "Invalid command" << endl;
if (input != "exit") {
goto start;
}
}
}
else if(argc == 2)
{
string input = argv[1];
if(input == "--help") core::Visuals::showhelp();
else if(input == "--version") core::Visuals::showversion();
else if(input == "--randomizer") core::Visuals::randomiser();
else if(input == "--clear") system("clear");
else if(input == "--cleanup") { core::initializer maininitializer; maininitializer.cleanup();}
else cout << "Invalid command" << endl;
}
}
catch (const std::exception &e) {
std::cerr << e.what() << '\n';
}
catch(core::initializer::filenotcreated &e)
{
std::cerr << "Error: File not created" << '\n';
}
catch(core::initializer::couldntencrypterrr &e)
{
std::cerr << "Error: Could not encrypt the file" << '\n';
}
catch(core::initializer::couldntdecrypterrr &e)
{
std::cout << "Error: Could not decrypt the file" << '\n';
std::cout << "Do you want to try again?(y/n): ";
char choice;
std::cin >> choice;
if(choice == 'y')
{
goto verybegin;
}
else
{
std::cout << "Exiting the program" << std::endl;
exit(0);
}
}
//==========================================test=here=====comment=after=testing==========================================
//std::cout << "Hello, World!" << std::endl;
// std::cout<< "MY PROJECT";
// core::PathManager mypath;
// cout<< mypath.gethome()<< endl;
// cout << mypath.getsymfolder() << endl;
// core::Task mytask("1^presentation^make the presentation slides^project^23/05/2023^NULL");
// cout<< mytask.gettaskname()<<endl;
// cout<< mytask.gettaskdetail()<<endl;
// cout<< mytask.gettasktag()<<endl;
// cout<< mytask.getattachment()<<endl;
// cout<< mytask.getdatedate()<<endl;
// cout<< mytask.getdatemonth()<<endl;
// cout<< mytask.getdateyear()<<endl;
// cout<< mytask.isUrgent()<<endl;
// std::string s = crypto::base64::encode("1^presentation^make the \npresentation slides^project^23/05/2023^NULL");
// cout << s << endl;
// cout << crypto::base64::encode(mytask.gettaskname()) << endl;
// cout << crypto::base64::decode(s) << endl;
// core::Task mytask("presentation","make the presentation slides","project","23/05/2023","NULL");
// cout <<"Task: "<< mytask.gettaskname() << endl;
// cout << mytask.packtask() << endl;
// std::string testData = "Hello";
// std::string encodedData = crypto::base64::encode(testData);
// std::string decodedData = crypto::base64::decode(encodedData);
// cout << "Original: " << testData << endl;
// cout << "Encoded: " << encodedData << endl;
// cout << "Decoded: " << decodedData << endl;
//core::inputtask myinputtask;
//myinputtask.insert();
// core::Visuals::asciiArtedName();
// core::taghandler mytaghandler("1^project");
// cout << mytaghandler.gettagname() << endl;
// cout << mytaghandler.getimportance() << endl;
// core::taghandler mytaghandler2("1^project");
// mytaghandler2.inserttag();
// core::table mytable;
// mytable.showTable();
// core::PathManager p;
// crypto::aes128 myaes;
// string password = "12345";
// cin >> password;
// myaes.encryptfile(p.gettaskfile(),p.getencryptedtaskfile(),password);
// //cin >> password;
// remove(p.gettaskfile().c_str());
// //myaes.decryptfile(p.getencryptedtaskfile(),p.gettaskfile(),password);
// core::initializer myinitializer;
// myinitializer.enterpassword();
// myinitializer.decrypttaskfile();
// core::initializer maininitializer;
// if (!maininitializer.dotsymfolderchecker()) {
// maininitializer.initialize();
// }
// maininitializer.enterpassword();
// maininitializer.decrypttaskfile();
// core::initializer myinitializer;
// myinitializer.enterpassword();
// myinitializer.decrypttaskfile();
return 0;
}