Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions resources/artwork/icons/im-user-away.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions resources/artwork/icons/im-user-busy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions resources/artwork/icons/im-user-online.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,12 @@ qt_add_qml_module(gonnect
ui/components/popups/AudioDeviceMenu.qml
ui/components/popups/BurgerMenu.qml
ui/components/popups/DialInInfo.qml
ui/components/popups/EditStatusText.qml
ui/components/popups/FirstAid.qml
ui/components/popups/HistoryListContextMenu.qml
ui/components/popups/JitsiHistoryListContextMenu.qml
ui/components/popups/Menu.qml
ui/components/popups/OwnAvatarContextMenu.qml
ui/components/popups/SearchResultPopup.qml
ui/components/popups/VideoDeviceMenu.qml
ui/components/popups/StreamingLightPopup.qml
Expand Down Expand Up @@ -410,6 +412,7 @@ qt_add_qml_module(gonnect
ui/components/HistoryList.qml
ui/components/MainTabBar.qml
ui/components/ParticipantsList.qml
ui/components/PresenceStatusIndicator.qml
ui/components/RTTDisplay.qml
ui/components/SettingsPage.qml
ui/components/TogglerList.qml
Expand Down Expand Up @@ -619,6 +622,10 @@ qt_add_qml_module(gonnect
platform/SearchProvider.h
${PLATFORM_SOURCES}

presence/GlobalStateAggregator.h
presence/GlobalStateAggregator.cpp
presence/PresenceState.h

rtt/RTTProvider.h
rtt/RTTProvider.cpp
rtt/RTTMessage.h
Expand Down Expand Up @@ -674,6 +681,8 @@ qt_add_qml_module(gonnect
ui/RandomRoomNameGenerator.cpp
ui/ParticipantsModel.h
ui/ParticipantsModel.cpp
ui/PersonCoinProvider.h
ui/PersonCoinProvider.cpp
ui/SearchListModel.h
ui/SearchListModel.cpp
ui/SearchListProxyModel.h
Expand Down Expand Up @@ -792,6 +801,7 @@ target_include_directories(gonnect
calendar
contacts
conference
presence
ui
ui/chat
usb
Expand Down
1 change: 1 addition & 0 deletions src/contacts/akonadi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ if(ENABLE_AKONADI)
target_include_directories(AkonadiAddressBookFactory
PRIVATE
${PROJECT_SOURCE_DIR}/src/contacts
${PROJECT_SOURCE_DIR}/src/presence
${PROJECT_SOURCE_DIR}/src/ui
${PROJECT_SOURCE_DIR}/src/sip
${PROJECT_SOURCE_DIR}/src
Expand Down
1 change: 1 addition & 0 deletions src/contacts/carddav/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ if(ENABLE_DAV)
target_include_directories(CardDAVAddressBookFactory
PRIVATE
${PROJECT_SOURCE_DIR}/src/contacts
${PROJECT_SOURCE_DIR}/src/presence
${PROJECT_SOURCE_DIR}/src/dbus/portal
${PROJECT_SOURCE_DIR}/src/ui
${PROJECT_SOURCE_DIR}/src/sip
Expand Down
1 change: 1 addition & 0 deletions src/contacts/csv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if(ENABLE_CSV)
target_include_directories(CSVAddressBookFactory
PRIVATE
${PROJECT_SOURCE_DIR}/src/contacts
${PROJECT_SOURCE_DIR}/src/presence
${PROJECT_SOURCE_DIR}/src/ui
${PROJECT_SOURCE_DIR}/src/sip
${PROJECT_SOURCE_DIR}/src
Expand Down
1 change: 1 addition & 0 deletions src/contacts/eds/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ if(ENABLE_EDS)
target_include_directories(EDSAddressBookFactory
PRIVATE
${PROJECT_SOURCE_DIR}/src/contacts
${PROJECT_SOURCE_DIR}/src/presence
${PROJECT_SOURCE_DIR}/src/dbus/portal
${PROJECT_SOURCE_DIR}/src/ui
${PROJECT_SOURCE_DIR}/src/sip
Expand Down
1 change: 1 addition & 0 deletions src/contacts/ldap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if(ENABLE_LDAP)
target_include_directories(LDAPAddressBookFactory
PRIVATE
${PROJECT_SOURCE_DIR}/src/contacts
${PROJECT_SOURCE_DIR}/src/presence
${PROJECT_SOURCE_DIR}/src/dbus/portal
${PROJECT_SOURCE_DIR}/src/ui
${PROJECT_SOURCE_DIR}/src/sip
Expand Down
1 change: 1 addition & 0 deletions src/contacts/msgraph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if(ENABLE_MSGRAPH)
target_include_directories(MSGraphAddressBookFactory
PRIVATE
${PROJECT_SOURCE_DIR}/src/contacts
${PROJECT_SOURCE_DIR}/src/presence
${PROJECT_SOURCE_DIR}/src/ui
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}
Expand Down
3 changes: 3 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <QtWebEngineQuick>
#include "Application.h"
#include "GlobalInfo.h"
#include "PersonCoinProvider.h"

#ifdef Q_OS_LINUX
# include <QDBusConnection>
Expand Down Expand Up @@ -116,6 +117,8 @@ int main(int argc, char *argv[])
QObject::connect(
&engine, &QQmlApplicationEngine::objectCreationFailed, &app,
[]() { QCoreApplication::exit(-1); }, Qt::QueuedConnection);

engine.addImageProvider(QLatin1String("personcoin"), new PersonCoinProvider);
engine.loadFromModule("base", "Main");

const auto &objs = engine.rootObjects();
Expand Down
3 changes: 3 additions & 0 deletions src/presence/GlobalStateAggregator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "GlobalStateAggregator.h"

GlobalStateAggregator::GlobalStateAggregator(QObject *parent) : QObject{ parent } { }
54 changes: 54 additions & 0 deletions src/presence/GlobalStateAggregator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#pragma once

#include <QObject>
#include <QQmlEngine>
#include "PresenceState.h"

class GlobalStateAggregator : public QObject
{
Q_OBJECT

Q_PROPERTY(PresenceState::State presenceState MEMBER m_presenceState NOTIFY presenceStateChanged
FINAL)
Q_PROPERTY(QString statusText MEMBER m_statusText NOTIFY statusTextChanged FINAL)

public:
static GlobalStateAggregator &instance()
{
static GlobalStateAggregator *_instance = nullptr;
if (!_instance) {
_instance = new GlobalStateAggregator;
}
return *_instance;
};

PresenceState::State presenceState() const { return m_presenceState; }
QString statusText() const { return m_statusText; }

private:
explicit GlobalStateAggregator(QObject *parent = nullptr);

PresenceState::State m_presenceState = PresenceState::State::Available;
QString m_statusText;

Q_SIGNALS:
void presenceStateChanged();
void statusTextChanged();
};

class GlobalStateAggregatorWrapper
{
Q_GADGET
QML_FOREIGN(GlobalStateAggregator)
QML_NAMED_ELEMENT(GlobalStateAggregator)
QML_SINGLETON

public:
static GlobalStateAggregator *create(QQmlEngine *, QJSEngine *)
{
return &GlobalStateAggregator::instance();
}

private:
GlobalStateAggregatorWrapper() = default;
};
17 changes: 17 additions & 0 deletions src/presence/PresenceState.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <QObject>
#include <QtQml>

class PresenceState : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_UNCREATABLE("")

public:
explicit PresenceState(QObject *parent = nullptr) : QObject{ parent } { };

enum class State { Unknown, Offline, Away, Busy, Available, Ringing };
Q_ENUM(State)
};
76 changes: 76 additions & 0 deletions src/sip/SIPAccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "ErrorBus.h"
#include "Credentials.h"
#include "EnumTranslation.h"
#include "GlobalStateAggregator.h"

#include <QUuid>

Expand All @@ -19,10 +20,14 @@ intptr_t SIPAccount::runningMessageIndex = 0;
SIPAccount::SIPAccount(const QString &group, QObject *parent)
: QObject(parent), Account(), m_account(group)
{
connect(this, &SIPAccount::isRegisteredChanged, this,
&SIPAccount::updatePresenceStateForwarding);
}

void SIPAccount::initialize()
{
m_accountConfig.presConfig.publishEnabled = true;

bool ok = false;
static QRegularExpression sipURI = QRegularExpression("^(sips?):([^@]+)(?:@(.+))?$");

Expand Down Expand Up @@ -1037,3 +1042,74 @@ SIPAccount::~SIPAccount()
qDeleteAll(m_calls);
m_calls.clear();
}

void SIPAccount::updatePresenceStateForwarding()
{
if (isRegistered() && !m_globalStateConnectionContext) {
// Establish
m_globalStateConnectionContext = new QObject(this);
auto &glob = GlobalStateAggregator::instance();

connect(&glob, &GlobalStateAggregator::presenceStateChanged, m_globalStateConnectionContext,
[this]() { forwardPresenceState(); });
connect(&glob, &GlobalStateAggregator::statusTextChanged, m_globalStateConnectionContext,
[this]() { forwardPresenceState(); });
forwardPresenceState();

} else if (!isRegistered() && m_globalStateConnectionContext) {
// Disconnect
m_globalStateConnectionContext->deleteLater();
m_globalStateConnectionContext = nullptr;
}
}

void SIPAccount::forwardPresenceState()
{
if (!isRegistered()) {
return;
}

setOnlineStatus(createPresenceStatusFromGlobal());
}

pj::PresenceStatus SIPAccount::createPresenceStatusFromGlobal() const
{
auto &glob = GlobalStateAggregator::instance();

pj::PresenceStatus pjStatus;
pjStatus.note = glob.statusText().toStdString();

switch (glob.presenceState()) {

case PresenceState::State::Unknown:
pjStatus.status = PJSUA_BUDDY_STATUS_UNKNOWN;
pjStatus.activity = PJRPID_ACTIVITY_UNKNOWN;
break;

case PresenceState::State::Offline:
pjStatus.status = PJSUA_BUDDY_STATUS_OFFLINE;
pjStatus.activity = PJRPID_ACTIVITY_UNKNOWN;
break;
case PresenceState::State::Away:
pjStatus.status = PJSUA_BUDDY_STATUS_ONLINE;
pjStatus.activity = PJRPID_ACTIVITY_AWAY;
break;

case PresenceState::State::Busy:
pjStatus.status = PJSUA_BUDDY_STATUS_ONLINE;
pjStatus.activity = PJRPID_ACTIVITY_BUSY;
break;

case PresenceState::State::Available:
pjStatus.status = PJSUA_BUDDY_STATUS_ONLINE;
pjStatus.activity = PJRPID_ACTIVITY_UNKNOWN;
break;

case PresenceState::State::Ringing:
pjStatus.status = PJSUA_BUDDY_STATUS_ONLINE;
pjStatus.activity = PJRPID_ACTIVITY_UNKNOWN;
break;
}

return pjStatus;
}
7 changes: 7 additions & 0 deletions src/sip/SIPAccount.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class SIPAccount : public QObject, public pj::Account

~SIPAccount();

private Q_SLOTS:
void updatePresenceStateForwarding();
void forwardPresenceState();

private:
void finalizeInitialization();

Expand All @@ -98,6 +102,8 @@ class SIPAccount : public QObject, public pj::Account

void reinitBuddies();

pj::PresenceStatus createPresenceStatusFromGlobal() const;

QList<SIPCall *> m_calls;
QList<SIPBuddy *> m_buddies;
QList<pjsua_transport_id> m_transportIds;
Expand All @@ -114,6 +120,7 @@ class SIPAccount : public QObject, public pj::Account
bool m_useInstantMessagingWithoutCheck = true;
bool m_rttEnabled = true;
bool m_afterResume = false;
QObject *m_globalStateConnectionContext = nullptr;

QString m_account;
QString m_domain;
Expand Down
3 changes: 3 additions & 0 deletions src/ui/GonnectWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@ BaseWindow {
control.ensureVisible()
control.updateTabSelection(control.conferencePageId, GonnectWindow.PageType.Conference)
}
function onShowStatusTextEditDialog() {
drawerStackView.push("qrc:/qt/qml/base/ui/components/popups/EditStatusText.qml")
}
function onFullscreenToggle() {
if (control.visibility === Window.FullScreen) {
control.showNormal()
Expand Down
Loading
Loading