Location Sharing on QT Client
How to use it?
In a conversation, the user can click on the location icon to display a map. If
Location Services is enabled on the device, the user’s position will be shown on the map, along with the locations of all other members who are sharing their location (from all conversations of the selected account). The user can toggle location sharing on and off by clicking the location sharing buttons. By default, the user’s location is shared for 15 minutes, but this setting can be modified in the app’s settings.
When a user is sharing their location in a conversation, a red location icon will appear on the conversation icon. If the user receives a location from another member, an orange location icon will be displayed on all conversations in which the member is present.
The user can interact with the map by recentering, zooming in and out, moving it, and closing it. The map can also be pinned or unpinned. When the map is unpinned, it can be repinned if the user is in the right account. This feature allows the user to keep the map visible while continuing to use Jami.
The user is already sharing location with conversation A and conversation B.
If the user switches to conversation C, the map is still visible and the user has two options
Click on the location sharing button to also share location with the members of conversation C.
Click the location sharing end button. This will bring up a pop-up that allows the user to either turn off location sharing entirely or only stop sharing their location with the members of conversation C.
If the window is unpinned, the user will not be able to click on the location sharing button because the window is no longer connected to a conversation. To start sharing location with new people, the user must re-pin the window. Note that unpinning the window does not affect any ongoing location sharing. Additionally, clicking on the location sharing end button while the window is unpinned will stop all current location sharing and no pop-up will appear to allow the user to select a specific conversation to stop sharing with.
Each account has its own unique map. If the user unpins the map while on account A, then switches to account B and unpins the map, two maps will be visible. The maps for accounts A and B display positions shared with those accounts, respectively, and are completely separate from each other
How it works? (technical)
This feature is divided into three parts:
Sending one’s position
Receiving a position
Displaying a position
Sending a position
As soon as a map is opened, the
Positioning class takes care of retrieving the current position using the
QGeoPositionInfoSource class of the
The position is then converted to JSON format and is transmitted to the
This class coordinates the entire position sharing process.
The position is then shared through the
It is shared:
Locally through the
localPositionReceivedsignal so that the user can see their own position
On the DHT to all conversations in the
positionShareConvIds_list. This list contains the keys of all conversations that the user wants to share their position with. From this key, the URIs of all participants are obtained and a position message is sent to each participant.
The JSON format of a position is as follows:
Type (position or stop message)
Time (unused by the QtClient)
An example of data:
When sending the position to the daemon, the author’s URI is also transmitted.
When the user stops sharing their position with a conversation, the conversation’s ID is simply removed from the
positionShareConvIds_ list. A “stop” message is also sent to each participant.
Receiving a position
When a position is received, it triggers the ‘onPositionReceived()’ slot. Whether it is a local position from the
QtPositioning module or a position from another contact.
positionManager level, the
objectListSharingUris_ list stores all of the client’s positions. The position is either:
Added (the URI is not present in the list)
Updated (the URI is already present in the list)
Deleted (type = “Stop”)
The position is stored in the list in the form of an object of type
positionObject. This type allows for a watchdog for each position. If the position is not updated within a certain time frame, it is removed from the list.
Displaying a position
When a position is received (slot
WebEngine module allows for the bridge between the library’s web technology and Qml. Each position is represented by a layer added to the map. The
newPosition() function adds a new layer, the
updatePosition() function updates the coordinates of the layer, and the
removePosition() function removes the layer.