forked from WorldsOfBabylon/ISIS-Messanger
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdbmain.hpp
49 lines (39 loc) · 1.28 KB
/
dbmain.hpp
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
#ifndef FRIENDSDB_H
#define FRIENDSDB_H
#include"dbabstract.h"
class dbmain : public dbAbstract
{
private:
void install(void);
bool installed;
public:
DB_ABSTRACT_HPP;
void query(void){};
QMap<QString, QVariant> getFriend(const char * nickname){
this->q.prepare("Select * from Friends where nick=:nick");
this->q.bindValue(":nick", nickname);
this->q.exec();
return this->q.boundValues();
}
bool getInstalled(void){
return this->installed;
}
bool addFriend(const char * nickname, const char * pubkey){
if (getIDFromNickname(nickname) != -1 ) return false;
this->q.prepare("Insert into Friends(nickname, pubkey) values(:nickname, :pubkey);");
this->q.bindValue(":nickname",nickname);
this->q.bindValue(":pubkey",pubkey);
return true;
}
QMap<QString, QVariant> getLastMessage(const char * nickname){
this->q.prepare("Select * from Messages where from=:nick");
this->q.bindValue(":nick", nickname);
this->q.exec();
return this->q.boundValues();
}
void addMessage(const char * message, int, bool); // one = self
QList<QString> * getMessages(const char * nickname);
dbmain();
dbmain(bool installing);
};
#endif // FRIENDSDB_H