Project 'savoirfairelinux/ring-daemon' was moved to 'savoirfairelinux/jami-daemon'. Please update any links and bookmarks that may still have the old path.
Select Git revision
-
Eden Abitbol authored
Update libupnp to version 1.8.4. For windows, the IPV6 preprocessor must be undefined. Or else libupnp won't initialize. Added visual studio 2017 support via one patch for windows that also combines previous windows patches. UPnPController: Class that the jami classes use to control the opening and closing of ports. Every service has it's own upnp controller. The controller does it's actions by using the upnp context class. Also refactored the functions used to add mappings. Instead of using two different functions with different types of parameters, we now use one function with parameters that have default values. The logic stays the same but the function call is more clear. UPnPContext: Class that holds a (linked) list of discovered IGDs and their corresponding protocols (which discovered them). Whenever the controller wants to add or remove a mapping, the context picks a valid IGD in it's list and uses the correct protocol to complete the required action. This class also has the ability to swap protocols for an IGD that was discovered by more then one protocol. UPnPProtocol: Virtual base class that defines the functions needed by the context to use the corresponding protocol. PUPnP: UPnPProtocol derived class that represents a upnp client that uses the portable upnp library (libupnp). Every time the client discovers a new IGD it uses a callback to add it to the context's main IGD linked list. It also has an internal list of IGDs that it discovered. Added features to this class include: - IGD event subscription. - Use UpnpInit2 function instead of deprecated UpnpInit function. It's also supposed to support IPv6. NatPmp: UPnPProtocol derived class that represents a upnp client that uses the NAT-PMP library (libnatpmp). Unlike libupnp, libnatpmp only supports discovering one IGD. Also uses callbacks to add the IGD it finds to the context's main IGD class. Also inclided debug warning prints whenever a controller opens and closes the ports. That way we can keep track of whenever the application opens and closes ports on the internet gateway device. Gitlab: #96 Change-Id: I199271edac2c6d93dc60c24e2e2aefe36de7950c
Eden Abitbol authoredUpdate libupnp to version 1.8.4. For windows, the IPV6 preprocessor must be undefined. Or else libupnp won't initialize. Added visual studio 2017 support via one patch for windows that also combines previous windows patches. UPnPController: Class that the jami classes use to control the opening and closing of ports. Every service has it's own upnp controller. The controller does it's actions by using the upnp context class. Also refactored the functions used to add mappings. Instead of using two different functions with different types of parameters, we now use one function with parameters that have default values. The logic stays the same but the function call is more clear. UPnPContext: Class that holds a (linked) list of discovered IGDs and their corresponding protocols (which discovered them). Whenever the controller wants to add or remove a mapping, the context picks a valid IGD in it's list and uses the correct protocol to complete the required action. This class also has the ability to swap protocols for an IGD that was discovered by more then one protocol. UPnPProtocol: Virtual base class that defines the functions needed by the context to use the corresponding protocol. PUPnP: UPnPProtocol derived class that represents a upnp client that uses the portable upnp library (libupnp). Every time the client discovers a new IGD it uses a callback to add it to the context's main IGD linked list. It also has an internal list of IGDs that it discovered. Added features to this class include: - IGD event subscription. - Use UpnpInit2 function instead of deprecated UpnpInit function. It's also supposed to support IPv6. NatPmp: UPnPProtocol derived class that represents a upnp client that uses the NAT-PMP library (libnatpmp). Unlike libupnp, libnatpmp only supports discovering one IGD. Also uses callbacks to add the IGD it finds to the context's main IGD class. Also inclided debug warning prints whenever a controller opens and closes the ports. That way we can keep track of whenever the application opens and closes ports on the internet gateway device. Gitlab: #96 Change-Id: I199271edac2c6d93dc60c24e2e2aefe36de7950c
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
main.cpp 6.51 KiB
/***************************************************************************
* Copyright (C) 2015-2017 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* 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 3 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 "mainwindow.h"
#include <QApplication>
#include <QFile>
#include "callmodel.h"
#include "media/audio.h"
#include "media/video.h"
#include "media/text.h"
#include "media/file.h"
#include "globalinstances.h"
#include "pixbufmanipulator.h"
#include "lrcinstance.h"
#include <QTranslator>
#include <QLibraryInfo>
#include <QFontDatabase>
#include <ciso646>
#ifdef Q_OS_WIN
#include <windows.h>
#endif
#ifdef _MSC_VER
#include <gnutls/gnutls.h>
#endif
#ifdef URI_PROTOCOL
#include "shmclient.h"
#endif
REGISTER_MEDIA();
void
Console()
{
#ifdef Q_OS_WIN
#ifdef _MSC_VER
// Print debug to output window if using VS
QObject::connect(
&LRCInstance::behaviorController(),
&lrc::api::BehaviorController::debugMessageReceived,
[](const std::string& message) {
OutputDebugStringA((message + "\n").c_str());
});
#else
AllocConsole();
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
COORD coordInfo;
coordInfo.X = 130;
coordInfo.Y = 9000;
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coordInfo);
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE),ENABLE_QUICK_EDIT_MODE| ENABLE_EXTENDED_FLAGS);
#endif
#endif
}
int
main(int argc, char *argv[])
{
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication a(argc, argv);
GlobalInstances::setPixmapManipulator(std::unique_ptr<PixbufManipulator>(new PixbufManipulator()));
auto startMinimized = false;
QString uri = "";
#ifdef _MSC_VER
gnutls_global_init();
#endif
LRCInstance::init();
for (auto string : QCoreApplication::arguments()) {
if (string == "-m" || string == "--minimized")
startMinimized = true;
if (string == "-d" || string == "--debug")
Console();
if (string.startsWith("ring:")) {
uri = string;
}
}
#ifdef URI_PROTOCOL
QSharedMemory* shm = new QSharedMemory("RingShm");
QSystemSemaphore* sem = new QSystemSemaphore("RingSem", 0);
if (not shm->create(1024)) {
if (not uri.isEmpty()) {
shm->attach();
shm->lock();
char *to = (char*) shm->data();
QChar *data = uri.data();
while (!data->isNull())
{
memset(to, data->toLatin1(), 1);
++data;
++to;
}
memset(to, 0, 1); //null terminator
shm->unlock();
}
sem->release();
delete shm;
exit(EXIT_SUCCESS);
}
//Client listening to shm event
memset((char*)shm->data(), 0, shm->size());
ShmClient* shmClient = new ShmClient(shm, sem);
#endif
const auto locale_name = QLocale::system().name();
const auto locale_lang = locale_name.split('_')[0];
QTranslator qtTranslator_lang;
QTranslator qtTranslator_name;
if (locale_name != locale_lang) {
qtTranslator_lang.load("qt_" + locale_lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
a.installTranslator(&qtTranslator_lang);
}
qtTranslator_name.load("qt_" + locale_name, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
a.installTranslator(&qtTranslator_name);
QTranslator lrcTranslator_lang;
QTranslator lrcTranslator_name;
if (locale_name != locale_lang) {
lrcTranslator_lang.load("share/libringclient/translations/lrc_" + locale_lang);
a.installTranslator(&lrcTranslator_lang);
}
lrcTranslator_name.load("share/libringclient/translations/lrc_" + locale_name);
a.installTranslator(&lrcTranslator_name);
QTranslator mainTranslator_lang;
QTranslator mainTranslator_name;
if (locale_name != locale_lang) {
mainTranslator_lang.load("share/ring/translations/ring_client_windows_" + locale_lang);
a.installTranslator(&mainTranslator_lang);
}
mainTranslator_name.load("share/ring/translations/ring_client_windows_" + locale_name);
a.installTranslator(&mainTranslator_name);
QFont font;
font.setFamily("Segoe UI");
a.setFont(font);
QFile file(":/stylesheet.css");
if(file.open(QIODevice::ReadOnly | QIODevice::Text))
{
a.setStyleSheet(file.readAll());
file.close();
}
QCoreApplication::setOrganizationName("Savoir-faire Linux");
QCoreApplication::setOrganizationDomain("ring.cx");
QCoreApplication::setApplicationName("Ring");
QFontDatabase::addApplicationFont(":/images/FontAwesome.otf");
MainWindow::instance().createThumbBar();
if (not uri.isEmpty()) {
startMinimized = false;
MainWindow::instance().onRingEvent(uri);
}
if (not startMinimized)
MainWindow::instance().show();
else {
MainWindow::instance().showMinimized();
MainWindow::instance().hide();
}
#ifdef URI_PROTOCOL
QObject::connect(shmClient, SIGNAL(RingEvent(QString)), &MainWindow::instance(), SLOT(onRingEvent(QString)));
QObject::connect(&a, &QApplication::aboutToQuit, [&a, &shmClient, &shm, &sem]() {
shmClient->terminate();
delete shmClient;
delete shm;
delete sem;
});
#endif
auto ret = a.exec();
QCoreApplication::exit();
GlobalSystemTray::instance().deleteLater();
GlobalSystemTray::instance().hide();
return ret;
}