From 3e35a9f96eae1720afbbd754f9e96e62070197d0 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 13 Aug 2014 03:32:18 +0100 Subject: add in copyrights to everything, not just the synapse subdir, and add a copyrighter.pl whilst we're at it --- webclient/app-controller.js | 16 ++++++++++++++++ webclient/app.js | 16 ++++++++++++++++ webclient/components/matrix/matrix-service.js | 16 ++++++++++++++++ webclient/room/room-controller.js | 16 ++++++++++++++++ webclient/rooms/rooms-controller.js | 16 ++++++++++++++++ 5 files changed, 80 insertions(+) (limited to 'webclient') diff --git a/webclient/app-controller.js b/webclient/app-controller.js index e7601cc213..41055bdcd2 100644 --- a/webclient/app-controller.js +++ b/webclient/app-controller.js @@ -1,3 +1,19 @@ +/* +Copyright 2014 matrix.org + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + /* * Main controller */ diff --git a/webclient/app.js b/webclient/app.js index 2a75560edd..2133a98cbf 100644 --- a/webclient/app.js +++ b/webclient/app.js @@ -1,3 +1,19 @@ +/* +Copyright 2014 matrix.org + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + var matrixWebClient = angular.module('matrixWebClient', [ 'ngRoute', 'MatrixWebClientController', diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js index f98874dc74..5f1731c1a8 100644 --- a/webclient/components/matrix/matrix-service.js +++ b/webclient/components/matrix/matrix-service.js @@ -1,3 +1,19 @@ +/* +Copyright 2014 matrix.org + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + 'use strict'; angular.module('matrixService', []) diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index e54751ef6d..7cb6cba650 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -1,3 +1,19 @@ +/* +Copyright 2014 matrix.org + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + angular.module('RoomController', []) .controller('RoomController', ['$scope', '$http', '$timeout', '$routeParams', '$location', 'matrixService', function($scope, $http, $timeout, $routeParams, $location, matrixService) { diff --git a/webclient/rooms/rooms-controller.js b/webclient/rooms/rooms-controller.js index 33912d63f9..a4499761bc 100644 --- a/webclient/rooms/rooms-controller.js +++ b/webclient/rooms/rooms-controller.js @@ -1,3 +1,19 @@ +/* +Copyright 2014 matrix.org + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + 'use strict'; angular.module('RoomsController', ['matrixService']) -- cgit 1.4.1 From 30efb04060c3b7e4ea99e1d03da9690fe7adc5d2 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Wed, 13 Aug 2014 11:09:30 +0200 Subject: Display image messages from the stream --- webclient/app.css | 8 ++++++++ webclient/room/room.html | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'webclient') diff --git a/webclient/app.css b/webclient/app.css index fd548c117b..13cd19a2ef 100644 --- a/webclient/app.css +++ b/webclient/app.css @@ -187,6 +187,14 @@ h1 { border: 0px ! important; } +.image { + display: block; + max-width:320px; + max-height:320px; + width: auto; + height: auto; +} + .bubble { padding: 6px; padding-left: 1em; diff --git a/webclient/room/room.html b/webclient/room/room.html index 276c3caa5a..600bc14eb8 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -32,7 +32,8 @@
{{ msg.content.msgtype === "m.emote" ? ("* " + (members[msg.user_id].displayname || msg.user_id) + " ") : "" }} - {{ msg.content.body }} + {{ msg.content.msgtype === "m.text" ? msg.content.body : "" }} + {{ msg.content.body }}
-- cgit 1.4.1 From c87e1f641858fbc2e6ed6b99ef05591a977bd4c4 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Wed, 13 Aug 2014 11:42:28 +0200 Subject: Room: Added a text input to type an image URL in order to send an image message --- webclient/app.css | 4 ++-- webclient/components/matrix/matrix-service.js | 11 +++++++++++ webclient/room/room-controller.js | 13 ++++++++++++- webclient/room/room.html | 12 ++++++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) (limited to 'webclient') diff --git a/webclient/app.css b/webclient/app.css index 13cd19a2ef..9a46613d49 100644 --- a/webclient/app.css +++ b/webclient/app.css @@ -43,7 +43,7 @@ h1 { } .inputBarTable tr td { - padding: 4px; + padding: 1px 4px; } .mainInput { @@ -118,7 +118,7 @@ h1 { overflow separetely. */ .room .page { - height: calc(100vh - 198px); + height: calc(100vh - 220px); } /*** Message table ***/ diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js index 5f1731c1a8..f054bf301e 100644 --- a/webclient/components/matrix/matrix-service.js +++ b/webclient/components/matrix/matrix-service.js @@ -197,6 +197,17 @@ angular.module('matrixService', []) return this.sendMessage(room_id, msg_id, content); }, + // Send an image message + sendImageMessage: function(room_id, image_url, image_alt, msg_id) { + var content = { + msgtype: "m.image", + url: image_url, + body: image_alt + }; + + return this.sendMessage(room_id, msg_id, content); + }, + // Send an emote message sendEmoteMessage: function(room_id, body, msg_id) { var content = { diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index 7cb6cba650..cbd5c1a175 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -27,7 +27,8 @@ angular.module('RoomController', []) $scope.messages = []; $scope.members = {}; $scope.stopPoll = false; - + + $scope.imageURLToSend = ""; $scope.userIDToInvite = ""; var shortPoll = function() { @@ -224,6 +225,16 @@ angular.module('RoomController', []) }); }; + $scope.sendImage = function(url) { + matrixService.sendImageMessage($scope.room_id, url).then( + function() { + console.log("Image sent"); + }, + function(reason) { + $scope.feedback = "Failed to send image: " + reason; + }); + }; + $scope.$on('$destroy', function(e) { console.log("onDestroyed: Stopping poll."); $scope.stopPoll = true; diff --git a/webclient/room/room.html b/webclient/room/room.html index 600bc14eb8..9cd1ec3645 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -63,6 +63,18 @@ {{ feedback }} + + + + + + + + + + + + -- cgit 1.4.1 From 55944ccf72882ae83dcf17a8013c63c49e51581d Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Wed, 13 Aug 2014 14:31:48 +0100 Subject: Use strings instead of opaque magic-number constants for presence states; rename AWAY to UNAVAILABLE --- synapse/api/constants.py | 8 ++++---- tests/handlers/test_presence.py | 24 ++++++++++++------------ tests/handlers/test_presencelike.py | 12 ++++++------ tests/rest/test_presence.py | 12 ++++++------ webclient/app.css | 2 +- webclient/room/room-controller.js | 11 ++++------- webclient/room/room.html | 2 +- 7 files changed, 34 insertions(+), 37 deletions(-) (limited to 'webclient') diff --git a/synapse/api/constants.py b/synapse/api/constants.py index 29687c3482..1ff1af76ec 100644 --- a/synapse/api/constants.py +++ b/synapse/api/constants.py @@ -37,7 +37,7 @@ class Feedback(object): class PresenceState(object): """Represents the presence state of a user.""" - OFFLINE = 0 - BUSY = 1 - ONLINE = 2 - FREE_FOR_CHAT = 3 + OFFLINE = u"offline" + UNAVAILABLE = u"unavailable" + ONLINE = u"online" + FREE_FOR_CHAT = u"free_for_chat" diff --git a/tests/handlers/test_presence.py b/tests/handlers/test_presence.py index e7102e4ab0..2299a2a7ba 100644 --- a/tests/handlers/test_presence.py +++ b/tests/handlers/test_presence.py @@ -27,7 +27,7 @@ from synapse.handlers.presence import PresenceHandler, UserPresenceCache OFFLINE = PresenceState.OFFLINE -BUSY = PresenceState.BUSY +UNAVAILABLE = PresenceState.UNAVAILABLE ONLINE = PresenceState.ONLINE @@ -149,12 +149,12 @@ class PresenceStateTestCase(unittest.TestCase): yield self.handler.set_state( target_user=self.u_apple, auth_user=self.u_apple, - state={"state": BUSY, "status_msg": "Away"}) + state={"state": UNAVAILABLE, "status_msg": "Away"}) mocked_set.assert_called_with("apple", - {"state": 1, "status_msg": "Away"}) + {"state": UNAVAILABLE, "status_msg": "Away"}) self.mock_start.assert_called_with(self.u_apple, - state={"state": 1, "status_msg": "Away"}) + state={"state": UNAVAILABLE, "status_msg": "Away"}) yield self.handler.set_state( target_user=self.u_apple, auth_user=self.u_apple, @@ -555,7 +555,7 @@ class PresencePushTestCase(unittest.TestCase): content={ "push": [ {"user_id": "@apple:test", - "state": 2}, + "state": "online"}, ], }), call( @@ -564,7 +564,7 @@ class PresencePushTestCase(unittest.TestCase): content={ "push": [ {"user_id": "@apple:test", - "state": 2}, + "state": "online"}, ], }) ], any_order=True) @@ -582,7 +582,7 @@ class PresencePushTestCase(unittest.TestCase): "remote", "m.presence", { "push": [ {"user_id": "@potato:remote", - "state": 2}, + "state": "online"}, ], } ) @@ -646,7 +646,7 @@ class PresencePushTestCase(unittest.TestCase): content={ "push": [ {"user_id": "@apple:test", - "state": 2}, + "state": "online"}, ], }), call( @@ -655,7 +655,7 @@ class PresencePushTestCase(unittest.TestCase): content={ "push": [ {"user_id": "@banana:test", - "state": 0}, + "state": "offline"}, ], }), ], any_order=True) @@ -666,7 +666,7 @@ class PresencePushTestCase(unittest.TestCase): self.handler._user_cachemap[self.u_clementine] = UserPresenceCache() self.handler._user_cachemap[self.u_clementine].update( - {"state": PresenceState.ONLINE}, self.u_clementine) + {"state": ONLINE}, self.u_clementine) self.room_members.append(self.u_potato) yield self.distributor.fire("user_joined_room", self.u_clementine, @@ -680,7 +680,7 @@ class PresencePushTestCase(unittest.TestCase): content={ "push": [ {"user_id": "@clementine:test", - "state": 2}, + "state": "online"}, ], }), ) @@ -882,7 +882,7 @@ class PresencePollingTestCase(unittest.TestCase): content={ "push": [ {"user_id": "@banana:test", - "state": 0, + "state": "offline", "status_msg": None}, ], }, diff --git a/tests/handlers/test_presencelike.py b/tests/handlers/test_presencelike.py index 12b7dca00d..224cf646f4 100644 --- a/tests/handlers/test_presencelike.py +++ b/tests/handlers/test_presencelike.py @@ -29,7 +29,7 @@ from synapse.handlers.profile import ProfileHandler OFFLINE = PresenceState.OFFLINE -BUSY = PresenceState.BUSY +UNAVAILABLE = PresenceState.UNAVAILABLE ONLINE = PresenceState.ONLINE @@ -125,12 +125,12 @@ class PresenceProfilelikeDataTestCase(unittest.TestCase): yield self.handlers.presence_handler.set_state( target_user=self.u_apple, auth_user=self.u_apple, - state={"state": BUSY, "status_msg": "Away"}) + state={"state": UNAVAILABLE, "status_msg": "Away"}) mocked_set.assert_called_with("apple", - {"state": 1, "status_msg": "Away"}) + {"state": UNAVAILABLE, "status_msg": "Away"}) self.mock_start.assert_called_with(self.u_apple, - state={"state": 1, "status_msg": "Away", + state={"state": UNAVAILABLE, "status_msg": "Away", "displayname": "Frank", "avatar_url": "http://foo"}) @@ -220,7 +220,7 @@ class PresenceProfilelikeDataTestCase(unittest.TestCase): content={ "push": [ {"user_id": "@apple:test", - "state": 2, + "state": "online", "displayname": "Frank", "avatar_url": "http://foo"}, ], @@ -238,7 +238,7 @@ class PresenceProfilelikeDataTestCase(unittest.TestCase): "remote", "m.presence", { "push": [ {"user_id": "@potato:remote", - "state": 2, + "state": "online", "displayname": "Frank", "avatar_url": "http://foo"}, ], diff --git a/tests/rest/test_presence.py b/tests/rest/test_presence.py index 5b1e060c5f..7c54e067c9 100644 --- a/tests/rest/test_presence.py +++ b/tests/rest/test_presence.py @@ -31,7 +31,7 @@ logging.getLogger().addHandler(logging.NullHandler()) OFFLINE = PresenceState.OFFLINE -BUSY = PresenceState.BUSY +UNAVAILABLE = PresenceState.UNAVAILABLE ONLINE = PresenceState.ONLINE @@ -69,7 +69,7 @@ class PresenceStateTestCase(unittest.TestCase): def test_get_my_status(self): mocked_get = self.mock_handler.get_state mocked_get.return_value = defer.succeed( - {"state": 2, "status_msg": "Available"}) + {"state": ONLINE, "status_msg": "Available"}) (code, response) = yield self.mock_server.trigger("GET", "/presence/%s/status" % (myid), None) @@ -87,12 +87,12 @@ class PresenceStateTestCase(unittest.TestCase): (code, response) = yield self.mock_server.trigger("PUT", "/presence/%s/status" % (myid), - '{"state": 1, "status_msg": "Away"}') + '{"state": "unavailable", "status_msg": "Away"}') self.assertEquals(200, code) mocked_set.assert_called_with(target_user=self.u_apple, auth_user=self.u_apple, - state={"state": 1, "status_msg": "Away"}) + state={"state": UNAVAILABLE, "status_msg": "Away"}) class PresenceListTestCase(unittest.TestCase): @@ -234,7 +234,7 @@ class PresenceEventStreamTestCase(unittest.TestCase): # I'll already get my own presence state change self.assertEquals({"start": "0", "end": "1", "chunk": [ {"type": "m.presence", - "content": {"user_id": "@apple:test", "state": 2}}, + "content": {"user_id": "@apple:test", "state": ONLINE}}, ]}, response) self.mock_datastore.set_presence_state.return_value = defer.succeed( @@ -251,5 +251,5 @@ class PresenceEventStreamTestCase(unittest.TestCase): self.assertEquals(200, code) self.assertEquals({"start": "1", "end": "2", "chunk": [ {"type": "m.presence", - "content": {"user_id": "@banana:test", "state": 2}}, + "content": {"user_id": "@banana:test", "state": ONLINE}}, ]}, response) diff --git a/webclient/app.css b/webclient/app.css index 9a46613d49..15b6c91300 100644 --- a/webclient/app.css +++ b/webclient/app.css @@ -106,7 +106,7 @@ h1 { background-color: #38AF00; } -.away { +.unavailable { background-color: #FFCC00; } diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index cbd5c1a175..5d1c65641e 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -123,17 +123,14 @@ angular.module('RoomController', []) var member = $scope.members[chunk.content.user_id]; if ("state" in chunk.content) { - var ONLINE = 2; - var AWAY = 1; - var OFFLINE = 0; - if (chunk.content.state === ONLINE) { + if (chunk.content.state === "online") { member.presenceState = "online"; } - else if (chunk.content.state === OFFLINE) { + else if (chunk.content.state === "offline") { member.presenceState = "offline"; } - else if (chunk.content.state === AWAY) { - member.presenceState = "away"; + else if (chunk.content.state === "unavailable") { + member.presenceState = "unavailable"; } } diff --git a/webclient/room/room.html b/webclient/room/room.html index 9cd1ec3645..5de2190b8b 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -14,7 +14,7 @@
{{ info.displayname || name }}
- + -- cgit 1.4.1