Initial commit
[keepassx] / src / lib / tools.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2008 by Tarek Saidi                                *
3  *   tarek.saidi@arcor.de                                                  *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; version 2 of the License.               *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18  ***************************************************************************/ 
19 #ifndef TOOLS_H
20 #define TOOLS_H
21
22 class IEntryHandle;
23
24 enum tKeyType {PASSWORD=0,KEYFILE=1,BOTH=2};
25 struct Translation {
26         QString nameCode;
27         QString nameLong;
28         QString nameEnglish;
29         QString author;
30 };
31 bool operator<(const Translation& t1, const Translation& t2);
32
33 #define CSTR(x)(QTextCodec::codecForLocale()->fromUnicode(x).constData())
34
35 const QIcon& getIcon(const QString& name);
36 const QPixmap* getPixmap(const QString& name);
37 void createBanner(QPixmap* Pixmap, const QPixmap* IconAlpha,const QString& Text,int Width);
38 void createBanner(QPixmap* Pixmap, const QPixmap* IconAlpha,const QString& Text,int Width,
39                                   QColor Color1, QColor Color2, QColor TextColor);
40 void openBrowser(const QString& UrlString);
41 void openBrowser(IEntryHandle* entry);
42 void showErrMsg(const QString& msg,QWidget* parent=NULL);
43 QString decodeFileError(QFile::FileError Code);
44 QString makePathRelative(const QString& Abs,const QString& Cur);
45 QString getImageFile(const QString& name);
46 bool createKeyFile(const QString& filename,QString* err, int length=32, bool Hex=true);
47 bool lockPage(void* addr, int len);
48 bool unlockPage(void* addr, int len);
49 bool syncFile(QFile* file);
50 void installTranslator();
51 bool isTranslationActive();
52 QList<Translation> getAllTranslations();
53 #ifdef Q_OS_WIN
54         #ifndef CSIDL_APPDATA
55                 #define CSIDL_APPDATA 0x001a // <username>\Application Data
56         #endif
57         QString qtWindowsConfigPath(int type);
58 #endif
59
60 #endif //TOOLS_H