Commit a845693c authored by Ronan's avatar Ronan

feat(Chat): deal with sip-uri in messages, on click the sip uri is used as chat room

parent cb31880c
......@@ -135,6 +135,7 @@ set(SOURCES
src/components/sound-player/SoundPlayer.cpp
src/components/telephone-numbers/TelephoneNumbersModel.cpp
src/components/timeline/TimelineModel.cpp
src/components/url-handlers/UrlHandlers.cpp
src/externals/single-application/SingleApplication.cpp
src/main.cpp
src/utils/LinphoneUtils.cpp
......@@ -186,6 +187,7 @@ set(HEADERS
src/components/sound-player/SoundPlayer.hpp
src/components/telephone-numbers/TelephoneNumbersModel.hpp
src/components/timeline/TimelineModel.hpp
src/components/url-handlers/UrlHandlers.hpp
src/externals/single-application/SingleApplication.hpp
src/externals/single-application/SingleApplicationPrivate.hpp
src/utils/LinphoneUtils.hpp
......
......@@ -357,6 +357,7 @@ void App::registerTypes () {
registerSingletonType<OwnPresenceModel>("OwnPresenceModel");
registerSingletonType<Presence>("Presence");
registerSingletonType<TimelineModel>("TimelineModel");
registerSingletonType<UrlHandlers>("UrlHandlers");
registerSingletonType<VideoCodecsModel>("VideoCodecsModel");
registerMetaType<ChatModel::EntryType>("ChatModel::EntryType");
......
......@@ -33,9 +33,10 @@
// =============================================================================
class QCommandLineParser;
class Cli;
class DefaultTranslator;
class QCommandLineParser;
class App : public SingleApplication {
Q_OBJECT;
......
......@@ -41,6 +41,7 @@
#include "sound-player/SoundPlayer.hpp"
#include "telephone-numbers/TelephoneNumbersModel.hpp"
#include "timeline/TimelineModel.hpp"
#include "url-handlers/UrlHandlers.hpp"
#include "other/clipboard/Clipboard.hpp"
#include "other/text-to-speech/TextToSpeech.hpp"
......
......@@ -140,14 +140,6 @@ SipAddressObserver *SipAddressesModel::getSipAddressObserver (const QString &sip
// -----------------------------------------------------------------------------
QString SipAddressesModel::interpretUrl (const QString &sipAddress) const {
shared_ptr<linphone::Address> lAddress = CoreManager::getInstance()->getCore()->interpretUrl(
::Utils::appStringToCoreString(sipAddress)
);
return lAddress ? ::Utils::coreStringToAppString(lAddress->asStringUriOnly()) : "";
}
QString SipAddressesModel::getTransportFromSipAddress (const QString &sipAddress) const {
const shared_ptr<const linphone::Address> address = linphone::Factory::get()->createAddress(
::Utils::appStringToCoreString(sipAddress)
......@@ -176,13 +168,27 @@ QString SipAddressesModel::addTransportToSipAddress (const QString &sipAddress,
);
if (!address)
return "";
return QString("");
address->setTransport(LinphoneUtils::stringToTransportType(transport.toUpper()));
return ::Utils::coreStringToAppString(address->asString());
}
// -----------------------------------------------------------------------------
QString SipAddressesModel::interpretUrl (const QString &sipAddress) {
shared_ptr<linphone::Address> lAddress = CoreManager::getInstance()->getCore()->interpretUrl(
::Utils::appStringToCoreString(sipAddress)
);
return lAddress ? ::Utils::coreStringToAppString(lAddress->asStringUriOnly()) : "";
}
QString SipAddressesModel::interpretUrl (const QUrl &sipAddress) {
return sipAddress.toString();
}
bool SipAddressesModel::sipAddressIsValid (const QString &sipAddress) {
return !!linphone::Factory::get()->createAddress(
::Utils::appStringToCoreString(sipAddress)
......
......@@ -24,6 +24,7 @@
#define SIP_ADDRESSES_MODEL_H_
#include <QAbstractListModel>
#include <QUrl>
#include "../chat/ChatModel.hpp"
#include "../contact/ContactModel.hpp"
......@@ -55,11 +56,12 @@ public:
// Sip addresses helpers.
// ---------------------------------------------------------------------------
Q_INVOKABLE QString interpretUrl (const QString &sipAddress) const;
Q_INVOKABLE QString getTransportFromSipAddress (const QString &sipAddress) const;
Q_INVOKABLE QString addTransportToSipAddress (const QString &sipAddress, const QString &transport) const;
Q_INVOKABLE static QString interpretUrl (const QString &sipAddress);
Q_INVOKABLE static QString interpretUrl (const QUrl &sipAddress);
Q_INVOKABLE static bool sipAddressIsValid (const QString &sipAddress);
// ---------------------------------------------------------------------------
......
/*
* UrlHandlers.cpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: June 16, 2017
* Author: Ronan Abhamon
*/
#include <QDesktopServices>
#include "../sip-addresses/SipAddressesModel.hpp"
#include "UrlHandlers.hpp"
// =============================================================================
UrlHandlers::UrlHandlers (QObject *parent) : QObject(parent) {
QDesktopServices::setUrlHandler("sip", this, "handleSip");
}
void UrlHandlers::handleSip (const QUrl &url) {
emit sip(SipAddressesModel::interpretUrl(url));
}
/*
* UrlHandlers.hpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: June 16, 2017
* Author: Ronan Abhamon
*/
#ifndef URL_HANDLERS_H_
#define URL_HANDLERS_H_
#include <QObject>
// =============================================================================
class UrlHandlers : public QObject {
Q_OBJECT;
public:
UrlHandlers (QObject *parent = Q_NULLPTR);
~UrlHandlers () = default;
public slots:
void handleSip (const QUrl &url);
signals:
void sip (const QString &sipAddress);
};
#endif // URL_HANDLERS_H_
......@@ -262,4 +262,16 @@ ApplicationWindow {
onClicked: CoreManager.forceRefreshRegisters()
}
// ---------------------------------------------------------------------------
// Url handlers.
// ---------------------------------------------------------------------------
Connections {
target: UrlHandlers
onSip: window.setView('Conversation', {
sipAddress: sipAddress
})
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment