forked from sugarlabs/sugar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add webaccount/webservice extension support
This is another patch in a series of patches for interacting with online accounts from Sugar. The relevant feature request is [1]. This patch introduces two new sections in sugar extensions: (1) webservice is stub for installing webservices; each web service is installed in a subdirectory of this directory. (2) cpsection/webaccount is a new control panel section for managing web service accounts. Account management services are loaded into individual subdirectories of cpsection/webaccount/services. A new helper method was also added to jarabe/webservice/accountsmanager and the unit test as updated accordingly. Note that this same directory structure can be set up in env.get_profile_path()/extensions for web services installed by the end user. [1] http://wiki.sugarlabs.org/go/Features/Web_services A first pass at a unit test for the new webaccount cpsection is also included. For naming consistency, this test was called test_webaccount while the exsiting test_webaccount was renamed to the more appropriate test_webservice.
- Loading branch information
1 parent
da547a6
commit 664b914
Showing
25 changed files
with
374 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
SUBDIRS = cpsection deviceicon globalkey | ||
SUBDIRS = cpsection deviceicon globalkey webservice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
SUBDIRS = aboutme aboutcomputer background datetime frame keyboard language \ | ||
modemconfiguration network power updater | ||
modemconfiguration network power updater webaccount | ||
|
||
sugardir = $(pkgdatadir)/extensions/cpsection | ||
sugar_PYTHON = __init__.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from pkgutil import extend_path | ||
__path__ = extend_path(__path__, __name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
SUBDIRS = services | ||
sugardir = $(pkgdatadir)/extensions/cpsection/webaccount | ||
|
||
sugar_PYTHON = \ | ||
__init__.py \ | ||
model.py \ | ||
view.py \ | ||
web_service.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright (C) 2013, Walter Bender | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 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 General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
||
from gettext import gettext as _ | ||
from pkgutil import extend_path | ||
|
||
__path__ = extend_path(__path__, __name__) | ||
|
||
CLASS = 'WebServicesConfig' | ||
ICON = 'module-webaccount' | ||
TITLE = _('Configure your Web Services') |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
SUBDIRS = | ||
|
||
sugardir = $(pkgdatadir)/extensions/cpsection/webaccount/services | ||
|
||
sugar_PYTHON = \ | ||
__init__.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from pkgutil import extend_path | ||
__path__ = extend_path(__path__, __name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Copyright (C) 2013, Walter Bender - Raul Gutierrez Segales | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 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 General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
||
import glib | ||
from gettext import gettext as _ | ||
|
||
from gi.repository import Gtk | ||
|
||
from jarabe.webservice.accountsmanager import get_webaccount_services | ||
from jarabe.controlpanel.sectionview import SectionView | ||
|
||
from sugar3.graphics.icon import CanvasIcon | ||
from sugar3.graphics import style | ||
|
||
|
||
class WebServicesConfig(SectionView): | ||
def __init__(self, model, alerts): | ||
SectionView.__init__(self) | ||
|
||
self._model = model | ||
self.restart_alerts = alerts | ||
|
||
services = get_webaccount_services() | ||
if len(services) == 0: | ||
label = Gtk.Label() | ||
label.set_markup( | ||
'<span size="x-large" weight="bold">' + | ||
glib.markup_escape_text( | ||
_('No web services are installed.\n' | ||
'Please visit %s for more details.' % | ||
'http://wiki.sugarlabs.org/go/WebServices')) + | ||
'</span>') | ||
label.show() | ||
self.add(label) | ||
return | ||
|
||
vbox = Gtk.VBox() | ||
hbox = Gtk.HBox(style.DEFAULT_SPACING) | ||
|
||
self._service_config_box = Gtk.VBox() | ||
|
||
for service in services: | ||
icon = CanvasIcon(icon_name=service.get_icon_name()) | ||
icon.connect('button_press_event', | ||
service.config_service_cb, | ||
self._service_config_box) | ||
icon.show() | ||
hbox.pack_start(icon, False, False, 0) | ||
|
||
hbox.show() | ||
vbox.pack_start(hbox, False, False, 0) | ||
|
||
scrolled = Gtk.ScrolledWindow() | ||
vbox.pack_start(scrolled, True, True, 0) | ||
|
||
self.add(vbox) | ||
scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) | ||
scrolled.show() | ||
|
||
workspace = Gtk.VBox() | ||
scrolled.add_with_viewport(workspace) | ||
workspace.show() | ||
|
||
workspace.add(self._service_config_box) | ||
workspace.show_all() | ||
vbox.show() | ||
|
||
def undo(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (C) 2013, Walter Bender - Raul Gutierrez Segales | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 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 General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
||
|
||
class WebService(): | ||
def get_icon_name(self): | ||
raise "Not implemented" | ||
|
||
def config_service_cb(self, widget, event, container): | ||
raise "Not implemented" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SUBDIRS = | ||
|
||
sugardir = $(pkgdatadir)/extensions/webservice | ||
sugar_PYTHON = \ | ||
__init__.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from pkgutil import extend_path | ||
__path__ = extend_path(__path__, __name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from pkgutil import extend_path | ||
__path__ = extend_path(__path__, __name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from pkgutil import extend_path | ||
__path__ = extend_path(__path__, __name__) |
2 changes: 2 additions & 0 deletions
2
tests/extensions/cpsection/webaccount/services/mock/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from pkgutil import extend_path | ||
__path__ = extend_path(__path__, __name__) |
45 changes: 45 additions & 0 deletions
45
tests/extensions/cpsection/webaccount/services/mock/service.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright (C) 2013, Walter Bender - Raul Gutierrez Segales | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 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 General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
||
from gi.repository import Gtk | ||
|
||
from jarabe.webservice import accountsmanager | ||
|
||
from cpsection.webaccount.web_service import WebService | ||
|
||
_SERVICE_NAME = 'mock' | ||
|
||
|
||
class WebService(WebService): | ||
|
||
def __init__(self): | ||
self._account = accountsmanager.get_account(_SERVICE_NAME) | ||
|
||
def get_icon_name(self): | ||
return _SERVICE_NAME | ||
|
||
def config_service_cb(self, widget, event, container): | ||
label = Gtk.Label(_SERVICE_NAME) | ||
|
||
for c in container.get_children(): | ||
container.remove(c) | ||
|
||
container.add(label) | ||
container.show_all() | ||
|
||
|
||
def get_service(): | ||
return WebService() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (C) 2013, Walter Bender - Raul Gutierrez Segales | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 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 General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
||
|
||
class WebService(): | ||
def get_icon_name(self): | ||
raise "Not implemented" | ||
|
||
def config_service_cb(self, widget, event, container): | ||
raise "Not implemented" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright (C) 2012, Daniel Narvaez | ||
# Copyright (C) 2013, Walter Bender | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 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 General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
||
from sugar3.test import unittest | ||
from sugar3.test import uitree | ||
|
||
ACCOUNT_NAME = 'mock' | ||
|
||
|
||
class TestWebAccount(unittest.UITestCase): | ||
|
||
def test_webaccount(self): | ||
with self.run_view("webaccount"): | ||
root = uitree.get_root() | ||
|
||
for name in [ACCOUNT_NAME]: | ||
node = root.find_child(name=name, role_name='label') | ||
self.assertIsNotNone(node) |
Oops, something went wrong.