Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F112696
matrix-sdk.hpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
matrix-sdk.hpp
View Options
/*
* This file is part of kazv.
* SPDX-FileCopyrightText: 2020-2023 tusooa <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#pragma once
#include
<libkazv-config.hpp>
#include
<immer/config.hpp>
// https://github.com/arximboldi/immer/issues/168
#include
<QObject>
#include
<QQmlEngine>
#include
<QString>
#include
<memory>
#include
<lager/extra/qt.hpp>
#include
<sdk-model.hpp>
#include
"meta-types.hpp"
class
MatrixRoomList
;
class
MatrixDeviceList
;
class
MatrixPromise
;
class
MatrixSdkTest
;
struct
MatrixSdkPrivate
;
class
MatrixSdk
:
public
QObject
{
Q_OBJECT
QML_ELEMENT
std
::
unique_ptr
<
MatrixSdkPrivate
>
m_d
;
/// @param d A dynamically allocated d-pointer, whose ownership
/// will be transferred to this MatrixSdk.
explicit
MatrixSdk
(
std
::
unique_ptr
<
MatrixSdkPrivate
>
d
,
QObject
*
parent
);
void
init
();
public
:
explicit
MatrixSdk
(
QObject
*
parent
=
0
);
~
MatrixSdk
()
override
;
LAGER_QT_READER
(
QString
,
serverUrl
);
LAGER_QT_READER
(
QString
,
userId
);
LAGER_QT_READER
(
QString
,
token
);
LAGER_QT_READER
(
QString
,
deviceId
);
Q_INVOKABLE
MatrixRoomList
*
roomList
()
const
;
Q_INVOKABLE
QString
mxcUriToHttp
(
QString
mxcUri
)
const
;
Q_INVOKABLE
MatrixDeviceList
*
devicesOfUser
(
QString
userId
)
const
;
private
:
// Replaces the store with another one
void
emplace
(
std
::
optional
<
Kazv
::
SdkModel
>
model
);
Q_SIGNALS
:
void
trigger
(
Kazv
::
KazvEvent
e
);
void
loginSuccessful
(
Kazv
::
KazvEvent
e
);
void
loginFailed
(
QString
errorCode
,
QString
errorMsg
);
void
discoverFailed
(
QString
errorCode
,
QString
errorMsg
);
void
createRoomSuccessful
();
void
createRoomFailed
(
QString
errorCode
,
QString
errorMsg
);
void
joinRoomSuccessful
(
const
QString
&
idOrAlias
);
void
joinRoomFailed
(
const
QString
&
idOrAlias
,
const
QString
&
errorCode
,
const
QString
&
errorMsg
);
void
sessionChanged
();
public
Q_SLOTS
:
void
login
(
const
QString
&
userId
,
const
QString
&
password
);
/**
* Serialize data to <AppDataDir>/sessions/<userid>/<deviceid>/
*
* If not logged in, do nothing.
*/
void
serializeToFile
()
const
;
/**
* Load session at <AppDataDir>/sessions/<sessionName> .
*
* @param sessionName A string in the form of <userid>/<deviceid> .
*
* @return true if successful, false otherwise.
*/
bool
loadSession
(
QString
sessionName
);
/**
* Start an empty session.
*
* The new session is not logged in, and need to call login().
*
* @return true if successful, false otherwise.
*/
bool
startNewSession
();
/**
* Get all saved sessions.
*
* @return A list of session names in the form of <userid>/<deviceid> .
*/
QStringList
allSessions
()
const
;
/**
* Create a new room.
*
* @param isPrivate Whether the room is private.
* @param name The room's name.
* @param alias The alias of the room.
* @param invite List of matrix ids of users to invite.
* @param isDirect Whether it is a direct message room.
* @param allowFederate Whether to allow users on other servers to join.
* @param topic The topic of the room.
* @param powerLevelContentOverride The content to override m.room.power_levels event.
*/
void
createRoom
(
bool
isPrivate
,
const
QString
&
name
,
const
QString
&
alias
,
const
QStringList
&
invite
,
bool
isDirect
,
bool
allowFederate
,
const
QString
&
topic
,
const
QJsonValue
&
powerLevelContentOverride
);
/**
* Join a room.
* @param idOrAlias The id or alias of the room to join.
* @param servers The servers to use when joining the room.
*/
void
joinRoom
(
const
QString
&
idOrAlias
,
const
QStringList
&
servers
);
/**
* Change the trust level of a device.
*
* @param userId The user id that owns the device.
* @param deviceId The device id to set the trust level.
* @param trustLevel The trust level.
*
* @return A MatrixPromise representing the progress.
*/
MatrixPromise
*
setDeviceTrustLevel
(
QString
userId
,
QString
deviceId
,
QString
trustLevel
);
/**
* Get the profile of the current user.
*
* @return A MatrixPromise representing the progress.
*/
MatrixPromise
*
getSelfProfile
();
/**
* Set the display name of the current user.
*
* @return A MatrixPromise representing the progress.
*/
MatrixPromise
*
setDisplayName
(
QString
displayName
);
/**
* Set the avatar url of the current user.
*
* @return A MatrixPromise representing the progress.
*/
MatrixPromise
*
setAvatarUrl
(
QString
avatarUrl
);
private
:
// Testing
friend
MatrixSdkTest
;
friend
MatrixSdk
*
makeTestSdk
(
Kazv
::
SdkModel
model
);
explicit
MatrixSdk
(
Kazv
::
SdkModel
model
,
bool
testing
=
false
,
QObject
*
parent
=
0
);
void
startThread
();
};
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Sat, Nov 23, 10:10 PM (21 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39157
Default Alt Text
matrix-sdk.hpp (4 KB)
Attached To
Mode
rK kazv
Attached
Detach File
Event Timeline
Log In to Comment