[-]
[+]
|
Changed |
_service:tar_git:harbour-fahrplan2.spec
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,7 +2,7 @@
<service name="tar_git">
<param name="url">https://github.com/poetaster/fahrplan</param>
<param name="branch">master</param>
- <param name="revision">2.0.37</param>
+ <param name="revision"> 2.0.38 </param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-fahrplan2-2.0.38.tar.bz2/data/sailfishos/harbour-fahrplan2.desktop
^
|
@@ -8,5 +8,5 @@
[X-Sailjail]
OrganizationName=de.smurfy
ApplicationName=harbour-fahrplan2
-Permissions=Internet;Location
+Permissions=Internet;Location;UserDirs
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-fahrplan2-2.0.38.tar.bz2/fahrplan2.pro
^
|
@@ -2,7 +2,11 @@
APP_NAME = Fahrplan
# Define Version
-VERSION = 2.0.37-1
+VERSION = 2.0.38-1
+
+#CONFIG+= openrepos
+
+DEFINES += BUILD_FOR_SAILFISHOS
# Switch for jolla to separate harbour and openrepo version
openrepos {
@@ -28,7 +32,7 @@
}
exists($$[QT_INSTALL_PREFIX]/include/sailfishapp/sailfishapp.h): {
DEFINES += FAHRPLAN_VERSION=\\\"$$VERSION\\\"
- DEFINES += FAHRPLAN_SETTINGS_NAMESPACE=\\\"harbour-fahrplan2\\\"
+ DEFINES += FAHRPLAN_SETTINGS_NAMESPACE=\\\"de.smurfy/harbour-fahrplan2\\\"
}
!ubuntu:!symbian:!exists("/usr/include/sailfishapp/sailfishapp.h"): {
DEFINES += FAHRPLAN_VERSION=\\\"$$VERSION\\\"
@@ -109,6 +113,7 @@
src/fahrplan_backend_manager.h \
src/parser/parser_mobilebahnde.h \
src/calendarthreadwrapper.h \
+ src/calendar_sfos_wrapper.h \
src/parser/parser_xmlnri.h \
src/parser/parser_hafasbinary.h \
src/fahrplan_parser_thread.h \
@@ -143,6 +148,7 @@
src/fahrplan_backend_manager.cpp \
src/parser/parser_mobilebahnde.cpp \
src/calendarthreadwrapper.cpp \
+ src/calendar_sfos_wrapper.cpp \
src/parser/parser_xmlnri.cpp \
src/parser/parser_hafasbinary.cpp \
src/fahrplan_parser_thread.cpp \
@@ -332,9 +338,8 @@
PKGCONFIG += sailfishapp
INCLUDEPATH += /usr/include/sailfishapp
- # we need additional stuff for calendar support
+ # we need additional stuff for calendar supportfahrplanBackend
openrepos {
- #PKGCONFIG += mkcal-qt5-devel kcalcore-qt5-devel
PKGCONFIG += libmkcal-qt5 libkcalcoren-qt5
INCLUDEPATH += /usr/include/mkcal-qt5 /usr/include/kcalcoren-qt5
}
@@ -488,4 +493,3 @@
translations.CONFIG = no_link
QMAKE_EXTRA_COMPILERS += translations
PRE_TARGETDEPS += compiler_translations_make_all
-
|
[-]
[+]
|
Added |
_service:tar_git:harbour-fahrplan2-2.0.38.tar.bz2/src/calendar_sfos_wrapper.cpp
^
|
@@ -0,0 +1,203 @@
+/****************************************************************************
+**
+** This file is a part of Fahrplan.
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License along
+** with this program. If not, see <http://www.gnu.org/licenses/>.
+**
+****************************************************************************/
+
+#include "calendar_sfos_wrapper.h"
+
+#include <QCoreApplication>
+#include <QThread>
+#include <QSettings>
+#include <QDesktopServices>
+#include <QTemporaryFile>
+#include <QStandardPaths>
+#include <QTextStream>
+#include <QList>
+#include <QDateTime>
+#include <QDir>
+#include <QUrl>
+#include <QFile>
+
+
+QString formatStations(const QDateTime dateTime, const QString &stationName, const QString &info = QString())
+{
+ QString station;
+ station = stationName;
+
+ if (info.isEmpty()) {
+ station = stationName;
+ } else {
+ //: STATION / PLATFORM
+ station = CalendarSfosWrapper::tr(" %1 / %2", "STATION / PLATFORM").arg(stationName, info);
+ }
+
+ QString dSpec = "dd.MM";
+ QString tSpec = "hh:mm:ss";
+
+ //: DATE TIME STATION
+ return CalendarSfosWrapper::tr(" %1 %2 %3", "DATE TIME STATION").arg(
+ // TODO: Don't force QLocale::ShortFormat for date, but make it configurable.
+ //dateTime.toString(QLocale().dateFormat(QLocale::ShortFormat)),
+ dateTime.toString(dSpec),
+ // Always use short format for time, else you get something like "12:35:00 t".
+ dateTime.toString(QLocale().timeFormat(QLocale::ShortFormat)),
+ station);
+}
+
+CalendarSfosWrapper::CalendarSfosWrapper(JourneyDetailResultList *result, QObject *parent) :
+ QObject(parent), m_result(result)
+{
+}
+
+CalendarSfosWrapper::~CalendarSfosWrapper()
+{
+
+}
+
+QString CalendarSfosWrapper::iterInfos(JourneyDetailResultItem *item)
+{
+return formatStations(item->departureDateTime(), item->departureStation(), item->departureInfo()) +
+ "---------------------------" +
+formatStations(item->arrivalDateTime(), item->arrivalStation(), item->arrivalInfo());
+}
+
+void CalendarSfosWrapper::addToCalendar()
+{
+
+ const QString viaStation = m_result->viaStation();
+ QSettings settings(FAHRPLAN_SETTINGS_NAMESPACE, "fahrplan2");
+ QString calendarEntryTitle;
+ QString calendarEntryDesc;
+
+ if (viaStation.isEmpty())
+ calendarEntryTitle = tr("%1 to %2").arg(m_result->departureStation(),
+ m_result->arrivalStation());
+ else
+ calendarEntryTitle = tr("%1 via %3 to %2").arg(m_result->departureStation(),
+ m_result->arrivalStation(),
+ viaStation);
+
+ if (!m_result->info().isEmpty())
+ calendarEntryDesc.append(m_result->info()).append("\n");
+
+ const bool compactFormat = settings.value("compactCalendarEntries", false).toBool();
+
+ QList<QString> slist;
+
+ for (int i=0; i < m_result->itemcount(); i++) {
+ JourneyDetailResultItem *item = m_result->getItem(i);
+
+ const QString train = item->direction().isEmpty()
+ ? item->train()
+ : tr("%1 to %2").arg(item->train(), item->direction());
+
+ calendarEntryDesc.append(formatStations(item->departureDateTime(),
+ item->departureStation(),
+ item->departureInfo()) );
+
+ if (!compactFormat && !train.isEmpty()) {
+ calendarEntryDesc.append(" >> ").append(train).append(", ");
+ //slist.append( train );
+ }
+ if (compactFormat && !train.isEmpty())
+ calendarEntryDesc.append(" >> ").append(train).append(", ");
+
+ /*
+ calendarEntryDesc.append(formatStations(item->arrivalDateTime(),
+ item->arrivalStation(),
+ item->arrivalInfo()));
+ if (!compactFormat) {
+ if (!item->info().isEmpty())
+ calendarEntryDesc.append(item->info());
+
+ }*/
+ }
+
+/*
+ if (!compactFormat)
+ calendarEntryDesc.append(
+ tr("#### Added by Fahrplan. Please, re-check the information before your journey. ####\n"));
+*/
+
+ QTemporaryFile *tmpFile = new QTemporaryFile(
+ QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) +
+ QDir::separator() + "fahrplan-event-XXXXXX.ics",
+ this);
+
+ // destructed and file deleted with this object
+
+
+ /*for (int i=0; i < m_result->itemcount(); i++) {
+ JourneyDetailResultItem *item = m_result->getItem(i);
+ aDesc.append(this->iterInfos(item));
+ }*/
+ // construct our ical doc
+ QString tSpec = "yyyyMMddThhmmss";
+ QString dDate = m_result->departureDateTime().toString(tSpec);
+ QString aDate = m_result->arrivalDateTime().toString(tSpec);
+
+ /*
+ QString aDesc = "BEGIN:VCALENDAR\n";
+ aDesc.append("PRODID:-//IDN smurfy.de//Fahrplan 2.0.38//EN\n");
+ aDesc.append("VERSION:2.0\n");
+ aDesc.append("BEGIN:VEVENT\n");
+ aDesc.append("DTSTART:" + dDate + "\n");
+ aDesc.append("DTEND:" + aDate + "\n");
+ aDesc.append("SUMMARY:" + calendarEntryTitle + "\n");
+ aDesc.append("DESCRIPTION:");
+ for ( const auto& i : slist )
+ {
+ aDesc.append( i + "\n" );
+ }
+ aDesc.append("END:VEVENT\n");
+ aDesc.append("END:VCALENDAR");
+
+ qDebug() << "icalfile: " << aDesc;
+ */
+
+ // It's annoying but they took some shortcuts in the parserser
+ // stuffing formatting in. Sigh.
+ // The info elements have fragments which don't render properly.
+ calendarEntryDesc.remove(QRegExp("<[^>]*>"));
+
+ if (tmpFile->open())
+ {
+ QTextStream stream( tmpFile );
+ //stream << aDesc;
+ /* This works until you get char \n in Desc */
+ stream << "BEGIN:VCALENDAR" << "\n"
+ << "PRODID:-//IDN smurfy.de//Fahrplan 2.0.38//EN" << "\n"
+ << "VERSION:2.0" << "\n"
+ << "BEGIN:VEVENT" << "\n"
+ << "DTSTART:" << dDate << "\n"
+ << "DTEND:" << aDate << "\n"
+ << "SUMMARY:" << calendarEntryTitle << "\n"
+ << "DESCRIPTION:" << calendarEntryDesc << "\n"
+ << "END:VEVENT" << "\n"
+ << "END:VCALENDAR";
+
+ tmpFile->close();
+ qDebug() << "Opening" << tmpFile->fileName();
+ if ( !QDesktopServices::openUrl(QUrl::fromLocalFile(tmpFile->fileName())) )
+ {
+ qWarning() << "QDesktopServices::openUrl fails!";
+ emit addCalendarEntryComplete(false);
+ } else {
|
[-]
[+]
|
Added |
_service:tar_git:harbour-fahrplan2-2.0.38.tar.bz2/src/calendar_sfos_wrapper.h
^
|
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** This file is a part of Fahrplan.
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License along
+** with this program. If not, see <http://www.gnu.org/licenses/>.
+**
+****************************************************************************/
+
+#ifndef CALENDARSFOSWRAPPER_H
+#define CALENDARSFOSWRAPPER_H
+
+#include <QObject>
+#include "parser/parser_definitions.h"
+
+class CalendarSfosWrapper : public QObject
+{
+ Q_OBJECT
+ public:
+ explicit CalendarSfosWrapper(JourneyDetailResultList *result, QObject *parent = 0);
+ virtual ~CalendarSfosWrapper();
+ QString iterInfos(JourneyDetailResultItem *item);
+ public slots:
+ void addToCalendar();
+ signals:
+ void addCalendarEntryComplete(bool success);
+ private:
+ JourneyDetailResultList * const m_result;
+};
+
+#endif // CALENDARSFOSWRAPPER_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-fahrplan2-2.0.38.tar.bz2/src/fahrplan.cpp
^
|
@@ -21,6 +21,7 @@
#include "fahrplan_parser_thread.h"
#include "fahrplan_backend_manager.h"
#include "calendarthreadwrapper.h"
+#include "calendar_sfos_wrapper.h"
#include "models/favorites.h"
#include "models/stationsearchresults.h"
#include "models/timetable.h"
@@ -45,6 +46,7 @@
, m_mode(DepartureMode)
, m_dateTime(QDateTime::currentDateTime())
{
+
settings = new QSettings(FAHRPLAN_SETTINGS_NAMESPACE, "fahrplan2");
setMode(static_cast<Mode>(settings->value("mode", DepartureMode).toInt()));
@@ -387,17 +389,25 @@
void Fahrplan::addJourneyDetailResultToCalendar(JourneyDetailResultList *result)
{
+
+#if defined(BUILD_FOR_SAILFISHOS)
+ CalendarSfosWrapper *wrapper = new CalendarSfosWrapper(result,this);
+ //connect( this, wrapper, SLOT( addToCalendar() ),this, SIGNAL(addCalendarEntryComplete(bool)) );
+ connect(wrapper,SIGNAL(addCalendarEntryComplete(bool)), SIGNAL(addCalendarEntryComplete(bool)));
+ wrapper->addToCalendar();
+
+#else
QThread *workerThread = new QThread(this);
CalendarThreadWrapper *wrapper = new CalendarThreadWrapper(result);
connect(workerThread, SIGNAL(started()), wrapper, SLOT(addToCalendar()));
connect(workerThread, SIGNAL(finished()), wrapper, SLOT(deleteLater()));
connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater()));
-
connect(wrapper,SIGNAL(addCalendarEntryComplete(bool)), SIGNAL(addCalendarEntryComplete(bool)));
wrapper->moveToThread(workerThread);
workerThread->start();
+#endif
}
Station Fahrplan::getStation(StationType type) const
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-fahrplan2-2.0.38.tar.bz2/src/gui/sailfishos/pages/JourneyDetailsResultsPage.qml
^
|
@@ -37,15 +37,15 @@
PushUpMenu {
id: pushUpMenu
- visible: (indicator.visible === false) && (fahrplanBackend.supportsCalendar)
+ //visible: (indicator.visible === false) && (fahrplanBackend.supportsCalendar)
MenuItem {
id: addToCalendar
text: qsTr("Add to calendar")
onClicked: {
fahrplanBackend.addJourneyDetailResultToCalendar(currentResult);
- addToCalendar.enabled = false;
- pushUpMenu.busy = true;
+ //addToCalendar.enabled = false;
+ //pushUpMenu.busy = true;
}
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-fahrplan2-2.0.38.tar.bz2/src/main.cpp
^
|
@@ -69,6 +69,35 @@
#include "models/trainrestrictions.h"
#include "models/backends.h"
+#if defined(BUILD_FOR_SAILFISHOS)
+// since we don't clean up on calendar export at runtime
+// we clean up on start. sub-optimal.
+void cleanIcs()
+{
+ QDir docs(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));
+ docs.setNameFilters(QStringList() << "fahrplan-event-*.ics");
+ docs.setFilter(QDir::Files);
+ foreach(QString icsFile, docs.entryList())
+ {
+ qDebug() <<"icsfile: "<< icsFile ;
+ docs.remove(icsFile);
+ }
+}
+void migrateConf()
+{
+ QDir config(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
+ QString oldConfigFileStr = config.path() + "/" + "harbour-fahrplan2/fahrplan2.conf";
+ QString newConfigFileStr = config.path() + "/" + "de.smurfy/harbour-fahrplan2/fahrplan2.conf";
+
+ qDebug() <<"configfile: "<< oldConfigFileStr ;
+ qDebug() <<"newfile: "<< newConfigFileStr ;
+ if (!config.exists("de.smurfy/harbour-fahrplan2"))
+ config.mkpath("de.smurfy/harbour-fahrplan2");
+ QFile cCnf(oldConfigFileStr);
+ cCnf.copy(newConfigFileStr);
+}
+#endif
+
#if defined(BUILD_FOR_HARMATTAN) || defined(BUILD_FOR_MAEMO_5) || defined(BUILD_FOR_SYMBIAN)
Q_DECL_EXPORT
#endif
@@ -79,9 +108,10 @@
#if defined(BUILD_FOR_SAILFISHOS)
//To support calendar access
#if defined(BUILD_FOR_OPENREPOS)
- qDebug()<<"openrepos.net build";
- setuid(getpwnam("nemo")->pw_uid);
- setgid(getgrnam("privileged")->gr_gid);
+ // deprecated, we've moved to DesktopService transfer
+ //qDebug()<<"openrepos.net build";
+ //setuid(getpwnam("defaultuser")->pw_uid);
+ //setgid(getgrnam("privileged")->gr_gid);
#endif
QGuiApplication* app = SailfishApp::application(argc, argv);
@@ -108,6 +138,12 @@
qDebug()<<"Startup";
+ #if defined(BUILD_FOR_SAILFISHOS)
+ app->setApplicationName("harbour-fahrplan2");
+ app->setOrganizationDomain("de.smurfy");
+ app->setOrganizationName("de.smurfy");
+ #endif
+
qRegisterMetaType<Station>();
qRegisterMetaType<StationsList>();
qRegisterMetaType<TimetableEntry>();
@@ -173,9 +209,13 @@
view->setGeometry(settings.value("geometry", QRect(100, 100, 400, 600)).toRect());
#elif defined(BUILD_FOR_SAILFISHOS)
qDebug()<<"SailfishOs";
+ // sailjail and calendar export cleanup
+ migrateConf();
+ cleanIcs();
view->setSource(QUrl("qrc:/src/gui/sailfishos/main.qml"));
view->showFullScreen();
+
#elif defined(BUILD_FOR_BLACKBERRY)
qDebug() << "Blackberry";
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-fahrplan2-2.0.38.tar.bz2/src/parser/parser_xmlrejseplanendk.cpp
^
|
@@ -22,8 +22,9 @@
ParserXmlRejseplanenDk::ParserXmlRejseplanenDk(QObject *parent) :
ParserHafasXml(parent)
{
+ //https://mobil.rejseplanen.dk/bin/iphone.exe?
baseXmlUrl = "https://www.rejseplanen.dk/bin/query.exe";
- baseSTTableUrl = "https://mobil.rejseplanen.dk/mobil-bin/stboard.exe/en";
+ baseSTTableUrl = "https://mobil.rejseplanen.dk/bin/iphone.exe/en";
baseUrl = "https://www.rejseplanen.dk/bin/query.exe";
STTableMode = 1;
|