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 QStringList AppSettings::getAllAccounts() {
44 sets.beginGroup("account");
45 accounts = sets.allKeys();
49 QString AppSettings::getCurrentKey() {
51 return sets.value("config/currentKey", "").toString();
53 void AppSettings::setCurrentKey(QString key) {
55 sets.setValue("config/currentKey", key);
57 QString AppSettings::getCurrentIp() {
59 return sets.value("account/" + getCurrentKey(), "").toString();
61 void AppSettings::setCurrentIp(QString ip) {
63 sets.setValue("account/" + getCurrentKey(), ip);
65 VlcDirectory AppSettings::getHomeDirectory() {
68 home.name = sets.value("config/accounts/" + getCurrentKey() + "/homeDirName", "Default").toString();
69 home.path = sets.value("config/accounts/" + getCurrentKey() + "/homeDirPath", "~/").toString();
72 bool AppSettings::setHomeDirectory(VlcDirectory dir) {
74 sets.setValue("config/accounts/" + getCurrentKey() + "/homeDirName", dir.name);
75 sets.setValue("config/accounts/" + getCurrentKey() + "/homeDirPath", dir.path);
78 QList<VlcDirectory>* AppSettings::getFavourites() {
80 QList<VlcDirectory> * favourites = new QList<VlcDirectory>();
82 sets.beginGroup("config/accounts/" + getCurrentKey() + "/favourites");
83 foreach ( QString key, sets.allKeys())
89 dir.path = sets.value(key, "~/").toString();
90 favourites->append(dir);
95 bool AppSettings::addFavourite(VlcDirectory dir) {
97 // should check for existing first otherwise it overwrites
98 if (0 < sets.value("config/accounts/" + getCurrentKey() + "/favourites/" + dir.name, "").toString().length()) {
99 dir.name = "_" + dir.name;
100 return addFavourite(dir);
102 sets.setValue("config/accounts/" + getCurrentKey() + "/favourites/" + dir.name, dir.path);
105 bool AppSettings::deleteFavourite(VlcDirectory dir) {
107 sets.remove("config/accounts/" + getCurrentKey() + "/favourites/" + dir.name);
110 int AppSettings::getStatusPollTimeout() {
111 return STATUS_POLL_TIMEOUT;
113 int AppSettings::getPingTimeout() {
116 int AppSettings::getConnectionTimeout() {
117 return CONNECTION_TIMEOUT;
119 int AppSettings::getRetrieveArtTimeout() {
120 return RETRIEVE_ART_TIMEOUT;
122 int AppSettings::getRetryNetworkTimeout() {
123 return RETRY_NETWORK_TIMEOUT;
125 bool AppSettings::getShowUnknownFileTypes() {
126 return SHOW_UNKNOWN_FILETYPES;
128 Orientation AppSettings::setOrientation(Orientation orientation) {
130 sets.setValue("config/orientation", (int)orientation);
133 Orientation AppSettings::getOrientation() {
135 return (Orientation)(sets.value("config/orientation", AUTO_ROTATE).toInt());