Initial commit
This commit is contained in:
commit
bb10adef79
|
|
@ -0,0 +1,76 @@
|
|||
# Miscellaneous
|
||||
*.class
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
.DS_Store
|
||||
.atom/
|
||||
.buildlog/
|
||||
.history
|
||||
.svn/
|
||||
native/
|
||||
test/.test_coverage.dart
|
||||
coverage/
|
||||
coverage_badge.svg
|
||||
|
||||
# IntelliJ related
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Visual Studio Code related
|
||||
.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
**/doc/api/
|
||||
.dart_tool/
|
||||
.flutter-plugins
|
||||
.flutter-plugins-dependencies
|
||||
.packages
|
||||
.pub-cache/
|
||||
.pub/
|
||||
build/
|
||||
pubspec.lock
|
||||
|
||||
# Android related
|
||||
**/android/**/gradle-wrapper.jar
|
||||
**/android/.gradle
|
||||
**/android/captures/
|
||||
**/android/gradlew
|
||||
**/android/gradlew.bat
|
||||
**/android/local.properties
|
||||
**/android/**/GeneratedPluginRegistrant.java
|
||||
|
||||
# iOS/XCode related
|
||||
**/ios/**/*.mode1v3
|
||||
**/ios/**/*.mode2v3
|
||||
**/ios/**/*.moved-aside
|
||||
**/ios/**/*.pbxuser
|
||||
**/ios/**/*.perspectivev3
|
||||
**/ios/**/*sync/
|
||||
**/ios/**/.sconsign.dblite
|
||||
**/ios/**/.tags*
|
||||
**/ios/**/.vagrant/
|
||||
**/ios/**/DerivedData/
|
||||
**/ios/**/Icon?
|
||||
**/ios/**/Pods/
|
||||
**/ios/**/.symlinks/
|
||||
**/ios/**/profile
|
||||
**/ios/**/xcuserdata
|
||||
**/ios/.generated/
|
||||
**/ios/Flutter/App.framework
|
||||
**/ios/Flutter/Flutter.framework
|
||||
**/ios/Flutter/Generated.xcconfig
|
||||
**/ios/Flutter/app.flx
|
||||
**/ios/Flutter/app.zip
|
||||
**/ios/Flutter/flutter_assets/
|
||||
**/ios/ServiceDefinitions.json
|
||||
**/ios/Runner/GeneratedPluginRegistrant.*
|
||||
|
||||
# Exceptions to above rules.
|
||||
!**/ios/**/default.mode1v3
|
||||
!**/ios/**/default.mode2v3
|
||||
!**/ios/**/default.pbxuser
|
||||
!**/ios/**/default.perspectivev3
|
||||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
stages:
|
||||
- coverage
|
||||
- builddocs
|
||||
- deploy
|
||||
|
||||
test:
|
||||
tags:
|
||||
- linux
|
||||
stage: coverage
|
||||
image: google/dart
|
||||
script:
|
||||
- pub get
|
||||
- pub run test
|
||||
|
||||
code_analyze:
|
||||
tags:
|
||||
- docker
|
||||
stage: coverage
|
||||
image: cirrusci/flutter
|
||||
dependencies: []
|
||||
script:
|
||||
- flutter format lib/ test/ test_driver/ --set-exit-if-changed
|
||||
- flutter analyze
|
||||
|
||||
build_api_doc:
|
||||
tags:
|
||||
- docker
|
||||
stage: builddocs
|
||||
image: cirrusci/flutter
|
||||
script:
|
||||
- dartdoc --exclude "dart:async,dart:collection,dart:convert,dart:core,dart:developer,dart:io,dart:isolate,dart:math,dart:typed_data,dart:ui"
|
||||
artifacts:
|
||||
paths:
|
||||
- doc/api/
|
||||
only:
|
||||
- main
|
||||
|
||||
pages:
|
||||
tags:
|
||||
- linux
|
||||
stage: deploy
|
||||
image: alpine:latest
|
||||
script:
|
||||
- mv doc/api/ public
|
||||
dependencies:
|
||||
- build_api_doc
|
||||
artifacts:
|
||||
paths:
|
||||
- public
|
||||
only:
|
||||
- main
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
## 1.0.0
|
||||
|
||||
- Initial version, created by Stagehand
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
# Contributing code to famedly talk
|
||||
|
||||
Everyone is welcome to contribute code to FamedlySDK, provided that they are willing to license their contributions under the same license as the project itself.
|
||||
Please follow these rules when contributing code to famedly talk:
|
||||
|
||||
## Merge Requests:
|
||||
- Never ever just push something directly to the master branch!
|
||||
- Create a new branch or fork this project and send a Merge Request.
|
||||
- Only Merge Requests with a working CI can be merged.
|
||||
- Only Merge Requests with at least one code reviewer can be merged.
|
||||
- Merge Requests may be refused if they don't follow the rules below.
|
||||
- A new Merge Request SHOULD never decrease the test coverage.
|
||||
|
||||
## Branches
|
||||
### Naming
|
||||
|
||||
Branches should get named by this pattern: `[Module Name]-[Type]-[Detail]`.
|
||||
|
||||
That means for example: "users-fix-attach-roles-issue#765".
|
||||
|
||||
Modules are various parts of the App. This can for example be the directory list or the chat room.
|
||||
|
||||
Types can be one of these:
|
||||
- **feature**
|
||||
- **enhance**
|
||||
- **cleanup**
|
||||
- **refactor**
|
||||
- **fix**
|
||||
- **hotfix** (should rarely get used)
|
||||
|
||||
The Detail part of the pattern should be a short description of what the branch delivers.
|
||||
|
||||
## Commit Messages
|
||||
|
||||
Commit Messages should get written in this pattern: `[[Module Name]] [Commit Message]`.
|
||||
That means for example: "[users] add fetch users endpoint".
|
||||
|
||||
|
||||
## File structure:
|
||||
- Every file must be named by the class and must be capitalized in the beginning.
|
||||
- Directories need to be lowercase.
|
||||
|
||||
## Code style:
|
||||
Please use code formatting. You can use VSCode or Android Studio. On other editors you need to run:
|
||||
```
|
||||
flutter format lib/**/*/*.dart
|
||||
```
|
||||
|
||||
## Code quality:
|
||||
- Don't repeat yourself! Use local variables, functions, classes.
|
||||
- Don't mix UI and business logic in the same environment.
|
||||
- Write tests for new classes, functions and widgets.
|
||||
- Keep it simple stupid: https://en.wikipedia.org/wiki/KISS_principle
|
||||
- Describe all of your classes, methods and attributes using **dartdoc** comments. Read this for more informations: https://dart.dev/guides/language/effective-dart/documentation
|
||||
|
|
@ -0,0 +1,661 @@
|
|||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
famedlySDK
|
||||
Copyright (C) 2019 famedly
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
A library for Dart developers.
|
||||
|
||||
Created from templates made available by Stagehand under a BSD-style
|
||||
[license](https://github.com/dart-lang/stagehand/blob/master/LICENSE).
|
||||
|
||||
## Usage
|
||||
|
||||
A simple usage example:
|
||||
|
||||
```dart
|
||||
import 'package:matrix_api_lite/matrix_api_lite.dart';
|
||||
|
||||
main() {
|
||||
var awesome = new Awesome();
|
||||
}
|
||||
```
|
||||
|
||||
## Features and bugs
|
||||
|
||||
Please file feature requests and bugs at the [issue tracker][tracker].
|
||||
|
||||
[tracker]: http://example.com/issues/replaceme
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
# Defines a default set of lint rules enforced for
|
||||
# projects at Google. For details and rationale,
|
||||
# see https://github.com/dart-lang/pedantic#enabled-lints.
|
||||
include: package:pedantic/analysis_options.yaml
|
||||
|
||||
# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
|
||||
# Uncomment to specify additional rules.
|
||||
# linter:
|
||||
# rules:
|
||||
# - camel_case_types
|
||||
|
||||
analyzer:
|
||||
# exclude:
|
||||
# - path/to/excluded/files/**
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
//import 'package:matrix_api_lite/matrix_api_lite.dart';
|
||||
|
||||
import 'package:matrix_api_lite/src/matrix_api.dart';
|
||||
|
||||
void main() async {
|
||||
final api = MatrixApi(homeserver: Uri.parse('https://matrix.org'));
|
||||
final capabilities = await api.requestServerCapabilities();
|
||||
print(capabilities.toJson());
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Matrix API Lite
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
library matrix_api_lite;
|
||||
|
||||
export 'src/matrix_api.dart';
|
||||
export 'src/utils/logs.dart';
|
||||
export 'src/utils/try_get_map_extension.dart';
|
||||
export 'src/model/algorithm_types.dart';
|
||||
export 'src/model/basic_event.dart';
|
||||
export 'src/model/basic_event_with_sender.dart';
|
||||
export 'src/model/basic_room_event.dart';
|
||||
export 'src/model/device.dart';
|
||||
export 'src/model/event_context.dart';
|
||||
export 'src/model/event_types.dart';
|
||||
export 'src/model/events_sync_update.dart';
|
||||
export 'src/model/filter.dart';
|
||||
export 'src/model/keys_query_response.dart';
|
||||
export 'src/model/login_response.dart';
|
||||
export 'src/model/login_types.dart';
|
||||
export 'src/model/matrix_connection_exception.dart';
|
||||
export 'src/model/matrix_event.dart';
|
||||
export 'src/model/matrix_exception.dart';
|
||||
export 'src/model/matrix_keys.dart';
|
||||
export 'src/model/message_types.dart';
|
||||
export 'src/model/notifications_query_response.dart';
|
||||
export 'src/model/one_time_keys_claim_response.dart';
|
||||
export 'src/model/open_graph_data.dart';
|
||||
export 'src/model/open_id_credentials.dart';
|
||||
export 'src/model/presence.dart';
|
||||
export 'src/model/presence_content.dart';
|
||||
export 'src/model/profile.dart';
|
||||
export 'src/model/public_rooms_response.dart';
|
||||
export 'src/model/push_rule_set.dart';
|
||||
export 'src/model/pusher.dart';
|
||||
export 'src/model/request_token_response.dart';
|
||||
export 'src/model/room_alias_informations.dart';
|
||||
export 'src/model/room_keys_info.dart';
|
||||
export 'src/model/room_keys_keys.dart';
|
||||
export 'src/model/room_summary.dart';
|
||||
export 'src/model/server_capabilities.dart';
|
||||
export 'src/model/stripped_state_event.dart';
|
||||
export 'src/model/supported_protocol.dart';
|
||||
export 'src/model/supported_versions.dart';
|
||||
export 'src/model/sync_update.dart';
|
||||
export 'src/model/tag.dart';
|
||||
export 'src/model/third_party_identifier.dart';
|
||||
export 'src/model/third_party_location.dart';
|
||||
export 'src/model/third_party_user.dart';
|
||||
export 'src/model/timeline_history_response.dart';
|
||||
export 'src/model/turn_server_credentials.dart';
|
||||
export 'src/model/upload_key_signatures_response.dart';
|
||||
export 'src/model/user_search_result.dart';
|
||||
export 'src/model/well_known_informations.dart';
|
||||
export 'src/model/who_is_info.dart';
|
||||
export 'src/model/auth/authentication_data.dart';
|
||||
export 'src/model/auth/authentication_identifier.dart';
|
||||
export 'src/model/auth/authentication_password.dart';
|
||||
export 'src/model/auth/authentication_phone_identifier.dart';
|
||||
export 'src/model/auth/authentication_recaptcha.dart';
|
||||
export 'src/model/auth/authentication_third_party_identifier.dart';
|
||||
export 'src/model/auth/authentication_three_pid_creds.dart';
|
||||
export 'src/model/auth/authentication_token.dart';
|
||||
export 'src/model/auth/authentication_types.dart';
|
||||
export 'src/model/auth/authentication_user_identifier.dart';
|
||||
export 'src/model/events/secret_storage_default_key_content.dart';
|
||||
export 'src/model/events/secret_storage_key_content.dart';
|
||||
export 'src/model/events/tombstone_content.dart';
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
abstract class AlgorithmTypes {
|
||||
static const String olmV1Curve25519AesSha2 = 'm.olm.v1.curve25519-aes-sha2';
|
||||
static const String megolmV1AesSha2 = 'm.megolm.v1.aes-sha2';
|
||||
static const String secretStorageV1AesHmcSha2 =
|
||||
'm.secret_storage.v1.aes-hmac-sha2';
|
||||
static const String megolmBackupV1Curve25519AesSha2 =
|
||||
'm.megolm_backup.v1.curve25519-aes-sha2';
|
||||
static const String pbkdf2 = 'm.pbkdf2';
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class AuthenticationData {
|
||||
String type;
|
||||
String session;
|
||||
|
||||
AuthenticationData({this.type, this.session});
|
||||
|
||||
AuthenticationData.fromJson(Map<String, dynamic> json) {
|
||||
type = json['type'];
|
||||
session = json['session'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (type != null) data['type'] = type;
|
||||
if (session != null) data['session'] = session;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class AuthenticationIdentifier {
|
||||
String type;
|
||||
|
||||
AuthenticationIdentifier({this.type});
|
||||
|
||||
AuthenticationIdentifier.fromJson(Map<String, dynamic> json) {
|
||||
type = json['type'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['type'] = type;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'authentication_user_identifier.dart';
|
||||
import 'authentication_data.dart';
|
||||
import 'authentication_identifier.dart';
|
||||
import 'authentication_phone_identifier.dart';
|
||||
import 'authentication_third_party_identifier.dart';
|
||||
import 'authentication_types.dart';
|
||||
|
||||
class AuthenticationPassword extends AuthenticationData {
|
||||
String user;
|
||||
String password;
|
||||
|
||||
/// You may want to cast this as [AuthenticationUserIdentifier] or other
|
||||
/// Identifier classes extending AuthenticationIdentifier.
|
||||
AuthenticationIdentifier identifier;
|
||||
|
||||
AuthenticationPassword(
|
||||
{String session, this.password, this.user, this.identifier})
|
||||
: super(
|
||||
type: AuthenticationTypes.password,
|
||||
session: session,
|
||||
);
|
||||
|
||||
AuthenticationPassword.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
user = json['user'];
|
||||
password = json['password'];
|
||||
identifier = AuthenticationIdentifier.fromJson(json['identifier']);
|
||||
switch (identifier.type) {
|
||||
case AuthenticationIdentifierTypes.userId:
|
||||
identifier = AuthenticationUserIdentifier.fromJson(json['identifier']);
|
||||
break;
|
||||
case AuthenticationIdentifierTypes.phone:
|
||||
identifier = AuthenticationPhoneIdentifier.fromJson(json['identifier']);
|
||||
break;
|
||||
case AuthenticationIdentifierTypes.thirdParty:
|
||||
identifier =
|
||||
AuthenticationThirdPartyIdentifier.fromJson(json['identifier']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
if (user != null) data['user'] = user;
|
||||
data['password'] = password;
|
||||
switch (identifier.type) {
|
||||
case AuthenticationIdentifierTypes.userId:
|
||||
data['identifier'] =
|
||||
(identifier as AuthenticationUserIdentifier).toJson();
|
||||
break;
|
||||
case AuthenticationIdentifierTypes.phone:
|
||||
data['identifier'] =
|
||||
(identifier as AuthenticationPhoneIdentifier).toJson();
|
||||
break;
|
||||
case AuthenticationIdentifierTypes.thirdParty:
|
||||
data['identifier'] =
|
||||
(identifier as AuthenticationThirdPartyIdentifier).toJson();
|
||||
break;
|
||||
default:
|
||||
data['identifier'] = identifier.toJson();
|
||||
break;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'authentication_identifier.dart';
|
||||
import 'authentication_types.dart';
|
||||
|
||||
class AuthenticationPhoneIdentifier extends AuthenticationIdentifier {
|
||||
String country;
|
||||
String phone;
|
||||
|
||||
AuthenticationPhoneIdentifier({this.country, this.phone})
|
||||
: super(type: AuthenticationIdentifierTypes.phone);
|
||||
|
||||
AuthenticationPhoneIdentifier.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
country = json['country'];
|
||||
phone = json['phone'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['country'] = country;
|
||||
data['phone'] = phone;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'authentication_data.dart';
|
||||
import 'authentication_types.dart';
|
||||
|
||||
class AuthenticationRecaptcha extends AuthenticationData {
|
||||
String response;
|
||||
|
||||
AuthenticationRecaptcha({String session, this.response})
|
||||
: super(
|
||||
type: AuthenticationTypes.recaptcha,
|
||||
session: session,
|
||||
);
|
||||
|
||||
AuthenticationRecaptcha.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
response = json['response'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['response'] = response;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'authentication_identifier.dart';
|
||||
import 'authentication_types.dart';
|
||||
|
||||
class AuthenticationThirdPartyIdentifier extends AuthenticationIdentifier {
|
||||
String medium;
|
||||
String address;
|
||||
|
||||
AuthenticationThirdPartyIdentifier({this.medium, this.address})
|
||||
: super(type: AuthenticationIdentifierTypes.thirdParty);
|
||||
|
||||
AuthenticationThirdPartyIdentifier.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
medium = json['medium'];
|
||||
address = json['address'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['medium'] = medium;
|
||||
data['address'] = address;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'authentication_data.dart';
|
||||
|
||||
/// For email based identity:
|
||||
/// https://matrix.org/docs/spec/client_server/r0.6.1#email-based-identity-homeserver
|
||||
/// Or phone number based identity:
|
||||
/// https://matrix.org/docs/spec/client_server/r0.6.1#phone-number-msisdn-based-identity-homeserver
|
||||
class AuthenticationThreePidCreds extends AuthenticationData {
|
||||
List<ThreepidCreds> threepidCreds;
|
||||
|
||||
AuthenticationThreePidCreds({String session, String type, this.threepidCreds})
|
||||
: super(
|
||||
type: type,
|
||||
session: session,
|
||||
);
|
||||
|
||||
AuthenticationThreePidCreds.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
if (json['threepidCreds'] != null) {
|
||||
threepidCreds = (json['threepidCreds'] as List)
|
||||
.map((item) => ThreepidCreds.fromJson(item))
|
||||
.toList();
|
||||
}
|
||||
|
||||
// This is so extremly stupid... kill it with fire!
|
||||
if (json['threepid_creds'] != null) {
|
||||
threepidCreds = (json['threepid_creds'] as List)
|
||||
.map((item) => ThreepidCreds.fromJson(item))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['threepidCreds'] = threepidCreds.map((t) => t.toJson()).toList();
|
||||
// Help me! I'm prisoned in a developer factory against my will,
|
||||
// where we are forced to work with json like this!!
|
||||
data['threepid_creds'] = threepidCreds.map((t) => t.toJson()).toList();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class ThreepidCreds {
|
||||
String sid;
|
||||
String clientSecret;
|
||||
String idServer;
|
||||
String idAccessToken;
|
||||
|
||||
ThreepidCreds(
|
||||
{this.sid, this.clientSecret, this.idServer, this.idAccessToken});
|
||||
|
||||
ThreepidCreds.fromJson(Map<String, dynamic> json) {
|
||||
sid = json['sid'];
|
||||
clientSecret = json['client_secret'];
|
||||
idServer = json['id_server'];
|
||||
idAccessToken = json['id_access_token'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['sid'] = sid;
|
||||
data['client_secret'] = clientSecret;
|
||||
data['id_server'] = idServer;
|
||||
data['id_access_token'] = idAccessToken;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'authentication_data.dart';
|
||||
import 'authentication_types.dart';
|
||||
|
||||
class AuthenticationToken extends AuthenticationData {
|
||||
String token;
|
||||
String txnId;
|
||||
|
||||
AuthenticationToken({String session, this.token, this.txnId})
|
||||
: super(
|
||||
type: AuthenticationTypes.token,
|
||||
session: session,
|
||||
);
|
||||
|
||||
AuthenticationToken.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
token = json['token'];
|
||||
txnId = json['txn_id'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['token'] = token;
|
||||
data['txn_id'] = txnId;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
abstract class AuthenticationTypes {
|
||||
static const String password = 'm.login.password';
|
||||
static const String recaptcha = 'm.login.recaptcha';
|
||||
static const String token = 'm.login.token';
|
||||
static const String oauth2 = 'm.login.oauth2';
|
||||
static const String sso = 'm.login.sso';
|
||||
static const String emailIdentity = 'm.login.email.identity';
|
||||
static const String msisdn = 'm.login.msisdn';
|
||||
static const String dummy = 'm.login.dummy';
|
||||
}
|
||||
|
||||
abstract class AuthenticationIdentifierTypes {
|
||||
static const String userId = 'm.id.user';
|
||||
static const String thirdParty = 'm.id.thirdparty';
|
||||
static const String phone = 'm.id.phone';
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'authentication_identifier.dart';
|
||||
import 'authentication_types.dart';
|
||||
|
||||
class AuthenticationUserIdentifier extends AuthenticationIdentifier {
|
||||
String user;
|
||||
|
||||
AuthenticationUserIdentifier({this.user})
|
||||
: super(type: AuthenticationIdentifierTypes.userId);
|
||||
|
||||
AuthenticationUserIdentifier.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
user = json['user'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['user'] = user;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class BasicEvent {
|
||||
String type;
|
||||
Map<String, dynamic> content;
|
||||
|
||||
BasicEvent({
|
||||
this.type,
|
||||
this.content,
|
||||
});
|
||||
|
||||
BasicEvent.fromJson(Map<String, dynamic> json) {
|
||||
type = json['type'];
|
||||
content = Map<String, dynamic>.from(json['content']);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['type'] = type;
|
||||
data['content'] = content;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'basic_event.dart';
|
||||
|
||||
class BasicEventWithSender extends BasicEvent {
|
||||
String senderId;
|
||||
|
||||
BasicEventWithSender();
|
||||
|
||||
BasicEventWithSender.fromJson(Map<String, dynamic> json) {
|
||||
final basicEvent = BasicEvent.fromJson(json);
|
||||
type = basicEvent.type;
|
||||
content = basicEvent.content;
|
||||
senderId = json['sender'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['sender'] = senderId;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'basic_event.dart';
|
||||
|
||||
class BasicRoomEvent extends BasicEvent {
|
||||
String roomId;
|
||||
|
||||
BasicRoomEvent({
|
||||
this.roomId,
|
||||
Map<String, dynamic> content,
|
||||
String type,
|
||||
}) : super(
|
||||
content: content,
|
||||
type: type,
|
||||
);
|
||||
|
||||
BasicRoomEvent.fromJson(Map<String, dynamic> json) {
|
||||
final basicEvent = BasicEvent.fromJson(json);
|
||||
content = basicEvent.content;
|
||||
type = basicEvent.type;
|
||||
roomId = json['room_id'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
if (roomId != null) data['room_id'] = roomId;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class Device {
|
||||
String deviceId;
|
||||
String displayName;
|
||||
String lastSeenIp;
|
||||
DateTime lastSeenTs;
|
||||
|
||||
Device.fromJson(Map<String, dynamic> json) {
|
||||
deviceId = json['device_id'];
|
||||
displayName = json['display_name'];
|
||||
lastSeenIp = json['last_seen_ip'];
|
||||
lastSeenTs = DateTime.fromMillisecondsSinceEpoch(json['last_seen_ts'] ?? 0);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['device_id'] = deviceId;
|
||||
if (displayName != null) {
|
||||
data['display_name'] = displayName;
|
||||
}
|
||||
if (lastSeenIp != null) {
|
||||
data['last_seen_ip'] = lastSeenIp;
|
||||
}
|
||||
if (lastSeenTs != null) {
|
||||
data['last_seen_ts'] = lastSeenTs.millisecondsSinceEpoch;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'matrix_event.dart';
|
||||
|
||||
class EventContext {
|
||||
String end;
|
||||
List<MatrixEvent> eventsAfter;
|
||||
MatrixEvent event;
|
||||
List<MatrixEvent> eventsBefore;
|
||||
String start;
|
||||
List<MatrixEvent> state;
|
||||
|
||||
EventContext.fromJson(Map<String, dynamic> json) {
|
||||
end = json['end'];
|
||||
if (json['events_after'] != null) {
|
||||
eventsAfter = <MatrixEvent>[];
|
||||
json['events_after'].forEach((v) {
|
||||
eventsAfter.add(MatrixEvent.fromJson(v));
|
||||
});
|
||||
}
|
||||
event = json['event'] != null ? MatrixEvent.fromJson(json['event']) : null;
|
||||
if (json['events_before'] != null) {
|
||||
eventsBefore = <MatrixEvent>[];
|
||||
json['events_before'].forEach((v) {
|
||||
eventsBefore.add(MatrixEvent.fromJson(v));
|
||||
});
|
||||
}
|
||||
start = json['start'];
|
||||
if (json['state'] != null) {
|
||||
state = <MatrixEvent>[];
|
||||
json['state'].forEach((v) {
|
||||
state.add(MatrixEvent.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (end != null) {
|
||||
data['end'] = end;
|
||||
}
|
||||
if (eventsAfter != null) {
|
||||
data['events_after'] = eventsAfter.map((v) => v.toJson()).toList();
|
||||
}
|
||||
if (event != null) {
|
||||
data['event'] = event.toJson();
|
||||
}
|
||||
if (eventsBefore != null) {
|
||||
data['events_before'] = eventsBefore.map((v) => v.toJson()).toList();
|
||||
}
|
||||
data['start'] = start;
|
||||
if (state != null) {
|
||||
data['state'] = state.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
abstract class EventTypes {
|
||||
// Room timeline and state event types
|
||||
static const String Message = 'm.room.message';
|
||||
static const String Sticker = 'm.sticker';
|
||||
static const String Reaction = 'm.reaction';
|
||||
static const String Redaction = 'm.room.redaction';
|
||||
static const String RoomAliases = 'm.room.aliases';
|
||||
static const String RoomCanonicalAlias = 'm.room.canonical_alias';
|
||||
static const String RoomCreate = 'm.room.create';
|
||||
static const String RoomJoinRules = 'm.room.join_rules';
|
||||
static const String RoomMember = 'm.room.member';
|
||||
static const String RoomPowerLevels = 'm.room.power_levels';
|
||||
static const String RoomName = 'm.room.name';
|
||||
static const String RoomPinnedEvents = 'm.room.pinned_events';
|
||||
static const String RoomTopic = 'm.room.topic';
|
||||
static const String RoomAvatar = 'm.room.avatar';
|
||||
static const String RoomTombstone = 'm.room.tombstone';
|
||||
static const String GuestAccess = 'm.room.guest_access';
|
||||
static const String HistoryVisibility = 'm.room.history_visibility';
|
||||
static const String Encryption = 'm.room.encryption';
|
||||
static const String Encrypted = 'm.room.encrypted';
|
||||
static const String CallInvite = 'm.call.invite';
|
||||
static const String CallAnswer = 'm.call.answer';
|
||||
static const String CallCandidates = 'm.call.candidates';
|
||||
static const String CallHangup = 'm.call.hangup';
|
||||
static const String Unknown = 'm.unknown';
|
||||
|
||||
// To device event types
|
||||
static const String RoomKey = 'm.room_key';
|
||||
static const String ForwardedRoomKey = 'm.forwarded_room_key';
|
||||
static const String RoomKeyRequest = 'm.room_key_request';
|
||||
static const String KeyVerificationRequest = 'm.key.verification.request';
|
||||
static const String KeyVerificationStart = 'm.key.verification.start';
|
||||
static const String KeyVerificationDone = 'm.key.verification.done';
|
||||
static const String KeyVerificationCancel = 'm.key.verification.cancel';
|
||||
static const String KeyVerificationAccept = 'm.key.verification.accept';
|
||||
static const String SecretRequest = 'm.secret.request';
|
||||
static const String SecretSend = 'm.secret.send';
|
||||
static const String CrossSigningSelfSigning = 'm.cross_signing.self_signing';
|
||||
static const String CrossSigningUserSigning = 'm.cross_signing.user_signing';
|
||||
static const String CrossSigningMasterKey = 'm.cross_signing.master';
|
||||
static const String MegolmBackup = 'm.megolm_backup.v1';
|
||||
static const String SecretStorageDefaultKey = 'm.secret_storage.default_key';
|
||||
static String secretStorageKey(String keyId) => 'm.secret_storage.key.$keyId';
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
import '../basic_event.dart';
|
||||
import '../../utils/try_get_map_extension.dart';
|
||||
|
||||
extension SecretStorageDefaultKeyContentBasicEventExtension on BasicEvent {
|
||||
SecretStorageDefaultKeyContent get parsedSecretStorageDefaultKeyContent =>
|
||||
SecretStorageDefaultKeyContent.fromJson(content);
|
||||
}
|
||||
|
||||
class SecretStorageDefaultKeyContent {
|
||||
String key;
|
||||
|
||||
SecretStorageDefaultKeyContent();
|
||||
|
||||
SecretStorageDefaultKeyContent.fromJson(Map<String, dynamic> json)
|
||||
: key = json.tryGet<String>('key');
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (key != null) data['key'] = key;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
import '../basic_event.dart';
|
||||
import '../../utils/try_get_map_extension.dart';
|
||||
|
||||
extension SecretStorageKeyContentBasicEventExtension on BasicEvent {
|
||||
SecretStorageKeyContent get parsedSecretStorageKeyContent =>
|
||||
SecretStorageKeyContent.fromJson(content);
|
||||
}
|
||||
|
||||
class SecretStorageKeyContent {
|
||||
PassphraseInfo passphrase;
|
||||
String iv;
|
||||
String mac;
|
||||
String algorithm;
|
||||
|
||||
SecretStorageKeyContent();
|
||||
|
||||
SecretStorageKeyContent.fromJson(Map<String, dynamic> json)
|
||||
: passphrase = json['passphrase'] is Map<String, dynamic>
|
||||
? PassphraseInfo.fromJson(json['passphrase'])
|
||||
: null,
|
||||
iv = json.tryGet<String>('iv'),
|
||||
mac = json.tryGet<String>('mac'),
|
||||
algorithm = json.tryGet<String>('algorithm');
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (passphrase != null) data['passphrase'] = passphrase.toJson();
|
||||
if (iv != null) data['iv'] = iv;
|
||||
if (mac != null) data['mac'] = mac;
|
||||
if (algorithm != null) data['algorithm'] = algorithm;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class PassphraseInfo {
|
||||
String algorithm;
|
||||
String salt;
|
||||
int iterations;
|
||||
int bits;
|
||||
|
||||
PassphraseInfo();
|
||||
|
||||
PassphraseInfo.fromJson(Map<String, dynamic> json)
|
||||
: algorithm = json.tryGet<String>('algorithm'),
|
||||
salt = json.tryGet<String>('salt'),
|
||||
iterations = json.tryGet<int>('iterations'),
|
||||
bits = json.tryGet<int>('bits');
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (algorithm != null) data['algorithm'] = algorithm;
|
||||
if (salt != null) data['salt'] = salt;
|
||||
if (iterations != null) data['iterations'] = iterations;
|
||||
if (bits != null) data['bits'] = bits;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import '../basic_event.dart';
|
||||
import '../../utils/try_get_map_extension.dart';
|
||||
|
||||
extension TombstoneContentBasicEventExtension on BasicEvent {
|
||||
TombstoneContent get parsedTombstoneContent =>
|
||||
TombstoneContent.fromJson(content);
|
||||
}
|
||||
|
||||
class TombstoneContent {
|
||||
String body;
|
||||
String replacementRoom;
|
||||
|
||||
TombstoneContent.fromJson(Map<String, dynamic> json)
|
||||
: body = json.tryGet<String>('body', ''),
|
||||
replacementRoom = json.tryGet<String>('replacement_room', '');
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['body'] = body;
|
||||
data['replacement_room'] = replacementRoom;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'matrix_event.dart';
|
||||
|
||||
class EventsSyncUpdate {
|
||||
String start;
|
||||
String end;
|
||||
List<MatrixEvent> chunk;
|
||||
|
||||
EventsSyncUpdate.fromJson(Map<String, dynamic> json) {
|
||||
start = json['start'];
|
||||
end = json['end'];
|
||||
chunk = json['chunk'] != null
|
||||
? (json['chunk'] as List).map((i) => MatrixEvent.fromJson(i)).toList()
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (start != null) {
|
||||
data['start'] = start;
|
||||
}
|
||||
if (end != null) {
|
||||
data['end'] = end;
|
||||
}
|
||||
if (chunk != null) {
|
||||
data['chunk'] = chunk.map((i) => i.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,222 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
enum EventFormat { client, federation }
|
||||
|
||||
class Filter {
|
||||
RoomFilter room;
|
||||
EventFilter presence;
|
||||
EventFilter accountData;
|
||||
EventFormat eventFormat;
|
||||
List<String> eventFields;
|
||||
|
||||
Filter({
|
||||
this.room,
|
||||
this.presence,
|
||||
this.accountData,
|
||||
this.eventFormat,
|
||||
this.eventFields,
|
||||
});
|
||||
|
||||
Filter.fromJson(Map<String, dynamic> json) {
|
||||
room = json['room'] != null ? RoomFilter.fromJson(json['room']) : null;
|
||||
presence = json['presence'] != null
|
||||
? EventFilter.fromJson(json['presence'])
|
||||
: null;
|
||||
accountData = json['account_data'] != null
|
||||
? EventFilter.fromJson(json['account_data'])
|
||||
: null;
|
||||
eventFormat = json['event_format'] != null
|
||||
? EventFormat.values.firstWhere(
|
||||
(e) => e.toString().split('.').last == json['event_format'])
|
||||
: null;
|
||||
eventFields = json['event_fields'] != null
|
||||
? json['event_fields'].cast<String>()
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (room != null) {
|
||||
data['room'] = room.toJson();
|
||||
}
|
||||
if (presence != null) {
|
||||
data['presence'] = presence.toJson();
|
||||
}
|
||||
if (eventFormat != null) {
|
||||
data['event_format'] = eventFormat.toString().split('.').last;
|
||||
}
|
||||
if (eventFields != null) {
|
||||
data['event_fields'] = eventFields;
|
||||
}
|
||||
if (accountData != null) {
|
||||
data['account_data'] = accountData.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class RoomFilter {
|
||||
List<String> notRooms;
|
||||
List<String> rooms;
|
||||
StateFilter ephemeral;
|
||||
bool includeLeave;
|
||||
StateFilter state;
|
||||
StateFilter timeline;
|
||||
StateFilter accountData;
|
||||
|
||||
RoomFilter({
|
||||
this.notRooms,
|
||||
this.rooms,
|
||||
this.ephemeral,
|
||||
this.includeLeave,
|
||||
this.state,
|
||||
this.timeline,
|
||||
this.accountData,
|
||||
});
|
||||
|
||||
RoomFilter.fromJson(Map<String, dynamic> json) {
|
||||
notRooms = json['not_rooms']?.cast<String>();
|
||||
rooms = json['rooms']?.cast<String>();
|
||||
state = json['state'] != null ? StateFilter.fromJson(json['state']) : null;
|
||||
includeLeave = json['include_leave'];
|
||||
timeline = json['timeline'] != null
|
||||
? StateFilter.fromJson(json['timeline'])
|
||||
: null;
|
||||
ephemeral = json['ephemeral'] != null
|
||||
? StateFilter.fromJson(json['ephemeral'])
|
||||
: null;
|
||||
accountData = json['account_data'] != null
|
||||
? StateFilter.fromJson(json['account_data'])
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (notRooms != null) {
|
||||
data['not_rooms'] = notRooms;
|
||||
}
|
||||
if (rooms != null) {
|
||||
data['rooms'] = rooms;
|
||||
}
|
||||
if (ephemeral != null) {
|
||||
data['ephemeral'] = ephemeral.toJson();
|
||||
}
|
||||
if (includeLeave != null) {
|
||||
data['include_leave'] = includeLeave;
|
||||
}
|
||||
if (state != null) {
|
||||
data['state'] = state.toJson();
|
||||
}
|
||||
if (timeline != null) {
|
||||
data['timeline'] = timeline.toJson();
|
||||
}
|
||||
if (accountData != null) {
|
||||
data['account_data'] = accountData.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class EventFilter {
|
||||
int limit;
|
||||
List<String> senders;
|
||||
List<String> types;
|
||||
List<String> notRooms;
|
||||
List<String> notSenders;
|
||||
|
||||
EventFilter(
|
||||
{this.limit, this.senders, this.types, this.notRooms, this.notSenders});
|
||||
|
||||
EventFilter.fromJson(Map<String, dynamic> json) {
|
||||
limit = json['limit'];
|
||||
types = json['senders']?.cast<String>();
|
||||
types = json['types']?.cast<String>();
|
||||
notRooms = json['not_rooms']?.cast<String>();
|
||||
notSenders = json['not_senders']?.cast<String>();
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (limit != null) data['limit'] = limit;
|
||||
if (types != null) data['types'] = types;
|
||||
if (notRooms != null) data['not_rooms'] = notRooms;
|
||||
if (notSenders != null) data['not_senders'] = notSenders;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class StateFilter extends EventFilter {
|
||||
List<String> notTypes;
|
||||
bool lazyLoadMembers;
|
||||
bool includeRedundantMembers;
|
||||
bool containsUrl;
|
||||
|
||||
StateFilter({
|
||||
this.notTypes,
|
||||
this.lazyLoadMembers,
|
||||
this.includeRedundantMembers,
|
||||
this.containsUrl,
|
||||
int limit,
|
||||
List<String> senders,
|
||||
List<String> types,
|
||||
List<String> notRooms,
|
||||
List<String> notSenders,
|
||||
}) : super(
|
||||
limit: limit,
|
||||
senders: senders,
|
||||
types: types,
|
||||
notRooms: notRooms,
|
||||
notSenders: notSenders,
|
||||
);
|
||||
|
||||
StateFilter.fromJson(Map<String, dynamic> json) {
|
||||
final eventFilter = EventFilter.fromJson(json);
|
||||
limit = eventFilter.limit;
|
||||
senders = eventFilter.senders;
|
||||
types = eventFilter.types;
|
||||
notRooms = eventFilter.notRooms;
|
||||
notSenders = eventFilter.notSenders;
|
||||
|
||||
notTypes = json['not_types']?.cast<String>();
|
||||
lazyLoadMembers = json['lazy_load_members'];
|
||||
includeRedundantMembers = json['include_redundant_members'];
|
||||
containsUrl = json['contains_url'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
if (limit != null) {
|
||||
data['limit'] = limit;
|
||||
}
|
||||
if (notTypes != null) {
|
||||
data['not_types'] = notTypes;
|
||||
}
|
||||
if (lazyLoadMembers != null) {
|
||||
data['lazy_load_members'] = notTypes;
|
||||
}
|
||||
if (includeRedundantMembers != null) {
|
||||
data['include_redundant_members'] = notTypes;
|
||||
}
|
||||
if (containsUrl != null) {
|
||||
data['contains_url'] = notTypes;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'matrix_keys.dart';
|
||||
|
||||
class KeysQueryResponse {
|
||||
Map<String, dynamic> failures;
|
||||
Map<String, Map<String, MatrixDeviceKeys>> deviceKeys;
|
||||
Map<String, MatrixCrossSigningKey> masterKeys;
|
||||
Map<String, MatrixCrossSigningKey> selfSigningKeys;
|
||||
Map<String, MatrixCrossSigningKey> userSigningKeys;
|
||||
|
||||
KeysQueryResponse.fromJson(Map<String, dynamic> json) {
|
||||
failures = json['failures'] != null
|
||||
? Map<String, dynamic>.from(json['failures'])
|
||||
: null;
|
||||
deviceKeys = json['device_keys'] != null
|
||||
? (json['device_keys'] as Map).map(
|
||||
(k, v) => MapEntry(
|
||||
k,
|
||||
(v as Map).map(
|
||||
(k, v) => MapEntry(
|
||||
k,
|
||||
MatrixDeviceKeys.fromJson(v),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: null;
|
||||
masterKeys = json['master_keys'] != null
|
||||
? (json['master_keys'] as Map).map(
|
||||
(k, v) => MapEntry(
|
||||
k,
|
||||
MatrixCrossSigningKey.fromJson(v),
|
||||
),
|
||||
)
|
||||
: null;
|
||||
|
||||
selfSigningKeys = json['self_signing_keys'] != null
|
||||
? (json['self_signing_keys'] as Map).map(
|
||||
(k, v) => MapEntry(
|
||||
k,
|
||||
MatrixCrossSigningKey.fromJson(v),
|
||||
),
|
||||
)
|
||||
: null;
|
||||
|
||||
userSigningKeys = json['user_signing_keys'] != null
|
||||
? (json['user_signing_keys'] as Map).map(
|
||||
(k, v) => MapEntry(
|
||||
k,
|
||||
MatrixCrossSigningKey.fromJson(v),
|
||||
),
|
||||
)
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (failures != null) {
|
||||
data['failures'] = failures;
|
||||
}
|
||||
if (deviceKeys != null) {
|
||||
data['device_keys'] = deviceKeys.map(
|
||||
(k, v) => MapEntry(
|
||||
k,
|
||||
v.map(
|
||||
(k, v) => MapEntry(
|
||||
k,
|
||||
v.toJson(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (masterKeys != null) {
|
||||
data['master_keys'] = masterKeys.map(
|
||||
(k, v) => MapEntry(
|
||||
k,
|
||||
v.toJson(),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (selfSigningKeys != null) {
|
||||
data['self_signing_keys'] = selfSigningKeys.map(
|
||||
(k, v) => MapEntry(
|
||||
k,
|
||||
v.toJson(),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (userSigningKeys != null) {
|
||||
data['user_signing_keys'] = userSigningKeys.map(
|
||||
(k, v) => MapEntry(
|
||||
k,
|
||||
v.toJson(),
|
||||
),
|
||||
);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'well_known_informations.dart';
|
||||
|
||||
class LoginResponse {
|
||||
String userId;
|
||||
String accessToken;
|
||||
String deviceId;
|
||||
WellKnownInformations wellKnownInformations;
|
||||
|
||||
LoginResponse.fromJson(Map<String, dynamic> json) {
|
||||
userId = json['user_id'];
|
||||
accessToken = json['access_token'];
|
||||
deviceId = json['device_id'];
|
||||
if (json['well_known'] is Map) {
|
||||
wellKnownInformations =
|
||||
WellKnownInformations.fromJson(json['well_known']);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (userId != null) data['user_id'] = userId;
|
||||
if (accessToken != null) data['access_token'] = accessToken;
|
||||
if (deviceId != null) data['device_id'] = deviceId;
|
||||
if (wellKnownInformations != null) {
|
||||
data['well_known'] = wellKnownInformations.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class LoginTypes {
|
||||
List<Flows> flows;
|
||||
|
||||
LoginTypes.fromJson(Map<String, dynamic> json) {
|
||||
if (json['flows'] != null) {
|
||||
flows = <Flows>[];
|
||||
json['flows'].forEach((v) {
|
||||
flows.add(Flows.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (flows != null) {
|
||||
data['flows'] = flows.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Flows {
|
||||
String type;
|
||||
|
||||
Flows.fromJson(Map<String, dynamic> json) {
|
||||
type = json['type'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['type'] = type;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
mixin EventType {
|
||||
static const String MarkedUnread = 'com.famedly.marked_unread';
|
||||
}
|
||||
|
||||
class MarkedUnread {
|
||||
bool unread;
|
||||
|
||||
MarkedUnread(this.unread);
|
||||
|
||||
MarkedUnread.fromJson(Map<String, dynamic> json) {
|
||||
if (!(json['unread'] is bool)) {
|
||||
unread = false;
|
||||
} else {
|
||||
unread = json['unread'];
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (unread != null) {
|
||||
data['unread'] = unread;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class MatrixConnectionException implements Exception {
|
||||
final dynamic original;
|
||||
final StackTrace stackTrace;
|
||||
MatrixConnectionException(this.original, this.stackTrace);
|
||||
|
||||
@override
|
||||
String toString() => original.toString();
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'stripped_state_event.dart';
|
||||
|
||||
class MatrixEvent extends StrippedStateEvent {
|
||||
String eventId;
|
||||
String roomId;
|
||||
DateTime originServerTs;
|
||||
Map<String, dynamic> unsigned;
|
||||
Map<String, dynamic> prevContent;
|
||||
String redacts;
|
||||
|
||||
MatrixEvent();
|
||||
|
||||
MatrixEvent.fromJson(Map<String, dynamic> json) {
|
||||
final strippedStateEvent = StrippedStateEvent.fromJson(json);
|
||||
content = strippedStateEvent.content;
|
||||
type = strippedStateEvent.type;
|
||||
senderId = strippedStateEvent.senderId;
|
||||
stateKey = strippedStateEvent.stateKey;
|
||||
eventId = json['event_id'];
|
||||
roomId = json['room_id'];
|
||||
originServerTs =
|
||||
DateTime.fromMillisecondsSinceEpoch(json['origin_server_ts']);
|
||||
unsigned = json['unsigned'] != null
|
||||
? Map<String, dynamic>.from(json['unsigned'])
|
||||
: null;
|
||||
prevContent = json['prev_content'] != null
|
||||
? Map<String, dynamic>.from(json['prev_content'])
|
||||
: null;
|
||||
redacts = json['redacts'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['event_id'] = eventId;
|
||||
data['origin_server_ts'] = originServerTs.millisecondsSinceEpoch;
|
||||
if (unsigned != null) {
|
||||
data['unsigned'] = unsigned;
|
||||
}
|
||||
if (prevContent != null) {
|
||||
data['prev_content'] = prevContent;
|
||||
}
|
||||
if (roomId != null) {
|
||||
data['room_id'] = roomId;
|
||||
}
|
||||
if (data['state_key'] == null) {
|
||||
data.remove('state_key');
|
||||
}
|
||||
if (redacts != null) {
|
||||
data['redacts'] = redacts;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
enum MatrixError {
|
||||
M_UNKNOWN,
|
||||
M_UNKNOWN_TOKEN,
|
||||
M_NOT_FOUND,
|
||||
M_FORBIDDEN,
|
||||
M_LIMIT_EXCEEDED,
|
||||
M_USER_IN_USE,
|
||||
M_THREEPID_IN_USE,
|
||||
M_THREEPID_DENIED,
|
||||
M_THREEPID_NOT_FOUND,
|
||||
M_THREEPID_AUTH_FAILED,
|
||||
M_TOO_LARGE,
|
||||
M_MISSING_PARAM,
|
||||
M_UNSUPPORTED_ROOM_VERSION,
|
||||
M_UNRECOGNIZED,
|
||||
}
|
||||
|
||||
/// Represents a special response from the Homeserver for errors.
|
||||
class MatrixException implements Exception {
|
||||
final Map<String, dynamic> raw;
|
||||
|
||||
/// The unique identifier for this error.
|
||||
String get errcode =>
|
||||
raw['errcode'] ??
|
||||
(requireAdditionalAuthentication ? 'M_FORBIDDEN' : 'M_UNKNOWN');
|
||||
|
||||
/// A human readable error description.
|
||||
String get errorMessage =>
|
||||
raw['error'] ??
|
||||
(requireAdditionalAuthentication
|
||||
? 'Require additional authentication'
|
||||
: 'Unknown error');
|
||||
|
||||
/// The frozen request which triggered this Error
|
||||
http.Response response;
|
||||
|
||||
MatrixException(this.response) : raw = json.decode(response.body);
|
||||
MatrixException.fromJson(Map<String, dynamic> content) : raw = content;
|
||||
|
||||
@override
|
||||
String toString() => '$errcode: $errorMessage';
|
||||
|
||||
/// Returns the [ResponseError]. Is ResponseError.NONE if there wasn't an error.
|
||||
MatrixError get error => MatrixError.values.firstWhere(
|
||||
(e) => e.toString() == 'MatrixError.${(raw["errcode"] ?? "")}',
|
||||
orElse: () => MatrixError.M_UNKNOWN);
|
||||
|
||||
int get retryAfterMs => raw['retry_after_ms'];
|
||||
|
||||
/// This is a session identifier that the client must pass back to the homeserver, if one is provided,
|
||||
/// in subsequent attempts to authenticate in the same API call.
|
||||
String get session => raw['session'];
|
||||
|
||||
/// Returns true if the server requires additional authentication.
|
||||
bool get requireAdditionalAuthentication => response != null
|
||||
? response.statusCode == 401
|
||||
: authenticationFlows != null;
|
||||
|
||||
/// For each endpoint, a server offers one or more 'flows' that the client can use
|
||||
/// to authenticate itself. Each flow comprises a series of stages. If this request
|
||||
/// doesn't need additional authentication, then this is null.
|
||||
List<AuthenticationFlow> get authenticationFlows {
|
||||
if (!raw.containsKey('flows') || !(raw['flows'] is List)) return null;
|
||||
var flows = <AuthenticationFlow>[];
|
||||
for (Map<String, dynamic> flow in raw['flows']) {
|
||||
if (flow['stages'] is List) {
|
||||
flows.add(AuthenticationFlow(List<String>.from(flow['stages'])));
|
||||
}
|
||||
}
|
||||
return flows;
|
||||
}
|
||||
|
||||
/// This section contains any information that the client will need to know in order to use a given type
|
||||
/// of authentication. For each authentication type presented, that type may be present as a key in this
|
||||
/// dictionary. For example, the public part of an OAuth client ID could be given here.
|
||||
Map<String, dynamic> get authenticationParams => raw['params'];
|
||||
|
||||
/// Returns the list of already completed authentication flows from previous requests.
|
||||
List<String> get completedAuthenticationFlows =>
|
||||
List<String>.from(raw['completed'] ?? []);
|
||||
}
|
||||
|
||||
/// For each endpoint, a server offers one or more 'flows' that the client can use
|
||||
/// to authenticate itself. Each flow comprises a series of stages
|
||||
class AuthenticationFlow {
|
||||
final List<String> stages;
|
||||
const AuthenticationFlow(this.stages);
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class MatrixSignableKey {
|
||||
String userId;
|
||||
String identifier;
|
||||
Map<String, String> keys;
|
||||
Map<String, Map<String, String>> signatures;
|
||||
Map<String, dynamic> unsigned;
|
||||
|
||||
MatrixSignableKey(this.userId, this.identifier, this.keys, this.signatures,
|
||||
{this.unsigned});
|
||||
|
||||
// This object is used for signing so we need the raw json too
|
||||
Map<String, dynamic> _json;
|
||||
|
||||
MatrixSignableKey.fromJson(Map<String, dynamic> json) {
|
||||
_json = json;
|
||||
userId = json['user_id'];
|
||||
keys = Map<String, String>.from(json['keys']);
|
||||
signatures = json['signatures'] is Map
|
||||
? Map<String, Map<String, String>>.from((json['signatures'] as Map)
|
||||
.map((k, v) => MapEntry(k, Map<String, String>.from(v))))
|
||||
: null;
|
||||
unsigned = json['unsigned'] is Map
|
||||
? Map<String, dynamic>.from(json['unsigned'])
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = _json ?? <String, dynamic>{};
|
||||
data['user_id'] = userId;
|
||||
data['keys'] = keys;
|
||||
|
||||
if (signatures != null) {
|
||||
data['signatures'] = signatures;
|
||||
}
|
||||
if (unsigned != null) {
|
||||
data['unsigned'] = unsigned;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class MatrixCrossSigningKey extends MatrixSignableKey {
|
||||
List<String> usage;
|
||||
String get publicKey => identifier;
|
||||
|
||||
MatrixCrossSigningKey(
|
||||
String userId,
|
||||
this.usage,
|
||||
Map<String, String> keys,
|
||||
Map<String, Map<String, String>> signatures, {
|
||||
Map<String, dynamic> unsigned,
|
||||
}) : super(userId, keys?.values?.first, keys, signatures, unsigned: unsigned);
|
||||
|
||||
@override
|
||||
MatrixCrossSigningKey.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
usage = List<String>.from(json['usage']);
|
||||
identifier = keys?.values?.first;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['usage'] = usage;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class MatrixDeviceKeys extends MatrixSignableKey {
|
||||
String get deviceId => identifier;
|
||||
List<String> algorithms;
|
||||
String get deviceDisplayName =>
|
||||
unsigned != null ? unsigned['device_display_name'] : null;
|
||||
|
||||
MatrixDeviceKeys(
|
||||
String userId,
|
||||
String deviceId,
|
||||
this.algorithms,
|
||||
Map<String, String> keys,
|
||||
Map<String, Map<String, String>> signatures, {
|
||||
Map<String, dynamic> unsigned,
|
||||
}) : super(userId, deviceId, keys, signatures, unsigned: unsigned);
|
||||
|
||||
@override
|
||||
MatrixDeviceKeys.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||
identifier = json['device_id'];
|
||||
algorithms = json['algorithms'].cast<String>();
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['device_id'] = deviceId;
|
||||
data['algorithms'] = algorithms;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
abstract class MessageTypes {
|
||||
static const String Text = 'm.text';
|
||||
static const String Emote = 'm.emote';
|
||||
static const String Notice = 'm.notice';
|
||||
static const String Image = 'm.image';
|
||||
static const String Video = 'm.video';
|
||||
static const String Audio = 'm.audio';
|
||||
static const String File = 'm.file';
|
||||
static const String Location = 'm.location';
|
||||
static const String Sticker = 'm.sticker';
|
||||
static const String BadEncrypted = 'm.bad.encrypted';
|
||||
static const String None = 'm.none';
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'matrix_event.dart';
|
||||
|
||||
class NotificationsQueryResponse {
|
||||
String nextToken;
|
||||
List<Notification> notifications;
|
||||
|
||||
NotificationsQueryResponse.fromJson(Map<String, dynamic> json) {
|
||||
nextToken = json['next_token'];
|
||||
notifications = <Notification>[];
|
||||
json['notifications'].forEach((v) {
|
||||
notifications.add(Notification.fromJson(v));
|
||||
});
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (nextToken != null) {
|
||||
data['next_token'] = nextToken;
|
||||
}
|
||||
data['notifications'] = notifications.map((v) => v.toJson()).toList();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Notification {
|
||||
List<String> actions;
|
||||
String profileTag;
|
||||
bool read;
|
||||
String roomId;
|
||||
int ts;
|
||||
MatrixEvent event;
|
||||
|
||||
Notification.fromJson(Map<String, dynamic> json) {
|
||||
actions = json['actions'].cast<String>();
|
||||
profileTag = json['profile_tag'];
|
||||
read = json['read'];
|
||||
roomId = json['room_id'];
|
||||
ts = json['ts'];
|
||||
event = MatrixEvent.fromJson(json['event']);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['actions'] = actions;
|
||||
if (profileTag != null) {
|
||||
data['profile_tag'] = profileTag;
|
||||
}
|
||||
data['read'] = read;
|
||||
data['room_id'] = roomId;
|
||||
data['ts'] = ts;
|
||||
data['event'] = event.toJson();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class OneTimeKeysClaimResponse {
|
||||
Map<String, dynamic> failures;
|
||||
Map<String, Map<String, dynamic>> oneTimeKeys;
|
||||
|
||||
OneTimeKeysClaimResponse.fromJson(Map<String, dynamic> json) {
|
||||
failures = Map<String, dynamic>.from(json['failures'] ?? {});
|
||||
oneTimeKeys = Map<String, Map<String, dynamic>>.from(json['one_time_keys']);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (failures != null) {
|
||||
data['failures'] = failures;
|
||||
}
|
||||
if (oneTimeKeys != null) {
|
||||
data['one_time_keys'] = oneTimeKeys;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class OpenGraphData {
|
||||
String ogTitle;
|
||||
String ogDescription;
|
||||
String ogImage;
|
||||
String ogImageType;
|
||||
int ogImageHeight;
|
||||
int ogImageWidth;
|
||||
int matrixImageSize;
|
||||
|
||||
OpenGraphData.fromJson(Map<String, dynamic> json) {
|
||||
ogTitle = json['og:title'];
|
||||
ogDescription = json['og:description'];
|
||||
ogImage = json['og:image'];
|
||||
ogImageType = json['og:image:type'];
|
||||
ogImageHeight = json['og:image:height'];
|
||||
ogImageWidth = json['og:image:width'];
|
||||
matrixImageSize = json['matrix:image:size'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (ogTitle != null) {
|
||||
data['og:title'] = ogTitle;
|
||||
}
|
||||
if (ogDescription != null) {
|
||||
data['og:description'] = ogDescription;
|
||||
}
|
||||
if (ogImage != null) {
|
||||
data['og:image'] = ogImage;
|
||||
}
|
||||
if (ogImageType != null) {
|
||||
data['og:image:type'] = ogImageType;
|
||||
}
|
||||
if (ogImageHeight != null) {
|
||||
data['og:image:height'] = ogImageHeight;
|
||||
}
|
||||
if (ogImageWidth != null) {
|
||||
data['og:image:width'] = ogImageWidth;
|
||||
}
|
||||
if (matrixImageSize != null) {
|
||||
data['matrix:image:size'] = matrixImageSize;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class OpenIdCredentials {
|
||||
String accessToken;
|
||||
String tokenType;
|
||||
String matrixServerName;
|
||||
double expiresIn;
|
||||
|
||||
OpenIdCredentials.fromJson(Map<String, dynamic> json) {
|
||||
accessToken = json['access_token'];
|
||||
tokenType = json['token_type'];
|
||||
matrixServerName = json['matrix_server_name'];
|
||||
expiresIn = json['expires_in'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['access_token'] = accessToken;
|
||||
data['token_type'] = tokenType;
|
||||
data['matrix_server_name'] = matrixServerName;
|
||||
data['expires_in'] = expiresIn;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'basic_event_with_sender.dart';
|
||||
import 'presence_content.dart';
|
||||
|
||||
class Presence extends BasicEventWithSender {
|
||||
PresenceContent presence;
|
||||
|
||||
Presence.fromJson(Map<String, dynamic> json) {
|
||||
final basicEvent = BasicEventWithSender.fromJson(json);
|
||||
type = basicEvent.type;
|
||||
content = basicEvent.content;
|
||||
senderId = basicEvent.senderId;
|
||||
presence = PresenceContent.fromJson(content);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
enum PresenceType { online, offline, unavailable }
|
||||
|
||||
class PresenceContent {
|
||||
PresenceType presence;
|
||||
int lastActiveAgo;
|
||||
String statusMsg;
|
||||
bool currentlyActive;
|
||||
|
||||
PresenceContent.fromJson(Map<String, dynamic> json) {
|
||||
presence = PresenceType.values
|
||||
.firstWhere((p) => p.toString().split('.').last == json['presence']);
|
||||
lastActiveAgo = json['last_active_ago'];
|
||||
statusMsg = json['status_msg'];
|
||||
currentlyActive = json['currently_active'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['presence'] = presence.toString().split('.').last;
|
||||
if (lastActiveAgo != null) {
|
||||
data['last_active_ago'] = lastActiveAgo;
|
||||
}
|
||||
if (statusMsg != null) {
|
||||
data['status_msg'] = statusMsg;
|
||||
}
|
||||
if (currentlyActive != null) {
|
||||
data['currently_active'] = currentlyActive;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class Profile {
|
||||
/// The user's avatar URL if they have set one, otherwise null.
|
||||
Uri avatarUrl;
|
||||
|
||||
/// The user's display name if they have set one, otherwise null.
|
||||
String displayname;
|
||||
|
||||
/// The matrix ID of this user. May be omitted.
|
||||
String userId;
|
||||
|
||||
Map<String, dynamic> additionalContent;
|
||||
|
||||
Profile(this.displayname, this.avatarUrl,
|
||||
{this.additionalContent = const {}});
|
||||
|
||||
Profile.fromJson(Map<String, dynamic> json)
|
||||
: avatarUrl =
|
||||
json['avatar_url'] != null ? Uri.parse(json['avatar_url']) : null,
|
||||
displayname = json['display_name'] ?? json['displayname'],
|
||||
userId = json['user_id'],
|
||||
additionalContent = json;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return additionalContent;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class PublicRoomsResponse {
|
||||
List<PublicRoom> chunk;
|
||||
String nextBatch;
|
||||
String prevBatch;
|
||||
int totalRoomCountEstimate;
|
||||
|
||||
PublicRoomsResponse.fromJson(Map<String, dynamic> json) {
|
||||
chunk = <PublicRoom>[];
|
||||
json['chunk'].forEach((v) {
|
||||
chunk.add(PublicRoom.fromJson(v));
|
||||
});
|
||||
nextBatch = json['next_batch'];
|
||||
prevBatch = json['prev_batch'];
|
||||
totalRoomCountEstimate = json['total_room_count_estimate'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['chunk'] = chunk.map((v) => v.toJson()).toList();
|
||||
if (nextBatch != null) {
|
||||
data['next_batch'] = nextBatch;
|
||||
}
|
||||
if (prevBatch != null) {
|
||||
data['prev_batch'] = prevBatch;
|
||||
}
|
||||
if (totalRoomCountEstimate != null) {
|
||||
data['total_room_count_estimate'] = totalRoomCountEstimate;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class PublicRoom {
|
||||
List<String> aliases;
|
||||
String avatarUrl;
|
||||
bool guestCanJoin;
|
||||
String name;
|
||||
int numJoinedMembers;
|
||||
String roomId;
|
||||
String topic;
|
||||
bool worldReadable;
|
||||
String canonicalAlias;
|
||||
|
||||
PublicRoom.fromJson(Map<String, dynamic> json) {
|
||||
aliases = json['aliases']?.cast<String>();
|
||||
avatarUrl = json['avatar_url'];
|
||||
guestCanJoin = json['guest_can_join'];
|
||||
canonicalAlias = json['canonical_alias'];
|
||||
name = json['name'];
|
||||
numJoinedMembers = json['num_joined_members'];
|
||||
roomId = json['room_id'];
|
||||
topic = json['topic'];
|
||||
worldReadable = json['world_readable'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (aliases != null) {
|
||||
data['aliases'] = aliases;
|
||||
}
|
||||
if (canonicalAlias != null) {
|
||||
data['canonical_alias'] = canonicalAlias;
|
||||
}
|
||||
if (avatarUrl != null) {
|
||||
data['avatar_url'] = avatarUrl;
|
||||
}
|
||||
data['guest_can_join'] = guestCanJoin;
|
||||
if (name != null) {
|
||||
data['name'] = name;
|
||||
}
|
||||
data['num_joined_members'] = numJoinedMembers;
|
||||
data['room_id'] = roomId;
|
||||
if (topic != null) {
|
||||
data['topic'] = topic;
|
||||
}
|
||||
data['world_readable'] = worldReadable;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
enum PushRuleKind { content, override, room, sender, underride }
|
||||
enum PushRuleAction { notify, dont_notify, coalesce, set_tweak }
|
||||
|
||||
class PushRuleSet {
|
||||
List<PushRule> content;
|
||||
List<PushRule> override;
|
||||
List<PushRule> room;
|
||||
List<PushRule> sender;
|
||||
List<PushRule> underride;
|
||||
|
||||
PushRuleSet.fromJson(Map<String, dynamic> json) {
|
||||
if (json['content'] != null) {
|
||||
content =
|
||||
(json['content'] as List).map((i) => PushRule.fromJson(i)).toList();
|
||||
}
|
||||
if (json['override'] != null) {
|
||||
override =
|
||||
(json['override'] as List).map((i) => PushRule.fromJson(i)).toList();
|
||||
}
|
||||
if (json['room'] != null) {
|
||||
room = (json['room'] as List).map((i) => PushRule.fromJson(i)).toList();
|
||||
}
|
||||
if (json['sender'] != null) {
|
||||
sender =
|
||||
(json['sender'] as List).map((i) => PushRule.fromJson(i)).toList();
|
||||
}
|
||||
if (json['underride'] != null) {
|
||||
underride =
|
||||
(json['underride'] as List).map((i) => PushRule.fromJson(i)).toList();
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (content != null) {
|
||||
data['content'] = content.map((v) => v.toJson()).toList();
|
||||
}
|
||||
if (override != null) {
|
||||
data['override'] = override.map((v) => v.toJson()).toList();
|
||||
}
|
||||
if (room != null) {
|
||||
data['room'] = room.map((v) => v.toJson()).toList();
|
||||
}
|
||||
if (sender != null) {
|
||||
data['sender'] = sender.map((v) => v.toJson()).toList();
|
||||
}
|
||||
if (underride != null) {
|
||||
data['underride'] = underride.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class PushRule {
|
||||
List<dynamic> actions;
|
||||
List<PushConditions> conditions;
|
||||
bool isDefault;
|
||||
bool enabled;
|
||||
String pattern;
|
||||
String ruleId;
|
||||
|
||||
PushRule.fromJson(Map<String, dynamic> json) {
|
||||
actions = json['actions'];
|
||||
isDefault = json['default'];
|
||||
enabled = json['enabled'];
|
||||
pattern = json['pattern'];
|
||||
ruleId = json['rule_id'];
|
||||
conditions = json['conditions'] != null
|
||||
? (json['conditions'] as List)
|
||||
.map((i) => PushConditions.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['actions'] = actions;
|
||||
data['default'] = isDefault;
|
||||
data['enabled'] = enabled;
|
||||
if (pattern != null) {
|
||||
data['pattern'] = pattern;
|
||||
}
|
||||
if (conditions != null) {
|
||||
data['conditions'] = conditions.map((i) => i.toJson()).toList();
|
||||
}
|
||||
data['rule_id'] = ruleId;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class PushConditions {
|
||||
String key;
|
||||
String kind;
|
||||
String pattern;
|
||||
String isOperator;
|
||||
|
||||
PushConditions(
|
||||
this.kind, {
|
||||
this.key,
|
||||
this.pattern,
|
||||
this.isOperator,
|
||||
});
|
||||
|
||||
PushConditions.fromJson(Map<String, dynamic> json) {
|
||||
key = json['key'];
|
||||
kind = json['kind'];
|
||||
pattern = json['pattern'];
|
||||
isOperator = json['is'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (key != null) {
|
||||
data['key'] = key;
|
||||
}
|
||||
data['kind'] = kind;
|
||||
if (pattern != null) {
|
||||
data['pattern'] = pattern;
|
||||
}
|
||||
if (isOperator != null) {
|
||||
data['is'] = isOperator;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class Pusher {
|
||||
String pushkey;
|
||||
String kind;
|
||||
String appId;
|
||||
String appDisplayName;
|
||||
String deviceDisplayName;
|
||||
String profileTag;
|
||||
String lang;
|
||||
PusherData data;
|
||||
|
||||
Pusher(
|
||||
this.pushkey,
|
||||
this.appId,
|
||||
this.appDisplayName,
|
||||
this.deviceDisplayName,
|
||||
this.lang,
|
||||
this.data, {
|
||||
this.profileTag,
|
||||
this.kind,
|
||||
});
|
||||
|
||||
Pusher.fromJson(Map<String, dynamic> json) {
|
||||
pushkey = json['pushkey'];
|
||||
kind = json['kind'];
|
||||
appId = json['app_id'];
|
||||
appDisplayName = json['app_display_name'];
|
||||
deviceDisplayName = json['device_display_name'];
|
||||
profileTag = json['profile_tag'];
|
||||
lang = json['lang'];
|
||||
data = PusherData.fromJson(json['data']);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['pushkey'] = pushkey;
|
||||
data['kind'] = kind;
|
||||
data['app_id'] = appId;
|
||||
data['app_display_name'] = appDisplayName;
|
||||
data['device_display_name'] = deviceDisplayName;
|
||||
if (profileTag != null) {
|
||||
data['profile_tag'] = profileTag;
|
||||
}
|
||||
data['lang'] = lang;
|
||||
data['data'] = this.data.toJson();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class PusherData {
|
||||
Uri url;
|
||||
String format;
|
||||
|
||||
PusherData({
|
||||
this.url,
|
||||
this.format,
|
||||
});
|
||||
|
||||
PusherData.fromJson(Map<String, dynamic> json) {
|
||||
if (json.containsKey('url')) {
|
||||
url = Uri.parse(json['url']);
|
||||
}
|
||||
format = json['format'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (url != null) {
|
||||
data['url'] = url.toString();
|
||||
}
|
||||
if (format != null) {
|
||||
data['format'] = format;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class RequestTokenResponse {
|
||||
String sid;
|
||||
String submitUrl;
|
||||
|
||||
RequestTokenResponse.fromJson(Map<String, dynamic> json) {
|
||||
sid = json['sid'];
|
||||
submitUrl = json['submit_url'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['sid'] = sid;
|
||||
data['submit_url'] = submitUrl;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class RoomAliasInformations {
|
||||
String roomId;
|
||||
List<String> servers;
|
||||
|
||||
RoomAliasInformations.fromJson(Map<String, dynamic> json) {
|
||||
roomId = json['room_id'];
|
||||
servers = json['servers'].cast<String>();
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['room_id'] = roomId;
|
||||
data['servers'] = servers;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'algorithm_types.dart';
|
||||
|
||||
enum RoomKeysAlgorithmType { v1Curve25519AesSha2 }
|
||||
|
||||
extension RoomKeysAlgorithmTypeExtension on RoomKeysAlgorithmType {
|
||||
String get algorithmString {
|
||||
switch (this) {
|
||||
case RoomKeysAlgorithmType.v1Curve25519AesSha2:
|
||||
return AlgorithmTypes.megolmBackupV1Curve25519AesSha2;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static RoomKeysAlgorithmType fromAlgorithmString(String s) {
|
||||
switch (s) {
|
||||
case AlgorithmTypes.megolmBackupV1Curve25519AesSha2:
|
||||
return RoomKeysAlgorithmType.v1Curve25519AesSha2;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class RoomKeysVersionResponse {
|
||||
RoomKeysAlgorithmType algorithm;
|
||||
Map<String, dynamic> authData;
|
||||
int count;
|
||||
String etag;
|
||||
String version;
|
||||
|
||||
RoomKeysVersionResponse.fromJson(Map<String, dynamic> json) {
|
||||
algorithm =
|
||||
RoomKeysAlgorithmTypeExtension.fromAlgorithmString(json['algorithm']);
|
||||
authData = json['auth_data'];
|
||||
count = json['count'];
|
||||
etag =
|
||||
json['etag'].toString(); // synapse replies an int but docs say string?
|
||||
version = json['version'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['algorithm'] = algorithm?.algorithmString;
|
||||
data['auth_data'] = authData;
|
||||
data['count'] = count;
|
||||
data['etag'] = etag;
|
||||
data['version'] = version;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class RoomKeysSingleKey {
|
||||
int firstMessageIndex;
|
||||
int forwardedCount;
|
||||
bool isVerified;
|
||||
Map<String, dynamic> sessionData;
|
||||
|
||||
RoomKeysSingleKey(
|
||||
{this.firstMessageIndex,
|
||||
this.forwardedCount,
|
||||
this.isVerified,
|
||||
this.sessionData});
|
||||
|
||||
RoomKeysSingleKey.fromJson(Map<String, dynamic> json) {
|
||||
firstMessageIndex = json['first_message_index'];
|
||||
forwardedCount = json['forwarded_count'];
|
||||
isVerified = json['is_verified'];
|
||||
sessionData = json['session_data'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['first_message_index'] = firstMessageIndex;
|
||||
data['forwarded_count'] = forwardedCount;
|
||||
data['is_verified'] = isVerified;
|
||||
data['session_data'] = sessionData;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class RoomKeysRoom {
|
||||
Map<String, RoomKeysSingleKey> sessions;
|
||||
|
||||
RoomKeysRoom({this.sessions}) {
|
||||
sessions ??= <String, RoomKeysSingleKey>{};
|
||||
}
|
||||
|
||||
RoomKeysRoom.fromJson(Map<String, dynamic> json) {
|
||||
sessions = (json['sessions'] as Map)
|
||||
.map((k, v) => MapEntry(k, RoomKeysSingleKey.fromJson(v)));
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['sessions'] = sessions.map((k, v) => MapEntry(k, v.toJson()));
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class RoomKeys {
|
||||
Map<String, RoomKeysRoom> rooms;
|
||||
|
||||
RoomKeys({this.rooms}) {
|
||||
rooms ??= <String, RoomKeysRoom>{};
|
||||
}
|
||||
|
||||
RoomKeys.fromJson(Map<String, dynamic> json) {
|
||||
rooms = (json['rooms'] as Map)
|
||||
.map((k, v) => MapEntry(k, RoomKeysRoom.fromJson(v)));
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['rooms'] = rooms.map((k, v) => MapEntry(k, v.toJson()));
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class RoomKeysUpdateResponse {
|
||||
String etag;
|
||||
int count;
|
||||
|
||||
RoomKeysUpdateResponse.fromJson(Map<String, dynamic> json) {
|
||||
etag = json['etag']; // synapse replies an int but docs say string?
|
||||
count = json['count'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['etag'] = etag;
|
||||
data['count'] = count;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class RoomSummary {
|
||||
List<String> mHeroes;
|
||||
int mJoinedMemberCount;
|
||||
int mInvitedMemberCount;
|
||||
RoomSummary.fromJson(Map<String, dynamic> json) {
|
||||
mHeroes =
|
||||
json['m.heroes'] != null ? List<String>.from(json['m.heroes']) : null;
|
||||
mJoinedMemberCount = json['m.joined_member_count'];
|
||||
mInvitedMemberCount = json['m.invited_member_count'];
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (mHeroes != null) {
|
||||
data['m.heroes'] = mHeroes;
|
||||
}
|
||||
if (mJoinedMemberCount != null) {
|
||||
data['m.joined_member_count'] = mJoinedMemberCount;
|
||||
}
|
||||
if (mInvitedMemberCount != null) {
|
||||
data['m.invited_member_count'] = mInvitedMemberCount;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
enum RoomVersionStability { stable, unstable }
|
||||
|
||||
class ServerCapabilities {
|
||||
MChangePassword mChangePassword;
|
||||
MRoomVersions mRoomVersions;
|
||||
Map<String, dynamic> customCapabilities;
|
||||
|
||||
ServerCapabilities.fromJson(Map<String, dynamic> json) {
|
||||
mChangePassword = json['m.change_password'] != null
|
||||
? MChangePassword.fromJson(json['m.change_password'])
|
||||
: null;
|
||||
mRoomVersions = json['m.room_versions'] != null
|
||||
? MRoomVersions.fromJson(json['m.room_versions'])
|
||||
: null;
|
||||
customCapabilities = Map<String, dynamic>.from(json);
|
||||
customCapabilities.remove('m.change_password');
|
||||
customCapabilities.remove('m.room_versions');
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (mChangePassword != null) {
|
||||
data['m.change_password'] = mChangePassword.toJson();
|
||||
}
|
||||
if (mRoomVersions != null) {
|
||||
data['m.room_versions'] = mRoomVersions.toJson();
|
||||
}
|
||||
for (final entry in customCapabilities.entries) {
|
||||
data[entry.key] = entry.value;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class MChangePassword {
|
||||
bool enabled;
|
||||
|
||||
MChangePassword.fromJson(Map<String, dynamic> json) {
|
||||
enabled = json['enabled'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['enabled'] = enabled;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class MRoomVersions {
|
||||
String defaultVersion;
|
||||
Map<String, RoomVersionStability> available;
|
||||
|
||||
MRoomVersions.fromJson(Map<String, dynamic> json) {
|
||||
defaultVersion = json['default'];
|
||||
available = (json['available'] as Map).map<String, RoomVersionStability>(
|
||||
(k, v) => MapEntry(
|
||||
k,
|
||||
RoomVersionStability.values
|
||||
.firstWhere((r) => r.toString().split('.').last == v),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['default'] = defaultVersion;
|
||||
data['available'] = available.map<String, dynamic>(
|
||||
(k, v) => MapEntry(k, v.toString().split('.').last));
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'basic_event_with_sender.dart';
|
||||
|
||||
class StrippedStateEvent extends BasicEventWithSender {
|
||||
String stateKey;
|
||||
|
||||
StrippedStateEvent();
|
||||
StrippedStateEvent.fromJson(Map<String, dynamic> json) {
|
||||
final basicEvent = BasicEventWithSender.fromJson(json);
|
||||
content = basicEvent.content;
|
||||
type = basicEvent.type;
|
||||
senderId = basicEvent.senderId;
|
||||
stateKey = json['state_key'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['state_key'] = stateKey;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class SupportedProtocol {
|
||||
List<String> userFields;
|
||||
List<String> locationFields;
|
||||
String icon;
|
||||
Map<String, ProtocolFieldType> fieldTypes;
|
||||
List<ProtocolInstance> instances;
|
||||
|
||||
SupportedProtocol.fromJson(Map<String, dynamic> json) {
|
||||
userFields = json['user_fields'].cast<String>();
|
||||
locationFields = json['location_fields'].cast<String>();
|
||||
icon = json['icon'];
|
||||
fieldTypes = (json['field_types'] as Map)
|
||||
.map((k, v) => MapEntry(k, ProtocolFieldType.fromJson(v)));
|
||||
instances = <ProtocolInstance>[];
|
||||
json['instances'].forEach((v) {
|
||||
instances.add(ProtocolInstance.fromJson(v));
|
||||
});
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['user_fields'] = userFields;
|
||||
data['location_fields'] = locationFields;
|
||||
data['icon'] = icon;
|
||||
data['field_types'] = fieldTypes.map((k, v) => MapEntry(k, v.toJson()));
|
||||
|
||||
data['instances'] = instances.map((v) => v.toJson()).toList();
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class ProtocolFieldType {
|
||||
String regexp;
|
||||
String placeholder;
|
||||
|
||||
ProtocolFieldType.fromJson(Map<String, dynamic> json) {
|
||||
regexp = json['regexp'];
|
||||
placeholder = json['placeholder'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['regexp'] = regexp;
|
||||
data['placeholder'] = placeholder;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class ProtocolInstance {
|
||||
String networkId;
|
||||
String desc;
|
||||
String icon;
|
||||
dynamic fields;
|
||||
|
||||
ProtocolInstance.fromJson(Map<String, dynamic> json) {
|
||||
networkId = json['network_id'];
|
||||
desc = json['desc'];
|
||||
icon = json['icon'];
|
||||
fields = json['fields'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['network_id'] = networkId;
|
||||
data['desc'] = desc;
|
||||
if (icon != null) {
|
||||
data['icon'] = icon;
|
||||
}
|
||||
data['fields'] = fields;
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class SupportedVersions {
|
||||
List<String> versions;
|
||||
Map<String, bool> unstableFeatures;
|
||||
|
||||
SupportedVersions.fromJson(Map<String, dynamic> json) {
|
||||
versions = json['versions'].cast<String>();
|
||||
unstableFeatures = Map<String, bool>.from(json['unstable_features'] ?? {});
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['versions'] = versions;
|
||||
if (unstableFeatures != null) {
|
||||
data['unstable_features'] = unstableFeatures;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,333 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'basic_event.dart';
|
||||
import 'basic_event_with_sender.dart';
|
||||
import 'basic_room_event.dart';
|
||||
import 'matrix_event.dart';
|
||||
import 'presence.dart';
|
||||
import 'room_summary.dart';
|
||||
import 'stripped_state_event.dart';
|
||||
|
||||
class SyncUpdate {
|
||||
String nextBatch;
|
||||
RoomsUpdate rooms;
|
||||
List<Presence> presence;
|
||||
List<BasicEvent> accountData;
|
||||
List<BasicEventWithSender> toDevice;
|
||||
DeviceListsUpdate deviceLists;
|
||||
Map<String, int> deviceOneTimeKeysCount;
|
||||
|
||||
SyncUpdate();
|
||||
|
||||
SyncUpdate.fromJson(Map<String, dynamic> json) {
|
||||
nextBatch = json['next_batch'];
|
||||
rooms = json['rooms'] != null ? RoomsUpdate.fromJson(json['rooms']) : null;
|
||||
presence = (json['presence'] != null && json['presence']['events'] != null)
|
||||
? (json['presence']['events'] as List)
|
||||
.map((i) => Presence.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
accountData =
|
||||
(json['account_data'] != null && json['account_data']['events'] != null)
|
||||
? (json['account_data']['events'] as List)
|
||||
.map((i) => BasicEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
toDevice =
|
||||
(json['to_device'] != null && json['to_device']['events'] != null)
|
||||
? (json['to_device']['events'] as List)
|
||||
.map((i) => BasicEventWithSender.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
deviceLists = json['device_lists'] != null
|
||||
? DeviceListsUpdate.fromJson(json['device_lists'])
|
||||
: null;
|
||||
deviceOneTimeKeysCount = json['device_one_time_keys_count'] != null
|
||||
? Map<String, int>.from(json['device_one_time_keys_count'])
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['next_batch'] = nextBatch;
|
||||
if (rooms != null) {
|
||||
data['rooms'] = rooms.toJson();
|
||||
}
|
||||
if (presence != null) {
|
||||
data['presence'] = {
|
||||
'events': presence.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (accountData != null) {
|
||||
data['account_data'] = {
|
||||
'events': accountData.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (toDevice != null) {
|
||||
data['to_device'] = {
|
||||
'events': toDevice.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (deviceLists != null) {
|
||||
data['device_lists'] = deviceLists.toJson();
|
||||
}
|
||||
if (deviceOneTimeKeysCount != null) {
|
||||
data['device_one_time_keys_count'] = deviceOneTimeKeysCount;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class RoomsUpdate {
|
||||
Map<String, JoinedRoomUpdate> join;
|
||||
Map<String, InvitedRoomUpdate> invite;
|
||||
Map<String, LeftRoomUpdate> leave;
|
||||
|
||||
RoomsUpdate();
|
||||
|
||||
RoomsUpdate.fromJson(Map<String, dynamic> json) {
|
||||
join = json['join'] != null
|
||||
? (json['join'] as Map)
|
||||
.map((k, v) => MapEntry(k, JoinedRoomUpdate.fromJson(v)))
|
||||
: null;
|
||||
invite = json['invite'] != null
|
||||
? (json['invite'] as Map)
|
||||
.map((k, v) => MapEntry(k, InvitedRoomUpdate.fromJson(v)))
|
||||
: null;
|
||||
leave = json['leave'] != null
|
||||
? (json['leave'] as Map)
|
||||
.map((k, v) => MapEntry(k, LeftRoomUpdate.fromJson(v)))
|
||||
: null;
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (join != null) {
|
||||
data['join'] = join.map((k, v) => MapEntry(k, v.toJson()));
|
||||
}
|
||||
if (invite != null) {
|
||||
data['invite'] = invite.map((k, v) => MapEntry(k, v.toJson()));
|
||||
}
|
||||
if (leave != null) {
|
||||
data['leave'] = leave.map((k, v) => MapEntry(k, v.toJson()));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SyncRoomUpdate {}
|
||||
|
||||
class JoinedRoomUpdate extends SyncRoomUpdate {
|
||||
RoomSummary summary;
|
||||
List<MatrixEvent> state;
|
||||
TimelineUpdate timeline;
|
||||
List<BasicRoomEvent> ephemeral;
|
||||
List<BasicRoomEvent> accountData;
|
||||
UnreadNotificationCounts unreadNotifications;
|
||||
|
||||
JoinedRoomUpdate();
|
||||
|
||||
JoinedRoomUpdate.fromJson(Map<String, dynamic> json) {
|
||||
summary =
|
||||
json['summary'] != null ? RoomSummary.fromJson(json['summary']) : null;
|
||||
state = (json['state'] != null && json['state']['events'] != null)
|
||||
? (json['state']['events'] as List)
|
||||
.map((i) => MatrixEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
timeline = json['timeline'] != null
|
||||
? TimelineUpdate.fromJson(json['timeline'])
|
||||
: null;
|
||||
|
||||
ephemeral =
|
||||
(json['ephemeral'] != null && json['ephemeral']['events'] != null)
|
||||
? (json['ephemeral']['events'] as List)
|
||||
.map((i) => BasicRoomEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
accountData =
|
||||
(json['account_data'] != null && json['account_data']['events'] != null)
|
||||
? (json['account_data']['events'] as List)
|
||||
.map((i) => BasicRoomEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
unreadNotifications = json['unread_notifications'] != null
|
||||
? UnreadNotificationCounts.fromJson(json['unread_notifications'])
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (summary != null) {
|
||||
data['summary'] = summary.toJson();
|
||||
}
|
||||
if (state != null) {
|
||||
data['state'] = {
|
||||
'events': state.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (timeline != null) {
|
||||
data['timeline'] = timeline.toJson();
|
||||
}
|
||||
if (ephemeral != null) {
|
||||
data['ephemeral'] = {
|
||||
'events': ephemeral.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (accountData != null) {
|
||||
data['account_data'] = {
|
||||
'events': accountData.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (unreadNotifications != null) {
|
||||
data['unread_notifications'] = unreadNotifications.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class InvitedRoomUpdate extends SyncRoomUpdate {
|
||||
List<StrippedStateEvent> inviteState;
|
||||
InvitedRoomUpdate.fromJson(Map<String, dynamic> json) {
|
||||
inviteState =
|
||||
(json['invite_state'] != null && json['invite_state']['events'] != null)
|
||||
? (json['invite_state']['events'] as List)
|
||||
.map((i) => StrippedStateEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (inviteState != null) {
|
||||
data['invite_state'] = {
|
||||
'events': inviteState.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class LeftRoomUpdate extends SyncRoomUpdate {
|
||||
List<MatrixEvent> state;
|
||||
TimelineUpdate timeline;
|
||||
List<BasicRoomEvent> accountData;
|
||||
|
||||
LeftRoomUpdate();
|
||||
|
||||
LeftRoomUpdate.fromJson(Map<String, dynamic> json) {
|
||||
state = (json['state'] != null && json['state']['events'] != null)
|
||||
? (json['state']['events'] as List)
|
||||
.map((i) => MatrixEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
timeline = json['timeline'] != null
|
||||
? TimelineUpdate.fromJson(json['timeline'])
|
||||
: null;
|
||||
accountData =
|
||||
(json['account_data'] != null && json['account_data']['events'] != null)
|
||||
? (json['account_data']['events'] as List)
|
||||
.map((i) => BasicRoomEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (state != null) {
|
||||
data['state'] = {
|
||||
'events': state.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (timeline != null) {
|
||||
data['timeline'] = timeline.toJson();
|
||||
}
|
||||
if (accountData != null) {
|
||||
data['account_data'] = {
|
||||
'events': accountData.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class TimelineUpdate {
|
||||
List<MatrixEvent> events;
|
||||
bool limited;
|
||||
String prevBatch;
|
||||
|
||||
TimelineUpdate();
|
||||
|
||||
TimelineUpdate.fromJson(Map<String, dynamic> json) {
|
||||
events = json['events'] != null
|
||||
? (json['events'] as List).map((i) => MatrixEvent.fromJson(i)).toList()
|
||||
: null;
|
||||
limited = json['limited'];
|
||||
prevBatch = json['prev_batch'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (events != null) {
|
||||
data['events'] = events.map((i) => i.toJson()).toList();
|
||||
}
|
||||
if (limited != null) {
|
||||
data['limited'] = limited;
|
||||
}
|
||||
if (prevBatch != null) {
|
||||
data['prev_batch'] = prevBatch;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class UnreadNotificationCounts {
|
||||
int highlightCount;
|
||||
int notificationCount;
|
||||
UnreadNotificationCounts.fromJson(Map<String, dynamic> json) {
|
||||
highlightCount = json['highlight_count'];
|
||||
notificationCount = json['notification_count'];
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (highlightCount != null) {
|
||||
data['highlight_count'] = highlightCount;
|
||||
}
|
||||
if (notificationCount != null) {
|
||||
data['notification_count'] = notificationCount;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class DeviceListsUpdate {
|
||||
List<String> changed;
|
||||
List<String> left;
|
||||
DeviceListsUpdate.fromJson(Map<String, dynamic> json) {
|
||||
changed = List<String>.from(json['changed'] ?? []);
|
||||
left = List<String>.from(json['left'] ?? []);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (changed != null) {
|
||||
data['changed'] = changed;
|
||||
}
|
||||
if (left != null) {
|
||||
data['left'] = left;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class Tag {
|
||||
double order;
|
||||
|
||||
Tag.fromJson(Map<String, dynamic> json) {
|
||||
order = double.tryParse(json['order'].toString());
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (order != null) {
|
||||
data['order'] = order;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class TagType {
|
||||
static const String Favourite = 'm.favourite';
|
||||
static const String LowPriority = 'm.lowpriority';
|
||||
static const String ServerNotice = 'm.server_notice';
|
||||
static bool isValid(String tag) => tag.startsWith('m.')
|
||||
? [Favourite, LowPriority, ServerNotice].contains(tag)
|
||||
: true;
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import '../../matrix_api_lite.dart';
|
||||
|
||||
class ThirdPartyIdentifier {
|
||||
ThirdPartyIdentifierMedium medium;
|
||||
String address;
|
||||
int validatedAt;
|
||||
int addedAt;
|
||||
|
||||
ThirdPartyIdentifier.fromJson(Map<String, dynamic> json) {
|
||||
medium = ThirdPartyIdentifierMedium.values
|
||||
.firstWhere((medium) => describeEnum(medium) == json['medium']);
|
||||
address = json['address'];
|
||||
validatedAt = json['validated_at'];
|
||||
addedAt = json['added_at'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['medium'] = describeEnum(medium);
|
||||
data['address'] = address;
|
||||
data['validated_at'] = validatedAt;
|
||||
data['added_at'] = addedAt;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class ThirdPartyLocation {
|
||||
String alias;
|
||||
String protocol;
|
||||
Map<String, dynamic> fields;
|
||||
|
||||
ThirdPartyLocation.fromJson(Map<String, dynamic> json) {
|
||||
alias = json['alias'];
|
||||
protocol = json['protocol'];
|
||||
fields = Map<String, dynamic>.from(json['fields']);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['alias'] = alias;
|
||||
data['protocol'] = protocol;
|
||||
data['fields'] = fields;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class ThirdPartyUser {
|
||||
String userId;
|
||||
String protocol;
|
||||
Map<String, dynamic> fields;
|
||||
|
||||
ThirdPartyUser.fromJson(Map<String, dynamic> json) {
|
||||
userId = json['userid'];
|
||||
protocol = json['protocol'];
|
||||
fields = Map<String, dynamic>.from(json['fields']);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['userid'] = userId;
|
||||
data['protocol'] = protocol;
|
||||
data['fields'] = fields;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'matrix_event.dart';
|
||||
|
||||
class TimelineHistoryResponse {
|
||||
String start;
|
||||
String end;
|
||||
List<MatrixEvent> chunk;
|
||||
List<MatrixEvent> state;
|
||||
|
||||
TimelineHistoryResponse.fromJson(Map<String, dynamic> json) {
|
||||
start = json['start'];
|
||||
end = json['end'];
|
||||
chunk = json['chunk'] != null
|
||||
? (json['chunk'] as List).map((i) => MatrixEvent.fromJson(i)).toList()
|
||||
: null;
|
||||
state = json['state'] != null
|
||||
? (json['state'] as List).map((i) => MatrixEvent.fromJson(i)).toList()
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (start != null) data['start'] = start;
|
||||
if (end != null) data['end'] = end;
|
||||
if (chunk != null) data['chunk'] = chunk.map((i) => i.toJson());
|
||||
if (state != null) data['state'] = state.map((i) => i.toJson());
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class TurnServerCredentials {
|
||||
String username;
|
||||
String password;
|
||||
List<String> uris;
|
||||
num ttl;
|
||||
|
||||
TurnServerCredentials.fromJson(Map<String, dynamic> json) {
|
||||
username = json['username'];
|
||||
password = json['password'];
|
||||
uris = json['uris'].cast<String>();
|
||||
ttl = json['ttl'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['username'] = username;
|
||||
data['password'] = password;
|
||||
data['uris'] = uris;
|
||||
data['ttl'] = ttl;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'matrix_exception.dart';
|
||||
|
||||
class UploadKeySignaturesResponse {
|
||||
Map<String, Map<String, MatrixException>> failures;
|
||||
|
||||
UploadKeySignaturesResponse.fromJson(Map<String, dynamic> json) {
|
||||
failures = json['failures'] != null
|
||||
? (json['failures'] as Map).map(
|
||||
(k, v) => MapEntry(
|
||||
k,
|
||||
(v as Map).map((k, v) => MapEntry(
|
||||
k,
|
||||
MatrixException.fromJson(v),
|
||||
)),
|
||||
),
|
||||
)
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (failures != null) {
|
||||
data['failures'] = failures.map(
|
||||
(k, v) => MapEntry(
|
||||
k,
|
||||
v.map(
|
||||
(k, v) => MapEntry(
|
||||
k,
|
||||
v.raw,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'profile.dart';
|
||||
|
||||
class UserSearchResult {
|
||||
List<Profile> results;
|
||||
bool limited;
|
||||
|
||||
UserSearchResult.fromJson(Map<String, dynamic> json) {
|
||||
results = <Profile>[];
|
||||
json['results'].forEach((v) {
|
||||
results.add(Profile.fromJson(v));
|
||||
});
|
||||
|
||||
limited = json['limited'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['results'] = results.map((v) => v.toJson()).toList();
|
||||
|
||||
data['limited'] = limited;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class WellKnownInformations {
|
||||
MHomeserver mHomeserver;
|
||||
MHomeserver mIdentityServer;
|
||||
Map<String, dynamic> content;
|
||||
|
||||
WellKnownInformations.fromJson(Map<String, dynamic> json) {
|
||||
content = json;
|
||||
mHomeserver = json['m.homeserver'] != null
|
||||
? MHomeserver.fromJson(json['m.homeserver'])
|
||||
: null;
|
||||
mIdentityServer = json['m.identity_server'] != null
|
||||
? MHomeserver.fromJson(json['m.identity_server'])
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = content;
|
||||
data['m.homeserver'] = mHomeserver.toJson();
|
||||
data['m.identity_server'] = mIdentityServer.toJson();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class MHomeserver {
|
||||
String baseUrl;
|
||||
|
||||
MHomeserver.fromJson(Map<String, dynamic> json) {
|
||||
baseUrl = json['base_url'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['base_url'] = baseUrl;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class WhoIsInfo {
|
||||
String userId;
|
||||
Map<String, DeviceInfo> devices;
|
||||
|
||||
WhoIsInfo.fromJson(Map<String, dynamic> json) {
|
||||
userId = json['user_id'];
|
||||
devices = json['devices'] != null
|
||||
? (json['devices'] as Map)
|
||||
.map((k, v) => MapEntry(k, DeviceInfo.fromJson(v)))
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['user_id'] = userId;
|
||||
if (devices != null) {
|
||||
data['devices'] = devices.map((k, v) => MapEntry(k, v.toJson()));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class DeviceInfo {
|
||||
List<Sessions> sessions;
|
||||
|
||||
DeviceInfo.fromJson(Map<String, dynamic> json) {
|
||||
if (json['sessions'] != null) {
|
||||
sessions = <Sessions>[];
|
||||
json['sessions'].forEach((v) {
|
||||
sessions.add(Sessions.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (sessions != null) {
|
||||
data['sessions'] = sessions.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Sessions {
|
||||
List<Connections> connections;
|
||||
|
||||
Sessions.fromJson(Map<String, dynamic> json) {
|
||||
if (json['connections'] != null) {
|
||||
connections = <Connections>[];
|
||||
json['connections'].forEach((v) {
|
||||
connections.add(Connections.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (connections != null) {
|
||||
data['connections'] = connections.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Connections {
|
||||
String ip;
|
||||
int lastSeen;
|
||||
String userAgent;
|
||||
|
||||
Connections.fromJson(Map<String, dynamic> json) {
|
||||
ip = json['ip'];
|
||||
lastSeen = json['last_seen'];
|
||||
userAgent = json['user_agent'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (ip != null) {
|
||||
data['ip'] = ip;
|
||||
}
|
||||
if (lastSeen != null) {
|
||||
data['last_seen'] = lastSeen;
|
||||
}
|
||||
if (userAgent != null) {
|
||||
data['user_agent'] = userAgent;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:logger/logger.dart';
|
||||
|
||||
class Logs extends Logger {
|
||||
static final Logs _singleton = Logs._internal();
|
||||
|
||||
factory Logs() {
|
||||
return _singleton;
|
||||
}
|
||||
|
||||
set level(Level newLevel) => Logger.level = newLevel;
|
||||
|
||||
final List<OutputEvent> outputEvents = [];
|
||||
|
||||
Logs._internal()
|
||||
: super(
|
||||
printer: PrettyPrinter(methodCount: 0, lineLength: 100),
|
||||
filter: _MatrixSdkFilter(),
|
||||
output: _CacheOutput(),
|
||||
);
|
||||
}
|
||||
|
||||
class _MatrixSdkFilter extends LogFilter {
|
||||
@override
|
||||
bool shouldLog(LogEvent event) => event.level.index >= Logger.level.index;
|
||||
}
|
||||
|
||||
class _CacheOutput extends ConsoleOutput {
|
||||
@override
|
||||
void output(OutputEvent event) {
|
||||
Logs().outputEvents.add(event);
|
||||
super.output(event);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
import 'logs.dart';
|
||||
|
||||
extension TryGetMapExtension on Map<String, dynamic> {
|
||||
T tryGet<T>(String key, [T fallbackValue]) {
|
||||
final value = this[key];
|
||||
if (value != null && !(value is T)) {
|
||||
Logs().w(
|
||||
'Expected "${T.runtimeType}" in event content for the Key "$key" but got "${value.runtimeType}".');
|
||||
return fallbackValue;
|
||||
}
|
||||
if (value == null && fallbackValue != null) {
|
||||
Logs().w(
|
||||
'Required field in event content for the Key "$key" is null. Set to "$fallbackValue".');
|
||||
return fallbackValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
name: matrix_api_lite
|
||||
description: A starting point for Dart libraries or applications.
|
||||
# version: 1.0.0
|
||||
# homepage: https://www.example.com
|
||||
|
||||
environment:
|
||||
sdk: '>=2.10.0 <3.0.0'
|
||||
|
||||
dependencies:
|
||||
http: ^0.12.2
|
||||
logger: ^0.9.4
|
||||
|
||||
dev_dependencies:
|
||||
pedantic: ^1.9.0
|
||||
test: ^1.14.4
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue