Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[In Progress] Port to TelepathyGlib #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions SearchActivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

import gi
gi.require_version('Gtk', '3.0')
gi.require_version('TelepathyGLib', '0.12')
from gi.repository import Gtk, Gdk
from gi.repository import TelepathyGLib

from sugar3.activity import activity
from sugar3 import profile
Expand All @@ -22,7 +24,6 @@
from toolbar_utils import button_factory, label_factory, separator_factory
from utils import json_load, json_dump, convert_seconds_to_minutes

import telepathy
import dbus
from dbus.service import signal
from dbus.gobject_service import ExportedGObject
Expand All @@ -45,6 +46,8 @@
SERVICE = 'org.sugarlabs.CookieSearchActivity'
IFACE = SERVICE

PATH = '/org/sugarlabs/CookieSearchActivity'


class SearchActivity(activity.Activity):
""" Searching strategy game """
Expand Down Expand Up @@ -206,28 +209,28 @@ def _joined_cb(self, activity):

def _new_tube_common(self, sharer):
""" Joining and sharing are mostly the same... """
if self._shared_activity is None:
if self.get_shared_activity() is None:
Copy link

@Aniket21mathur Aniket21mathur May 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change necessary? Can this change might be a reason for the port not to work properly? @quozl @tonadev .
I have seen other ports and didn't noticed it in any.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self._shared_activity is in the GTK 2 toolkit sugar-toolkit, and is not in the GTK 3 toolkit sugar-toolkit-gtk3.

self.get_shared_activity is in both toolkits.

My guess is that the code hadn't been changed during the port to GTK 3, before the port to TelepathyGLib. If we're not sure if collaboration worked for the GTK 2 release of the activity, the way to be sure is to test that release.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I also think that collaboration should be tested for GTK 2 first, It seems that there are not much changes from telepathy to TelepathyGlib for this activity, and the differences @quozl pointed out might be seen before telepathy port.

Game playing board state is mostly shared, but not fully; differences are;

Now seen a couple of instances where collaboration code is not properly ported to GTK 3 .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is endemic. Root cause is missing-in-action activity maintainers, and well-meaning volunteers during GCI or students in GSoC who have concentrated on a GTK 3 port without fully understanding the collaboration feature, and reviewers with the same limited focus. Another cause is activities copied from other activities that do collaboration, without implementing collaboration in the new activity. Is why we re-worded the project idea this time, and @nswarup14 is doing "Maintain 25 activities" rather than "Port to GTK 3".

_logger.debug("Error: Failed to share or join activity ... \
_shared_activity is null in _shared_cb()")
get_shared_activity() is null in _shared_cb()")
return

self.initiating = sharer
self.waiting_for_hand = not sharer

self.conn = self._shared_activity.telepathy_conn
self.tubes_chan = self._shared_activity.telepathy_tubes_chan
self.text_chan = self._shared_activity.telepathy_text_chan
self.conn = self.get_shared_activity().telepathy_conn
self.tubes_chan = self.get_shared_activity().telepathy_tubes_chan
self.text_chan = self.get_shared_activity().telepathy_text_chan

self.tubes_chan[telepathy.CHANNEL_TYPE_TUBES].connect_to_signal(
self.tubes_chan[TelepathyGLib.IFACE_CHANNEL_TYPE_TUBES].connect_to_signal(
'NewTube', self._new_tube_cb)

if sharer:
_logger.debug('This is my activity: making a tube...')
id = self.tubes_chan[telepathy.CHANNEL_TYPE_TUBES].OfferDBusTube(
id = self.tubes_chan[TelepathyGLib.IFACE_CHANNEL_TYPE_TUBES].OfferDBusTube(
SERVICE, {})
else:
_logger.debug('I am joining an activity: waiting for a tube...')
self.tubes_chan[telepathy.CHANNEL_TYPE_TUBES].ListTubes(
self.tubes_chan[TelepathyGLib.IFACE_CHANNEL_TYPE_TUBES].ListTubes(
reply_handler=self._list_tubes_reply_cb,
error_handler=self._list_tubes_error_cb)
self._game.set_sharing(True)
Expand All @@ -246,16 +249,16 @@ def _new_tube_cb(self, id, initiator, type, service, params, state):
_logger.debug('New tube: ID=%d initator=%d type=%d service=%s \
params=%r state=%d' % (id, initiator, type, service, params, state))

if (type == telepathy.TUBE_TYPE_DBUS and service == SERVICE):
if state == telepathy.TUBE_STATE_LOCAL_PENDING:
if (type == TelepathyGLib.TubeType.DBUS and service == SERVICE):
if state == TelepathyGLib.TubeState.LOCAL_PENDING:
self.tubes_chan[
telepathy.CHANNEL_TYPE_TUBES].AcceptDBusTube(id)
TelepathyGLib.IFACE_CHANNEL_TYPE_TUBES].AcceptDBusTube(id)

tube_conn = TubeConnection(
self.conn, self.tubes_chan[
telepathy.CHANNEL_TYPE_TUBES], id,
TelepathyGLib.IFACE_CHANNEL_TYPE_TUBES], id,
group_iface=self.text_chan[
telepathy.CHANNEL_INTERFACE_GROUP])
TelepathyGLib.IFACE_CHANNEL_INTERFACE_GROUP])

self.chattube = ChatTube(tube_conn, self.initiating,
self.event_received_cb)
Expand Down