Merging r732:766 from trunk to branches/0.3.
[quassel.git] / src / common / util.h
1 /***************************************************************************
2  *   Copyright (C) 2005/06 by the Quassel Project                          *
3  *   devel@quassel-irc.org                                                 *
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; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef _UTIL_H_
22 #define _UTIL_H_
23
24 #include <QDir>
25 #include <QIODevice>
26 #include <QVariant>
27 #include <QString>
28 #include <QMetaMethod>
29
30
31 // TODO Use versions from Network instead
32 QString nickFromMask(QString mask);
33 QString userFromMask(QString mask);
34 QString hostFromMask(QString mask);
35 bool isChannelName(QString str);
36
37
38 QString secondsToString(int timeInSeconds);
39
40 //! Take a string and decode it using the specified text codec, recognizing utf8.
41 /** This function takes a string and first checks if it is encoded in utf8, in which case it is
42  *  decoded appropriately. Otherwise, the specified text codec is used to transform the string.
43  *  \param input The input string containing encoded data
44  *  \param codec The text codec we use if the input is not utf8
45  *  \return The decoded string.
46  */
47 QString decodeString(const QByteArray &input, QTextCodec *codec = 0);
48
49 // NOTE: We have static copies of these in SignalProxy...
50 //void writeDataToDevice(QIODevice *, const QVariant &);
51 //bool readDataFromDevice(QIODevice *, quint32 &, QVariant &);
52
53 uint editingDistance(const QString &s1, const QString &s2);
54
55 QByteArray methodName(const QMetaMethod &method);
56
57 QDir quasselDir();
58
59 #endif