Merge branch 'license-fix-foobar-typo' into 'master'

[License] Replace 'foobar' with 'famedlysdk' in all Files.

Closes #15

See merge request famedly/famedlysdk!11
This commit is contained in:
Marcel 2019-06-21 12:38:08 +00:00
commit c295841935
20 changed files with 243 additions and 269 deletions

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
library famedlysdk;

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
import 'dart:async';

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
import 'dart:async';

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
import 'dart:convert';
@ -29,7 +29,6 @@ import './Room.dart';
/// A single Matrix event, e.g. a message in a chat.
class Event {
/// The Matrix ID for this event in the format '$localpart:server.abc'.
final String id;
@ -58,7 +57,10 @@ class Event {
/// The json payload of the content. The content highly depends on the type.
final Map<String, dynamic> content;
Event(this.id, this.sender, this.time,{
Event(
this.id,
this.sender,
this.time, {
this.room,
this.stateKey,
this.status = 2,
@ -82,28 +84,44 @@ class Event {
/// Get the real type.
EventTypes get type {
switch (environment) {
case "m.room.avatar": return EventTypes.RoomAvatar;
case "m.room.name": return EventTypes.RoomName;
case "m.room.topic": return EventTypes.RoomTopic;
case "m.room.Aliases": return EventTypes.RoomAliases;
case "m.room.canonical_alias": return EventTypes.RoomCanonicalAlias;
case "m.room.create": return EventTypes.RoomCreate;
case "m.room.join_rules": return EventTypes.RoomJoinRules;
case "m.room.member": return EventTypes.RoomMember;
case "m.room.power_levels": return EventTypes.RoomPowerLevels;
case "m.room.avatar":
return EventTypes.RoomAvatar;
case "m.room.name":
return EventTypes.RoomName;
case "m.room.topic":
return EventTypes.RoomTopic;
case "m.room.Aliases":
return EventTypes.RoomAliases;
case "m.room.canonical_alias":
return EventTypes.RoomCanonicalAlias;
case "m.room.create":
return EventTypes.RoomCreate;
case "m.room.join_rules":
return EventTypes.RoomJoinRules;
case "m.room.member":
return EventTypes.RoomMember;
case "m.room.power_levels":
return EventTypes.RoomPowerLevels;
case "m.room.message":
switch (content["msgtype"] ?? "m.text") {
case "m.text": return EventTypes.Text;
case "m.notice": return EventTypes.Notice;
case "m.emote": return EventTypes.Emote;
case "m.image": return EventTypes.Image;
case "m.video": return EventTypes.Video;
case "m.audio": return EventTypes.Audio;
case "m.file": return EventTypes.File;
case "m.location": return EventTypes.Location;
case "m.text":
return EventTypes.Text;
case "m.notice":
return EventTypes.Notice;
case "m.emote":
return EventTypes.Emote;
case "m.image":
return EventTypes.Image;
case "m.video":
return EventTypes.Video;
case "m.audio":
return EventTypes.Audio;
case "m.file":
return EventTypes.File;
case "m.location":
return EventTypes.Location;
}
}
}
/// Generate a new Event object from a json string, mostly a table row.
@ -132,7 +150,6 @@ class Event {
List<Event> eventList = await matrix.store.getEventList(room);
return eventList;
}
}
enum EventTypes {

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:famedlysdk/src/Client.dart';

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
import 'dart:async';

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:famedlysdk/src/responses/ErrorResponse.dart';

View file

@ -18,14 +18,13 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:http/http.dart' as http;
/// Represents a special response from the Homeserver for errors.
class ErrorResponse {
/// The unique identifier for this error.
String errcode;

View file

@ -18,13 +18,12 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
/// Represents a new event (e.g. a message in a room) or an update for an
/// already known event.
class EventUpdate {
/// Usually 'timeline', 'state' or whatever.
final String eventType;

View file

@ -18,13 +18,12 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
/// Represents a new room or an update for an
/// already known room.
class RoomUpdate {
/// All rooms have an idea in the format: !uniqueid:server.abc
final String id;

View file

@ -18,12 +18,11 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
/// Represents a new global event like presence or account_data.
class UserUpdate {
/// Usually 'presence', 'account_data' or whatever.
final String eventType;

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
// TODO: localize this!
@ -32,8 +32,7 @@ class ChatTime {
/// Insert with a timestamp [ts] which represents the milliseconds since
/// the Unix epoch.
ChatTime(num ts) {
if (ts != null)
dateTime = DateTime.fromMillisecondsSinceEpoch(ts);
if (ts != null) dateTime = DateTime.fromMillisecondsSinceEpoch(ts);
}
/// Returns a ChatTime object which represents the current time.
@ -51,12 +50,16 @@ class ChatTime {
bool sameDay =
sameYear && now.month == dateTime.month && now.day == dateTime.day;
bool sameWeek = sameYear && !sameDay && now.millisecondsSinceEpoch - dateTime.millisecondsSinceEpoch < 1000*60*60*24*7;
bool sameWeek = sameYear &&
!sameDay &&
now.millisecondsSinceEpoch - dateTime.millisecondsSinceEpoch <
1000 * 60 * 60 * 24 * 7;
if (sameDay) {
return toTimeString();
} else if (sameWeek) {
switch (dateTime.weekday) { // TODO: Needs localization
switch (dateTime.weekday) {
// TODO: Needs localization
case 1:
return "Montag";
case 2:
@ -103,7 +106,8 @@ class ChatTime {
operator ==(dynamic other) {
if (other is ChatTime)
return this.toTimeStamp() == other.toTimeStamp();
else return false;
else
return false;
}
/// Two message events can belong to the same environment. That means that they
@ -114,7 +118,8 @@ class ChatTime {
/// Checks if two ChatTimes are close enough to belong to the same
/// environment.
bool sameEnvironment(ChatTime prevTime) {
return toTimeStamp() - prevTime.toTimeStamp() < 1000*60*minutesBetweenEnvironments;
return toTimeStamp() - prevTime.toTimeStamp() <
1000 * 60 * minutesBetweenEnvironments;
}
/// Returns a simple time String.

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:famedlysdk/src/Client.dart';

View file

@ -18,21 +18,20 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:flutter_test/flutter_test.dart';
import 'package:famedlysdk/src/utils/ChatTime.dart';
void main() {
/// All Tests related to the ChatTime
group("ChatTime", () {
test("Comparing", () async {
final int originServerTs = DateTime.now().millisecondsSinceEpoch - (ChatTime.minutesBetweenEnvironments-1)*1000*60;
final int oldOriginServerTs = DateTime.now().millisecondsSinceEpoch - (ChatTime.minutesBetweenEnvironments+1)*1000*60;
final int originServerTs = DateTime.now().millisecondsSinceEpoch -
(ChatTime.minutesBetweenEnvironments - 1) * 1000 * 60;
final int oldOriginServerTs = DateTime.now().millisecondsSinceEpoch -
(ChatTime.minutesBetweenEnvironments + 1) * 1000 * 60;
final ChatTime chatTime = ChatTime(originServerTs);
final ChatTime oldChatTime = ChatTime(oldOriginServerTs);

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:famedlysdk/src/responses/PushrulesResponse.dart';

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:flutter_test/flutter_test.dart';

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:http/testing.dart';
@ -95,13 +95,8 @@ class FakeMatrixApi extends MockClient {
{
"actions": [
"notify",
{
"set_tweak": "sound",
"value": "default"
},
{
"set_tweak": "highlight"
}
{"set_tweak": "sound", "value": "default"},
{"set_tweak": "highlight"}
],
"default": true,
"enabled": true,
@ -111,18 +106,14 @@ class FakeMatrixApi extends MockClient {
],
"override": [
{
"actions": [
"dont_notify"
],
"actions": ["dont_notify"],
"conditions": [],
"default": true,
"enabled": false,
"rule_id": ".m.rule.master"
},
{
"actions": [
"dont_notify"
],
"actions": ["dont_notify"],
"conditions": [
{
"key": "content.msgtype",
@ -141,14 +132,8 @@ class FakeMatrixApi extends MockClient {
{
"actions": [
"notify",
{
"set_tweak": "sound",
"value": "ring"
},
{
"set_tweak": "highlight",
"value": false
}
{"set_tweak": "sound", "value": "ring"},
{"set_tweak": "highlight", "value": false}
],
"conditions": [
{
@ -164,18 +149,11 @@ class FakeMatrixApi extends MockClient {
{
"actions": [
"notify",
{
"set_tweak": "sound",
"value": "default"
},
{
"set_tweak": "highlight"
}
{"set_tweak": "sound", "value": "default"},
{"set_tweak": "highlight"}
],
"conditions": [
{
"kind": "contains_display_name"
}
{"kind": "contains_display_name"}
],
"default": true,
"enabled": true,
@ -184,20 +162,11 @@ class FakeMatrixApi extends MockClient {
{
"actions": [
"notify",
{
"set_tweak": "sound",
"value": "default"
},
{
"set_tweak": "highlight",
"value": false
}
{"set_tweak": "sound", "value": "default"},
{"set_tweak": "highlight", "value": false}
],
"conditions": [
{
"is": "2",
"kind": "room_member_count"
}
{"is": "2", "kind": "room_member_count"}
],
"default": true,
"enabled": true,
@ -206,14 +175,8 @@ class FakeMatrixApi extends MockClient {
{
"actions": [
"notify",
{
"set_tweak": "sound",
"value": "default"
},
{
"set_tweak": "highlight",
"value": false
}
{"set_tweak": "sound", "value": "default"},
{"set_tweak": "highlight", "value": false}
],
"conditions": [
{
@ -239,10 +202,7 @@ class FakeMatrixApi extends MockClient {
{
"actions": [
"notify",
{
"set_tweak": "highlight",
"value": false
}
{"set_tweak": "highlight", "value": false}
],
"conditions": [
{
@ -258,10 +218,7 @@ class FakeMatrixApi extends MockClient {
{
"actions": [
"notify",
{
"set_tweak": "highlight",
"value": false
}
{"set_tweak": "highlight", "value": false}
],
"conditions": [
{

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:flutter_test/flutter_test.dart';
@ -26,20 +26,22 @@ import 'package:famedlysdk/src/Client.dart';
import 'package:famedlysdk/src/utils/MxContent.dart';
void main() {
/// All Tests related to the MxContent
group("MxContent", () {
test("Formatting", () async {
Client client = Client("testclient");
client.homeserver = "https://testserver.abc";
final String mxc = "mxc://exampleserver.abc/abcdefghijklmn";
final MxContent content = MxContent(mxc);
expect(content.getDownloadLink(client),"${client.homeserver}/_matrix/media/r0/download/exampleserver.abc/abcdefghijklmn");
expect(content.getThumbnail(client, width: 50, height: 50),"${client.homeserver}/_matrix/media/r0/thumbnail/exampleserver.abc/abcdefghijklmn?width=50&height=50&method=crop");
expect(content.getThumbnail(client, width: 50, height: 50, method: ThumbnailMethod.scale),"${client.homeserver}/_matrix/media/r0/thumbnail/exampleserver.abc/abcdefghijklmn?width=50&height=50&method=scale");
expect(content.getDownloadLink(client),
"${client.homeserver}/_matrix/media/r0/download/exampleserver.abc/abcdefghijklmn");
expect(content.getThumbnail(client, width: 50, height: 50),
"${client.homeserver}/_matrix/media/r0/thumbnail/exampleserver.abc/abcdefghijklmn?width=50&height=50&method=crop");
expect(
content.getThumbnail(client,
width: 50, height: 50, method: ThumbnailMethod.scale),
"${client.homeserver}/_matrix/media/r0/thumbnail/exampleserver.abc/abcdefghijklmn?width=50&height=50&method=scale");
});
});
}

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:flutter_test/flutter_test.dart';

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:flutter_test/flutter_test.dart';
@ -28,7 +28,6 @@ void main() {
/// All Tests related to the Event
group("User", () {
test("Create from json", () async {
final String id = "@alice:server.abc";
final String membership = "join";
final String displayName = "Alice";
@ -51,7 +50,6 @@ void main() {
expect(user.avatarUrl.mxc, avatarUrl);
expect(user.powerLevel, powerLevel);
expect(user.calcDisplayname(), displayName);
});
});
}