| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2012 Ricardo Villalba <[email protected]>
|
|---|
| 3 |
|
|---|
| 4 | This program is free software; you can redistribute it and/or modify
|
|---|
| 5 | it under the terms of the GNU General Public License as published by
|
|---|
| 6 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 7 | (at your option) any later version.
|
|---|
| 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 Free Software
|
|---|
| 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 | #include "mplayerversion.h"
|
|---|
| 20 | #include "global.h"
|
|---|
| 21 | #include "preferences.h"
|
|---|
| 22 |
|
|---|
| 23 | #include <QRegExp>
|
|---|
| 24 |
|
|---|
| 25 | using namespace Global;
|
|---|
| 26 |
|
|---|
| 27 | QString MplayerVersion::mplayer2_version;
|
|---|
| 28 | bool MplayerVersion::is_mplayer2 = false;
|
|---|
| 29 |
|
|---|
| 30 | int MplayerVersion::mplayerVersion(QString string) {
|
|---|
| 31 | //static QRegExp rx_mplayer_revision("^MPlayer (\\S+)-SVN-r(\\d+)-(.*)");
|
|---|
| 32 | static QRegExp rx_mplayer_revision("^MPlayer (.*)[-\\.]r(\\d+)(.*)");
|
|---|
| 33 | static QRegExp rx_mplayer_version("^MPlayer ([a-z,0-9,.]+)-(.*)");
|
|---|
| 34 | static QRegExp rx_mplayer_git("^MPlayer GIT(.*)", Qt::CaseInsensitive);
|
|---|
| 35 | static QRegExp rx_mplayer_version_final("1.0rc([0-9])");
|
|---|
| 36 | static QRegExp rx_mplayer2_version("^MPlayer2 (.*) \\(C\\).*", Qt::CaseInsensitive);
|
|---|
| 37 | #ifndef Q_OS_WIN
|
|---|
| 38 | static QRegExp rx_mplayer_version_ubuntu("^MPlayer (\\d):(\\d)\\.(\\d)~(.*)");
|
|---|
| 39 | static QRegExp rx_mplayer_version_mandriva("^MPlayer ([a-z0-9\\.]+)-\\d+\\.([a-z0-9]+)\\.[\\d\\.]+[a-z]+[\\d\\.]+-(.*)");
|
|---|
| 40 | #endif
|
|---|
| 41 |
|
|---|
| 42 | int mplayer_svn = 0;
|
|---|
| 43 | mplayer2_version = QString::null;
|
|---|
| 44 | is_mplayer2 = false;
|
|---|
| 45 |
|
|---|
| 46 | #ifdef Q_OS_WIN
|
|---|
| 47 | // Hack to recognize mplayer 1.0rc2 from CCCP:
|
|---|
| 48 | if (string.startsWith("MPlayer CCCP ")) {
|
|---|
| 49 | string.remove("CCCP ");
|
|---|
| 50 | qDebug("MplayerVersion::mplayerVersion: removing CCCP: '%s'", string.toUtf8().data());
|
|---|
| 51 | }
|
|---|
| 52 | #else
|
|---|
| 53 | // Hack to recognize mplayer 1.0rc1 from Ubuntu:
|
|---|
| 54 | if (rx_mplayer_version_ubuntu.indexIn(string) > -1) {
|
|---|
| 55 | int v1 = rx_mplayer_version_ubuntu.cap(2).toInt();
|
|---|
| 56 | int v2 = rx_mplayer_version_ubuntu.cap(3).toInt();
|
|---|
| 57 | QString rest = rx_mplayer_version_ubuntu.cap(4);
|
|---|
| 58 | //qDebug("%d - %d - %d", rx_mplayer_version_ubuntu.cap(1).toInt(), v1 , v2);
|
|---|
| 59 | string = QString("MPlayer %1.%2%3").arg(v1).arg(v2).arg(rest);
|
|---|
| 60 | qDebug("MplayerVersion::mplayerVersion: line converted to '%s'", string.toUtf8().data());
|
|---|
| 61 | }
|
|---|
| 62 | // Hack to recognize mplayer version from Mandriva:
|
|---|
| 63 | if (rx_mplayer_version_mandriva.indexIn(string) > -1) {
|
|---|
|
|---|