1 /* VLC-REMOTE for MAEMO 5
2 * Copyright (C) 2010 Schutz Sacha <istdasklar@gmail.com>, Dru Moore <usr@dru-id.co.uk>, Yann Nave <yannux@onbebop.net>
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2,
5 * or (at your option) any later version, as published by the Free
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #include <QStringList>
19 #include <QNetworkInterface>
20 #include "appsettings.h"
22 AppSettings::AppSettings() {
25 AppSettings::~AppSettings() {
28 bool AppSettings::isConnected() {
29 QNetworkInterface wlan = QNetworkInterface::interfaceFromName("wlan0");
30 QNetworkInterface gprs = QNetworkInterface::interfaceFromName("gprs0");
32 if( (wlan.isValid() && wlan.flags().testFlag(QNetworkInterface::IsUp)) || (gprs.isValid() && gprs.flags().testFlag(QNetworkInterface::IsUp)) )
41 QString AppSettings::getCurrentKey() {
43 return sets.value("config/currentKey", "").toString();
45 QString AppSettings::getCurrentIp() {
47 return sets.value("account/" + getCurrentKey(), "").toString();
49 VlcDirectory AppSettings::getHomeDirectory() {
52 home.name = sets.value("config/accounts/" + getCurrentKey() + "/homeDirName", "Default").toString();
53 home.path = sets.value("config/accounts/" + getCurrentKey() + "/homeDirPath", "~/").toString();
56 bool AppSettings::setHomeDirectory(VlcDirectory dir) {
58 sets.setValue("config/accounts/" + getCurrentKey() + "/homeDirName", dir.name);
59 sets.setValue("config/accounts/" + getCurrentKey() + "/homeDirPath", dir.path);
62 QList<VlcDirectory>* AppSettings::getFavourites() {
64 QList<VlcDirectory> * favourites = new QList<VlcDirectory>();
66 sets.beginGroup("config/accounts/" + getCurrentKey() + "/favourites");
67 foreach ( QString key, sets.allKeys())
73 dir.path = sets.value(key, "~/").toString();
74 favourites->append(dir);
79 bool AppSettings::addFavourite(VlcDirectory dir) {
81 // should check for existing first otherwise it overwrites
82 if (0 < sets.value("config/accounts/" + getCurrentKey() + "/favourites/" + dir.name, "").toString().length()) {
83 dir.name = "_" + dir.name;
84 return addFavourite(dir);
86 sets.setValue("config/accounts/" + getCurrentKey() + "/favourites/" + dir.name, dir.path);
89 bool AppSettings::deleteFavourite(VlcDirectory dir) {
91 sets.remove("config/accounts/" + getCurrentKey() + "/favourites/" + dir.name);
94 int AppSettings::getStatusPollTimeout() {
95 return STATUS_POLL_TIMEOUT;
97 int AppSettings::getPingTimeout() {
100 int AppSettings::getConnectionTimeout() {
101 return CONNECTION_TIMEOUT;
103 int AppSettings::getRetrieveArtTimeout() {
104 return RETRIEVE_ART_TIMEOUT;
106 int AppSettings::getRetryNetworkTimeout() {
107 return RETRY_NETWORK_TIMEOUT;
109 bool AppSettings::getShowUnknownFileTypes() {
110 return SHOW_UNKNOWN_FILETYPES;
112 Orientation AppSettings::setOrientation(Orientation orientation) {
114 sets.setValue("config/orientation", (int)orientation);
117 Orientation AppSettings::getOrientation() {
119 return (Orientation)(sets.value("config/orientation", AUTO_ROTATE).toInt());